示例#1
0
        public static void UseSwaggerSettings(this IApplicationBuilder app, IConfiguration configuration)
        {
            SwaggerOptions swaggerOptions = configuration.GetSection("SwaggerOptions").Get <SwaggerOptions>();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint(swaggerOptions.EndPointUrl, swaggerOptions.Description);
            });
        }
        public static void AddSwaggerSettings(this IServiceCollection services, IConfiguration configuration)
        {
            SwaggerOptions swaggerOptions = configuration.GetSection("SwaggerOptions").Get <SwaggerOptions>();

            services.AddSwaggerGen(c =>
            {
                c.CustomSchemaIds(i => i.FullName);
                c.SwaggerDoc(swaggerOptions.Version, new OpenApiInfo
                {
                    Title       = swaggerOptions.Title,
                    Version     = swaggerOptions.Version,
                    Description = swaggerOptions.Description
                });
            });
        }