aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Microsoft.Extensions.ApiDescription.Server - Nullable query parameters are not generated as nullable in OpenAPI Document

Open MattParkerDev opened this issue 6 months ago • 0 comments

cc: @captainsafia Nullable query parameters are not generated as nullable in OpenAPI Document, such as:

group.MapGet("long", (long? myLong) => { })
			.WithName("NullableLong");

becomes:

"get": {
        "tags": [
          "Nullable"
        ],
        "operationId": "NullableLong",
        "parameters": [
          {
            "name": "myLong",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }

I believe the cause is line 745: https://github.com/dotnet/aspnetcore/blob/684e739228ae335a81e0dc7154e5c362f478cfc8/src/OpenApi/src/Services/OpenApiDocumentService.cs#L739-L761

Is there a historical reason for always unwrapping nullable parameter types?

MattParkerDev avatar Jun 13 '25 15:06 MattParkerDev