🩹(backend) fix swagger and redoc documentation urls#1258
🩹(backend) fix swagger and redoc documentation urls#1258merahul22 wants to merge 3 commits intosuitenumerique:mainfrom
Conversation
Use canonical documentation routes and add a regression test.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughThis pull request fixes a bug in the Swagger and Redoc documentation URL routes by removing double slashes in the path construction. The changes include modifying URL patterns in the Django URL configuration from Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/backend/meet/urls.py`:
- Around line 45-47: Replace the re_path entry for the ReDoc endpoint with path
so the API_VERSION string is matched literally instead of as a regex: locate the
URL entry that uses SpectacularRedocView.as_view(url_name="client-api-schema")
and name="redoc-schema" and change it to use path(...) (consistent with the
Swagger endpoints) so settings.API_VERSION is treated as a literal segment and
avoids `.` matching any character.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d84632d3-4d9a-46fd-8209-e5bd00d66fc4
📒 Files selected for processing (3)
CHANGELOG.mdsrc/backend/core/tests/swagger/test_openapi_schema.pysrc/backend/meet/urls.py
| f"{settings.API_VERSION}/redoc/", | ||
| SpectacularRedocView.as_view(url_name="client-api-schema"), | ||
| name="redoc-schema", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Confirm API_VERSION contains a dot and redoc uses re_path
rg -n --type=py 'API_VERSION\s*=' src/backend/meet/settings.py
rg -n --type=py 're_path\(\s*f"\{settings\.API_VERSION\}/redoc/"' src/backend/meet/urls.py
# 2) Demonstrate equivalent regex behavior (dot wildcard)
python - <<'PY'
import re
pattern = r"v1.0/redoc/"
candidates = ["v1.0/redoc/", "v1x0/redoc/", "v1-0/redoc/"]
for c in candidates:
print(f"{c}: {bool(re.match(pattern, c))}")
PYRepository: suitenumerique/meet
Length of output: 127
🏁 Script executed:
cat -n src/backend/meet/urls.py | head -55 | tail -20Repository: suitenumerique/meet
Length of output: 854
🏁 Script executed:
# Also search more broadly for redoc patterns
rg -n --type=py 'redoc' src/backend/meet/urls.py -B 2 -A 2Repository: suitenumerique/meet
Length of output: 279
🏁 Script executed:
# Check if there are other re_path usages with settings in urls.py
rg -n --type=py 're_path' src/backend/meet/urls.py
# Verify the python regex demo that was in the initial request
python - <<'PY'
import re
pattern = r"v1.0/redoc/"
candidates = ["v1.0/redoc/", "v1x0/redoc/", "v1-0/redoc/"]
print("Pattern:", pattern)
for c in candidates:
result = bool(re.match(pattern, c))
print(f"{c}: {result}")
PYRepository: suitenumerique/meet
Length of output: 206
Use path instead of re_path for ReDoc to avoid regex overmatching.
At line 44, re_path interprets v1.0 as regex, where . matches any character. This allows non-canonical URLs like v1x0/redoc/ and v1-0/redoc/ to match. Use path() for literal matching, consistent with the Swagger endpoints above (lines 31, 39).
Proposed fix
- re_path(
+ path(
f"{settings.API_VERSION}/redoc/",
SpectacularRedocView.as_view(url_name="client-api-schema"),
name="redoc-schema",
),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/backend/meet/urls.py` around lines 45 - 47, Replace the re_path entry for
the ReDoc endpoint with path so the API_VERSION string is matched literally
instead of as a regex: locate the URL entry that uses
SpectacularRedocView.as_view(url_name="client-api-schema") and
name="redoc-schema" and change it to use path(...) (consistent with the Swagger
endpoints) so settings.API_VERSION is treated as a literal segment and avoids
`.` matching any character.
|
Good catch, thanks. You're right that I’ll also double-check the double-slash route strings to make sure Swagger and ReDoc stay consistent. |
|
Good catch, thanks. I updated the ReDoc route to use |
|



🩹(backend) fix swagger and redoc documentation urls
Purpose
The Swagger and ReDoc routes were defined with a double slash in the Django URL configuration, which exposed the documentation on non-canonical paths like
/v1.0//swagger/and/v1.0//redoc/. This change fixes the route definitions so the documentation is served on the expected URLs.Proposal
Update the backend URL patterns to use canonical documentation paths and add a regression test to prevent this issue from coming back.
/v1.0/swagger//v1.0/redoc/200