-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
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
A nullable enum query parameter is produced as straight string type in the OpenApi schema, the $ref statement is missing:
"parameters": [
{
"name": "status",
"in": "query",
"schema": {
"type": "string",
"default": null
}
}
],
... if the enum parameter is not nullable, the OpenApi schema has a proper $ref statement to link the asscociated enum component:
"parameters": [
{
"name": "status",
"in": "query",
"schema": {
"$ref": "#/components/schemas/MyStatus"
}
}
],
Expected Behavior
A nullable enum query parameter should be presented by default with a $ref statement to link the asscociated enum component:
"parameters": [
{
"name": "status",
"in": "query",
"schema": {
"$ref": "#/components/schemas/MyStatus",
"default": null
}
}
],
Steps To Reproduce
-
Brand new .NET 9 Web API from template, with OpenAPI enabled.
-
Define the enum:
[JsonConverter(typeof(JsonStringEnumConverter<MyStatus>))]
public enum MyStatus
{
MyStatus1,
MyStatus2,
MyStatus3
}
- Update WeatherForecastController Get method signature to include a nullable enum query parameter:
public IEnumerable<WeatherForecast> Get([FromQuery] MyStatus? status = null) { ...
- Launch app
- Look at /openapi/v1.json
- Observe status parameter of GetWeatherForecast operation
Exceptions (if any)
No response
.NET Version
9.0.103
Anything else?
No response
jankaltenecker and Donneh
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