File: compat.py

package info (click to toggle)
python-flasgger 0.9.5%2Bdfsg.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,152 kB
  • sloc: javascript: 6,403; python: 3,665; makefile: 9; sh: 1
file content (50 lines) | stat: -rw-r--r-- 999 bytes parent folder | download | duplicates (3)
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)