Support configuring document-level parts of OpenAPI schema #44192
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
feature-openapi
Milestone
Starting in .NET 7, we added support for a
WithOpenApi
extension method on endpoints that allowed users to modify theOpenApiOperation
associated with a particular endpoint. For example, we can modify the summary of an OpenApi Operation associated with an endpoint using the following.However, this API has a major limitation: it doesn't allow modifying aspects of the OpenAPI definition that exist at the document-level. This includes things like:
OpenApiSecuritySchemes
from authentication configuration #39761)IMO, a super ✨ amazing ✨ experience would be supporting a
WithOpenApi
extension method directly on theWebApplication
so that users could modify theOpenApiDocument
associated with their application:One thing to note here, is how the app-level
WithOpenApi
and the endpoint-specificWithOpenApi
will interact with each other. If I'm operating on the app-levelWithOpenApi
, can I modify operation-level details that can then be examined within an application?If this was the case, we'd probably want there to be an
OpenApiDocument
in DI that is projected upon from theWithOpenApi
extension methods targeting each endpoint/endpoint group/document.While writing this issue, I came across microsoft/OpenAPI.NET#673, which proposes a builder-style syntax for building an OpenAPI document. This would be a great feature to add into the application.
The text was updated successfully, but these errors were encountered: