foreach (var description in provider.ApiVersionDescriptions) { services.AddSwaggerDocument(document => { document.OperationProcessors.Add(new OperationSecurityScopeProcessor("JWT token")); document.DocumentName = description.GroupName; document.Version = description.GroupName; document.ApiGroupNames = new string[] { description.GroupName }; //jwt 认证 document.AddSecurity("JWT token", Enumerable.Empty<string>(), new OpenApiSecurityScheme() { Type = OpenApiSecuritySchemeType.ApiKey, Name = nameof(Authorization), In = OpenApiSecurityApiKeyLocation.Header, Description = "将token值复制到如下格式: nBearer {token}" } );
}); }
4,nswag中间件
app.UseOpenApi(); app.UseSwaggerUi3(setting => { });
是的我们做任何配置,如果你愿意其实有很多好玩的。但上面的配置方式足够多版本的控制与nswag交互。
(编辑:ASP站长)
【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。
|