-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When using ASP.NET Core 9’s built-in OpenAPI support (Microsoft.AspNetCore.OpenApi), the schema generator incorrectly handles multiple properties of the same generic type (IList). The first property is generated correctly with a $ref to the component schema, but the second property produces an empty items object.
It will generate:
"weatherPoints1": {
"type": "array",
"items": {
"$ref": "#/components/schemas/WeatherPoints"
}
},
"weatherPoints2": {
"type": "array",
"items": { }
}
Expected Behavior
"weatherPoints2": {
"type": "array",
"items": {
"$ref": "#/components/schemas/WeatherPoints"
}
}
Steps To Reproduce
- Create a minimal API project in .NET 9.
- Add the following classes:
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public IList<WeatherPoints> WeatherPoints1 { get; set; } = new List<WeatherPoints>();
public IList<WeatherPoints> WeatherPoints2 { get; set; } = new List<WeatherPoints>();
public string? Summary { get; set; }
}
public class WeatherPoints
{
public int Point { get; set; }
}
- Map an endpoint returning WeatherForecast:
app.MapGet("/weatherforecast", () => new WeatherForecast())
.WithName("GetWeatherForecast")
.WithOpenApi();
- Run the app and inspect /openapi/v1.json.
Exceptions (if any)
No response
.NET Version
9.0.306
Anything else?
- .NET SDK: 9.0.x
- ASP.NET Core: 9.0
- Package: Microsoft.AspNetCore.OpenApi
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi