fix(swagger): support URL prefix via APPLICATION_ROOT in OpenAPI and Swagger UI#40908
fix(swagger): support URL prefix via APPLICATION_ROOT in OpenAPI and Swagger UI#40908rusackas wants to merge 2 commits into
Conversation
…Swagger UI Adopts #34407 by @rsbhatti. Serves the OpenAPI spec and an APPLICATION_ROOT-aware Swagger UI for Superset deployments behind a URL prefix (reverse proxy), gated by a new FAB_API_SWAGGER_UI_SUPERSET_APP_ROOT flag (default False). Adoption cleanups over the original: - keep the existing FAB_API_SWAGGER_UI flag (the original removed it) - drop an unrelated AUTH_ROLE_PUBLIC change that the original accidentally included - add ASF license headers and type hints to the new openapi module - fix the SupsersetSwaggerView -> SupersetSwaggerView class-name typo - add a unit test for the schema-name resolver Closes #34407 Fixes #33304 Co-authored-by: rsbhatti <rajvindrasinghbhatti12@gmail.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Review Agent Run #65fc76Actionable Suggestions - 0Additional Suggestions - 2
Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40908 +/- ##
==========================================
- Coverage 64.13% 64.13% -0.01%
==========================================
Files 2653 2655 +2
Lines 143606 143685 +79
Branches 33132 33143 +11
==========================================
+ Hits 92105 92149 +44
- Misses 49888 49919 +31
- Partials 1613 1617 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…malize app root Address review feedback: - Gate the APPLICATION_ROOT-aware Swagger/OpenAPI registration on FAB_API_SWAGGER_UI so the global Swagger disable still takes precedence. - Suppress FAB's default OpenAPI/Swagger views (FAB_ADD_OPENAPI_VIEWS) when the prefix-aware variant is active, so the two don't register duplicate URL rules for /api/<version>/_openapi and /swagger/<version>. - Normalize APPLICATION_ROOT (treat '/' as empty, strip trailing slash) so the Swagger UI spec URL is not built as a protocol-relative '//api/...' URL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #6b7c0fActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
Adopts #34407 by @rsbhatti — thank you for the original work! 🙏
When Superset is deployed behind a reverse proxy with a URL prefix (
APPLICATION_ROOT/SUPERSET_APP_ROOT), the Swagger UI breaks because it can't generate the OpenAPI server URLs or locate the spec under the prefix (#33304). This adds anAPPLICATION_ROOT-aware OpenAPI endpoint (/api/<version>/_openapi) and Swagger view, gated by a new config flag:When enabled, the spec's
serversURL and the Swagger UI'sopenapi_uriare resolved throughAPPLICATION_ROOT, so the docs work under a prefix. Default behavior is unchanged.What changed vs. the original PR
I adopted #34407 and applied a few cleanups so it's merge-ready:
FAB_API_SWAGGER_UI = Trueflag (the original inadvertently removed it).AUTH_ROLE_PUBLIC = 'Public'change the original accidentally included.superset/openapimodule.SupsersetSwaggerView→SupersetSwaggerViewclass-name typo.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend; gated behind a default-off config flag.
TESTING INSTRUCTIONS
Manual: set
APPLICATION_ROOT = "/myprefix"andFAB_API_SWAGGER_UI_SUPERSET_APP_ROOT = True, then load the Swagger UI under the prefix and confirm the spec loads and server URLs include the prefix.ADDITIONAL INFORMATION
Closes #34407
🤖 Generated with Claude Code