添加swagger搜索功能
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
ada55aefd4
commit
38d1c2f92a
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -116,6 +116,9 @@ public static class SwaggerSetup
|
|||
//DocExpansion设置为none可折叠所有方法
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
|
||||
// 开启Swagger UI的搜索/过滤功能
|
||||
options.EnableFilter();
|
||||
|
||||
//DefaultModelsExpandDepth设置为 - 1 可不显示models
|
||||
options.DefaultModelsExpandDepth(-1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!-- HTML for static distribution bundle build -->
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
@ -112,8 +112,23 @@
|
|||
}, info: function () {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
fn: {
|
||||
opsFilter: function (taggedOps, phrase) {
|
||||
var normalPhrase = phrase.toLowerCase();
|
||||
return taggedOps.map(function (tagObj, tag) {
|
||||
var operations = tagObj.get("operations").filter(function (op) {
|
||||
var summary = op.getIn(["operation", "summary"]) || "";
|
||||
var path = op.get("path") || "";
|
||||
var tagMatch = tag.toLowerCase().indexOf(normalPhrase) !== -1;
|
||||
return tagMatch || summary.toLowerCase().indexOf(normalPhrase) !== -1 || path.toLowerCase().indexOf(normalPhrase) !== -1;
|
||||
});
|
||||
return tagObj.set("operations", operations);
|
||||
}).filter(function (tagObj) {
|
||||
return tagObj.get("operations").size > 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue