예제 #1
0
        /// <inheritdoc />
        public void Configure(SwaggerGenOptions options)
        {
            options.SchemaFilter <DescribeEnumMemberValues>();

            //options.ResolveConflictingActions(apiDesctions => apiDesctions.First());

            // options.DocumentFilter<CustomSwaggerFilter>();


            // options.MapType<AccountType>(c =>
            //{
            //    return new OpenApiSchema {type = "string", @enum = Enum.GetNames(typeof(AccountType)) };
            //});



            //options.MapType<AccountType>(() => new OpenApiSchema { Type = "string", Enum = Enum.GetNames(typeof(AccountType)) });


            //  options.MapType<AccountType>(() => new OpenApiSchema { Type = "string", Enum = (IList<IOpenApiAny>)Enum.GetNames(typeof(AccountType)).ToList() });



            options.OperationFilter <SwaggerDefaultValues>();
            //options.OperationFilter<HeaderParameters>();

            // add a swagger document for each discovered API version
            // note: you might choose to skip or document deprecated API versions differently
            foreach (var description in _provider.ApiVersionDescriptions)
            {
                options.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(description));
            }

            // integrate xml comments
            XmlCommentsFiles.ForEach(file => options.IncludeXmlComments(file, includeControllerXmlComments: true));

            options.CustomSchemaIds(x =>
            {
                if (Interfaces.Contains(x.Name))
                {
                    return($"Interface.{x.Name}");
                }
                else
                {
                    return($"Model.{x.Name}");
                }
            });

            options.ExampleFilters();
        }
        /// <inheritdoc />
        public void Configure(SwaggerGenOptions options)
        {

            options.OperationFilter<SwaggerDefaultValues>();
            options.OperationFilter<AddRequiredHeaderParameter>();

            // add a swagger document for each discovered API version
            // note: you might choose to skip or document deprecated API versions differently
            foreach (var description in _provider.ApiVersionDescriptions)
            {
                options.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(description));
            }

            // integrate xml comments
            XmlCommentsFiles.ForEach(file => options.IncludeXmlComments(file, includeControllerXmlComments: true));

            options.CustomSchemaIds(x => $"Models.{x.Name}");
        }