public static IServiceCollection AddSwaggerGenConfiguration(this IServiceCollection services) { services.AddSwaggerExamplesFromAssemblyOf <Startup>(); return(services.AddSwaggerGen(c => { var basePath = AppContext.BaseDirectory; c.SwaggerDoc("v1", new OpenApiInfo { Title = "Pdf.Storage", Version = "v1", Description = File.ReadAllText(Path.Combine(basePath, "ApiDescription.md")) }); c.ExampleFilters(); c.AddSecurityDefinition("ApiKey", ApiKey.OpenApiSecurityScheme); c.AddSecurityRequirement(ApiKey.OpenApiSecurityRequirement("ApiKey")); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(basePath, xmlFile); c.IncludeXmlComments(xmlPath); })); }