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

Error resolving $ref pointer #541

Closed
ramsey opened this issue Jun 19, 2018 · 11 comments
Closed

Error resolving $ref pointer #541

ramsey opened this issue Jun 19, 2018 · 11 comments

Comments

@ramsey
Copy link

ramsey commented Jun 19, 2018

I'm using speccy to resolve separate OpenAPI files into a single file, but while this single file validates and displays properly in the Swagger Editor, ReDoc has problems with it.

Actual Results

This is the error I'm seeing when trying to load my OpenAPI documentation in ReDoc:

Error resolving $ref pointer "https://files.benramsey.com/test/openapi-redoc/openapi.json#/paths/~1user/post/requestBody/content/application~1vnd.example%2Bjson/schema". Token "application/vnd.example%2Bjson" does not exist.

redoc-error

You can see a live example of the error here:

Expected Results

I expect to see ReDoc render the documentation, like this: https://files.benramsey.com/test/openapi-redoc/working.html.

Steps To Reproduce

A complete example repository with all the source files and instructions I use to generate them is located here: https://github.com/ramsey/openapi-redoc-testing.

Noteworthy Behavior

In the example repository, if I move the external path schemas (./openapi/paths/user.yaml and ./openapi/paths/user-id.yaml) into the ./openapi/openapi.yaml file (instead of using $ref), then when I resolve it with speccy, ReDoc is properly able to render this.

This working example was produced by moving the external path schemas into the main openapi.yaml document:


It's possible this is an issue with how speccy resolves the paths and not ReDoc, but I've discussed with @philsturgeon, and he recommended I talk to the ReDoc team first to rule it out.

@RomanHotsiy
Copy link
Member

Thanks again for the detailed issue report!

It seems to be caused by the issue in json-schema-ref-parser. I've opened a PR already: APIDevTools/json-schema-ref-parser#90

@ramsey
Copy link
Author

ramsey commented Jun 20, 2018

Thanks for investigating.

I built a new standalone redoc with the commit from your PR here: APIDevTools/json-schema-ref-parser#90

Unfortunately, I'm still getting an error, though the error has changed. You can see it here: https://files.benramsey.com/test/openapi-redoc/parser-5fe2988.html

Perhaps I built the standalone version wrong? I changed the dependency in package.json to:

"json-schema-ref-parser": "git+https://github.com/RomanGotsiy/json-schema-ref-parser.git#5fe2988"

And then I ran npm run bundle and grabbed the files from the bundles/ folder.

@RomanHotsiy
Copy link
Member

Opened one more PR: manuelstofer/json-pointer#30 (which is a dependency of openapi-sampler which is a dependency of ReDoc)

I will try to migrate openapi-sampler to use json-schema-ref-parser's json pointer resolver to not depend on two libs for the same functionality.

RomanHotsiy added a commit that referenced this issue Jun 20, 2018
@RomanHotsiy
Copy link
Member

actually just figured out I was wrong with the PR to json-pointer.
Fixed it directly in openapi-sampler and released 1.0.0-beta.13

@ramsey
Copy link
Author

ramsey commented Jun 20, 2018

Great! That does fix the problem:
https://files.benramsey.com/test/openapi-redoc/redoc-52adc93.html

@ramsey
Copy link
Author

ramsey commented Jun 20, 2018

(together with your PR to json-schema-ref-parser, that is)

@thj-dk
Copy link

thj-dk commented Jun 21, 2018

When can we expect this fix to be released? :)

@RomanHotsiy
Copy link
Member

Once this fix is released Mermade/oas-kit#70

@ramsey
Copy link
Author

ramsey commented Jul 12, 2018

It looks like the fix in Mermade/oas-kit#70 is in swagger2openapi v3.0.x, and ReDoc was updated to v3.1.2 in e80881f, but even though my example is loading from the CDN (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js), I'm still seeing the same error.

See here: https://files.benramsey.com/test/openapi-redoc/index.html

@RomanHotsiy
Copy link
Member

Oh, sorry.
It's blocked by APIDevTools/json-schema-ref-parser#90 now :(

@ramsey
Copy link
Author

ramsey commented Jul 16, 2018

Thanks!

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