You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to translate the existing Swashbuckle c# documentation to vb.net.
I need the "authentication" button to appear on the swagger documentation page.
The fact is that in the documentation found for C# the following function appears:
`
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "API Auth",
Description = "A simple demo with JWT Auth APIs and Basic Auth APIs",
Contact = new OpenApiContact
{
Name = @"GitHub Repository",
Email = string.Empty,
Url = new Uri("https://XXX/X")
}
});
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath, true);
// add JWT Authentication
var securityScheme = new OpenApiSecurityScheme
{
Name = "JWT Authentication",
Description = "Enter JWT Bearer token **_only_**",
In = ParameterLocation.Header,
Type = SecuritySchemeType.Http,
Scheme = "bearer", // must be lower case
BearerFormat = "JWT",
Reference = new OpenApiReference
{
Id = JwtBearerDefaults.AuthenticationScheme,
Type = ReferenceType.SecurityScheme
}
};
c.AddSecurityDefinition(securityScheme.Reference.Id, securityScheme);
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{securityScheme, new string[] { }}
});
// add Basic Authentication
var basicSecurityScheme = new OpenApiSecurityScheme
{
Type = SecuritySchemeType.Http,
Scheme = "basic",
Reference = new OpenApiReference { Id = "BasicAuth", Type = ReferenceType.SecurityScheme }
};
c.AddSecurityDefinition(basicSecurityScheme.Reference.Id, basicSecurityScheme);
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{basicSecurityScheme, new string[] { }}
});
});
`
I have not found the way to access "services"
The global files of my API are:
/global.asax
/App_Start/WebApiConfig.vb
Thank you for your time
The text was updated successfully, but these errors were encountered:
Good day,
I have tried to translate the existing Swashbuckle c# documentation to vb.net.
I need the "authentication" button to appear on the swagger documentation page.
The fact is that in the documentation found for C# the following function appears:
`
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "API Auth",
Description = "A simple demo with JWT Auth APIs and Basic Auth APIs",
Contact = new OpenApiContact
{
Name = @"GitHub Repository",
Email = string.Empty,
Url = new Uri("https://XXX/X")
}
});
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath, true);
`
I have not found the way to access "services"
The global files of my API are:
/global.asax
/App_Start/WebApiConfig.vb
Thank you for your time
The text was updated successfully, but these errors were encountered: