Install the package first
Install-Package NSwag.AspNetCore
Copy the code
public void ConfigureServices(IServiceCollection services)
{
//swagger
services.AddOpenApiDocument(settings =>
{
settings.AddSecurity("Authentication Token", Enumerable.Empty<string> (),new OpenApiSecurityScheme()
{
Scheme = "bearer",
Description = "Authorization:Bearer of {your JWT token}
authorized address :/Base_Manage /home/submitlogin ",
Name = "Authorization",
In = OpenApiSecurityApiKeyLocation.Header,
Type = OpenApiSecuritySchemeType.Http
});
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseOpenApi(); // Add swagger to generate API document (default routing document /swagger/v1/swagger.json)
app.UseSwaggerUi3();// Add Swagger UI to the request pipe (default route: / Swagger).
}
Copy the code