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

Swagger UI cannot expand operations #1

Open
nikos opened this issue Feb 24, 2017 · 6 comments
Open

Swagger UI cannot expand operations #1

nikos opened this issue Feb 24, 2017 · 6 comments

Comments

@nikos
Copy link

nikos commented Feb 24, 2017

When trying to click on an operation (for example "get posts") Swagger is not able to expand the details, but seems to try to open an non-existant URL: http://localhost:8888/api/#!/blog%2Fposts/get_posts_collection

swagger-open-problem

@postrational
Copy link
Owner

I looks as if the JavaScript sources did not load correctly. Are you seeing any errors in the Console or Network tabs of Dev Tools?

@nikos
Copy link
Author

nikos commented Feb 28, 2017

Nope, that was the idea of my animated gif, that you can see that there are no errors. For me the URL pattern issues for Swagger seems related on how flask-restplus is used in combination with Blueprint. As soon as I initialize the API without Blueprint, Swagger UI is happy.

@postrational
Copy link
Owner

So far, i was unable to reproduce your problem. Could you perhaps submit a pull request with the change you had to make to fix it?

@niko86
Copy link

niko86 commented Apr 3, 2017

I had the same issue, I resolved it by using the requirements.txt package version for flask-restplus, I had been using the most recent pip install version.

@postrational
Copy link
Owner

Possibly related to: noirbizarre/flask-restplus#278

@jwmullally
Copy link

FYI it looks like the flask-restplus issue mentioned in the last comment is also breaking bravado client generation (see noirbizarre/flask-restplus#278 (comment) )

It seems like an upstream issue, but could be worth fixing here as this tutorial is high up on search indexes for "Flask REST Swagger", and client generation is one of the main reasons to use Swagger.

This is a workaround:

diff --git a/rest_api_demo/api/blog/endpoints/categories.py b/rest_api_demo/api/blog/endpoints/categories.py
index 140d173..c974f56 100644
--- a/rest_api_demo/api/blog/endpoints/categories.py
+++ b/rest_api_demo/api/blog/endpoints/categories.py
@@ -9,7 +9,7 @@ from rest_api_demo.database.models import Category
 
 log = logging.getLogger(__name__)
 
-ns = api.namespace('blog/categories', description='Operations related to blog categories')
+ns = api.namespace('blog_categories', path='/blog/categories', description='Operations related to blog categories')
 
 
 @ns.route('/')
diff --git a/rest_api_demo/api/blog/endpoints/posts.py b/rest_api_demo/api/blog/endpoints/posts.py
index 0294c18..95f0313 100644
--- a/rest_api_demo/api/blog/endpoints/posts.py
+++ b/rest_api_demo/api/blog/endpoints/posts.py
@@ -10,7 +10,7 @@ from rest_api_demo.database.models import Post
 
 log = logging.getLogger(__name__)
 
-ns = api.namespace('blog/posts', description='Operations related to blog posts')
+ns = api.namespace('blog_posts', path='/blog/posts', description='Operations related to blog posts')
 
 
 @ns.route('/')

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

4 participants