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交互。
(编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|