using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Threading.Tasks; namespace Backend.API.Config { internal static class SwaggerExtensions { internal static IServiceCollection AddSwaggerDocumentation(this IServiceCollection services) { services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Sample CQRS Catalogue.Backend.API", Version = "v1", Description = "Sample .NET Core REST API CQRS implementation using Clean Architecture.", }); var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML"; var commentsFile = Path.Combine(baseDirectory, commentsFileName); // options.IncludeXmlComments(commentsFile); }); return services; } internal static IApplicationBuilder UseSwaggerDocumentation(this IApplicationBuilder app) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample CQRS API V1"); }); return app; } } }