flask-restful-swagger
flask-restful-swagger copied to clipboard
Error extract operations
If any method (get, post,put, or delete) are not defined on a resource, swagger crashes, on file swagger.py, on line 98 you should validate if the method exist... and else, you should continue witch other one. Not all resources contains all methods.
My fast solution:
for method in resource.methods: ++ if method.lower() not in resource.dict: ++ continue method_impl = resource.dict[method.lower()]
I hope this helps!
Hi @sebaxq thanks for the issue (and very thanks for the proposed solution :smile:) However, I think I'm missing something. In the example there are cases where not all {put,get,post,delete} are defined, yet it doesn't crash. Could you provide a repro?
Hi @rantav I am creating an architecture and I am using inheritance to build services, here is on swagger breaks. I attached a picture of a small example.

Hi @sebaxq at first I thought it was b/c of inheritance and the fact that in the base class all four methods are defined but not all of them are defined in the concrete class. So I created a test case here https://github.com/rantav/flask-restful-swagger/commit/fd75de00cc1c3cbb5774f0ae7cbf488539d5060b
But this test passes. So I am still confused.... Would you be able to run this new test case I created and report? cheer.
Hello, I run the test case and it crashes. I attached a picture with the error.

Here the module package info:
Metadata-Version: 1.0 Name: flask-restful-swagger Version: 0.11 Summary: Extrarct swagger specs from your flast-restful project Home-page: https://github.com/rantav/flask-restful-swagger Author: Ran Tavory Author-email: UNKNOWN License: MIT Description: Please see documentation here: https://github.com/rantav/flask-restful-swagger Platform: UNKNOWN
Looks like a matter of versioning, maybe python version of a package version.
What does pip freeze tell you?
pip freeze
Flask==0.10.1
Flask-RESTful==0.2.8
Jinja2==2.7.1
MarkupSafe==0.18
SQLAlchemy==0.8.4
Werkzeug==0.9.4
distribute==0.6.35
itsdangerous==0.23
six==1.4.1
stevedore==0.8
virtualenvwrapper==3.7
wsgiref==0.1.2
And python --version:
python --version
Python 2.7.2
Sorry for the delay, here are my versions:
pip freeze
Flask==0.10
Flask-RESTful==0.2.12
Jinja2==2.7.3
MarkupSafe==0.19
SQLAlchemy==0.9.0
Werkzeug==0.9.4
distribute==0.7.3
itsdangerous==0.24
six==1.6.1
wsgiref==0.1.2
python --version
Python 2.7.5
My coworkers have the same error and we use my solution temporary.
Hi @sebaxq I'm sorry for the delay but I just can't repro your error. I have installed the same python version as you have and all the dependencies at exactly the same version that you have but still no bug :grimacing:
$ pip freeze
Flask==0.10
Flask-RESTful==0.2.12
Jinja2==2.7.3
MarkupSafe==0.19
SQLAlchemy==0.9.0
Werkzeug==0.9.4
aniso8601==0.82
distribute==0.6.35
itsdangerous==0.24
pytz==2014.4
six==1.6.1
stevedore==0.8
virtualenvwrapper==3.7
wsgiref==0.1.2
$ python --version
Python 2.7.5
and yet:
$ PYTHONPATH=. python examples/inheritance.py
* Running on http://127.0.0.1:5000/
* Restarting with reloader
# All OK
I'm at loss.
Also, your solution isn't clear to me. resource.dict doesn't exist, only __dict__ does.