Open Joseda8 opened 1 year ago
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! We take all the libraries for our apps from JFrog Artifactory or Nexus Repository (depending on the project/team), which have internet access, or rather only to global PyPi.
A very hackish way is to overwrite spectree/page.py
before SpecTree is instantiated.
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?
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?