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 refs not working #45

Open
zd-dalibor opened this issue Aug 21, 2018 · 12 comments
Labels
bug

Comments

@zd-dalibor
Copy link

@zd-dalibor zd-dalibor commented Aug 21, 2018

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'
@cassioconti

This comment has been minimized.

Copy link

@cassioconti cassioconti commented Jan 17, 2019

image

@Galiaf47

This comment has been minimized.

Copy link

@Galiaf47 Galiaf47 commented Jan 22, 2019

Long time still here. Good reason to use another tool. Could you please increase the priority of this issue?

@cbaurand

This comment has been minimized.

Copy link

@cbaurand cbaurand commented Feb 13, 2019

We are interested in a fix for that! Thanks.

@Niggggggo

This comment has been minimized.

Copy link

@Niggggggo Niggggggo commented Feb 25, 2019

Any news on this?

@gilgwath

This comment has been minimized.

Copy link

@gilgwath gilgwath commented Mar 8, 2019

Hello

I tried this with the following setup:

  • Swagger Viewer: 2.2.0
  • VS code: 1.3.1.1
  • Electron: 3.1.2
  • Node.js: 10.2.0
  • OS: Windows 10.0.16299

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

@arjun-g

This comment has been minimized.

Copy link
Owner

@arjun-g arjun-g commented Mar 11, 2019

Hey devs, very sorry for the delayed response. Will try to push a fix for this by this week.

@arjun-g arjun-g added the bug label Mar 11, 2019
@arjun-g arjun-g pinned this issue Mar 11, 2019
@hatakawas

This comment has been minimized.

Copy link

@hatakawas hatakawas commented Mar 21, 2019

Any news?

@arjun-g

This comment has been minimized.

Copy link
Owner

@arjun-g arjun-g commented Mar 26, 2019

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.

@gilgwath

This comment has been minimized.

Copy link

@gilgwath gilgwath commented Mar 26, 2019

I just updated and tried relative paths with no prefix, "." and "./" as well as absolute paths (with and without spaces in them) and it works. The example values for request and response body all show the correct Sample Value and Model.

Thanks for fixing this so quickly ! Good work!

After changing the path style I have to manually do the "Preview Swagger" command, the auto refresh does not pick it up and the Sample Values and Models are blank. But that's not that big a deal.

The Models section at the bottom of the page however does not display the models imported from other files, even though they are picked up for the Model/Sample Value in the HTTP Method descriptions. Should I file a separate issue for this?

@arjun-g

This comment has been minimized.

Copy link
Owner

@arjun-g arjun-g commented Mar 26, 2019

@gilgwath thanks for your feedback.

I just noticed changes to referenced files doesn't auto refresh the viewer. This might be a difficult one to fix but I will look into it.

Regarding the Models section issue it would great if you can share me some sample files for which this happens.

@Timunas

This comment has been minimized.

Copy link

@Timunas Timunas commented Mar 28, 2019

I'm trying to reference a file using ../../directory/file.yaml and I get the same error.
I'm using the new version 2.2.1 at least is what visual studio code shows.

@Galiaf47

This comment has been minimized.

Copy link

@Galiaf47 Galiaf47 commented Mar 31, 2019

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?

yuri1969 added a commit to yuri1969/vs-swagger-viewer that referenced this issue Apr 2, 2019
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 validation and error reporting a bit
arjun-g added a commit that referenced this issue Apr 14, 2019
Fix for a part of #45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.