xiaoymin / knife4j

Knife4j is a set of Swagger2 and OpenAPI3 All-in-one enhancement solution
https://doc.xiaominfo.com
Apache License 2.0
4.13k stars 621 forks source link

支持多后端语言实现接口文档渲染 #827

Open iszhangsc opened 2 months ago

iszhangsc commented 2 months ago

能否像swagger-ui-dist 那样,提供一个 CSSJS 文件的CDN,然后由后端使用一个 html文件引入这两个文件, 并添加相应的配置即可. 如下是使用 swagger-ui-dist 的使用示例

<!DOCTYPE html>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css">
    <link rel="shortcut icon" href="https://fastapi.tiangolo.com/img/favicon.png">
    <title>fastapi接口文档标题 - Swagger UI</title>
</head>
<body>
<div id="swagger-ui">
</div>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
<!-- `SwaggerUIBundle` is now available on the page -->
<script>
    const ui = SwaggerUIBundle({
        url: '/v3/api-docs/default',
    "dom_id": "#swagger-ui",
"layout": "BaseLayout",
"deepLinking": true,
"showExtensions": true,
"showCommonExtensions": true,
oauth2RedirectUrl: window.location.origin + '/docs/oauth2-redirect',
    presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIBundle.SwaggerUIStandalonePreset
        ],
    })
</script>
</body>
</html>
HHC26 commented 2 months ago

希望其他后端语言也能否使用这个好看的ui