Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Identify long-term strategy for JSON schema generation
In .NET 7, we added support for a new Microsoft.AspNetCore.OpenApi
package that is designed to work with minimal API applications and provide constructs that allow users to directly modify the OpenApiOperation
associated with their endpoints.
At the moment, the package integrates into Swashbuckle using an ad-hoc merge and replace strategy wherein:
- If an OpenApiOperation exists in the endpoint metadata, it is used instead of using the one generated by SwaggerGenerator and
- Swashbuckle's schema generator is leveraged to generate the OpenApiSchema since
Microsoft.AspNetCore.OpenApi
doesn't support full reflection schema generation to put
In the future, it would be great to unify this ad-hoc strategy, especially now that OpenAPI v3.1's OpenAPI schema exactly matches JSON schema (ref).
Some possibilities include:
- Implementing schema generation support lower in the stack at the
Microsoft.OpenApi
layer (see https://github.com/microsoft/OpenAPI.NET/issues/836) - Leverage an established JSON schema generation library (like json-everything) to standardize on schema generation throughout the stack
- Leverage System.Text.Json's new
TypeInfoResolver
API (ref) to standardize on schema generation
With the long-term goal of:
- Removing the merge and replace strategy/hack in Swashbuckle
- Allowing users to modify schemas in their
WithOpenApi
invocations on route handler endpoints
cc: @domaindrivendev @darrelmiller
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.