配置文件
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v0.1.0",//版本号
Title = "尹大师框架说明,QQ:1390788386",//文档标题
Description = "框架说明文档",//文档描述
Contact = new OpenApiContact { Name = "道法自然", Email = "1390788386@qq.com"}//联系人
});
// Assign scope requirements to operations based on AuthorizeAttribute
//options.OperationFilter<SecurityRequirementsOperationFilter>();
//设置swagger的xml文档
//c.DocInclusionPredicate((docName, description) => true);
//// Define the BearerAuth scheme that's in use
//c.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
//{
// Description = "JWT Authorization header using the Bearer scheme. Example: "Authorization: Bearer {token}"",
// Name = "Authorization",
// In = "header",
// Type = "apiKey"
//});
//// Assign scope requirements to operations based on AuthorizeAttribute
//c.OperationFilter<SecurityRequirementsOperationFilter>();
// c.DocInclusionPredicate((docName, description) => true);
//c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
//{
// Description = "Authorization format : Bearer {token}",
// Name = "Authorization",
// In = "header",
// Type = "apiKey"
//});//api界面新增authorize按钮
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "西方输入Token,使用Bearer开头",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
BearerFormat = "JWT",
Scheme = "Bearer"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference {
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[] { }
}
});
string filepath = $"{AppContext.BaseDirectory}YMNNetCoreFrameWork.Host.xml";
c.IncludeXmlComments(filepath);
});