flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

Is it possible to specify specs on a resource that is not in the same module as the API?

Open gro1m opened this issue 3 years ago • 1 comments

Ask a question Is it possible to specify specs on a resource that is not in the same module as the API?

Additional context I have posted the question as well on StackOverflow, but it did not receive much attention: https://stackoverflow.com/questions/73253718/flask-restx-how-to-specify-swagger-request-body-expectation-if-resource-resides.

The idea is to pass the specs as on the Methods of the resource definition and that in the app definition file this resource can just be added. When doing the resource definition I will not be able to access the api.expect decorator. Is there a solution to this problem? Thanks!

gro1m avatar Aug 17 '22 13:08 gro1m

Yes, you just need to use the flask application factory structure to create your API. There is a good example of how to do this with flask-restx here: https://github.com/a-luna/flask-api-tutorial

peter-doggart avatar Aug 22 '22 09:08 peter-doggart