/// <summary>
        /// Initializes a new instance of the <see cref="FilterSet"/> class.
        /// </summary>
        /// <param name="filterSet">Filter set to be copied from.</param>
        public FilterSet(FilterSet filterSet)
        {
            if (filterSet == null)
            {
                return;
            }

            // We create a new instance of FilterSet per call as a safeguard
            // against unintentional modification of the private _defaultFilterSet.
            foreach (var filter in filterSet)
            {
                Add(filter);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the default filter sets.
        /// </summary>
        public static FilterSet GetDefaultFilterSet(FilterSetVersion version)
        {
            if (_defaultFilterSet == null)
            {
                _defaultFilterSet = new FilterSet();

                switch (version)
                {
                case FilterSetVersion.V1:
                    //Document config filters
                    _defaultFilterSet.Add(new DocumentVariantAttributesFilter());

                    //Document filters
                    _defaultFilterSet.Add(new AssemblyNameToInfoFilter());
                    _defaultFilterSet.Add(new UrlToServerFilter());
                    _defaultFilterSet.Add(new MemberSummaryToSchemaDescriptionFilter());
                    _defaultFilterSet.Add(new SecurityToSecurityRequirementDocumentFilter());

                    //Operation config filters
                    _defaultFilterSet.Add(new CommonAnnotationFilter());

                    //Operation filters
                    _defaultFilterSet.Add(new GroupToTagFilter());
                    _defaultFilterSet.Add(new ParamToParameterFilter());
                    _defaultFilterSet.Add(new ParamToRequestBodyFilter());
                    _defaultFilterSet.Add(new RemarksToDescriptionFilter());
                    _defaultFilterSet.Add(new ResponseToResponseFilter());
                    _defaultFilterSet.Add(new SummaryToSummaryFilter());
                    _defaultFilterSet.Add(new SecurityToSecurityRequirementOperationFilter());

                    //Pre processing operation filters
                    _defaultFilterSet.Add(new PopulateInAttributeFilter());
                    _defaultFilterSet.Add(new ConvertAlternativeParamTagsFilter());
                    _defaultFilterSet.Add(new ValidateInAttributeFilter());
                    _defaultFilterSet.Add(new BranchOptionalPathParametersFilter());

                    //Post processing document filters
                    _defaultFilterSet.Add(new RemoveFailedGenerationOperationFilter());

                    return(_defaultFilterSet);

                default:
                    throw new FilterSetVersionNotSupportedException(version.ToString());
                }
            }

            return(new FilterSet(_defaultFilterSet));
        }
 private List <T> TypeCastFilters <T>(FilterSet filtersToTypeCast) where T : IFilter
 {
     return(filtersToTypeCast.OfType <T>().ToList());
 }
 /// <summary>
 /// Creates a new instance of <see cref="OpenApiGeneratorFilterConfig"/> with default filters.
 /// </summary>
 public OpenApiGeneratorFilterConfig(FilterSetVersion filterSetVersion)
 {
     Filters = FilterSet.GetDefaultFilterSet(filterSetVersion);
 }
Beispiel #5
0
 private List <T> TypeCastFilters <T>(FilterSet filtersToTypeCast) where T : IFilter
 {
     return(filtersToTypeCast.Where(filter => filter is T).Select(filter => (T)filter).ToList());
 }