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

Unable to add swagger-ui index as index in v3 #1851

Open
karisN opened this issue Jan 17, 2024 · 1 comment
Open

Unable to add swagger-ui index as index in v3 #1851

karisN opened this issue Jan 17, 2024 · 1 comment

Comments

@karisN
Copy link

karisN commented Jan 17, 2024

Description

Unable to service swagger ui as index in v3
Flask app

app = connexion.App(
    __name__,
    specification_dir="./openapi/",
)
app.add_api(
    "openapi.yaml",
    pythonic_params=True,
    strict_validation=True,
    validator_map=validators.VALIDATOR_MAP,
    swagger_ui_options=SwaggerUIOptions(
        swagger_ui_path="/",
        swagger_ui_config={"showCommonExtensions": True},
    ),
    **additional_kwargs,
)

Expected behaviour

It serves swagger index as index

Actual behaviour

lib/python3.10/site-packages/connexion/middleware/swagger_ui.py:152: in add_swagger_ui
    self.router.add_route(methods=["GET"], path=console_ui_path, endpoint=redirect)
/lib/python3.10/site-packages/starlette/routing.py:802: in add_route
    route = Route(


    def __init__(
        self,
        path: str,
        endpoint: typing.Callable[..., typing.Any],
        *,
        methods: typing.Optional[typing.List[str]] = None,
        name: typing.Optional[str] = None,
        include_in_schema: bool = True,
    ) -> None:
>       assert path.startswith("/"), "Routed paths must start with '/'"
E       AssertionError: Routed paths must start with '/'

@karisN
Copy link
Author

karisN commented Jan 18, 2024

Actually, I don't think my propose PR fixes most of the issues if you're adding apis with a base path of "/" as well.
It'll get process twice, once by RouterMiddleware, then by SwaggerUIMiddleware, instead of a centralize list of routes putting the "/" at the end.

Thoughts from anyone who wants to serve swagger-ui at root?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant