Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External reference is invalid when it appears in object properties #499

Closed
lusingander opened this issue Feb 28, 2022 · 2 comments · Fixed by #982
Closed

External reference is invalid when it appears in object properties #499

lusingander opened this issue Feb 28, 2022 · 2 comments · Fixed by #982

Comments

@lusingander
Copy link

lusingander commented Feb 28, 2022

Error occurs while loading spec file when references internal object definitions(defined in same file), and references external schema definitions in its properties.

some/dir/openapi.yml

openapi: 3.0.0
info:
  title: 'spec'
  version: 1.2.3

paths:
  /foo:
    get:
      summary: get foo
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Foo"

components:
  schemas:
    Foo:
      type: object
      properties:
        id:
          $ref: "./common/foo.yml"

some/dir/common/foo.yml

type: string

In this case, following errors occurs:

open some/common/foo.yml: no such file or directory

It seems that file paths is joined incorrectly.

@lusingander
Copy link
Author

In the following patterns, everything works correctly.

paths:
  /foo:
    get:
      summary: get foo
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    $ref: "./common/foo.yml"
paths:
  /foo:
    get:
      summary: get foo
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Foo"

components:
  schemas:
    Foo:
      $ref: "./common/foo.yml"
paths:
  /foo:
    get:
      summary: get foo
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Foo"

components:
  schemas:
    Foo:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Bar"
    Bar:
      type: string

@lusingander
Copy link
Author

It seems that #478 will resolve this issue.

AnatolyRugalev added a commit to AnatolyRugalev/kin-openapi that referenced this issue Jul 10, 2024
fenollp pushed a commit that referenced this issue Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant