| 3 | |
| 4 | |
| 5 | def setup_swagger(app): |
| 6 | with app.app_context(): |
| 7 | from flasgger import Swagger |
| 8 | app.config['SWAGGER'] = { |
| 9 | 'title': 'Diffgram Default API' |
| 10 | } |
| 11 | swagger = Swagger(app, template = { |
| 12 | "swagger": "2.0", |
| 13 | "info": { |
| 14 | "title": "Diffgram Default API", |
| 15 | "version": "1.0", |
| 16 | }, |
| 17 | "consumes": [ |
| 18 | "application/json", |
| 19 | ], |
| 20 | "produces": [ |
| 21 | "application/json", |
| 22 | ], |
| 23 | }) |
| 24 | data = swagger.get_apispecs() |
| 25 | path = "docs/swagger_spec.json" |
| 26 | with open(path, "w") as write_file: |
| 27 | json.dump(data, write_file, indent = 4) |
| 28 | return path |