-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger_ui.py
More file actions
157 lines (138 loc) · 4.51 KB
/
swagger_ui.py
File metadata and controls
157 lines (138 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
"""
Swagger UI HTML template for ComfyUI-OneAPI-Swagger
"""
SWAGGER_UI_HTML = """
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ComfyUI-OneAPI-Swagger - Swagger UI</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.11.0/swagger-ui.min.css">
<style>
body {
margin: 0;
padding: 0;
}
.topbar {
display: none;
}
.swagger-ui .info {
margin: 30px 0;
}
.swagger-ui .info .title {
font-size: 36px;
color: #3b4151;
}
.swagger-ui .scheme-container {
background: #f7f7f7;
padding: 20px;
margin: 20px 0;
border-radius: 4px;
}
/* 自定义配色 */
.swagger-ui .opblock.opblock-post {
background: rgba(73, 204, 144, 0.1);
border-color: #49cc90;
}
.swagger-ui .opblock.opblock-post .opblock-summary-method {
background: #49cc90;
}
.swagger-ui .opblock.opblock-get {
background: rgba(97, 175, 254, 0.1);
border-color: #61affe;
}
.swagger-ui .opblock.opblock-get .opblock-summary-method {
background: #61affe;
}
/* 优化响应式 */
@media (max-width: 768px) {
.swagger-ui .info .title {
font-size: 28px;
}
}
/* 自定义头部横幅 */
.custom-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px 20px;
text-align: center;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.custom-header h1 {
margin: 0;
font-size: 32px;
font-weight: 600;
}
.custom-header p {
margin: 10px 0 0 0;
font-size: 16px;
opacity: 0.9;
}
.custom-header .links {
margin-top: 15px;
}
.custom-header a {
color: white;
text-decoration: none;
margin: 0 10px;
padding: 8px 16px;
background: rgba(255,255,255,0.2);
border-radius: 4px;
transition: background 0.3s;
}
.custom-header a:hover {
background: rgba(255,255,255,0.3);
}
</style>
</head>
<body>
<!-- 自定义头部 -->
<div class="custom-header">
<h1>✨ ComfyUI-OneAPI-Swagger</h1>
<p>简洁的 REST API 接口执行 ComfyUI 工作流</p>
<div class="links">
<a href="https://github.com/hackyinge/ComfyUI-OneAPI-Swagger" target="_blank">📦 GitHub</a>
<a href="/oneapi/openapi.json" target="_blank">📄 OpenAPI JSON</a>
</div>
</div>
<!-- Swagger UI 容器 -->
<div id="swagger-ui"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.11.0/swagger-ui-bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.11.0/swagger-ui-standalone-preset.min.js"></script>
<script>
window.onload = function() {
// 初始化 Swagger UI
const ui = SwaggerUIBundle({
url: '/oneapi/openapi.json',
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "BaseLayout",
defaultModelsExpandDepth: 1,
defaultModelExpandDepth: 1,
docExpansion: 'list',
filter: true,
tryItOutEnabled: true,
// 自定义请求拦截器
requestInterceptor: (request) => {
// 可以在这里添加自定义请求头
return request;
},
// 自定义响应拦截器
responseInterceptor: (response) => {
return response;
}
});
window.ui = ui;
};
</script>
</body>
</html>
"""