"schema": {
"$ref": "./mydef.json"
}
Issue
I want to import a swagger using import in URL.
This swagger has relative $ref, but are not resolved. Indeed for every $ref I have the error:
✖ Swagger Error Reference could not be resolved: ./mydef.json
You cannot use the relative reference syntax in the editor. Why? Because what is it relative to? You can use external references but please use the entire host/port/path to them.
This answer might be naive: it is relative to the main/default swagger.json that the editor has no problems finding (location api/swagger/swagger.json)?
E.g. both files are in the same location
api/swagger/swagger.json
api/swagger/path-pets-get.json
then this reference should work:
paths:
/pets:
$ref: 'path-pets-get.yaml' # or './path-pets-get.json'
According to http://swagger.io/specification/#referenceObject
See also #639.
楼上就是坑人
in swagger.yaml, $ref for file must use full path, e.g. $ref: "api/swagger/routes/calendar.yaml"
in /calendar.yaml contains another $ref: "../model/calendar.yaml", in here it must be relative path, because model/calendar.yaml‘s parent is api/swagger/routes/calendar.yaml
in a world, use full path in swagger.yaml, in other yaml file use relative path
Most helpful comment
This answer might be naive: it is relative to the main/default
swagger.jsonthat the editor has no problems finding (locationapi/swagger/swagger.json)?E.g. both files are in the same location
then this reference should work:
According to http://swagger.io/specification/#referenceObject
See also #639.