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

Redoc view broken #631

Closed
Hraesvelg opened this issue Jan 12, 2022 · 11 comments
Closed

Redoc view broken #631

Hraesvelg opened this issue Jan 12, 2022 · 11 comments

Comments

@tfranzel
Copy link
Owner

This seems like an upstream issue. We use a CDN for the UIs. Redoc is vanilla and swagger only has minor changes. They both use the latest version via CDN. You can change this with our settings:

SPECTACULAR_SETTINGS = {
    'REDOC_DIST': 'https://cdn.jsdelivr.net/npm/redoc@latest',
}

Upstream problems usually get resolved quickly. Otherwise change the latest to a version that works for you.

@Hraesvelg
Copy link
Author

thanks tfranzel, i tried your settings with many version but without effect. you are right, it seems the error come from redoc, if you search "slugify" in redoc https://cdn.jsdelivr.net/npm/redoc@2.0.0-rc.59/bundles/redoc.standalone.js you find the message and yes probably a comparison failed

@tfranzel
Copy link
Owner

If this happens for several different version, we may need look into it. ReDoc has been working fine last I checked. Maybe it chokes on your specific schema for some reason. Generally it's not supposed to throw exceptions no matter what the schema contains. It's hard to say more without the actual schema that produces the error.

Maybe we produce a schema ReDoc has issues with. I would need more context to investigate. In either case you should open an issue upstream.

@Hraesvelg
Copy link
Author

I can't share the entire schema because he contains sensible informations, but i can confirm that file is valid for pyyaml. the safe_load() work without error. i will try to remove specific part to see if redoc return view...

@tfranzel
Copy link
Owner

I can't share the entire schema because he contains sensible informations

yeah I figured that. Valid yaml does not necessarily mean valid OpenAPI. A better indicator would be do validate the schema against the OpenAPI specification:

./manage.py spectacular --validate --file schema.yml

But that again is not gonna catch all potential issues. You will need to produce a minimal reproduction, otherwise I can't really do anything. Have you checked if SwaggerUI works as expected? that could give a hint. I would start removing stuff from the schema until its not broken anymore.

@Hraesvelg
Copy link
Author

Ok bad news for me ...

i checked the schema with spectacular --validate : he return 8 errors but without important just missing serializer in viewset and he say that he ignore it...
i have also generate the view with redoc-cli and it works ! the redoc.standalone.js is include directly in the html so i can't check the version

@tfranzel
Copy link
Owner

the warning are there to guide you to a accurate schema. 99% of those default to something valid, however that may not match your API perfectly, hence the warning. they are supposed to be fixed with @extend_schema etc. (see documentation on how to use it)

If the command does not fail with a big stacktrace (highlighting the offenses) then the schema appears to be valid wrt the OpenAPI specification.

pretty sure redoc.standalone.js contain a version string if you inspect it in browser debugger. I cannot comment on the difference between the redoc-cli output and the "web" version. I believe in theory they should be functionally identical.

@tfranzel
Copy link
Owner

looks like this could be related: Redocly/redoc#690

though I would have thought that specific issue with tags would make --validate fail. you should check for null in tags first. i'm not aware of a case that would generate empty tags by default though. if that is the case we might have a bug.

@Hraesvelg
Copy link
Author

Hraesvelg commented Jan 17, 2022

Hi tfranzel,

i found the origin issue ! it is because i have "tags" key at the end of my schema :
if you want, you can try to add :

tags:
- FOO
- BAR

redoc-cli return the same error when i have this element in my schema (slugify ...)

Edit :
after i commented the TAGS settings, it works but it seems redoc doesn't show my components/schema ...

@tfranzel
Copy link
Owner

So it is a upstream issue after all i suppose. for us there is nothing really that we should or could change.

You should open an issue with them with a minimal reproduction. you can reference this issue.

@tfranzel
Copy link
Owner

tfranzel commented Feb 1, 2022

closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up.

@tfranzel tfranzel closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants