-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Reduce reliance on ApiExplorer types for Microsoft.AspNetCore.OpenApi
consumption
#44209
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
Thanks for contacting us. We're moving this issue to the |
I would also like to bring up the fact that all endpoints are opt into open API by default because of this. If we design a new way I like the explicit opt in via an explicit call to WithOpenApi. Using groups, you can also apply that to many endpoints without much hassle. It's a much cleaner way to enable things. |
Agree here. I'll add that this would mean we have |
@captainsafia We should write down what we think the template would look like after we finish the work (basically start with that end goal in mind). As well as a before and after simple todo API. |
So, Does this mean For Controller based APIs use? builder.Services.AddEndpointsApiExplorer(); For Minimal APIs use? builder.Services.WithOpenApi(); Also is this |
Not quite. For controller-based APIs, you'll want to use
Something like this, but
Perhaps, or some type approximate to it. The main goal is to provide a way to capture the entire collection of |
Closing this. We support generating the OpenAPI document by default now, and implicitly take a dependency on ApiExplorer so that we can generate docs for both minimal and controller-style APIs. Templates will be updated in .NET 9 Preview 5. |
In .NET 7, we introduced the new
Microsoft.AspNetCore.OpenApi
package that generates anOpenApiOperation
definition for a given minimal endpoint and its metadata. One of the goals of this package was to remove the reliance on ApiExplorer and it's types that existed in the current implementation for OpenAPI definitions.Currently, even if a user is using
WithOpenApi
exclusively to document their endpoints they still have to include the following in their application to register the minimal API-specific implementations of ApiExplorer.Open source dependencies like Swashbuckle and NSwag still rely on ApiExplorer-specific types, like
IApiDescriptionGroupCollectionProvider
, to determine all of the endpoints that are associated with an application. Reducing the reliance on this type for minimal API scenarios in particular would allow us to remove theAddEndpointsApiExplorer
from the template.There's a chance that if we do #44192, then we wouldn't need to find a different way to derive all the endpoints in an application and can instead use the OpenApiDocument directly as the source of truth.
The text was updated successfully, but these errors were encountered: