SchemaGeneratorOptions

We found 10 examples in language CSharp for this search. You will see 13 fragments of code.
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TestTask_Core3.Classes
{
    //public class SwaggerGenOptions
    //{
    //    public SwaggerGeneratorOptions SwaggerGeneratorOptions { get; set; }
    //    public SchemaGeneratorOptions SchemaGeneratorOptions { get; set; }
    //    public List<FilterDescriptor> ParameterFilterDescriptors { get; set; }
    //    public List<FilterDescriptor> OperationFilterDescriptors { get; set; }
    //    public List<FilterDescriptor> DocumentFilterDescriptors { get; set; }
    //    public List<FilterDescriptor> SchemaFilterDescriptors { get; set; }
    //}
}


        private void ApplyFilters(OpenApiSchema schema, ModelMetadata modelMetadata, SchemaRepository schemaRepository, JsonContract jsonContract)
        {
            var context = new SchemaFilterContext(modelMetadata, schemaRepository, SchemaGenerator, jsonContract);

            foreach (var filter in SchemaGeneratorOptions.SchemaFilters)
            {
                filter.Apply(schema, context);
            }
        }


        private void ConfigureGenerator(SchemaGeneratorOptions options, params IValidator[] validators)
        {
            IValidatorFactory validatorFactory = new CustomValidatorFactory(validators);

            options.SchemaFilters.Add(
                new FluentValidationRules(
                    validatorFactory
                )
            );
        }

using appfibre.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace appfibre.AspNetCore
{
    public class appfibreServiceeOptions
    {
        public appfibreServiceeOptions()
        {
            Workspaces = new Dictionary<string, Workspace>();
        }

        /*public SwaggerGeneratorOptions SwaggerGeneratorOptions { get; set; }
        public SchemaGeneratorOptions SchemaGeneratorOptions { get; set; }
        public List<FilterDescriptor> ParameterFilterDescriptors { get; set; }
        public List<FilterDescriptor> RequestBodyFilterDescriptors { get; set; }
        public List<FilterDescriptor> OperationFilterDescriptors { get; set; }
        public List<FilterDescriptor> DocumentFilterDescriptors { get; set; }
        public List<FilterDescriptor> SchemaFilterDescriptors { get; set; }*/

        public Dictionary<string, Workspace> Workspaces { get; set; }
    }
}


        protected override bool CanGenerateSchemaFor(ModelMetadata modelMetadata, JsonContract jsonContract)
        {
            return SchemaGeneratorOptions.GeneratePolymorphicSchemas
                && SchemaGeneratorOptions.SubTypesResolver(modelMetadata.ModelType).Any();
        }


        protected override bool CanGenerateSchemaFor(ModelMetadata modelMetadata, JsonContract jsonContract)
        {
            var modelType = modelMetadata.ModelType;

            return SchemaGeneratorOptions.CustomTypeMappings.ContainsKey(modelType)
                || KnownTypeMappings.ContainsKey(modelType)
                || typeof(IFormFile).IsAssignableFrom(modelType)
                || typeof(FileResult).IsAssignableFrom(modelType);
        }

        public static IServiceCollection AddAppFibre(this IServiceCollection services, Action<appfibreServiceeOptions> setupAction = null)
        {
            // Add Mvc convention to ensure ApiExplorer is enabled for all actions
            /*services.Configure<MvcOptions>(c =>
                c.Conventions.Add(new SwaggerApplicationConvention()));

            // Register custom configurators that takes values from SwaggerGenOptions (i.e. high level config)
            // and applies them to SwaggerGeneratorOptions and SchemaGeneratorOptoins (i.e. lower-level config)
            services.AddTransient<IConfigureOptions<SwaggerGeneratorOptions>, ConfigureSwaggerGeneratorOptions>();
            services.AddTransient<IConfigureOptions<SchemaGeneratorOptions>, ConfigureSchemaGeneratorOptions>();

            // Register generator and it's dependencies
            services.TryAddTransient<ISwaggerProvider, SwaggerGenerator>();
            services.TryAddTransient(s => s.GetRequiredService<IOptions<SwaggerGeneratorOptions>>().Value);
            services.TryAddTransient<ISchemaGenerator, SchemaGenerator>();
            services.TryAddTransient(s => s.GetRequiredService<IOptions<SchemaGeneratorOptions>>().Value);
            services.TryAddTransient<ISerializerDataContractResolver>(s =>
            {
#if (!NETSTANDARD2_0)
                var serializerOptions = s.GetService<IOptions<JsonOptions>>()?.Value?.JsonSerializerOptions
                    ?? new JsonSerializerOptions();
#else
                var serializerOptions = new JsonSerializerOptions();
#endif

                return new JsonSerializerDataContractResolver(serializerOptions);
            });

            // Used by the <c>dotnet-getdocument</c> tool from the Microsoft.Extensions.ApiDescription.Server package.
            services.TryAddSingleton<IDocumentProvider, DocumentProvider>();

            if (setupAction != null) services.ConfigureSwaggerGen(setupAction);*/

            return services;
        }

        public static void ConfigureAppFibre(this IServiceCollection services, Action<appfibreServiceeOptions> setupAction)
        {
            services.Configure(setupAction);
        }


        public void Configure(SchemaGeneratorOptions options)
        {
            DeepCopy(_swaggerGenOptions.SchemaGeneratorOptions, options);

            // Create and add any filters that were specified through the FilterDescriptor lists
            _swaggerGenOptions.SchemaFilterDescriptors.ForEach(
                filterDescriptor => options.SchemaFilters.Add(CreateFilter<ISchemaFilter>(filterDescriptor)));
        }

        private void DeepCopy(SchemaGeneratorOptions source, SchemaGeneratorOptions target)
        {
            target.CustomTypeMappings = new Dictionary<Type, Func<OpenApiSchema>>(source.CustomTypeMappings);
            target.DescribeAllEnumsAsStrings = source.DescribeAllEnumsAsStrings;
            target.DescribeStringEnumsInCamelCase = source.DescribeStringEnumsInCamelCase;
            target.SchemaIdSelector = source.SchemaIdSelector;
            target.IgnoreObsoleteProperties = source.IgnoreObsoleteProperties;
            target.GeneratePolymorphicSchemas = source.GeneratePolymorphicSchemas;
            target.SubTypesResolver = source.SubTypesResolver;
            target.SchemaFilters = new List<ISchemaFilter>(source.SchemaFilters);
        }

        private TFilter CreateFilter<TFilter>(FilterDescriptor filterDescriptor)
        {
            return (TFilter)ActivatorUtilities
                .CreateInstance(_serviceProvider, filterDescriptor.Type, filterDescriptor.Arguments);
        }

        public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config)
        {

            services.AddDbContext<DataContext>(opt =>
            {
                opt.UseSqlite(config.GetConnectionString("DefaultConnection"));
            });
            services.AddCors(opt =>
            {
                opt.AddPolicy("CorsPolicy", policy =>
                 {
                     policy.AllowAnyHeader().AllowAnyMethod()
                     .AllowCredentials()
                     .WithOrigins("http://localhost:3000");
                 });
            });
            services.AddMediatR(typeof(List.Handler).Assembly);
            services.AddAutoMapper(typeof(MappingProfiles).Assembly);
            services.AddScoped<IUserAccessor, UserAccessor>();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo { Title = "API", Version = "v1" });
                c.SchemaGeneratorOptions = new SchemaGeneratorOptions { SchemaIdSelector = type => type.FullName };
            });
            services.AddScoped<IPhotoAccessor, PhotoAccessor>();
            services.Configure<CloudinarySettings>(config.GetSection("Cloudinary"));
            services.AddSignalR();
            return services;
        }

        public static async Task Main(string[] args)
        {
            await WebHost
                .CreateDefaultBuilder(args)
                .UseSerilog((context, loggerConfiguration) =>
                {
                    loggerConfiguration.ReadFrom.Configuration(context.Configuration);

                    loggerConfiguration.Enrich.FromLogContext()
                        .Enrich.WithProperty("Environment", "Development")
                        .Enrich.WithProperty("Application", "iCBM")
                        .Enrich.WithProperty("Version", "0.0");
                })
                .ConfigureServices(services =>
                {
                    var configuration = services.BuildServiceProvider().GetService<IConfiguration>();

                    services
                        .AddSqlContext<CbmContext>(configuration)
                        .AddScoped<ICbmContext>(provider => provider.GetRequiredService<CbmContext>())
                        .AddScoped<DbContext>(provider => provider.GetRequiredService<CbmContext>())
                        .AddScoped<DbContextBase>(provider => provider.GetRequiredService<CbmContext>())
                        .AddInMemoryCommandDispatcher()
                        .AddInMemoryEventDispatcher()
                        .AddInMemoryQueryDispatcher()
                        .AddCommandHandlers()
                        .AddQueryHandlers()
                        .AddEventHandlers()
                        .AddEventDispatcherCommandDecorator()
                        .AddTransactionCommandDecorator()
                        .AddCommandHandlerLoggingDecorator()
                        .AddEFCoreRepository()
                        .AddAutoMapperWithDefaultProfile()
                        .AddJwt()
                        .AddErrorHandler<ExceptionToResponseMapper>()
                        .AddSwaggerGen(c =>
                        {
                            c.SchemaGeneratorOptions = new SchemaGeneratorOptions()
                            {
                                SchemaFilters = new List<ISchemaFilter>() { new IgnoreReadOnlySchemaFilter() }
                            };
                            c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebApp1", Version = "v1" });
                        });

                    services.AddControllers(opts =>
                    {
                        opts.ModelBinderProviders.InsertBodyAndRouteBinding();
                    });

                    services.AddCors(options =>
                    {
                        options.AddPolicy(name: "allow-all",
                            builder =>
                            {
                                builder
                                    .AllowAnyHeader()
                                    .AllowAnyMethod()
                                    .AllowAnyOrigin();
                            });
                    });

                    services.AddMvc();
                })
                .Configure(app =>
                {
                    app.UseSwagger();
                    app.UseSwaggerUI(c =>
                    {
                        c.RoutePrefix = string.Empty;
                        c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApp1 v1");
                    });

                    app.UseErrorHandler();
                    app.UseHttpsRedirection();
                    app.UseRouting();
                    app.UseAuthorization();
                    app.UseCors("allow-all");
                    app.UseEndpoints(endpoints =>
                    {
                        endpoints.MapControllers();
                    });

                })
                .Build()
                .MigrateDbContext<CbmContext>(null, true)
                .RunAsync();
        }

Swashbuckle.AspNetCore.SwaggerGen.SchemaGeneratorOptions : Object

Constructors :

public SchemaGeneratorOptions()

Methods :

public IDictionary<Type, Func<OpenApiSchema>> get_CustomTypeMappings()
public Void set_CustomTypeMappings(IDictionary<Type, Func<OpenApiSchema>> value = )
public Func<Type, String> get_SchemaIdSelector()
public Void set_SchemaIdSelector(Func<Type, String> value = )
public Boolean get_IgnoreObsoleteProperties()
public Void set_IgnoreObsoleteProperties(Boolean value = )
public Boolean get_GeneratePolymorphicSchemas()
public Void set_GeneratePolymorphicSchemas(Boolean value = )
public Func<Type, IEnumerable<Type>> get_SubTypesResolver()
public Void set_SubTypesResolver(Func<Type, IEnumerable<Type>> value = )
public Func<Type, String> get_DiscriminatorSelector()
public Void set_DiscriminatorSelector(Func<Type, String> value = )
public Boolean get_UseInlineDefinitionsForEnums()
public Void set_UseInlineDefinitionsForEnums(Boolean value = )
public IList<ISchemaFilter> get_SchemaFilters()
public Void set_SchemaFilters(IList<ISchemaFilter> value = )
public Boolean get_DescribeAllEnumsAsStrings()
public Void set_DescribeAllEnumsAsStrings(Boolean value = )
public Boolean get_DescribeStringEnumsInCamelCase()
public Void set_DescribeStringEnumsInCamelCase(Boolean value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()