Skip to content

Failed to parse swagger 2.0 document that contains null value at examples #1959

@filzrev

Description

@filzrev

Describe the bug

When parsing swagger 2.0 document that contains null value at examples.
It failed to parse document with OpenApiError with message Expected a value and Pointer: null.

It's occurred when using Microsoft.OpenApi.Readers 2.0.0-preview2.
When using 1.6.22, It can successfully parse document without problems.

OpenApi File To Reproduce

{
  "swagger": "2.0",
  "info": {
    "title": "Example",
    "version": "1.0"
  },
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "description": "200:OK",
            "examples": {
              "application/json": {
                "dummyValue": null
              }
            }
          }
        }
      }
    }
  },
  "host": "localhost",
  "basePath": "/",
}

Expected behavior
OpenApiDocument.Parse(text).OpenApiDocument returns parsed OpenAPI documents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions