I created several endpoints in Flask and created yml files for each of them. So, for example I have 10 endpoints and 10 small yaml files. It is not very comfort to use it, so I want put all the descriprions into 1 yml file. I tried this: app script:
from flask import Flask, jsonify, abort, make_response, request
from flasgger import Swagger, swag_from
app = Flask(__name__)
swagger = Swagger(app)
@app.route('/api/test/<int:ids>', methods=['GET'])
@swag_from('app.yml')
def test(ids):
"""
Test function
Some test function for debugging Swagger.
"""
return jsonify({"var1": 12312300, "var2":"sdfsdf"})
@app.route('/api/test2/<int:var>', methods=['GET'])
@swag_from('app.yml')
def test(var):
"""
Test function 2
Some test function for debugging Swagger.
"""
abort(make_response(jsonify(message="There is no model with this index"), 404))
and my app.yml
:
paths:
/api/test2/<int:var>:
get:
return some information
---
tags:
- stage1:
- name: var
description: ID
in: path
required: true
type: integer
responses:
200:
description: OK.
/api/test/<int:ids>:
get:
Test function
Some test function for debugging Swagger.
---
tags:
- stage1
parameters:
- name: ids
description: ID
in: path
required: true
type: integer
responses:
200:
description: OK.
405:
description: Invalid input
But this throw the error:
Errors Fetch errorINTERNAL SERVER ERROR /apispec_1.json
this mean something wrong in my yml
file. How to write it correctly?
I found such issue on the github: https://github.com/rochacbruno/flasgger/issues/264