Test Failed
Push — develop ( 7b8724...4f7432 )
by Nicolas
02:47 queued 13s
created

generate_openapi   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 0
1
import json
2
3
from fastapi.openapi.utils import get_openapi
4
5
from glances.main import GlancesMain
6
7
# sys.path.append('./glances/outputs')
8
from glances.outputs.glances_restful_api import GlancesRestfulApi
9
10
# Init Glances core
11
core = GlancesMain(args_begin_at=2)
12
test_config = core.get_config()
13
test_args = core.get_args()
14
15
app = GlancesRestfulApi(config=test_config, args=test_args)._app
16
17
with open('./docs/openapi.json', 'w') as f:
18
    json.dump(
19
        get_openapi(
20
            title=app.title,
21
            version=app.version,
22
            # Set the OenAPI version
23
            # It's an hack to make openapi.json compatible with tools like https://editor.swagger.io/
24
            # Please read https://fastapi.tiangolo.com/reference/fastapi/?h=openapi#fastapi.FastAPI.openapi_version
25
            openapi_version="3.0.2",
26
            description=app.description,
27
            routes=app.routes,
28
        ),
29
        f,
30
    )
31