对swagger的封装,包含认证,默认头,默认公共query参数,文件上传
"SwaggerOption": {
"Enabled": true,
"MiniProfilerEnabled": false,
"XmlComments": [ "", "" ],
"RoutePrefix": "swagger",
"Description": "this is swagger for netcore",
"Title": "Demo swagger",
"Version": "first version",
"TermsOfService": "netcore.com",
"Contact": {
"Email": "[email protected]",
"Name": "swagger",
"Url": "[email protected]"
},
"License": {
"Name": "",
"Url": ""
},
"Headers": [ //swagger默认头参数
{
"Name": "User",
"Description": "用户"
}
],
"Query": [ //swagger默认url公共参数
{
"Name": "sign",
"Description": "签名"
},
{
"Name": "timestamp",
"Description": "客户端时间戳"
}
]
}
public void ConfigureServices(IServiceCollection services,IConfiguration configuration)
{
services.AddNetProSwagger(configuration);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseNetProSwagger();
}
webapi项目中不能包含Web相关组件,例如 Microsoft.VisualStudio.Web.CodeGeneration.Design 否则会导致swagger异常