• 开源DDD设计模式框架YMNNetCoreFrameWork第五篇-Swagger增加权限认证


    配置文件
    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); });

  • 相关阅读:
    Arduino学习笔记10
    Arduino学习笔记07
    Arduino学习笔记6
    Arduino学习笔记5
    Arduino学习笔记4
    Arduino学习笔记3
    linux下库文件的编程
    学习编程语言究竟学什么
    Arduino学习笔记2---数字温度计
    Arduino学习笔记0---开发板的了解
  • 原文地址:https://www.cnblogs.com/topguntopgun/p/12271530.html
Copyright © 2020-2023  润新知