Skip to content

Cannot put extension in RequestBody serialized to OASv2 #510

Closed

Description

@dipidoo

Microsoft.OpenAPI NuGet v1.2.2

Serializing to OASv3 outputs the extension as expected. The v2 spec seems to allow it.

Repro:

            var doc = new OpenApiDocument()
            {
                Paths = new OpenApiPaths()
            };
            doc.Paths.Add("/bar", new OpenApiPathItem()
            {
                Operations = { { OperationType.Post, new OpenApiOperation()
                {
                    RequestBody = new OpenApiRequestBody()
                    {
                        Extensions = { { "x-ms-foo", new OpenApiBoolean(true) } }
                    }
                } } }
            });
            Console.Out.Write(doc.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0));

Actual:

{
  "swagger": "2.0",
  "info": { },
  "paths": {
    "/bar": {
      "post": {
        "consumes": [ ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "schema": { }
          }
        ],
        "responses": { }
      }
    }
  }
}

Expected:

{
  "swagger": "2.0",
  "info": { },
  "paths": {
    "/bar": {
      "post": {
        "consumes": [ ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "schema": { },
            "x-ms-foo": true
          }
        ],
        "responses": { }
      }
    }
  }
}

Activity

  1. dipidoo commented on Aug 10, 2020

    @dipidoo
    MemberAuthor

    Additionally, it also seems to be unable to read the extension off a spec, using OpenApiStringReader

  2. added this to the 1.2.3 milestone on Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions