public void ConfigureServices(IServiceCollection services) { ... services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIs", Version = "v1" }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, Name = "Authorization", Type = SecuritySchemeType.ApiKey, }); c.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Name = "Token", Type = SecuritySchemeType.ApiKey, In = ParameterLocation.Header, Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Token", }, }, Array.Empty<string>() } }); }); ... } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IUnitOfWork uow) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //########################################## Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "APIs"); }); //########################################## app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); .... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)