openapi-preprocessor icon indicating copy to clipboard operation
openapi-preprocessor copied to clipboard

YAML objects named "components" don't resolve

Open Sarah-MultiSafepay opened this issue 3 years ago • 1 comments

If I create a YAML object named "components" in my input.yaml file, any $ref, $inline or $merge commands don't resolve. It works fine if I name it "component" though.

Example input file with "components":

components:
  $inline: /../../openapi/openapi.json#/components

Example output:

{
  "components": {
    "$inline": "/../../openapi/openapi.json#/components"
  }
}

And when I rename it to "component":

Example input file:

component:
  $inline: /../../openapi/openapi.json#/components

Example output:

{
  "component": {
    "BearerAuth": {
      "scheme": "bearer",
      "type": "http"
    }
  }
}

I think I'm on the latest version: v0.0.0-20210319105711-a82b92013e23

@dolmen, can you help?

Sarah-MultiSafepay avatar Feb 15 '22 11:02 Sarah-MultiSafepay

/components is handled specially and it looks like there is a bug here.

Here is a workaround: use $inline on child properties of /components:

{
  "components": {
    "schemas": {
      "$inline": "../../openapi/openapi.json#/components/schemas"
    },
    "responses": {
      "$inline": "../../openapi/openapi.json#/components/responses"
    },
    ...
}

dolmen avatar Jun 02 '22 15:06 dolmen