-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I created a web api in .net 10 preview 4 with AddOpenApi (version OpenApi3_0), and added ProblemDetails to the weather forecast controller. The generated ProblemDetails schema looks like this:
"ProblemDetails": {
"type": "object",
"properties": {
"type": {
"type": "string",
"nullable": true
},
"title": {
"type": "string",
"nullable": true
},
"status": {
"pattern": "^-?(?:0|[1-9]\d*)$",
"format": "int32"
},
"detail": {
"type": "string",
"nullable": true
},
"instance": {
"type": "string",
"nullable": true
}
}
},
Shouldn't it also have additionalProperties to mark that it could contain more properties than the ones defined in the schema, like the ValidationProblemDetails schema has on the errors node?
"ValidationProblemDetails": {
"type": "object",
"properties": {
"type": {
"type": "string",
"nullable": true,
},
"title": {
"type": "string",
"nullable": true,
},
"status": {
"pattern": "^-?(?:0|[1-9]\d*)$",
"format": "int32"
},
"detail": {
"type": "string",
"nullable": true,
},
"instance": {
"type": "string",
"nullable": true,
},
"errors": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Expected Behavior
No response
Steps To Reproduce
New ASP.NET Core Web API with .NET 10.
In Program.cs:
builder.Services.AddOpenApi(c => { c.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi3_0; });
In the WeatherForecastController, add the following attributes to the Get method:
[ProducesResponseType<ProblemDetails>(StatusCodes.Status500InternalServerError, MediaTypeNames.Application.ProblemJson)] [ProducesResponseType<ValidationProblemDetails>(StatusCodes.Status500InternalServerError, MediaTypeNames.Application.ProblemJson)]
Exceptions (if any)
No response
.NET Version
10.0.100-preview.4.25258.110
Anything else?
No response