@@ -26,46 +26,65 @@ public bool Equals(OpenApiSchema? x, OpenApiSchema? y)
26
26
return true ;
27
27
}
28
28
29
- return GetHashCode ( x ) == GetHashCode ( y ) ;
29
+ return Instance . Equals ( x . AdditionalProperties , y . AdditionalProperties ) &&
30
+ x . AdditionalPropertiesAllowed == y . AdditionalPropertiesAllowed &&
31
+ x . AllOf . SequenceEqual ( y . AllOf , Instance ) &&
32
+ x . AnyOf . SequenceEqual ( y . AnyOf , Instance ) &&
33
+ x . Deprecated == y . Deprecated &&
34
+ OpenApiAnyComparer . Instance . Equals ( x . Default , y . Default ) &&
35
+ x . Description == y . Description &&
36
+ OpenApiDiscriminatorComparer . Instance . Equals ( x . Discriminator , y . Discriminator ) &&
37
+ OpenApiAnyComparer . Instance . Equals ( x . Example , y . Example ) &&
38
+ x . ExclusiveMaximum == y . ExclusiveMaximum &&
39
+ x . ExclusiveMinimum == y . ExclusiveMinimum &&
40
+ x . Extensions . Count == y . Extensions . Count
41
+ && x . Extensions . Keys . All ( k => y . Extensions . ContainsKey ( k ) && x . Extensions [ k ] is IOpenApiAny anyX && y . Extensions [ k ] is IOpenApiAny anyY && OpenApiAnyComparer . Instance . Equals ( anyX , anyY ) ) &&
42
+ OpenApiExternalDocsComparer . Instance . Equals ( x . ExternalDocs , y . ExternalDocs ) &&
43
+ x . Enum . SequenceEqual ( y . Enum , OpenApiAnyComparer . Instance ) &&
44
+ x . Format == y . Format &&
45
+ Instance . Equals ( x . Items , y . Items ) &&
46
+ x . Title == y . Title &&
47
+ x . Type == y . Type &&
48
+ x . Maximum == y . Maximum &&
49
+ x . MaxItems == y . MaxItems &&
50
+ x . MaxLength == y . MaxLength &&
51
+ x . MaxProperties == y . MaxProperties &&
52
+ x . Minimum == y . Minimum &&
53
+ x . MinItems == y . MinItems &&
54
+ x . MinLength == y . MinLength &&
55
+ x . MinProperties == y . MinProperties &&
56
+ x . MultipleOf == y . MultipleOf &&
57
+ x . OneOf . SequenceEqual ( y . OneOf , Instance ) &&
58
+ Instance . Equals ( x . Not , y . Not ) &&
59
+ x . Nullable == y . Nullable &&
60
+ x . Pattern == y . Pattern &&
61
+ x . Properties . Keys . All ( k => y . Properties . ContainsKey ( k ) && Instance . Equals ( x . Properties [ k ] , y . Properties [ k ] ) ) &&
62
+ x . ReadOnly == y . ReadOnly &&
63
+ x . Required . Order ( ) . SequenceEqual ( y . Required . Order ( ) ) &&
64
+ OpenApiReferenceComparer . Instance . Equals ( x . Reference , y . Reference ) &&
65
+ x . UniqueItems == y . UniqueItems &&
66
+ x . UnresolvedReference == y . UnresolvedReference &&
67
+ x . WriteOnly == y . WriteOnly &&
68
+ OpenApiXmlComparer . Instance . Equals ( x . Xml , y . Xml ) ;
30
69
}
31
70
32
71
public int GetHashCode ( OpenApiSchema obj )
33
72
{
34
73
var hashCode = new HashCode ( ) ;
35
74
hashCode . Add ( obj . AdditionalProperties , Instance ) ;
36
75
hashCode . Add ( obj . AdditionalPropertiesAllowed ) ;
37
- foreach ( var item in obj . AllOf )
38
- {
39
- hashCode . Add ( item , Instance ) ;
40
- }
41
- foreach ( var item in obj . AnyOf )
42
- {
43
- hashCode . Add ( item , Instance ) ;
44
- }
76
+ hashCode . Add ( obj . AllOf . Count ) ;
77
+ hashCode . Add ( obj . AnyOf . Count ) ;
45
78
hashCode . Add ( obj . Deprecated ) ;
46
79
hashCode . Add ( obj . Default , OpenApiAnyComparer . Instance ) ;
47
80
hashCode . Add ( obj . Description ) ;
48
81
hashCode . Add ( obj . Discriminator , OpenApiDiscriminatorComparer . Instance ) ;
49
82
hashCode . Add ( obj . Example , OpenApiAnyComparer . Instance ) ;
50
83
hashCode . Add ( obj . ExclusiveMaximum ) ;
51
84
hashCode . Add ( obj . ExclusiveMinimum ) ;
52
- foreach ( ( var key , var value ) in obj . Extensions )
53
- {
54
- hashCode . Add ( key ) ;
55
- if ( value is IOpenApiAny any )
56
- {
57
- hashCode . Add ( any , OpenApiAnyComparer . Instance ) ;
58
- }
59
- else
60
- {
61
- hashCode . Add ( value ) ;
62
- }
63
- }
85
+ hashCode . Add ( obj . Extensions . Count ) ;
64
86
hashCode . Add ( obj . ExternalDocs , OpenApiExternalDocsComparer . Instance ) ;
65
- foreach ( var item in obj . Enum )
66
- {
67
- hashCode . Add ( item , OpenApiAnyComparer . Instance ) ;
68
- }
87
+ hashCode . Add ( obj . Enum . Count ) ;
69
88
hashCode . Add ( obj . Format ) ;
70
89
hashCode . Add ( obj . Items , Instance ) ;
71
90
hashCode . Add ( obj . Title ) ;
@@ -79,23 +98,13 @@ public int GetHashCode(OpenApiSchema obj)
79
98
hashCode . Add ( obj . MinLength ) ;
80
99
hashCode . Add ( obj . MinProperties ) ;
81
100
hashCode . Add ( obj . MultipleOf ) ;
82
- foreach ( var item in obj . OneOf )
83
- {
84
- hashCode . Add ( item , Instance ) ;
85
- }
101
+ hashCode . Add ( obj . OneOf . Count ) ;
86
102
hashCode . Add ( obj . Not , Instance ) ;
87
103
hashCode . Add ( obj . Nullable ) ;
88
104
hashCode . Add ( obj . Pattern ) ;
89
- foreach ( ( var key , var value ) in obj . Properties )
90
- {
91
- hashCode . Add ( key ) ;
92
- hashCode . Add ( value , Instance ) ;
93
- }
105
+ hashCode . Add ( obj . Properties . Count ) ;
94
106
hashCode . Add ( obj . ReadOnly ) ;
95
- foreach ( var item in obj . Required . Order ( ) )
96
- {
97
- hashCode . Add ( item ) ;
98
- }
107
+ hashCode . Add ( obj . Required . Count ) ;
99
108
hashCode . Add ( obj . Reference , OpenApiReferenceComparer . Instance ) ;
100
109
hashCode . Add ( obj . UniqueItems ) ;
101
110
hashCode . Add ( obj . UnresolvedReference ) ;
0 commit comments