1- using MongoDB . Bson . Serialization . Attributes ;
21using Newtonsoft . Json ;
32using NJsonSchema ;
43using NSwag . Generation . Processors ;
@@ -32,22 +31,16 @@ public void Process(DocumentProcessorContext context)
3231 typeof ( InversePropertyAttribute ) ,
3332 typeof ( ForeignKeyAttribute ) ,
3433 typeof ( JsonIgnoreAttribute ) ,
35- typeof ( BsonIgnoreAttribute ) ,
3634 } ;
37- foreach ( var att in excludeAttributes )
38- {
39- excludedProperties . AddRange ( PowerfulGetProperties ( type ) . Where ( t => t . GetCustomAttribute ( att ) != null || t . PropertyType == typeof ( MongoDB . Bson . ObjectId ) ) . Select ( x => x . Name . ToLower ( ) ) ) ;
40- excludedProperties . AddRange ( PowerfulGetFields ( type ) . Where ( t => t . GetCustomAttribute ( att ) != null || t . FieldType == typeof ( MongoDB . Bson . ObjectId ) ) . Select ( x => x . Name . ToLower ( ) ) ) ;
41- }
4235 excludedProperties = excludedProperties . Distinct ( ) . ToList ( ) ;
4336
4437 var uniqueItemsProperties = new List < string > ( ) ;
45- uniqueItemsProperties . AddRange ( PowerfulGetProperties ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerUniqueItems ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
46- uniqueItemsProperties . AddRange ( PowerfulGetFields ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerUniqueItems ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
38+ uniqueItemsProperties . AddRange ( PowerfulGetProperties ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerUniqueItemsAttribute ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
39+ uniqueItemsProperties . AddRange ( PowerfulGetFields ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerUniqueItemsAttribute ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
4740
4841 var ignoreInheritProps = new List < string > ( ) ;
49- ignoreInheritProps . AddRange ( PowerfulGetProperties ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerIgnoreInheritProps ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
50- ignoreInheritProps . AddRange ( PowerfulGetFields ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerIgnoreInheritProps ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
42+ ignoreInheritProps . AddRange ( PowerfulGetProperties ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerIgnoreInheritPropsAttribute ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
43+ ignoreInheritProps . AddRange ( PowerfulGetFields ( type ) . Where ( t => t . GetCustomAttribute ( typeof ( SwaggerIgnoreInheritPropsAttribute ) ) != null ) . Select ( t => t . Name . ToLower ( ) ) ) ;
5144
5245 var customDefaultValsProperties = new List < ( string name , object ? initVal , object ? defaultVal ) > ( ) ;
5346 if ( instance != null && ! type . IsEnum )
@@ -84,18 +77,3 @@ public FieldInfo[] PowerfulGetFields(Type type)
8477 . Where ( x => ! x . Name . Contains ( "k__BackingField" ) )
8578 . ToArray ( ) ;
8679}
87-
88- [ AttributeUsage ( AttributeTargets . Property | AttributeTargets . Field ) ]
89- public class SwaggerExcludeAttribute : Attribute
90- {
91- }
92-
93- [ AttributeUsage ( AttributeTargets . Property | AttributeTargets . Field ) ]
94- public class SwaggerUniqueItems : Attribute
95- {
96- }
97-
98- [ AttributeUsage ( AttributeTargets . Property | AttributeTargets . Field ) ]
99- public class SwaggerIgnoreInheritProps : Attribute
100- {
101- }
0 commit comments