解决FastAPI项目swaggerUI打不开的问题

解决FastAPI项目swaggerUI打不开的问题

## 正常的实例化API操作
from fastapi import FastAPI
app = FastAPI()
  • 在实例化API之前加以下内容
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi import FastAPI, applications
def swagger_monkey_patch(*args, **kwargs):
    return get_swagger_ui_html(
        *args, **kwargs,
        swagger_js_url='https://cdn.bootcdn.net/ajax/libs/swagger-ui/4.10.3/swagger-ui-bundle.js',
        swagger_css_url='https://cdn.bootcdn.net/ajax/libs/swagger-ui/4.10.3/swagger-ui.css'
    )

applications.get_swagger_ui_html = swagger_monkey_patch

你可能感兴趣的:(ui,开发语言,python)