自学内容网 自学内容网

fastapi swagger文档无法渲染问题

由于fastapi默认使用国外的cdn获得支持swagger文档的js和css文件, 所以在国内, /docs接口渲染不出来.

解决方法1

在app生效之前,将生成swagger文档的方法替换掉.(在fastapi为:fastapi.openapi.docs.get_swagger_ui_html)

from fastapi import FastAPI, applications
from fastapi.openapi.docs import get_swagger_ui_html
​
def swagger_monkey_patch(*args, **kwargs):
    &#

原文地址:https://blog.csdn.net/qq_25439417/article/details/140623811

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!