private void ConfigureSwaggerUI(SwaggerUIOptions options) { ExtendedOpenApiInfo openApiInfo = Configuration.GetSection("Swagger").Get <ExtendedOpenApiInfo>(); if (!string.IsNullOrWhiteSpace(openApiInfo?.UriResource)) { string name = openApiInfo.Name ?? "Unknown"; options.SwaggerEndpoint($"/swagger/{openApiInfo.UriResource}/swagger.json", name); } }
/// <summary> /// Provides swagger configuration. /// </summary> public static IServiceCollection AddSwagger(this IServiceCollection services, IConfiguration configuration) { ExtendedOpenApiInfo openApiInfo = configuration.GetSection("Swagger").Get <ExtendedOpenApiInfo>(); return(services .AddSwaggerGenNewtonsoftSupport() .AddSwaggerGen(options => { if (!string.IsNullOrWhiteSpace(openApiInfo?.UriResource)) { options.SwaggerDoc(openApiInfo.UriResource, openApiInfo); } //TODO Think, maybe needs to download all the documentation that is in the application folder string xmlFile = $"{Assembly.GetEntryAssembly().GetName().Name}.xml"; string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); if (File.Exists(xmlPath)) { options.IncludeXmlComments(xmlPath); } })); }