Documentation to explitly specify how to serve Swagger UI using apisec ?
mkmoisen opened this issue · comments
Perhaps this is too obvious for most, but I struggled a bit figuring out how to use the result of my apispec to actually serve a Swagger UI from my Flask app.
I think other noobs might benefit if the documentation laid out clear steps on how to serve a Swagger UI, for example using Flask. I finally figured this out from this blog post here after a few hours of researching different solutions.
Beginners might waste a lot of time researching third party tools to do this simple task of serving the Swagger UI, when they are not required.
E.g, create a route that serves the base static html file from Swagger here. The css/js/image files could also be served from flask, or to make it simple in the documentation they could be linked to someone's hosted files. Line 42 of this file should look something like this:
url: "{{ url_for('serve_swagger_spec') }}",
And the route for this serve_swagger_spec
can be created like so:
spec = APISpec(...)
@app.get('/swagger/spec/')
def serve_swagger_spec():
return jsonify(spec.to_dict()), 200