Exposing API Documentation Using Flask and Swagger
<p>I have build a small service with <code>flask</code> and already wrote a swagger yaml file to describe it's API. How can I expose the swagger file through the flask app?</p>

<p>I didn't mean to expose the file itself (<code>send_from_directory</code>) but to create new endpoint that will show it as swagger-ui (interactive, if possible)</p>

<p>OK, this is what I did.</p>

<p>I used <code>flasgger</code> to and wrap my app with <code>flasgger.Swagger</code>. than I added 2 endpoints:</p>

<ol>
<li><code>/_api</code> serves the YAML file (with <code>send_from_directory</code>)</li>
<li><code>/api</code> redirects to the flasgger api <code>/apidocs/index.html?url=/api</code> I'm sure it can be done better, but I
failed to find it.</li>
</ol>

<p>github: <a href="https://github.com/eplaut/python-butler/blob/master/butler/butler.py#L119" rel="nofollow">https://github.com/eplaut/python-butler/blob/master/butler/butler.py#L119</a></p>

python flask swagger