Skip to content

Swagger UI Path Issue #107

Description

@DanielHabenicht

If the app is hosted behind a reverse proxy and the hosted endpoint adds a /api in front the swagger ui breaks, as it can not load the file from the root of the site:

Image

Stripping the / from the path in swagger ui solves this by making use of the dynamic path behaviour and leads to the correct path /api/openapi.json

Patch:

diff --git a/app/backend/.venv/lib/python3.11/site-packages/quart_schema/extension.py b/app/backend/.venv/lib/python3.11/site-packages/quart_schema/extension_new.py
index adcd222a..93e73e42 100644
--- a/app/backend/.venv/lib/python3.11/site-packages/quart_schema/extension.py
+++ b/app/backend/.venv/lib/python3.11/site-packages/quart_schema/extension.py
@@ -330,7 +330,7 @@ class QuartSchema:
         return await render_template_string(
             SWAGGER_TEMPLATE,
             title=self.info.title,
-            openapi_path=self.openapi_path,
+            openapi_path=self.openapi_path.lstrip("/"),
             swagger_js_url=current_app.config["QUART_SCHEMA_SWAGGER_JS_URL"],
             swagger_css_url=current_app.config["QUART_SCHEMA_SWAGGER_CSS_URL"],
         )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions