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

Unable to reference a local yaml file. #14

Open
lalaqc opened this issue Apr 28, 2017 · 6 comments
Open

Unable to reference a local yaml file. #14

lalaqc opened this issue Apr 28, 2017 · 6 comments

Comments

@lalaqc
Copy link

lalaqc commented Apr 28, 2017

Cannot reference an object type specified in another local yaml file.

Example:

Persons:
    type: array
    items:
      $ref: "person.yaml#/Person"

@MinjieTao
Copy link

I have the same problem

@mfeitoza
Copy link

Same...

@ikarm
Copy link

ikarm commented Jan 9, 2018

any workaround for the problem

@tim-digitised
Copy link

Hey guys - I was having the same problem, but not with this particular extension, but just in general. Ended up finding and using this: https://github.com/mohsen1/multi-file-swagger-example and then wrote a small node app to monitor my files and update when ever changes are made.

Hope this helps

@cassioconti
Copy link

Seems related to #45

@skwasniak
Copy link

skwasniak commented Feb 25, 2022

any workaround for the problem

The only one I can think of is to compile a single file as in the Step 6 of this article (https://davidgarcia.dev/posts/how-to-split-open-api-spec-into-multiple-files/).

UPDATE:

Make sure to have the correct paths, which are file specific. So assuming you have the following file structure:

api/
├── definitions
│   └── Pet.yaml
├── main.yaml
└── paths
    └── cmd
        └── getPetById.yaml

In the main file you will write:

# main.yaml
...
paths:
    /pets/{petId}:
      $ref: "definitions/Pet.yaml"
...
definitions:
  Pet:
    $ref: "paths/cmd/getPetById.yaml"

And in the Pet.yaml (notice the relative path to Pet.yaml!):

# getPetById.yaml
  responses:
    "200":
      description: "Successful operation"
      schema:
          $ref: "../../main.yaml#/definitions/Pet"

You can use swagger-cli to validate the file, and see better error descriptions.

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

No branches or pull requests

7 participants