Skip to content

How can I access OpenApiDocument at runtime #60330

Open
@EliveltonRepolho

Description

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 the OpenApiDocument.

Here where I found the endpoint mapped that access OpenApiDocumentService to generate the OpenApi document, but they are all internal classes.

endpoints.MapGet(pattern, async (HttpContext context, string documentName = OpenApiConstants.DefaultDocumentName) =>
{
  ...
  var documentService = context.RequestServices.GetKeyedService<OpenApiDocumentService>(lowercasedDocumentName);
  .... 
  var document = await documentService.GetOpenApiDocumentAsync(context.RequestServices, context.RequestAborted);
  ....
}

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions