I have build a small service with flask
and already wrote a swagger yaml file to describe it's API. How can I expose the swagger file through the flask app?
I didn't mean to expose the file itself (send_from_directory
) but to create new endpoint that will show it as swagger-ui (interactive, if possible)
OK, this is what I did.
I used flasgger
to and wrap my app with flasgger.Swagger
. than I added 2 endpoints:
/_api
serves the YAML file (with send_from_directory
)/api
redirects to the flasgger api /apidocs/index.html?url=/api
I'm sure it can be done better, but I
failed to find it.