Debian Codegraph @

examples/specs_route_example.py

raw symbols SCIP
1 """
2 In this example a custom specs_route is set.
3 """
4 from flask import Flask
5 try:
6 from http import HTTPStatus
7 except ImportError:
8 import httplib as HTTPStatus
9 from flasgger import Swagger
10
11 swagger_config = {
12 "headers": [
13 ],
14 "specs": [
15 {
16 "endpoint": 'specifications',
17 "route": '/specifications.json',
18 "rule_filter": lambda rule: True, # all in
19 "model_filter": lambda tag: True, # all in
20 }
21 ],
22 "static_url_path": "/flasgger_static",
23 # "static_folder": "static", # must be set by user
24 "specs_route": "/documentation/swagger/"
25 }
26
27 app = Flask(__name__)
28 swag = Swagger(app, config=swagger_config)
29
30
31 def test_swag(client, specs_data):
32 """
33 This test is runs automatically in Travis CI
34
35 :param client: Flask app test client
36 :param specs_data: {'url': {swag_specs}} for every spec in app
37 """
38 assert client.get('/documentation/swagger/').status_code == HTTPStatus.OK
39 assert specs_data.get('/specifications.json') is not None
40
41
42 if __name__ == '__main__':
43 app.run(debug=True)