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

Better error messages for diagnosis #113

Closed
natke opened this issue Sep 16, 2016 · 11 comments
Closed

Better error messages for diagnosis #113

natke opened this issue Sep 16, 2016 · 11 comments
Assignees

Comments

@natke
Copy link

natke commented Sep 16, 2016

When I try to render the documentation for my swagger.json spec, I get the following error:

Oops... ReDoc failed to render this spec

Unable to resolve $ref pointer

It's a rather large specification and probably has an error in it, but I need some more information to locate the error (if there is one). Is it possible to get access to some more information about the error?

I tried to run the demo locally but could not run the following step:

npm run jspm-install

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "jspm-install"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1

npm ERR! missing script: jspm-install

@RomanHotsiy
Copy link
Member

@natke, yes this error message definitely should be improved.
I will check this.

Actually, this error message comes from tool I use for reference resolving so most likely your spec has some unresolvable references. Try to validate your spec using editor.swagger.io.

Regarding npm run jspm-install: it's not actual anymore, I just forgot to update steps. Thanks for reporting this.

@natke
Copy link
Author

natke commented Sep 16, 2016

Thanks for the quick reply.

Is the tool you talking about: https://www.npmjs.com/package/json-schema-ref-parser?

I ran the spec through the tool manually and it generated the resolved spec fine. But maybe I didn't exactly replicate the calls to this tool in the way that redoc is doing? Is it possible to summarize the API calls you are using?

@RomanHotsiy
Copy link
Member

@natke, would be great if you're able to provide me with a minimal reproducible spec or the actual spec you are trying to visualize with ReDoc?

@natke
Copy link
Author

natke commented Sep 17, 2016

Hi again, I did manage to get it working. I think the problem was that I was trying to serve a file. Once I served both my index.html and my spec over http it worked fine.

I think that error message is not actually from the parser - it is from your code, but it looks like there is an unresolved promise somewhere in the call chain. Might be worth looking into, and adding some better diagnostics and tests.

@natke natke closed this as completed Sep 20, 2016
@RomanHotsiy
Copy link
Member

@natke, If you don't mind I will keep this issue open as it is not fixed: error messages sometimes are not clear

@natke
Copy link
Author

natke commented Sep 20, 2016

No problem - just wanted to indicate that I didn't have any further issues

@krsyoung
Copy link

@natke curious if I'm getting the same thing you were. What I was trying to do was run redoc with a local index.html and swagger file (i.e. just open them from the filesystem vs serving via HTTP). Is this what you were originally doing when you received the error?

In my case I get a full error as:

Unable to resolve $ref pointer "file:///tmp/instagram.yaml"

The HTML had:

<!DOCTYPE html>
<html>
<head>
  <title>API Docs</title>
  <!-- needed for mobile devices -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
  <redoc spec-url="instagram.yaml"></redoc>
  <script src="redoc.min.js"></script>
</body>
</html>

@natke
Copy link
Author

natke commented Sep 27, 2016

Yep, that's exactly what I saw

@pupi1985
Copy link

pupi1985 commented Nov 9, 2016

This actually looks like a bug. Faced the same issue here doing the same thing.

Unhandled Promise rejection:
Error: Uncaught (in promise): SyntaxError: Unable to resolve $ref pointer "file:///path/to/my/file/swagger.json"
at l (https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:45:23914)
at https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:45:24286
at t.invokeTask (https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:45:29397)
at Object.onInvokeTask (https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:11:1812)
at t.invokeTask (https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:45:29333)
at n.runTask (https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:45:26757)
at o (https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js:45:23374)

Same file is properly validated on the online editor. It is also properly displayed from a local web server, which has been my workaround so far.

@RomanHotsiy
Copy link
Member

RomanHotsiy commented Nov 12, 2016

@pupi1985 yes, I had a look at this and this is actually the issue.
The reason is that BigstickCarpet/json-schema-ref-parser doesn't support file:/// protocol.

I will fix this but this is not on the next-to-do queue coz this can be workarounded by simply running webserver

@RomanHotsiy
Copy link
Member

Will track this issue here: #149

Closing this as obsolete.

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

4 participants