Skip to content

🩹(backend) fix swagger and redoc documentation urls#1258

Open
merahul22 wants to merge 3 commits intosuitenumerique:mainfrom
merahul22:backend-swagger-fix
Open

🩹(backend) fix swagger and redoc documentation urls#1258
merahul22 wants to merge 3 commits intosuitenumerique:mainfrom
merahul22:backend-swagger-fix

Conversation

@merahul22
Copy link
Copy Markdown

@merahul22 merahul22 commented Apr 9, 2026

🩹(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.

  • replace the double-slash Swagger route with /v1.0/swagger/
  • replace the double-slash ReDoc route with /v1.0/redoc/
  • add a backend test that checks both documentation endpoints return 200
  • add a changelog entry for the fix

Use canonical documentation routes and add a regression test.
@lebaudantoine
Copy link
Copy Markdown
Collaborator

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

Walkthrough

This 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 f"{settings.API_VERSION}//swagger/" to f"{settings.API_VERSION}/swagger/" (and similarly for the Redoc endpoint), adding a new test to verify both documentation endpoints return HTTP 200 status, and updating the changelog to document the fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing double-slash issues in Swagger and ReDoc documentation URLs in the backend.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of the fix, the proposal, and listing completed checklist items that match the actual code changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 170763a and cb1e383.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/backend/core/tests/swagger/test_openapi_schema.py
  • src/backend/meet/urls.py

Comment thread src/backend/meet/urls.py
Comment on lines +45 to 47
f"{settings.API_VERSION}/redoc/",
SpectacularRedocView.as_view(url_name="client-api-schema"),
name="redoc-schema",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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))}")
PY

Repository: suitenumerique/meet

Length of output: 127


🏁 Script executed:

cat -n src/backend/meet/urls.py | head -55 | tail -20

Repository: 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 2

Repository: 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}")
PY

Repository: 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.

@merahul22
Copy link
Copy Markdown
Author

Good catch, thanks. You're right that re_path() treats v1.0 as a regex pattern, so . can overmatch. I'll switch the ReDoc route to path() for literal matching.

I’ll also double-check the double-slash route strings to make sure Swagger and ReDoc stay consistent.

@merahul22
Copy link
Copy Markdown
Author

Good catch, thanks. I updated the ReDoc route to use path() instead of re_path() so the API version is matched literally, and kept it consistent with the Swagger routes.

@sonarqubecloud
Copy link
Copy Markdown

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

Successfully merging this pull request may close these issues.

3 participants