public static void UseSwaggerSettings(this IApplicationBuilder app, ISwaggerConfiguration swaggerConfiguration) { if (!swaggerConfiguration.IsEnabled()) { return; } app.UseSwagger(options => { options.RouteTemplate = swaggerConfiguration.JsonRoute; }); app.UseSwaggerUI(opt => { opt.SwaggerEndpoint( swaggerConfiguration.UIEndpoint, swaggerConfiguration.Description ); opt.DocumentTitle = swaggerConfiguration.Title; opt.DefaultModelsExpandDepth(0); opt.RoutePrefix = swaggerConfiguration.RoutePrefix; }); }
public static void AddSwaggerSettings(this IServiceCollection services, ISwaggerConfiguration swaggerConfiguration) { if (!swaggerConfiguration.IsEnabled()) { return; } services.AddSwaggerGen(c => { c.SwaggerDoc(swaggerConfiguration.Version, new OpenApiInfo { Version = swaggerConfiguration.Version, Title = swaggerConfiguration.Title, Description = swaggerConfiguration.Description }); AddJwtAuthentication(c, swaggerConfiguration); var xmlFile = $"{Assembly.GetEntryAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); }