Redoc: Invalid Spec Leads to Error Without Init Callback

Created on 26 Oct 2018  路  12Comments  路  Source: Redocly/redoc

Hello. In ReDoc 2.0.0-alpha.40 when generating ReDoc from a YAML file with a path with an empty tag (only the hyphen) ReDoc results in a "Something went wrong..." page with the below stack trace. The callback provided to init() is not invoked, so the surrounding application cannot recover from the error.

slugify: string argument expected
Stack trace
Error: slugify: string argument expected
    at t (http://localhost:9000/scripts/redoc.standalone.js:52:44272)
    at ae (http://localhost:9000/scripts/redoc.standalone.js:99:16985)
    at new e (http://localhost:9000/scripts/redoc.standalone.js:99:38568)
    at Function.e.getTagsItems (http://localhost:9000/scripts/redoc.standalone.js:99:51355)
    at Function.e.buildStructure (http://localhost:9000/scripts/redoc.standalone.js:99:50551)
    at new <anonymous> (http://localhost:9000/scripts/redoc.standalone.js:99:38384)
    at new e (http://localhost:9000/scripts/redoc.standalone.js:105:28591)
    at t.makeStore (http://localhost:9000/scripts/redoc.standalone.js:99:60285)
    at t.render (http://localhost:9000/scripts/redoc.standalone.js:99:61129)
    at Ai (http://localhost:9000/scripts/redoc.standalone.js:68:62703)

ReDoc Version: 2.0.0-alpha.40 
Commit: 8f7fccc
bug

Most helpful comment

@rosshardy ahh, got it. Sorry.
Reopening.

All 12 comments

(only the hyphen)

is not an empty tag. It is equivalent to:

- null

So this is not valid spec as tags should be an array of string

image

To fix your spec you can use empty string:

- ""

@RomanGotsiy The issue is not the validity of the spec. The issue is that there is no way to recover from this in a solution leveraging ReDoc because the callback on init() is not honored. The ReDoc documentation says that the callback is called in the cases of an error, but in this case it is not.

@rosshardy ahh, got it. Sorry.
Reopening.

For additional context of the use case: we are trying to build a VSCode plugin which previews specs real-time as they are being built out or modified. However when the user edits tags and clears the tag out, the preview bombs out and there's no apparent way to recover ReDoc after the user corrects the spec.

For additional context of the use case: we are trying to build a VSCode plugin which previews specs real-time as they are being built out or modified.

馃槻This sounds super exciting! Is there any chance I can take a sneak peek of it?

I will look into the issue ASAP (most likely tomorrow morning).

At the current time we are not permitted by our company to open source our efforts, however we would like to contribute it back to the community so others can benefit from it as we benefit from much open-source. We are working on changing our company's position on this. If that happens, we would be happy to share it.

Thank you for looking into it promptly!

Fixed! Will be released in the upcoming alpha.

At the current time we are not permitted by our company to open source our efforts

Could you at least share a screenshot or a gif of it with me privatelly? E.g. DM on twitter. I'm super curious 馃

Yes. E-mailed it to you. Thanks again for the prompt turnaround!

@RomanGotsiy any estimate when the next alpha build will be released? Thank you.

Will be released early this week.

Will be released early this week.

Will the release be coming soon? Thanks!

@rosshardy Check out [email protected] or use redoc@next

Was this page helpful?
0 / 5 - 0 ratings