-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
45 lines (37 loc) · 1.18 KB
/
app.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: BSD-2-Clause
import json
import logging
from flask_restx import Api
from tern_api import __version__, tern_api
from tern_api.api.v1.common_models import api_models_namespace
from tern_api.api.v1.reports import ns as report_v1
from tern_api.api.v1.version import ns as version_v1
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s %(levelname)s %(message)s",
datefmt="%H:%M:%S",
)
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(message)s",
datefmt="%H:%M:%S",
)
api = Api(
tern_api,
version=__version__.version,
title="Tern REST API",
description="Tern Project REST API",
)
api.add_namespace(api_models_namespace)
api.add_namespace(version_v1, path="/api/v1/version")
api.add_namespace(report_v1, path="/api/v1/report")
def export_swagger_json(filepath):
tern_api.config["SERVER_NAME"] = "localhost"
with tern_api.app_context().__enter__():
with open(filepath, "w") as f:
swagger_json = json.dumps(api.__schema__, indent=4)
f.write(swagger_json)