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

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