forked from flasgger/flasgger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compat.py
50 lines (41 loc) · 999 Bytes
/
compat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Test compatibility with pre 0.5.14 version
- produces was accepted as string
- definitions references had method prefix
"""
from flask import Flask, jsonify, request
from flasgger import Swagger
app = Flask(__name__)
app.config['SWAGGER'] = {
# set to True so instead of
# $ref: '#/definitions/alert'
# we get
# $ref: '#/definitions/index_post_alert'
'prefix_ids': True
}
swag = Swagger(app)
@app.route('/', methods=['POST'])
def index():
"""
Test the compatibility
This is just a test for flasgger 0.5.14 compat
---
parameters:
- in: body
name: body
schema:
id: alert
properties:
message:
type: string
produces:
application/json
responses:
200:
description: Alert
schema:
$ref: '#/definitions/index_post_alert'
"""
return jsonify({'message': request.json.get('message')})
if __name__ == '__main__':
app.run(debug=True)