Open arkady opened 4 years ago
Had this same doubt and found this blog post that explained it well:
https://medium.com/koko-networks/automated-swagger-api-doc-with-flask-restful-a78119bc4473
Basically, you need to make your Pets
Resource also inherit from flask_apispec.views.MethodResource
, and later register it with docs.register(Pets)
Had this same doubt and found this blog post that explained it well:
https://medium.com/koko-networks/automated-swagger-api-doc-with-flask-restful-a78119bc4473
Basically, you need to make your
Pets
Resource also inherit fromflask_apispec.views.MethodResource
, and later register it withdocs.register(Pets)
So, I'm doing this(docs.register(MyClass)), but when I register my docs, the following error occurs:
Traceback:
File "flask-api-template\app\resources\domain_resource.py", line 9, in <module> from app.services import DomainService
File "flask-api-template\app\__init__.py", line 42, in <module>register_resources(app, docs)
File "flask-api-template\app\resources\__init__.py", line 11, in register_resources domains.register_module(app, docs)
File "flask-api-template\app\resources\domain_resource.py", line 55, in register_module docs.register(DomainService)
File "flask-api-template\venv\lib\site-packages\flask_apispec\extension.py", line 124, in register self._defer(self._register, target, endpoint, blueprint,
File "flask-api-template\venv\lib\site-packages\flask_apispec\extension.py", line 72, in _defer bound()
File "flask-api-template\venv\lib\site-packages\flask_apispec\extension.py", line 150, in _register raise TypeError() TypeError
Process finished with exit code 1
I've made several changes and nothing solves it, could you give me any suggestions?
@andresichelero Im seeing the same thing. Did you ever figure this out?
Figured it out for anyone else who runs into this issue. Class has to also inherit from MethodResource
:
class Pets(Resource, MethodResource):
....
I have a
flask_restful
-based app and would like to layer flask-apispec on top of it, but I am probably not understanding how to do this correctly.Current code is something like this:
I am having trouble with getting
flask_apispec
decorators applied properly to these methods. Is there a "right way" for this?