vs-swagger-viewer
vs-swagger-viewer copied to clipboard
Unable to reference a local yaml file.
Cannot reference an object type specified in another local yaml file.
Example:
Persons: type: array items: $ref: "person.yaml#/Person"
I have the same problem
Same...
any workaround for the problem
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
Seems related to #45
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.