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 will never display in urls correctly #157
Comments
I can get swagger to display just fine, but i have restricted security for validation so the validation doesn't work currently. If I change the redoc template to point to the /swagger.json url it seems to work fine. |
swagger validator response with permissions.AllowAny:
|
I'm sorry, I don't really follow.
Am I getting this right?? In any case, I would need more than this in order to trace the bug, like something to reproduce it - project code, or at least the generated swagger files. |
Sorry for taking so long to get back to you. I have tried a couple of things and here is what I have found: current urls.py swagger_info = openapi.Info(
title="Streisand API",
default_version='v1',
description="""Streisand API Swagger Definition""", # noqa
terms_of_service="https://www.something.com/policies/terms/",
contact=openapi.Contact(email="contact@something.xyz"),
license=openapi.License(name="MIT License"),
)
SchemaView = get_schema_view(
validators=['ssv', 'flex'],
public=True,
permission_classes=(permissions.IsAuthenticated,),
) URLS for redoc and swagger: url(r'^swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'),
url(r'^swagger/$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
url(r'^redoc/$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
url(r'^cached/swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=None), name='cschema-json'),
url(r'^cached/swagger/$', SchemaView.with_ui('swagger', cache_timeout=None), name='cschema-swagger-ui'),
url(r'^cached/redoc/$', SchemaView.with_ui('redoc', cache_timeout=None), name='cschema-redoc'), swagger urls are fine. Redoc urls are not. If I use a base html file with redoc in it: Because I still get the error for any redoc url.
I have attached my swagger json file for you to review. |
Just an FYI I was able to spin up a stand-alone redoc instance and npm installed. Redoc had no problem with using swagger.json or swagger.yaml as the specurl but received the exact same error with ?format=openapi. I honestly have no idea how your demo site works using it. |
Hmm... which version of redoc did you use?
|
Here is my package.json { |
And do you get differing swagger JSON content when downloading from |
Well I can’t set the specurl as itself/?format=openapi. Maybe I’m trying something wrong. I have to set the spec as the swagger file. Am I doing something wrong? |
I mean if you go
Do you get identical files? |
You can’t wget that way it outputs To a file called index.html?format=openapi |
Wget for swagger.json works fine |
I could work on updating your Redoc file to requesting the swagger json file if that would help. Not sure where in your code you do this besides the static folder. |
|
The latest commit on master should allow you to set the spec url for the bundled ReDoc... can you confirm that it works if you set it to |
Yes that worked perfectly thank you so much!! You are awesome and I love this package and your responsiveness to the repo!! |
Confirmed that the setting fixes it but it doesn’t work if I don’t use the new spec url setting.
|
I'm having a hard time following... If you set REDOC_SETTINGS = {
'SPEC_URL': 'https://api.something.com/api/v1/swagger.json'
} Does it then magically start working? Or does it have no effect? Make sure to install drf-yasg from this git repo (because the SPEC_URL change is not yet pushed to pypi). |
Sorry for the confusion. What I am saying is that yes it does work, with the new setting. I was just letting you know that the new setting is the only way to fix it and ?format=openapi continues to break it. Thanks for adding that to the code! |
Given that I can't reproduce this, and that a workaround has been implemented, I'm closing this as a heisenbug... |
@axnsan12 @theSaltman I'm getting this same issue in
then redoc works fine. Without that and a setup like the one above and the one in the docs I get: This is an issue as i want to have multiple docs endpoints and seeing as the redoc setting is global, this workaround isn't enough. |
That's still not enough info to work on, I'd need a full project that reproduces this, or some output to compare from the two different URLs... |
What output do you need? the |
Ever since I have installed drf-yasg (Almost 6 months ago), I cannot seem to get redoc to work correctly.
Here is the normal error I get:
Here is my usual url layout for swagger and redoc:
And my settings:
Quick note: if I change permissions to permissions.AllowAny Redoc fails but validation still works.
The text was updated successfully, but these errors were encountered: