Swagger UI for flask-potion based app Swagger UI for flask-potion based app flask flask

Swagger UI for flask-potion based app


There is no clean way to do this. However, a hackish solution for the same exists-

Flasgger works for default flask routes. We can re-define the routes that were defined earlier using flask-potion, as default flask routes and make calls to the earlier flask-potion functions from the newly created functions. Note- Changing the existing routes to the new routes didn't work for me. I had to mask the old calls with new ones and call the old function from the new ones.

Note- This only works for custom routes that are written by the user and doesn't work for default routes that are generated from data model by flask potion.

Existing code-

class ProductResource(BaseModelResource):    @Route.GET('/num_products')    def product_count():        return product.query(...)     

Refactored Code -

class ProductResource(BaseModelResource):    def product_count():            return product.query(...)@app.route('/num_products', methods=['GET'])def product_count_main():    output = product_count()    Response(str(output), content_type='application/json')