-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Background and Motivation
As Swashbuckle is no longer supported in .NET 9, we've started migrating our operation filters to operation transformers to prepare for the .NET 9 release.
In some of our current Swashbuckle filters, we need to add types to the schema that isn't described in the ApiDescription, in order to reference these types in eg. operation.Responses.
We do this today with the following line:
var schema = context.SchemaGenerator.GenerateSchema(myType, context.SchemaRepository);
We tried to do the same in our IOpenApiOperationTransformer implementation:
var componentService = context.ApplicationServices.GetRequiredKeyedService<OpenApiSchemaService>(context.DocumentName);
var schema = await componentService.GetOrCreateSchemaAsync(myType, null, true, cancellationToken);
The problem is that OpenApiSchemaService is internal, not public, so it's impossible to add schema for additional types.
Proposed API
Make OpenApiSchemaService public, or provide GetOrCreateSchemaAsync in a public api, preferable the OpenApiOperationTransformerContext.