Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access swagger doc web page in local environment? #1119

Open
zealot-shin opened this issue Feb 7, 2025 · 0 comments
Open

How to access swagger doc web page in local environment? #1119

zealot-shin opened this issue Feb 7, 2025 · 0 comments

Comments

@zealot-shin
Copy link

I used to use fastapi to develop python web apps. Now I'm interested in robyn.
I want to access swagger ui docs page in local environment which means no internet access.
In fastapi, I can define self-custom swagger ui html method as below:

def swagger_monkey_patch(*args, **kwargs):
"""
Wrap the function which is generating the HTML for the /docs endpoint and
overwrite the default values for the swagger js and css.
"""
return get_swagger_ui_html(
*args, **kwargs,
swagger_js_url="/static/swagger-ui-bundle.js",
swagger_css_url="/static/swagger-ui.css",
swagger_favicon_url="/static/favicon.png"
)

Actual monkey patch

applications.get_swagger_ui_html = swagger_monkey_patch

mount local swagger-ui files

app.mount('/static', StaticFiles(directory="./static/swagger-ui"), name='static')

if name == "main":
import uvicorn

uvicorn.run(app, host="0.0.0.0", port=9080)

While this app is running, I can access swagger-ui docs page on 127.0.0.1:9080/docs without internet access.

However, I don't see any patch method I can define to use local resource files.

Could someone please tell me how to localize swagger ui docs?

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

No branches or pull requests

1 participant