Reputation: 515
I have a module that performs one function and would like to expose this function through an API specified with Swagger.
I used the Swagger codegen to generate a Flask application. I found the thing_controller.py
file and know that I need to link the my backend in that file, where the codegen put the line return 'do some magic!
I was wondering how to best structure this application. I would like to have:
I would like to be able to import src/thing
in the thing_controller.py
file. That way I can call return thing.func()
to perform all operations needed.
Upvotes: 0
Views: 392
Reputation: 434
I created a python module to create swagger + jsonapi services: https://github.com/thomaxxl/safrs
If you run the demo, it creates an example method (send_mail) that can be invoked from the swagger UI: https://github.com/thomaxxl/safrs/blob/master/examples/demo.py
If you make it a classmethod, you won't need object instances.
This solution may not fit your requirements thoug, but it's like 5min work to get it running
Upvotes: 1