Skip to content

Description in Response cannot be null #3069

Description

@StefH

Describe the bug
According to the spec, the description cannot be null.
https://spec.openapis.org/oas/v3.0.4.html

OpenApi File To Reproduce

var doc = new OpenApiDocument
{
    Paths = new OpenApiPaths
    {
        ["/example"] = new OpenApiPathItem
        {
            Operations = new Dictionary<HttpMethod, OpenApiOperation>
            {
                [HttpMethod.Get] = new OpenApiOperation
                {
                    Responses = new OpenApiResponses
                    {
                        ["200"] = new OpenApiResponse
                        {
                            // No description
                        }
                    }
                }
            }
        }
    }
};

using var stringWriter = new StringWriter();
doc.SerializeAs(OpenApiSpecVersion.OpenApi3_0, new OpenApiJsonWriter(stringWriter));
var result = stringWriter.ToString();

Expected behavior

{
  "openapi": "3.0.4",
  "info": { },
  "paths": {
    "/example": {
      "get": {
        "responses": {
          "200": {
          }
        }
      }
    }
  }
}

Actual behavior

{
  "openapi": "3.0.4",
  "info": { },
  "paths": {
    "/example": {
      "get": {
        "responses": {
          "200": {
            "description": null
          }
        }
      }
    }
  }
}

I used latest NuGet.


Swagger:

Image

Activity

  1. linked a pull request that will close this issueOmit null OpenAPI response descriptions #3077on Sep 10, 2026
  2. baywet commented on Sep 11, 2026

    @baywet
    Member

    Hi Stef Heyenrath (@StefH),
    Thank you for using the SDK and for reaching out.

    I've had copilot put together a pull request to address this issue. #3077

    Let me know if you have any additional comments or questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions