internal SwashbuckleOptions GetSwashbuckleOptions()
        {
            AddGlobalDocumentFilters();
            AddODataDocumentFilters();

            var swaggerProviderOptions = new SwaggerProviderOptions(
                _swaggerDocsConfig.GetFieldValue <Func <ApiDescription, string, bool> >("_versionSupportResolver"),
                _swaggerDocsConfig.GetFieldValue <IEnumerable <string> >("_schemes"),
                _swaggerDocsConfig.GetSecurityDefinitions(),
                _swaggerDocsConfig.GetFieldValue <bool>("_ignoreObsoleteActions"),
                _swaggerDocsConfig.GetFieldValue <Func <ApiDescription, string> >("_groupingKeySelector"),
                _swaggerDocsConfig.GetFieldValue <IComparer <string> >("_groupingKeyComparer"),
                GetODataCustomSchemaMappings(),
                _swaggerDocsConfig.GetFieldValue <IEnumerable <Func <ISchemaFilter> > >("_schemaFilters", true).Select(factory => factory()),
                _swaggerDocsConfig.GetFieldValue <IList <Func <IModelFilter> > >("_modelFilters", true).Select(factory => factory()).ToList(),
                _swaggerDocsConfig.GetFieldValue <bool>("_ignoreObsoleteProperties"),
                _swaggerDocsConfig.GetFieldValue <Func <Type, string> >("_schemaIdSelector"),
                _swaggerDocsConfig.GetFieldValue <bool>("_describeAllEnumsAsStrings"),
                _swaggerDocsConfig.GetFieldValue <bool>("_describeStringEnumsInCamelCase"),
                GetODataOperationFilters(),
                GetODataDocumentFilters(),
                _swaggerDocsConfig.GetFieldValue <Func <IEnumerable <ApiDescription>, ApiDescription> >("_conflictingActionsResolver"),
                _swaggerDocsConfig.GetFieldValue <bool>("_applyFiltersToAllSchemas"),
                _swaggerDocsConfig.GetFieldValue <IEnumerable <Func <XPathDocument> > >("_xmlDocFactories").Select(factory => factory).ToList()
                );

            return(new SwashbuckleOptions(swaggerProviderOptions));
        }
        public SwashbuckleOptions(SwaggerProviderOptions swaggerProviderOptions)
        {
            Contract.Requires(swaggerProviderOptions != null);

            VersionSupportResolver = swaggerProviderOptions.VersionSupportResolver;
            Schemes                        = swaggerProviderOptions.Schemes;
            SecurityDefinitions            = swaggerProviderOptions.SecurityDefinitions;
            IgnoreObsoleteActions          = swaggerProviderOptions.IgnoreObsoleteActions;
            GroupingKeySelector            = swaggerProviderOptions.GroupingKeySelector ?? Descriptions.ApiDescriptionExtensions.DefaultGroupingKeySelector;
            GroupingKeyComparer            = swaggerProviderOptions.GroupingKeyComparer ?? Comparer <string> .Default;
            CustomSchemaMappings           = swaggerProviderOptions.CustomSchemaMappings ?? new Dictionary <Type, Func <Schema> >();
            SchemaFilters                  = swaggerProviderOptions.SchemaFilters ?? new List <ISchemaFilter>();
            ModelFilters                   = swaggerProviderOptions.ModelFilters ?? new List <IModelFilter>();
            IgnoreObsoleteProperties       = swaggerProviderOptions.IgnoreObsoleteProperties;
            SchemaIdSelector               = swaggerProviderOptions.SchemaIdSelector ?? DefaultSchemaIdSelector;
            DescribeAllEnumsAsStrings      = swaggerProviderOptions.DescribeAllEnumsAsStrings;
            DescribeStringEnumsInCamelCase = swaggerProviderOptions.DescribeStringEnumsInCamelCase;
            OperationFilters               = swaggerProviderOptions.OperationFilters ?? new List <IOperationFilter>();
            DocumentFilters                = swaggerProviderOptions.DocumentFilters ?? new List <IDocumentFilter>();
            ConflictingActionsResolver     = swaggerProviderOptions.ConflictingActionsResolver;
            ApplyFiltersToAllSchemas       = swaggerProviderOptions.ApplyFiltersToAllSchemas;
            XmlDocFactories                = swaggerProviderOptions.XmlDocFactories;

            //Add the xml comments files to the filters
            foreach (var xmlDocFactory in XmlDocFactories)
            {
                var xmlDoc = xmlDocFactory();
                this.ModelFilters.Insert(0, new ApplyXmlTypeComments(xmlDoc));
                this.OperationFilters.Insert(0, new ApplyXmlActionComments(xmlDoc));
            }
        }