From 9f7767c8022f5e6ad70253ef1c94fc22dbd04f1e Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 25 Sep 2024 22:10:34 -0500 Subject: http-api: T6736: regenerate openapi docs --- src/services/vyos-http-api-server | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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}') -- cgit v1.2.3