[BUG] hyperf/swagger 组件 HttpServer类 getHtml()方法中的 https://unpkg.hyperf.wiki 会报 421 Misdirected Request 导致生成的swagger接口文档白屏
tbc295 opened this issue · comments
tbc295 commented
hyperf/swagger 组件 HttpServer类 getHtml()方法中的 https://unpkg.hyperf.wiki 会报 421 Misdirected Request --cloudflare 导致生成的swagger接口文档白屏 看不到页面,坐标日本。
Steinweber commented
I got same problem some hours ago.
Workaround:
swagger.php config
'html' => file_get_contents(BASE_PATH . '/storage/swagger/swagger-ui.html'),
Create BASE_PATH . '/storage/swagger/swagger-ui.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="SwaggerUI"
/>
<title>SwaggerUI</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.14.0/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@5.14.0/swagger-ui-bundle.js" crossorigin></script>
<script src="https://unpkg.com/swagger-ui-dist@5.14.0/swagger-ui-standalone-preset.js" crossorigin></script>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
url: GetQueryString("search"),
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
layout: "StandaloneLayout",
});
};
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
var context = "";
if (r != null)
context = decodeURIComponent(r[2]);
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "/http.json" : context;
}
</script>
</body>
</html>