public NetRpcSwaggerProvider(ISchemaGenerator schemaGenerator, IOptions <SwaggerGeneratorOptions> optionsAccessor)
 {
     _schemaRepository = new SchemaRepository();
     _schemaGenerator  = schemaGenerator;
     _options          = optionsAccessor.Value;
     _doc = new OpenApiDocument();
 }
        public ISwaggerProvider GetSwaggerProvider(HttpRequestMessage swaggerRequest)
        {
            var httpConfig = swaggerRequest.GetConfiguration();

            var securityDefintitions = _securitySchemeBuilders.Any()
                ? _securitySchemeBuilders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Build())
                : null;

            // NOTE: Instantiate & add the XML comments filters here so they're executed before any
            // custom filters AND so they can share the same XPathDocument (perf. optimization)
            var modelFilters     = _modelFilters.Select(factory => factory()).ToList();
            var operationFilters = _operationFilters.Select(factory => factory()).ToList();

            foreach (var xmlDocFactory in _xmlDocFactories)
            {
                var xmlDoc = xmlDocFactory();
                modelFilters.Insert(0, new ApplyXmlTypeComments(xmlDoc));
                operationFilters.Insert(0, new ApplyXmlActionComments(xmlDoc));
            }

            foreach (var s in _securitySchemeBuilders.Where(x => x.Value.GetType() == typeof(ApiKeySchemeBuilder)))
            {
                var apiKeySch = (ApiKeySchemeBuilder)s.Value;
                operationFilters.Add(new ApplySwaggerOperationApiKey(apiKeySch.name, apiKeySch.type));
            }

            var options = new SwaggerGeneratorOptions(
                versionSupportResolver: _versionSupportResolver,
                schemes: _schemes,
                securityDefinitions: securityDefintitions,
                ignoreObsoleteActions: _ignoreObsoleteActions,
                accessControlAllowOrigin: _accessControlAllowOrigin,
                groupingKeySelector: _groupingKeySelector,
                groupingKeyComparer: _groupingKeyComparer,
                customSchemaMappings: _customSchemaMappings,
                schemaFilters: _schemaFilters.Select(factory => factory()).ToList(),
                modelFilters: modelFilters,
                ignoreObsoleteProperties: _ignoreObsoleteProperties,
                schemaIdSelector: _schemaIdSelector,
                describeAllEnumsAsStrings: _describeAllEnumsAsStrings,
                describeStringEnumsInCamelCase: _describeStringEnumsInCamelCase,
                ignoreObsoleteEnumConstants: _ignoreObsoleteEnumConstants,
                applyFiltersToAllSchemas: _applyFiltersToAllSchemas,
                ignoreIsSpecifiedMembers: _ignoreIsSpecifiedMembers,
                operationFilters: operationFilters,
                documentFilters: _documentFilters.Select(factory => factory()).ToList(),
                conflictingActionsResolver: _conflictingActionsResolver,
                operationIdResolver: _operationIdResolver
                );

            var defaultProvider = new SwaggerGenerator(
                httpConfig.Services.GetApiExplorer(),
                httpConfig.SerializerSettingsOrDefault(),
                _versionInfoBuilder.Build(),
                options);

            return((_customProviderFactory != null)
                ? _customProviderFactory(defaultProvider)
                : defaultProvider);
        }
        internal ISwaggerProvider GetSwaggerProvider(HttpRequestMessage swaggerRequest)
        {
            var httpConfig = swaggerRequest.GetConfiguration();

            var securityDefintitions = _securitySchemeBuilders.Any()
                ? _securitySchemeBuilders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Build())
                : null;

            var options = new SwaggerGeneratorOptions(
                versionSupportResolver: _versionSupportResolver,
                schemes: _schemes,
                securityDefinitions: securityDefintitions,
                ignoreObsoleteActions: _ignoreObsoleteActions,
                groupingKeySelector: _groupingKeySelector,
                groupingKeyComparer: _groupingKeyComparer,
                customSchemaMappings: _customSchemaMappings,
                schemaFilters: _schemaFilters.Select(factory => factory()),
                modelFilters: _modelFilters.Select(factory => factory()),
                ignoreObsoleteProperties: _ignoreObsoleteProperties,
                schemaIdSelector: _schemaIdSelector,
                describeAllEnumsAsStrings: _describeAllEnumsAsStrings,
                describeStringEnumsInCamelCase: _describeStringEnumsInCamelCase,
                operationFilters: _operationFilters.Select(factory => factory()),
                documentFilters: _documentFilters.Select(factory => factory()),
                conflictingActionsResolver: _conflictingActionsResolver
                );

            return(new SwaggerGenerator(
                       httpConfig.Services.GetApiExplorer(),
                       httpConfig.SerializerSettingsOrDefault(),
                       _versionInfoBuilder.Build(),
                       options));
        }
        public SwaggerGenerator GetGenerator(HttpRequestMessage swaggerRequest)
        {
            var basePath      = BasePathResolver(swaggerRequest);
            var targetVersion = _targetVersionResolver(swaggerRequest);

            var apiDescriptions = swaggerRequest.GetConfiguration().Services.GetApiExplorer()
                                  .ApiDescriptions
                                  .Where(apiDesc => !_ignoreObsoleteActions || apiDesc.IsNotObsolete())
                                  .Where(apiDesc => _versionSupportResolver(apiDesc, targetVersion));

            var options = new SwaggerGeneratorOptions(
                _declarationNameResolver,
                _resourceNameComparer,
                _customTypeMappings,
                _polymorphicTypes,
                _modelFilterFactories.Select(factory => factory()),
                _operationFilterFactories.Select(factory => factory()),
                _apiInfo,
                _authorizations
                );

            return(new SwaggerGenerator(
                       basePath,
                       targetVersion,
                       apiDescriptions,
                       options));
        }
        public ConventionalRoutingSwaggerGenerator(SwaggerGeneratorOptions options,
                                                   IConventionalRoutingApiDescriptionGroupCollectionProvider apiDescriptionsProvider,
                                                   ISchemaGenerator schemaGenerator) : base(options, apiDescriptionsProvider, schemaGenerator)
        {
            if (options.TagsSelector.Method.Name.Equals("DefaultTagsSelector",
                                                        StringComparison.InvariantCultureIgnoreCase))
            {
                options.TagsSelector = (apiDesc) =>
                {
                    if (apiDesc.GroupName != null)
                    {
                        return(new[] { apiDesc.GroupName });
                    }

                    var controllerActionDescriptor = apiDesc.ActionDescriptor as ControllerActionDescriptor;

                    try
                    {
                        if (controllerActionDescriptor.RouteValues.TryGetValue("area", out string area) &&
                            !string.IsNullOrEmpty(area))
                        {
                            return(new[] { $"{area}.{controllerActionDescriptor.ControllerName}" });
                        }

                        return(new[] { controllerActionDescriptor.ControllerName });
                    }
                    catch (Exception ex)
                    {
                        return(options.TagsSelector.Invoke(apiDesc));
                    }
                };
            }
        }
        public static void Init(TestContext testContext)
        {
            var t = typeof(CompaniesController);

            var config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            config.EnsureInitialized();

            var apiExplorer = new ApiExplorer(config);
            var settings    = new JsonSerializerSettings();
            var versions    = new Dictionary <string, Info> {
                { "v1", new Info()
                  {
                      version = "v1", title = "Test API"
                  } }
            };
            var options = new SwaggerGeneratorOptions(operationFilters: new IOperationFilter[]
            {
                // default filters used by Swashbuckle
                new HandleFromUriParams(),
                new ApplySwaggerOperationAttributes(),
                new ApplySwaggerResponseAttributes(),
                new ApplySwaggerOperationFilterAttributes(),

                // our custom filters
                new AddAsObjectAnnotationOperationFilter(),
                new HandleGridViewDataSetReturnType()
            });
            var generator = new SwaggerGenerator(apiExplorer, settings, versions, options);

            document = generator.GetSwagger("http://localhost:61453/", "v1");
        }
        private IEnumerable <MediaTypeFormatter> GetSupportedSwaggerFormatters(SwaggerGeneratorOptions options)
        {
            var jsonFormatter = new JsonMediaTypeFormatter
            {
                SerializerSettings = new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    Converters        = new List <JsonConverter>()
                    {
                        new VendorExtensionsConverter()
                    }
                }
            };

            if (options.DescribeAllEnumsAsStrings)
            {
                jsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter()
                {
                    CamelCaseText = options.DescribeStringEnumsInCamelCase
                });
            }

            // NOTE: The custom converter would not be neccessary in Newtonsoft.Json >= 5.0.5 as JsonExtensionData
            // provides similar functionality. But, need to stick with older version for WebApi 5.0.0 compatibility
            return(new[] { jsonFormatter });
        }
        internal ISwaggerProvider GetSwaggerProvider(HttpRequestMessage swaggerRequest)
        {
            var httpConfig = swaggerRequest.GetConfiguration();

            var securityDefintitions = _securitySchemeBuilders.Any()
                ? _securitySchemeBuilders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Build())
                : null;

            var describeAllEnumsAsStrings = _describeAllEnumsAsStrings ||
                                            httpConfig.HasJsonConverterOfType <StringEnumConverter>();

            var options = new SwaggerGeneratorOptions(
                versionSupportResolver: _versionSupportResolver,
                schemes: _schemes,
                securityDefinitions: securityDefintitions,
                ignoreObsoleteActions: _ignoreObsoleteActions,
                groupingKeySelector: _groupingKeySelector,
                groupingKeyComparer: _groupingKeyComparer,
                customSchemaMappings: _customSchemaMappings,
                schemaFilters: _schemaFilters.Select(factory => factory()),
                ignoreObsoleteProperties: _ignoreObsoleteProperties,
                useFullTypeNameInSchemaIds: _useFullTypeNameInSchemaIds,
                describeAllEnumsAsStrings: describeAllEnumsAsStrings,
                operationFilters: _operationFilters.Select(factory => factory()),
                documentFilters: _documentFilters.Select(factory => factory()),
                conflictingActionsResolver: _conflictingActionsResolver
                );

            return(new SwaggerGenerator(
                       httpConfig.Services.GetApiExplorer(),
                       httpConfig.GetJsonContractResolver(),
                       _versionInfoBuilder.Build(),
                       options));
        }
Exemple #9
0
        public SwaggerOptions()
        {
            SwaggerGeneratorOptions = new SwaggerGeneratorOptions();
            SwaggerGeneratorOptions.OperationFilters.Add(new ApplySwaggerOperationAttributes());
            SwaggerGeneratorOptions.OperationFilters.Add(new ApplySwaggerResponseAttributes());

            SchemaGeneratorOptions = new SchemaGeneratorOptions();
        }
        public void CreateObjectSchema_Null()
        {
            var mock   = new Mock <JsonSerializerSettings>();
            var opt    = new SwaggerGeneratorOptions();
            var schema = new SchemaRegistry(mock.Object, opt);

            Assert.Throws <NullReferenceException>(() => schema.CreateObjectSchema(null));
        }
Exemple #11
0
 public ContractSwaggerDocGenerator(SwaggerGeneratorOptions options, string address, IContractAssembly assembly, string defaultWalletName = "", string defaultSenderAddress = "")
 {
     this.options              = options;
     this.address              = address;
     this.assembly             = assembly;
     this.defaultWalletName    = defaultWalletName;
     this.defaultSenderAddress = defaultSenderAddress;
 }
 public DocumentProvider(
     IOptions <SwaggerGeneratorOptions> generatorOptions,
     IOptions <SwaggerOptions> options,
     ISwaggerProvider swaggerProvider)
 {
     _generatorOptions = generatorOptions.Value;
     _options          = options.Value;
     _swaggerProvider  = swaggerProvider;
 }
        public MultiOperationSwaggerGenerator(ISwaggerProvider sp)
        {
            var sg            = (SwaggerGenerator)sp;
            var privateFields = sg.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);

            _apiExplorer            = privateFields.First(pf => pf.Name == "_apiExplorer").GetValue(sg) as IApiExplorer;
            _jsonSerializerSettings = privateFields.First(pf => pf.Name == "_jsonSerializerSettings").GetValue(sg) as JsonSerializerSettings;
            _apiVersions            = privateFields.First(pf => pf.Name == "_apiVersions").GetValue(sg) as IDictionary <string, Info>;
            _options = privateFields.First(pf => pf.Name == "_options").GetValue(sg) as SwaggerGeneratorOptions;
        }
        public void CreateDictionarySchema_Empty()
        {
            var mock = new Mock <JsonDictionaryContract>(typeof(Dictionary <int, int>));
            var mockJsonSerializer = new Mock <JsonSerializerSettings>();

            var opt    = new SwaggerGeneratorOptions();
            var schema = new SchemaRegistry(mockJsonSerializer.Object, opt);

            Assert.DoesNotThrow(() => schema.CreateDictionarySchema(mock.Object));
        }
Exemple #15
0
        public SwaggerOptions()
        {
            RootUrlResolver = new DefaultRootUrlResolver();

            SchemaGeneratorOptions = new SchemaGeneratorOptions();

            SwaggerGeneratorOptions = new SwaggerGeneratorOptions();
            SwaggerGeneratorOptions.OperationFilters.Add(new ApplySwaggerOperationAttributes());
            SwaggerGeneratorOptions.OperationFilters.Add(new ApplySwaggerResponseAttributes());
        }
 public MySwaggerGenerator(
     IApiExplorer apiExplorer,
     JsonSerializerSettings jsonSerializerSettings,
     IDictionary <string, Info> apiVersions,
     SwaggerGeneratorOptions options = null)
 {
     _apiExplorer            = apiExplorer;
     _jsonSerializerSettings = jsonSerializerSettings;
     _apiVersions            = apiVersions;
     _options = options ?? new SwaggerGeneratorOptions();
 }
        public void CreateEnumSchema_empty()
        {
            var contract = new JsonPrimitiveContract(typeof(int));
            var mock     = new Mock <JsonSerializerSettings>();
            var opt      = new SwaggerGeneratorOptions();

            var schema = new SchemaRegistry(mock.Object, opt);
            var enu    = schema.CreateEnumSchema(contract, typeof(int));

            Assert.IsNotNull(enu);
        }
        public void GetOrRegister_registerMultiple_DifferentType_SameName_ThrowsError()
        {
            var          mock     = new Mock <JsonSerializerSettings>();
            var          opt      = new SwaggerGeneratorOptions();
            var          schema   = new SchemaRegistry(mock.Object, opt);
            var          model1   = new { Property1 = "Property1" };
            var          model2   = new { Property2 = "Property2" };
            const string testType = "testTypeName";

            schema.GetOrRegister(model1.GetType(), testType);
            Assert.Throws <InvalidOperationException>(() => schema.GetOrRegister(model2.GetType(), testType));
        }
Exemple #19
0
        public static void Init(TestContext testContext)
        {
            var knownTypesOptions = Options.Create(new DotvvmApiOptions());

            knownTypesOptions.Value.AddKnownType(typeof(Company <string>));

            var options = new SwaggerGeneratorOptions
            {
                DocInclusionPredicate = (version, api) => true,
                OperationFilters      =
                {
                    new RemoveReadOnlyFromUriParametersOperationFilter(),
                    new RemoveBindNoneFromUriParametersOperationFilter(),
                    new AddAsObjectOperationFilter(knownTypesOptions)
                },
                DocumentFilters =
                {
                    new HandleKnownTypesDocumentFilter(knownTypesOptions)
                },
                SwaggerDocs =
                {
                    { "v1", new Info()
                        {
                            Title = "Test API", Version = "v1"
                        } }
                }
            };

            var serviceCollection = new ServiceCollection()
                                    .AddSingleton <ObjectPoolProvider, DefaultObjectPoolProvider>()
                                    .AddSingleton <IHostingEnvironment, HostingEnvironment>()
                                    .AddSingleton <DiagnosticSource>(p => new DiagnosticListener("test"))
                                    .AddLogging();

            serviceCollection.AddMvc(setup => setup.Conventions.Add(new ApiExplorerVisibilityEnabledConvention()))
            .AddApplicationPart(typeof(CompaniesController).Assembly);

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var apiDescriptionGroupCollectionProvider = serviceProvider.GetRequiredService <IApiDescriptionGroupCollectionProvider>();

            var schemaSettings = new SchemaRegistryOptions()
            {
                SchemaFilters =
                {
                    new AddTypeToModelSchemaFilter()
                }
            };

            var schemaRegistryFactory = new SchemaRegistryFactory(new JsonSerializerSettings(), schemaSettings);
            var generator             = new SwaggerGenerator(apiDescriptionGroupCollectionProvider, schemaRegistryFactory, options);

            document = generator.GetSwagger("v1");
        }
        public void CreateObjectSchema_addXmlName()
        {
            var mock   = new Mock <JsonSerializerSettings>();
            var opt    = new SwaggerGeneratorOptions();
            var schema = new SchemaRegistry(mock.Object, opt);
            var c      = new JsonObjectContract(typeof(int));
            var obj    = schema.CreateObjectSchema(c, false);

            Assert.IsNull(obj.xml);
            obj = schema.CreateObjectSchema(c, true);
            Assert.IsNotNull(obj.xml);
        }
        public void GetOrRegister_withTypeName()
        {
            var          mock     = new Mock <JsonSerializerSettings>();
            var          opt      = new SwaggerGeneratorOptions();
            var          schema   = new SchemaRegistry(mock.Object, opt);
            var          model    = new { Property1 = "Property1" };
            const string typeName = "testTypeName";

            schema.GetOrRegister(model.GetType(), typeName);

            Assert.That(schema.Definitions, Is.Not.Null.And.ContainKey(typeName));
            Assert.That(schema.Definitions[typeName].properties, Is.Not.Null.And.ContainKey("Property1"));
        }
Exemple #22
0
        public SwaggerGenOptions()
        {
            _swaggerGeneratorOptions = new SwaggerGeneratorOptions();
            _schemaRegistryOptions   = new SchemaRegistryOptions();

            _operationFilterDescriptors = new List <FilterDescriptor <IOperationFilter> >();
            _documentFilterDescriptors  = new List <FilterDescriptor <IDocumentFilter> >();
            _schemaFilterDescriptors    = new List <FilterDescriptor <ISchemaFilter> >();

            // Enable Annotations
            OperationFilter <SwaggerAttributesOperationFilter>();
            SchemaFilter <SwaggerAttributesSchemaFilter>();
        }
Exemple #23
0
        public SwaggerBuilder(IOptions <SwaggerGeneratorOptions> swaggerGenOptions,
                              GrpcServiceDescriptor handlers,
                              Func <IDictionary <Type, Func <OpenApiSchema> > > typeMapFactory)
        {
            _swaggerGenOptions = swaggerGenOptions.Value;
            _handlers          = handlers;
            var typesMap = typeMapFactory?.Invoke() ?? new Dictionary <Type, Func <OpenApiSchema> >();

            foreach (var(type, schema) in typesMap)
            {
                _primitiveTypeMap[type] = schema;
            }
        }
        public void GetOrRegister_withoutTypeName()
        {
            string SchemaIdSelector(Type arg) => arg.FullName;

            var mock = new Mock <JsonSerializerSettings>();
            var opt = new SwaggerGeneratorOptions(schemaIdSelector: SchemaIdSelector);
            var schema = new SchemaRegistry(mock.Object, opt);
            var modelType = new { Property1 = "Property1" }.GetType();

            schema.GetOrRegister(modelType);

            Assert.That(schema.Definitions, Is.Not.Null.And.ContainKey(SchemaIdSelector(modelType)));
            Assert.That(schema.Definitions[SchemaIdSelector(modelType)].properties, Is.Not.Null.And.ContainKey("Property1"));
        }
        public void CreateEnumSchema_camelCase()
        {
            var contract = new JsonPrimitiveContract(typeof(int));
            var mock     = new Mock <JsonSerializerSettings>();
            var opt      = new SwaggerGeneratorOptions(
                describeAllEnumsAsStrings: true,
                describeStringEnumsInCamelCase: true
                );

            var schema = new SchemaRegistry(mock.Object, opt);
            var enu    = schema.CreateEnumSchema(contract, typeof(int));

            Assert.IsNotNull(enu);
        }
        public void GetOrRegister_registerMultiple_SameType_SameName_RegistersOne()
        {
            var          mock     = new Mock <JsonSerializerSettings>();
            var          opt      = new SwaggerGeneratorOptions();
            var          schema   = new SchemaRegistry(mock.Object, opt);
            var          model    = new { Property1 = "Property1" };
            const string testType = "testTypeName";

            schema.GetOrRegister(model.GetType(), testType);
            schema.GetOrRegister(model.GetType(), testType);

            Assert.That(schema.Definitions, Is.Not.Null.And.Count.EqualTo(1));
            Assert.That(schema.Definitions, Contains.Key(testType));
            Assert.That(schema.Definitions[testType].properties, Is.Not.Null.And.ContainKey("Property1"));
        }
 public ContractSwaggerController(
     SwaggerGeneratorOptions options,
     SwaggerUIOptions uiOptions,
     ILoader loader,
     IWalletManager walletmanager,
     IStateRepositoryRoot stateRepository,
     Network network)
 {
     this.options         = options;
     this.uiOptions       = uiOptions;
     this.loader          = loader;
     this.walletmanager   = walletmanager;
     this.stateRepository = stateRepository;
     this.network         = network;
 }
Exemple #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SwaggerGenerator"/> class.
        /// </summary>
        /// <param name="apiDescriptionsProvider"><see cref="IApiDescriptionGroupCollectionProvider"/> for providing API descriptions.</param>
        /// <param name="schemaRegistryFactory"><see cref="ISchemaRegistryFactory"/> for creating schema registries.</param>
        /// <param name="optionsAccessor"><see cref="IOptions{T}"/> for <see cref="SwaggerGeneratorOptions"/>.</param>
        /// <param name="eventDocumentGenerator"><see cref="IDocumentGenerator{T}"/> for <see cref="IEvent"/>.</param>
        /// <param name="commandDocumentGenerator"><see cref="IDocumentGenerator{T}"/> for <see cref="ICommand"/>.</param>
        /// <param name="queryDocumentGenerator"><see cref="IDocumentGenerator{T}"/> for <see cref="IQuery"/>.</param>
        public SwaggerGenerator(
            IApiDescriptionGroupCollectionProvider apiDescriptionsProvider,
            ISchemaRegistryFactory schemaRegistryFactory,
            IOptions <SwaggerGeneratorOptions> optionsAccessor,
            IDocumentGenerator <IEvent> eventDocumentGenerator,
            IDocumentGenerator <ICommand> commandDocumentGenerator,
            IDocumentGenerator <IQuery> queryDocumentGenerator)
        {
            _apiDescriptionsProvider  = apiDescriptionsProvider;
            _schemaRegistryFactory    = schemaRegistryFactory;
            _eventDocumentGenerator   = eventDocumentGenerator;
            _commandDocumentGenerator = commandDocumentGenerator;
            _queryDocumentGenerator   = queryDocumentGenerator;
            _options = optionsAccessor.Value;

            ConfigureGenerators();

            _originalGenerator = new OriginalSwaggerGenerator(_apiDescriptionsProvider, _schemaRegistryFactory, _options);
        }
Exemple #29
0
        public CustomSwaggerGenerator(SwaggerGeneratorOptions options, IApiDescriptionGroupCollectionProvider apiDescriptionsProvider, ISchemaGenerator schemaGenerator)
        {
            // We change schema generator options to replace SchemaIdSelector function to a document-dependent implementation
            // Unfortunately this member declared as private, there is no another way to obtain options in this member.
            var optionsFieldInfo       = schemaGenerator.GetType().GetField("_generatorOptions", BindingFlags.Instance | BindingFlags.NonPublic);
            var schemaGeneratorOptions = (SchemaGeneratorOptions)optionsFieldInfo.GetValue(schemaGenerator);

            var defaultSchemaIdSelectorMethodInfo = schemaGeneratorOptions.GetType().GetMethod("DefaultSchemaIdSelector", BindingFlags.Instance | BindingFlags.NonPublic);

            schemaGeneratorOptions.SchemaIdSelector = (
                type =>
                (Attribute.GetCustomAttribute(type, typeof(SwaggerSchemaIdAttribute)) as SwaggerSchemaIdAttribute)?.Id ??
                (
                    _documentName == SwaggerServiceCollectionExtensions.platformUIDocName ?
                    type.FullName :
                    (string)defaultSchemaIdSelectorMethodInfo.Invoke(schemaGeneratorOptions, new object[] { type })
                )
                );

            _swaggerGenerator = new SwaggerGenerator(options, apiDescriptionsProvider, schemaGenerator);
        }
        private SwaggerGenerator Subject(
            Action <FakeApiDescriptionGroupCollectionProvider> setupApis = null,
            Action <SwaggerGeneratorOptions> setupAction = null)
        {
            var apiDescriptionsProvider = new FakeApiDescriptionGroupCollectionProvider();

            setupApis?.Invoke(apiDescriptionsProvider);

            var options = new SwaggerGeneratorOptions();

            options.SwaggerDocs.Add("v1", new OpenApiInfo {
                Title = "API", Version = "v1"
            });

            setupAction?.Invoke(options);

            return(new SwaggerGenerator(
                       apiDescriptionsProvider,
                       new SchemaRegistryFactory(new JsonSerializerSettings(), new SchemaRegistryOptions()),
                       options
                       ));
        }