Пример #1
0
        internal static IServiceCollection AddSwaggerDocumentation(this IServiceCollection services, IConfiguration Configuration)
        {
            var swaggerSection = Configuration.GetSection(nameof(SwaggerConfiguration));

            services.Configure <SwaggerConfiguration>(swaggerSection);

            IServiceProvider provider = services.BuildServiceProvider();

            SwaggerConfiguration swaggerConfig = GetSwaggerConfiguration(provider);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc(swaggerConfig.Version, swaggerConfig.GetOpenApiInfo());
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            return(services);
        }