예제 #1
0
        public static IServiceCollection AddElectSwagger(this IServiceCollection services, [NotNull] Action <ElectSwaggerOptions> configuration)
        {
            services.Configure(configuration);

            var options = configuration.GetValue();

            if (!options.IsEnable)
            {
                return(services);
            }

            // Update File Content base on Configuration

            SwaggerHelper.UpdateApiDocFileContent(options.Title, SwaggerHelper.GetSwaggerEndpoint(options), options.AuthTokenType, options.JsonViewerUrl);

            SwaggerHelper.UpdateApiJsonViewerFileContent(options.Title);

            // Config Swagger
            services.AddSwaggerGen(swaggerGenOptions =>
            {
                swaggerGenOptions.AddElectSwaggerGenOptions(configuration);

                options.ExtendOptions?.Invoke(swaggerGenOptions, options);
            });

            return(services);
        }