我使用的是asp.netcore 3.1和openapi 3.0.1
我已经使用以下代码向我的API添加了授权:
services.AddSwaggerGen(setupAction =>
{
setupAction.SwaggerDoc("APIs_Documentation", new OpenApiInfo
{
Title = "Project APIs",
Version = "1"
});
setupAction.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme()
{
Type = SecuritySchemeType.Http,
Scheme = "bearer",
Description = "Enter token here",
Name = "Authorization",
@In = ParameterLocation.Header,
});
setupAction.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "oauth2",
}
},new List<string>()}
});
});
有没有办法为下一个图像中弹出的授权对话框的值字段设置默认值?
1条答案
按热度按时间qij5mzcb1#
如果您正在寻找添加默认头的方法,可以在C#中这样做:
);
或者想要将其添加到Swagger UI:related question