Skip to content

.NET9: Microsoft.AspNetCore.OpenApi.OpenApiSchemaService should not be internal  #57798

@jornhd

Description

@jornhd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions