summaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-09-25 22:10:34 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-09-29 22:21:21 -0500
commit9f7767c8022f5e6ad70253ef1c94fc22dbd04f1e (patch)
treec1bc0dc812285b5f68c5ca7c526456efbbe3ebe2 /src/services
parent954be34bc938acc9e14d9fb3b32c8f96cd999959 (diff)
downloadvyos-1x-9f7767c8022f5e6ad70253ef1c94fc22dbd04f1e.tar.gz
vyos-1x-9f7767c8022f5e6ad70253ef1c94fc22dbd04f1e.zip
http-api: T6736: regenerate openapi docs
Diffstat (limited to 'src/services')
-rwxr-xr-xsrc/services/vyos-http-api-server15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server
index 6bfc2c435..558561182 100755
--- a/src/services/vyos-http-api-server
+++ b/src/services/vyos-http-api-server
@@ -113,6 +113,19 @@ def flatten_keys(d: dict) -> list[dict]:
return keys_list
+def regenerate_docs(app: FastAPI) -> None:
+ docs = ('/openapi.json', '/docs', '/docs/oauth2-redirect', '/redoc')
+ remove = []
+ for r in app.routes:
+ if r.path in docs:
+ remove.append(r)
+ for r in remove:
+ app.routes.remove(r)
+
+ app.openapi_schema = None
+ app.setup()
+
+
def initialization(session: SessionState, app: FastAPI = app):
# pylint: disable=global-statement,broad-exception-caught,import-outside-toplevel
@@ -171,6 +184,8 @@ def initialization(session: SessionState, app: FastAPI = app):
from api.graphql.routers import graphql_clear
graphql_clear(app)
+ regenerate_docs(app)
+
LOG.debug('Active routes are:')
for r in app.routes:
LOG.debug(f'{r.path}')