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

Resolver error at ... Could not resolve reference because of: Unauthorized #3220

Closed
dylancwood opened this issue Jun 10, 2017 · 6 comments
Closed

Comments

@dylancwood
Copy link

  • swagger-ui-dist version v3.0.13

Our server uses http-basic authentication to protect our API docs (for some reason that I don't understand). Once a user logs in, the browser will send the appropriate authorization header with all requests for JS, CSS, XHR, images, etc... The swagger-ui renders quite well, except that it has a giant red error message on top stating the following:

Errors:
Resolver error at definitions.status.$ref
Could not resolve reference because of: Unauthorized
Resolver error at definitions.supportedStoresData.$ref
Could not resolve reference because of: Unauthorized

screen shot 2017-06-09 at 7 26 11 pm

This is due to a 401 response when trying to retrieve definitions.json.

Looking at the network panel of Chrome dev tools, I see that the core JSON swagger file was fetched via XHR using the HTTP authorization headers as expected. However, the request to get definitions.json did not include any authorization headers.

screen shot 2017-06-09 at 7 24 09 pm
(Above: Network request to get core swagger.json file)

screen shot 2017-06-09 at 7 23 06 pm
(Above: Network request to get definitions.json file)

Thanks in advance for any advice.

@shockey
Copy link
Contributor

shockey commented Jun 10, 2017

Is this what you're looking for? #2793

@dylancwood
Copy link
Author

@shockey: Thank you, I had not seen that issue. It sounds like there is a work-around, but I don't see why that should be necessary. When someone authorizes (enters username/pwd) using the browser's built-in http-basic auth system, then the browser will send the authorization header on all future requests to the same protocol/domain/port. This is how swagger-ui is able to load all the assets (js, css, ajax, etc...) without re-prompting for a password each time.

There must be something special about the way definitions are retrieved that is causing the browser to omit authorization headers.

@shockey
Copy link
Contributor

shockey commented Jun 21, 2017

@dylancwood, I'm inclined to say that your PR last week (referenced above this comment) solves this 😄 Am I correct?

@shockey
Copy link
Contributor

shockey commented Nov 29, 2017

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.

@shockey shockey closed this as completed Nov 29, 2017
@anjukuriakose
Copy link

Hi,

Getting the same error.

In swagger, its validating . Please help me on this.
error

@shockey
Copy link
Contributor

shockey commented Oct 16, 2018

@anjukuriakose, it appears that your $refs are missing a # at the beginning of their values - it should be #/definitions/MathResourceList, not /definitions/MathResourceList.

@lock lock bot locked and limited conversation to collaborators Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants