-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Question] Is it possible to load the Swagger UI offline? #261
Comments
Thanks for asking. I think it's possible if we package the related frontend source code into the Python package. Does that mean you can access internal PyPI but cannot access other websites? |
You can pair spectree with https://github.com/sveint/flask-swagger-ui for now. Not a perfect solution, but an easy workaround. Here's a quick example: https://gist.github.com/jaykv/cd9afb91fa5a2fafc206345b7dd4b984 |
We also use SpecTree in our closed perimeter where there is no internet access! |
A very hackish way is to overwrite from spectree.page import DEFAULT_PAGE_TEMPLATES
app = Flask(...)
def _rewrite_cdn():
DEFAULT_PAGE_TEMPLATES["redoc"] = DEFAULT_PAGE_TEMPLATES["redoc"].replace("https://cdn.jsdelivr.net/npm/redoc@next/bundles/", "localhost/assets")
_rewrite_cdn()
spec = SpecTree("flask")
spec.register(app) |
Is there any news on this issue? |
Similar to @cardin's comment. You can pack all the swagger related HTML/CSS/JS into one string. Assume you already done it, you can use the code below: from spectree import SpecTree
spec = SpecTree(page_templates={"swagger": YOUR_OFFLINE_SWAGGER_HTML_STRING}) |
The service I'm making runs on the localhost with not necessarily access to Internet. When I open the Swagger endpoint in the browser I can see the next messages in the console:
So I want to know... How to load the Swagger interface offline?
The text was updated successfully, but these errors were encountered: