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

Swagger Editor does not resolve local files referenced with $ref #1630

Closed
vnalla opened this issue Jan 9, 2018 · 6 comments
Closed

Swagger Editor does not resolve local files referenced with $ref #1630

vnalla opened this issue Jan 9, 2018 · 6 comments

Comments

@vnalla
Copy link

vnalla commented Jan 9, 2018

Q A
Bug or feature request? Looks like a bug
Which Swagger/OpenAPI version? Swagger version 2.0
Which Swagger-Editor version? 3.2.2
How did you install Swagger-Editor? downloaded from github, unzipped and opened index.html file in FireFox browser
Which broswer & version? FireFox 52.4.0(32-bit52ESRv2
Which operating system? Windows 7
   parameters:
        - $ref: './header_parameters.yaml#/xcsimessageid'
        - $ref: './header_parameters.yaml#/xcsitimetolive'
        - $ref: './header_parameters.yaml#/ctnid'
  parameters:
        - $ref: >-
            file:///C:/OpenAPI/header_parameters.yaml#/xcsimessageid
        - $ref: >-
            file:///C:/OpenAPI/header_parameters.yaml#/xcsitimetolive
        - $ref: 'file:///C:/OpenAPI/header_parameters.yaml#/ctnid'

Configuration (browser query string, constructor, config.yaml)

No special configuration

Expected Behavior

If the spec is broken in to multiple files, there should be a way to resolve the files with relative path. All the files are in the same directory.

Current Behavior

ERROR: Could not resolve reference because of: Tried to resolve a relative URL ...
the second one with file:/// prefix results in the error: Could not resolve reference because of: NetworkError when attempting to fetch resource.
Replaced them with http url's but still the same network error as file uri. The files are served from Tomcat 7 and CORS filter enabled at the server level in <CATALINA_BASE>/conf/web.xml file

Possible Solution

relative path should work

Context

Trying to break specification in to multiple files.

@hkosova
Copy link
Contributor

hkosova commented Jan 9, 2018

Related (or duplicate): #1409, #1534

@shockey
Copy link
Contributor

shockey commented Jan 11, 2018

@vnalla, hopefully you can clarify one thing for me: are you accessing your Swagger-Editor through a file:// URI or is your Tomcat server serving it to you?

@vnalla
Copy link
Author

vnalla commented Jan 15, 2018

I tried both, with the same error:

    parameters:
      - $ref: >-
            http://localhost:7070/files/header_parameters.yaml#/xcsimessageid
        - $ref: >-
            http://localhost:7070/files/header_parameters.yaml#/xcsitimetolive
        - $ref: >-
            http://localhost:7070/files/header_parameters.yaml#/ctnid

Could not resolve reference because of: NetworkError when attempting to fetch resource.

@vnalla
Copy link
Author

vnalla commented Jan 15, 2018

if the swagger editor is deployed in the same server, serving the files than it is able to resolve references, otherwise it is not even sending the requests from browser and results in the following errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:7070/files/e911address.yaml. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). (unknown)
TypeError: NetworkError when attempting to fetch resource.

@shockey
Copy link
Contributor

shockey commented Jan 15, 2018

@vnalla, ah, I see. This is not Swagger-Editor's fault: in order to allow your browser to make requests to a different origin, you need to set some specific browser security-related headers. https://enable-cors.org is a good place to start for this.

For more context, check out Same-origin policy.

@shockey
Copy link
Contributor

shockey commented Jan 22, 2018

Closing due to inactivity.

This is simply to keep our issue tracker clean - feel free to comment if there are any further thoughts or concerns, and we'll be happy to reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants