Bug description
I'm having an issue with accessing the /api/v1/_openapi
endpoint. It looks like it redirects to /api/v1/_openapi
but it should be going to /prefix/api/v1/_openapi
it would be nice to expose the swagger config so we can do something like this.
OPENAPI_SWAGGER_UI_CONFIG = {
"url": "/prefix/api/v1/_openapi"
}
Not sure if anyone else has seen this issue or is able to replicate it.
To replicate the issue just set
SUPERSET_APP_ROOT = "/prefix"
then attempt to go to /prefix/swagger/v1
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.10
Node version
I don't know
Browser
Chrome
Additional context
This was done via docker image
FROM apache/superset:GHA-dev-14737083364
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hey @irodriguez-nebustream! I'm Dosu, your friendly bot here to help you squash bugs, answer questions, and assist you in becoming a contributor. I'm here while you wait for a human maintainer. Let's tackle this issue together!
I found a similar unsolved discussion titled Swagger API page is empty, which might be related to the issue you're experiencing with accessing the Swagger API after enabling prefix routing [1].
To address your issue, you can customize the OpenAPI/Swagger UI configuration to accommodate prefix routing by setting the root path prefix using the SUPERSET_APP_ROOT
environment variable. This can be done by customizing the Flask entrypoint. The create_app
function in superset/app.py
allows you to specify a non-root path for the application using the superset_app_root
parameter. Here's how you can configure it:
FLASK_APP="superset:create_app(superset_app_root='/charts')"
Alternatively, you can use the --app
argument with flask run
:
flask --app "superset.app:create_app(superset_app_root='/charts')"
The AppRootMiddleware
class in superset/app.py
ensures that the application, including the OpenAPI/Swagger UI, is served under the specified prefix by adjusting the PATH_INFO
and SCRIPT_NAME
environment variables. This setup should help in correctly routing the API endpoints under the specified prefix [2][3].
Additionally, ensure that your Swagger/OpenAPI configuration is correctly set up to reflect the prefix in the URL. If you want to expose the Swagger config, you might need to adjust the configuration to include the prefix in the url
parameter, as you suggested. However, the specific setting OPENAPI_SWAGGER_UI_CONFIG
wasn't found in the available documentation, so you might need to explore the codebase or configuration files further to implement this change.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
Comment From: rusackas
Seems like a bit of an edge case... we'll leave this open, but we'd openly welcome a PR since it's not likely to get prioritized by the usual core contributors.