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
Strip trailing slashes from root_path.
  • Loading branch information
iksteen committed Mar 31, 2020
commit edd212d1bf261d912feba9c8e0eeb4f64671abfc
3 changes: 2 additions & 1 deletion fastapi/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def __init__(
self.setup()

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

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