-
Notifications
You must be signed in to change notification settings - Fork 10.3k
How can I access OpenApiDocument at runtime #60330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
By implementing a custom document transformer, you have access to the document to change it as you see fit before it is returned to the client: https://learn.microsoft.com/aspnet/core/fundamentals/openapi/customize-openapi |
yeah, I did implement my customizations, the OpenApi document which is returned by the endpoint looks good, but how can I access the |
Ah I see - I don't think there's a way to do that. |
@EliveltonRepolho Thanks for filing this issue! @martincostello's response seems correct based on my understanding of the question. Currently, there's no public API for accessing the in-memory OpenAPI document. Out of curiousity, how and where are you trying to access the OpenApiDocument? |
Got it, our use case is for a internal framework build for a Backend For Front (BFF), which exposes metadata related to the endpoints (similar to OpenAPI json but with different schema, and with some enrichment), since it is generated on backend side, we take advantage of all properties already present in |
@EliveltonRepolho In the example above, is your endpoint returning the OpenAPI document back in the response or do you return your own type that you derive from the OpenAPI document? What metadata from the document do you pull? I might have a proposed resolution for you based on those questions. 🤔 |
@captainsafia in the example, we return our own type which is derived from OpenAPI document. What we do is:
|
@EliveltonRepolho Ah, I see. I was going to recommend using the underlying Absent this, you might have to leverage private reflection (for now) to resolve the OpenAPI document service and interact with. |
How can I access
OpenApiDocument
with new OpenApi package ?I can see that today the only options are during build time and using the mapped endpoint, but will only have the jsom/yaml file. I wanted to access the
OpenApiDocument
at runtime so I can work with some metadata I need to expose based on theOpenApiDocument
.Here where I found the endpoint mapped that access
OpenApiDocumentService
to generate the OpenApi document, but they are all internal classes.Thanks
The text was updated successfully, but these errors were encountered: