vs-swagger-viewer: External refs not working
If you have ref like this $ref: "common.yaml#/definitions/StatusMessage"
you will get this error message:
Resolver error at paths./authenticate.post.responses.401.schema.$ref
Could not resolve reference because of: Tried to resolve a relative URL, without having a basePath. path: 'common.yaml' basePath: 'undefined'
Resolver error at paths./authenticate.post.responses.default.$ref
Could not resolve reference because of: Tried to resolve a relative URL, without having a basePath. path: 'common.yaml' basePath: 'undefined'
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 31
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Issue fix - "External refs not working #45" — committed to arjun-g/vs-swagger-viewer by arjun-g 5 years ago
- Fix for a part of #45 As mentioned by @Galiaf47, not having the main file in project root causes validation errors. * Changed the working directory to match the main Swagger file * Refactored the va... — committed to yuri1969/vs-swagger-viewer by yuri1969 5 years ago
- Merge pull request #56 from yuri1969/45-request-by-@Galiaf47 Fix for a part of #45 — committed to arjun-g/vs-swagger-viewer by arjun-g 5 years ago
Long time still here. Good reason to use another tool. Could you please increase the priority of this issue?
Hey devs, very sorry for the delayed response. Will try to push a fix for this by this week.
Hello
I tried this with the following setup:
I tried using relative paths using ".", “./” prefix and no prefix. All of them result in the same error as mentioned above. I even tried to use absolute paths, still the same error. It still thinks it’s a relative path. In a desperate attempt I even tried an absolute path with protocol prefix “file:///”, still no luck.
So I went ahead and busted out a linter. Openapi-lint says the file is valid. So there’s definitely something wrong with the parsing of the paths here.
My team and I would be really glad if this would get resolved soon. This bug makes it difficult to work on large projects, because keeping every thing in one file is just not feasible.
Thanks for your effort and cheers
Thanks for fix. There is another bug. If you make a workspace with two directories, where a project in one directory and openapi.yml is in another directory $ref: 'User.yml will look into first directory and will not find it. I am creating separate project for openapi and want to have it in the same workspace as main project, but this setup does not work for me. Could you please look at this case?
Published a new version (2.2.1) with fix for this. After trying with multiple complicated methods, the fix seemed to be a rather simpler one. But I am not closing this issue for now. Still skeptical if this resolves all use cases.
Is there any news on this? I have just started to use Swagger with swagger-ui-express and when I try to use a simple reference like
I get again the classical error without any details:
I tried to use
"basePath": "/"
, but it does nothingAny news?