Debian Codegraph @

examples/use_openapi.py

raw symbols SCIP
1 """
2 In this example `openapi` version is used instead of `swagger` version.
3 """
4 from flask import Flask
5 from flasgger import Swagger
6
7 app = Flask(__name__)
8 swag = Swagger(app, config={
9 'headers': [],
10 'specs': [
11 {
12 'endpoint': 'apispec',
13 'route': '/apispec.json'
14 }
15 ],
16 'openapi': '3.0.1'
17 })
18
19
20 def test_swag(client, specs_data):
21 """
22 This test is runs automatically in Travis CI
23
24 :param client: Flask app test client
25 :param specs_data: {'url': {swag_specs}} for every spec in app
26 """
27 for spec in specs_data.values():
28 assert 'openapi' in spec
29 assert '3.0.1' == spec['openapi']
30 assert 'swagger' not in spec
31
32
33 if __name__ == '__main__':
34 app.run(debug=True)