public static IServiceCollection AddCustomSwagger(
            this IServiceCollection services,
            SwaggerConfiguration configuration)
        {
            if (!configuration.IsEnabled)
            {
                return(services);
            }

            services.AddSwaggerGen(c =>
            {
                foreach (var info in configuration.ApplicationInfo)
                {
                    c.SwaggerDoc(info.Version, info);
                }
            });

            return(services);
        }
        public static IApplicationBuilder UseCustomSwagger(
            this IApplicationBuilder app,
            SwaggerConfiguration configuration)
        {
            if (!configuration.IsEnabled)
            {
                return(app);
            }

            app.UseSwagger();
            app.UseSwaggerUi(c =>
            {
                foreach (var info in configuration.ApplicationInfo)
                {
                    c.SwaggerEndpoint($"/swagger/{info.Version}/swagger.json", info.Title);
                }
            });

            return(app);
        }
        private static OpenApiInfo CreateSwaggerInfoForApiVersion(ApiVersionDescription description, SwaggerConfiguration swaggerConfiguration)
        {
            var info = new OpenApiInfo()
            {
                Title       = swaggerConfiguration.Name,
                Description = swaggerConfiguration.Description,
                Version     = description.ApiVersion.ToString()
            };

            if (info.Version.Equals("1.0"))
            {
                info.Description += "<br>Initial version.";
            }
            else
            {
                var versionDescription = swaggerConfiguration.VersionIngDescriptions?[info.Version];
                if (!string.IsNullOrWhiteSpace(versionDescription))
                {
                    info.Description += $"<br>{versionDescription}";
                }
            }

            if (description.IsDeprecated)
            {
                info.Description += "<br><br><span style=\"color: #ff0000;font-weight: bold;\">This version is already deprecated.</span>";
            }

            return(info);
        }