Skip to content

feat: add tags to swagger and order them based on workflow#6885

Open
Holmus wants to merge 1 commit intomainfrom
feat/add-swagger-tags
Open

feat: add tags to swagger and order them based on workflow#6885
Holmus wants to merge 1 commit intomainfrom
feat/add-swagger-tags

Conversation

@Holmus
Copy link
Contributor

@Holmus Holmus commented Mar 9, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

The Swagger UI at /api/v1/docs/ previously grouped all 443 operations under a single api tag, making it difficult to navigate. This PR adds logical tag grouping via drf-spectacular preprocessing and postprocessing hooks, splitting operations into 20 sections based on URL path patterns (e.g. Organisations, Projects, Features, Integrations). Operations with explicit tags (sdk, mcp, experimental) are left unchanged. The Swagger UI now displays sections in workflow order - Authentication first, then core resources, then configuration/admin.

How did you test this code?

  1. Ran the full openapi unit test suite: pytest tests/unit/api/test_unit_openapi.py tests/unit/api/test_mcp_openapi.py
  2. Generated the schema locally and verified all 443 operations are assigned to the correct tags with zero unmatched operations.
  3. Verified the MCP schema generation still works correctly (postprocessing preserves explicit tags).
  4. Ran locally and visually verified result.

@Holmus Holmus requested a review from a team as a code owner March 9, 2026 15:24
@Holmus Holmus requested review from khvn26 and removed request for a team March 9, 2026 15:24
@vercel
Copy link

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Mar 9, 2026 3:24pm
flagsmith-frontend-preview Ignored Ignored Mar 9, 2026 3:24pm
flagsmith-frontend-staging Ignored Ignored Mar 9, 2026 3:24pm

Request Review

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-6885 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-6885 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-6885 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-6885 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-6885 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-6885 Finished ✅ Results

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Free Tier Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Default preprocessing hook dropped when overriding PREPROCESSING_HOOKS
    • I restored drf_spectacular.hooks.preprocess_exclude_path_format in PREPROCESSING_HOOKS so the default format-suffix path deduplication is preserved alongside the custom hook.

Create PR

Or push these changes by commenting:

@cursor push bb2444f165
Preview (bb2444f165)
diff --git a/api/app/settings/common.py b/api/app/settings/common.py
--- a/api/app/settings/common.py
+++ b/api/app/settings/common.py
@@ -543,6 +543,7 @@
         "environments.identities.traits.openapi",
     ],
     "PREPROCESSING_HOOKS": [
+        "drf_spectacular.hooks.preprocess_exclude_path_format",
         "api.openapi.preprocessing_filter_spec",
     ],
     "POSTPROCESSING_HOOKS": [
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

],
"PREPROCESSING_HOOKS": [
"api.openapi.preprocessing_filter_spec",
],
Copy link

Choose a reason for hiding this comment

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

Default preprocessing hook dropped when overriding PREPROCESSING_HOOKS

Medium Severity

The POSTPROCESSING_HOOKS correctly re-includes the drf-spectacular default drf_spectacular.hooks.postprocess_schema_enums, but PREPROCESSING_HOOKS does not re-include the default drf_spectacular.hooks.preprocess_exclude_path_format. That default hook filters out format-suffixed path duplicates (e.g. .json/.api variants). Overriding the setting with only the new preprocessing_filter_spec hook silently drops it, potentially causing duplicate or format-suffixed paths to appear in the generated schema.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default value for PREPROCESSING_HOOKS in drf-spectacular is [], preprocess_exclude_path_format is only listed as an example in the docs, not included by default. So we're not dropping any existing behaviour here.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.25%. Comparing base (c5953c2) to head (23d07e2).

Files with missing lines Patch % Lines
api/api/openapi.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6885      +/-   ##
==========================================
- Coverage   98.33%   98.25%   -0.09%     
==========================================
  Files        1334     1334              
  Lines       49661    49545     -116     
==========================================
- Hits        48836    48681     -155     
- Misses        825      864      +39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  10 passed

Details

stats  10 tests across 7 suites
duration  47.9 seconds
commit  23d07e2
info  🔄 Run: #15169 (attempt 1)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 2 seconds
commit  23d07e2
info  🔄 Run: #15169 (attempt 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant