litestar icon indicating copy to clipboard operation
litestar copied to clipboard

Bug: Duplication in request URL path when configuring OpenAPI Servers

Open mohammedbabelly20 opened this issue 7 months ago • 0 comments

Description

All requests URLs in documentation have duplicate paths when configuring the Litestar app with a custom path and configure the OpenAPI with servers. So the final request URL has the full server url from OpenAPIConfig and the path added from the Litestar app. http://localhost:8000/api/v3/api/v3/... instead of http://localhost:8000/api/v3/...

URL to code causing the issue

No response

MCVE

return Litestar(path="api/v3", ...)


return OpenAPIConfig(
    path="/schema",
    servers=[Server(url="http://localhost:8000/api/v3")],
    render_plugins=[StoplightRenderPlugin(version="latest")],
)

Steps to reproduce

1. Create an OpenAPIConfig that has at least one server e.g. `http://localhost:8000/api/v3`
2. Create a new Litestar app with `api/v3` path and use the OpenAPIConfig from above
3. Run the application and access the schema
4. See that all requests in schema has full server URL from OpenAPI and also the app path which is `api/path` so the final URL is incorrect `http://localhost:8000/api/v3/api/v3/...`

Screenshots

No response

Logs

No response

Litestar Version

2.9.1

Platform

  • [X] Linux
  • [X] Mac
  • [X] Windows
  • [ ] Other (Please specify in the description above)

[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar

mohammedbabelly20 avatar Jul 01 '24 07:07 mohammedbabelly20