8000 Cannot put extension in RequestBody serialized to OASv2 · Issue #510 · microsoft/OpenAPI.NET · GitHub
[go: up one dir, main page]

Skip to content

Cannot put extension in RequestBody serialized to OASv2 #510

@dipidoo

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": { }
      }
    }
  }
}

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

      0