.Net OpenApi - JsonStringEnumConverter Enums should explicitly be generated as string type (to be rendered correctly by SwaggerUI) #62022
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 using SwaggerUI with the built-In OpenAPI interface in .Net 9, enum members are not displayed in the Schemas section.
OpenAPI generates the enum schema:
In SwaggerUI enum members are not displayed in the Schemas section:
Expected Behavior
OpenAPI should generate the schema with type explicitly set to "string":
... in order to be rendered correctly by SwaggerUI.
I assume "type": "string" is missing, because SwaggerGen creates the schema exactly like that.
Should JsonStringEnumConverter enums not explicitly be documented in OpenAPI Spec as string type anyway?
Steps To Reproduce
Brand new .NET 9 Web API from template, with OpenAPI enabled.
Define the enum:
Add enum property to the WeatherForecast model:
Nuget Package "Swashbuckle.AspNetCore.SwaggerUI"
Launch app
Look at /swagger/index.html
Observe MyStatus in the Schemas section.
Exceptions (if any)
No response
.NET Version
9.0.204
Anything else?
Scalar can deal with the current OpenAPI generator output, enum members are displayed. But Scalar lacks OpenIdConnect support, which makes it currently unusable by our project.
The text was updated successfully, but these errors were encountered: