Add Open API prefix route - correct docs behind reverse proxy (#26)

Add Open API prefix route - correct docs behind reverse proxy.
This commit is contained in:
Kabir Khan
2019-02-14 10:57:49 -08:00
committed by Sebastián Ramírez
parent 890f1f7899
commit 0ea0d0e82a
9 changed files with 191 additions and 4 deletions
+3 -2
View File
@@ -215,7 +215,8 @@ def get_openapi(
version: str,
openapi_version: str = "3.0.2",
description: str = None,
routes: Sequence[BaseRoute]
routes: Sequence[BaseRoute],
openapi_prefix: str = ""
) -> Dict:
info = {"title": title, "version": version}
if description:
@@ -234,7 +235,7 @@ def get_openapi(
if result:
path, security_schemes, path_definitions = result
if path:
paths.setdefault(route.path, {}).update(path)
paths.setdefault(openapi_prefix + route.path, {}).update(path)
if security_schemes:
components.setdefault("securitySchemes", {}).update(
security_schemes