Description
When generating OpenAPI documents for endpoints whose request bodies have nested types referencing arrays of other types, OpenApiSchemaService throws InvalidOperationException instead of producing the schema.
Reproduction
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi();
app.MapPost("/items", (ItemRequest req) => Results.Ok());
app.Run();
public class ItemRequest
{
public required List<ItemReference> References { get; init; }
}
public class ItemReference
{
public required string Id { get; init; }
}
Hitting /openapi/v1.json throws:
System.InvalidOperationException: The schema for type 'ItemReference' could not be resolved.
at Microsoft.AspNetCore.OpenApi.Services.OpenApiSchemaService.GetSchemaForType(Type, ...)
Expected
OpenAPI document should generate with ItemRequest.References as an array of ItemReference references.
Version
.NET 11.0
Description
When generating OpenAPI documents for endpoints whose request bodies have nested types referencing arrays of other types,
OpenApiSchemaServicethrowsInvalidOperationExceptioninstead of producing the schema.Reproduction
Hitting
/openapi/v1.jsonthrows:Expected
OpenAPI document should generate with
ItemRequest.Referencesas an array ofItemReferencereferences.Version
.NET 11.0