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));
            }
        }
Exemplo n.º 2
0
        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));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
        /// Use this constructor to customize all <see cref="ODataSwaggerProvider" /> dependencies.
        /// </summary>
        /// <param name="defaultProvider">The default provider.</param>
        /// <param name="options">The options.</param>
        /// <param name="apiVersions">The version information.</param>
        /// <param name="odataApiExplorer">The API explorer.</param>
        /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
        internal ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerProviderOptions options, IDictionary<string, Info> apiVersions, IApiExplorer odataApiExplorer, HttpConfiguration httpConfig)
        {
            Contract.Requires(defaultProvider != null);
            Contract.Requires(odataApiExplorer != null);
            Contract.Requires(httpConfig != null);
            Contract.Requires(options != null);

            _defaultProvider = defaultProvider;
            _httpConfig = httpConfig;
            _options = new ODataSwaggerProviderOptions(options);
            _apiVersions = apiVersions;
            _odataApiExplorer = odataApiExplorer;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
        /// Use this constructor to customize all <see cref="ODataSwaggerProvider" /> dependencies.
        /// </summary>
        /// <param name="defaultProvider">The default provider.</param>
        /// <param name="options">The options.</param>
        /// <param name="apiVersions">The version information.</param>
        /// <param name="odataApiExplorer">The API explorer.</param>
        /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
        internal ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerProviderOptions options, IDictionary <string, Info> apiVersions, IApiExplorer odataApiExplorer, HttpConfiguration httpConfig)
        {
            Contract.Requires(defaultProvider != null);
            Contract.Requires(odataApiExplorer != null);
            Contract.Requires(httpConfig != null);
            Contract.Requires(options != null);

            _defaultProvider  = defaultProvider;
            _httpConfig       = httpConfig;
            _options          = new ODataSwaggerProviderOptions(options);
            _apiVersions      = apiVersions;
            _odataApiExplorer = odataApiExplorer;
        }
        public ODataSwaggerProviderOptions(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;
        }
Exemplo n.º 6
0
        public ODataSwaggerProviderOptions(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 ?? DefaultConflictingActionsResolver;
        }