diff options
-rwxr-xr-x | src/services/vyos-http-api-server | 15 |
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}') |