Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ASGI root_path for openapi docs #1199

Merged
merged 11 commits into from
Jun 11, 2020
Prev Previous commit
Next Next commit
Please mypy.
  • Loading branch information
iksteen committed Mar 31, 2020
commit 79d056a071567964c869a66482a64df41be9ff6b
4 changes: 2 additions & 2 deletions fastapi/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def __init__(
self.openapi_schema: Optional[Dict[str, Any]] = None
self.setup()

def get_openapi_prefixed(self, req: Request, path: str = "") -> str:
def get_openapi_prefixed(self, req: Request, path: Optional[str] = "") -> str:
prefix = self._openapi_prefix or req.scope.get("root_path", "").rstrip("/")
return prefix + path
return prefix + (path or "")

def openapi(self, openapi_prefix: str) -> Dict:
if not self.openapi_schema:
Expand Down