♻️(backend) prefix Swagger routes with /api

Inspired by commit eb23aef in suitenumerique/docs. The same base
route path is used everywhere, which helps when the backend sits
behind an ingress serving it with a regex like `api/*`.
This commit is contained in:
lebaudantoine
2026-05-30 18:54:53 +02:00
committed by aleb_the_flash
parent 88b722e741
commit 4d27f217fc
3 changed files with 7 additions and 6 deletions
+1
View File
@@ -24,6 +24,7 @@ and this project adheres to
- 🩹(frontend) improve reaction toolbar centering with dynamic positioning - 🩹(frontend) improve reaction toolbar centering with dynamic positioning
- 🚀 (paas) remove buildpack requirements.txt to use the new uv.lock #1349 - 🚀 (paas) remove buildpack requirements.txt to use the new uv.lock #1349
- ✨(backend) allow room configuration and access level via external api #1260 - ✨(backend) allow room configuration and access level via external api #1260
- ♻️(backend) prefix Swagger routes with /api
### Fixed ### Fixed
- 🩹(backend) fix swagger and redoc documentation URLs - 🩹(backend) fix swagger and redoc documentation URLs
@@ -34,7 +34,7 @@ def test_openapi_client_schema():
) )
assert output.getvalue() == "" assert output.getvalue() == ""
response = Client().get("/v1.0/swagger.json") response = Client().get("/api/v1.0/swagger.json")
assert response.status_code == 200 assert response.status_code == 200
with open( with open(
@@ -52,8 +52,8 @@ def test_openapi_documentation_routes(mock_staticfiles):
"""Swagger and ReDoc documentation should be served on canonical URLs.""" """Swagger and ReDoc documentation should be served on canonical URLs."""
client = Client() client = Client()
swagger_response = client.get("/v1.0/swagger/") swagger_response = client.get("/api/v1.0/swagger/")
redoc_response = client.get("/v1.0/redoc/") redoc_response = client.get("/api/v1.0/redoc/")
assert swagger_response.status_code == 200 assert swagger_response.status_code == 200
assert redoc_response.status_code == 200 assert redoc_response.status_code == 200
+3 -3
View File
@@ -29,7 +29,7 @@ if settings.DEBUG:
if settings.USE_SWAGGER or settings.DEBUG: if settings.USE_SWAGGER or settings.DEBUG:
urlpatterns += [ urlpatterns += [
path( path(
f"{settings.API_VERSION}/swagger.json", f"api/{settings.API_VERSION}/swagger.json",
SpectacularJSONAPIView.as_view( SpectacularJSONAPIView.as_view(
api_version=settings.API_VERSION, api_version=settings.API_VERSION,
urlconf="core.urls", urlconf="core.urls",
@@ -37,12 +37,12 @@ if settings.USE_SWAGGER or settings.DEBUG:
name="client-api-schema", name="client-api-schema",
), ),
path( path(
f"{settings.API_VERSION}/swagger/", f"api/{settings.API_VERSION}/swagger/",
SpectacularSwaggerView.as_view(url_name="client-api-schema"), SpectacularSwaggerView.as_view(url_name="client-api-schema"),
name="swagger-ui-schema", name="swagger-ui-schema",
), ),
path( path(
f"{settings.API_VERSION}/redoc/", f"api/{settings.API_VERSION}/redoc/",
SpectacularRedocView.as_view(url_name="client-api-schema"), SpectacularRedocView.as_view(url_name="client-api-schema"),
name="redoc-schema", name="redoc-schema",
), ),