Skip to content

OpenApi 3.1: dereferencing of Objects with outside context #447

@char0n

Description

@char0n

During the dereferencing of Response and Header Objects, certain situations may arise where resulting dereferenced graph will no longer reflect the intention of specification author.

Response Object example:

{
  "openapi": "3.1.0",
  "components": {
    "responses": {
      "201": {
        "description": "201 description",
        "headers": {
          "Content-Type": {
            "description": "The number of allowed requests in the current period",
            "schema": {
              "type": "integer"
            }
          }
        }
      },
      "400": {
        "$ref": "#/components/responses/201"
      }
    }
  } 
}

Dereferenced form:

{
  "openapi": "3.1.0",
  "components": {
    "responses": {
      "201": {
        "description": "201 description",
        "headers": {
          "Content-Type": {
            "description": "The number of allowed requests in the current period",
            "schema": {
              "type": "integer"
            }
          }
        }
      },
      "400": {
        "description": "201 description",
        "headers": {
          "Content-Type": {
            "description": "The number of allowed requests in the current period",
            "schema": {
              "type": "integer"
            }
          }
        }
      }
    }
  } 
}

The original "201" response is now listed under code "400", but original Response metadata are still set to httpStatusCode=201. We need to remedy this by overriding metadata of Response` after dereferencing has occured.

The same applies for Header Object, possibly Path Item Object and Media Type Object

Full mapping of Objects with outside context can be found here: #450

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions