flasgger / flasgger

Easy OpenAPI specs and Swagger UI for your Flask API

Home Page:http://flasgger.pythonanywhere.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extracting YAML/JSON spec from docstrings

FedericoCeratto opened this issue · comments

Hello and thanks for developing swagger.
It would be very useful to be able to extract a YAML/JSON file from the docstrings. It would allow keeping the API specs close to the implementation code but also provide a spec file to API users. Is there a recommended way to do it?

As a temporary workaround I used:

s = Swagger(app, parse=True)
...
with app.app_context():
    apispecs = s.get_apispecs()

Or fetching the apispec URL locally:

with app.test_client() as client:                                                                         
    j = client.get("/apispec_1.json").json