OpenAPI schema generation for nullable enums produce a null value option #60986
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
feature-openapi
Is there an existing issue for this?
Describe the bug
When an API method returns a model with a nullable field (or simply returns a nullable enum), the generated enum schema contains 'null' value at the end of the list, which is redundant and actually causes issues with models produced by source code generators (I've noticed an issue with at least this one but it may cause issues with others as well).
When returning a nullable enum outside of model, e.g.
The output is also inconsistent with the output from the scenario above (note the missing
"nullable": true
):Expected Behavior
I believe that nullable enums should always be modeled like so in all scenarios:
Steps To Reproduce
dotnet new webapi
)Microsoft.Extensions.ApiDescription.Server
version 9.0.2Program.cs
that came with the template with this code:For the other scenario (where the enum is not encapsulated within another model) use the following code:
Exceptions (if any)
No response
.NET Version
9.0.200
Anything else?
No response
The text was updated successfully, but these errors were encountered: