@@ -145,92 +145,27 @@ public override void Compare(
145
145
. Compare ( sourceSchema . Items , targetSchema . Items , comparisonContext ) ) ;
146
146
}
147
147
148
- if ( sourceSchema . Reference != null
149
- && targetSchema . Reference != null
150
- && sourceSchema . Reference . Id != targetSchema . Reference . Id )
151
- {
152
- WalkAndAddOpenApiDifference (
153
- comparisonContext ,
154
- OpenApiConstants . DollarRef ,
155
- new OpenApiDifference
156
- {
157
- OpenApiDifferenceOperation = OpenApiDifferenceOperation . Update ,
158
- SourceValue = sourceSchema . Reference ? . Id ,
159
- TargetValue = targetSchema . Reference ? . Id ,
160
- OpenApiComparedElementType = typeof ( string )
161
- } ) ;
162
-
163
- return ;
164
- }
165
-
166
- if ( sourceSchema . Reference != null )
167
- {
168
- sourceSchema = ( OpenApiSchema ) comparisonContext . SourceDocument . ResolveReference (
169
- sourceSchema . Reference ) ;
170
- }
171
-
172
- if ( targetSchema . Reference != null )
173
- {
174
- targetSchema = ( OpenApiSchema ) comparisonContext . TargetDocument . ResolveReference (
175
- targetSchema . Reference ) ;
176
- }
148
+ WalkAndCompare (
149
+ comparisonContext ,
150
+ OpenApiConstants . Properties ,
151
+ ( ) => comparisonContext
152
+ . GetComparer < IDictionary < string , OpenApiSchema > > ( )
153
+ . Compare ( sourceSchema . Properties ,
154
+ targetSchema . Properties , comparisonContext ) ) ;
177
155
178
- if ( targetSchema . Properties != null )
179
- {
180
- IEnumerable < string > newPropertiesInTarget = sourceSchema . Properties == null
181
- ? targetSchema . Properties . Keys
182
- : targetSchema . Properties . Keys . Except ( sourceSchema . Properties . Keys )
183
- . ToList ( ) ;
184
-
185
- WalkAndCompare ( comparisonContext , OpenApiConstants . Properties , ( ) =>
186
- {
187
- foreach ( var newPropertyInTarget in newPropertiesInTarget )
188
- {
189
- WalkAndAddOpenApiDifference (
190
- comparisonContext ,
191
- newPropertyInTarget ,
192
- new OpenApiDifference
193
- {
194
- OpenApiDifferenceOperation = OpenApiDifferenceOperation . Add ,
195
- TargetValue = new KeyValuePair < string , OpenApiSchema > ( newPropertyInTarget ,
196
- targetSchema . Properties [ newPropertyInTarget ] ) ,
197
- OpenApiComparedElementType = typeof ( KeyValuePair < string , OpenApiSchema > )
198
- } ) ;
199
- }
200
- } ) ;
201
- }
156
+ WalkAndCompare (
157
+ comparisonContext ,
158
+ OpenApiConstants . ExternalDocs ,
159
+ ( ) => comparisonContext
160
+ . GetComparer < OpenApiExternalDocs > ( )
161
+ . Compare ( sourceSchema . ExternalDocs , targetSchema . ExternalDocs , comparisonContext ) ) ;
202
162
203
- if ( sourceSchema . Properties != null )
204
- {
205
- WalkAndCompare ( comparisonContext , OpenApiConstants . Properties , ( ) =>
206
- {
207
- foreach ( var sourceSchemaProperty in sourceSchema . Properties )
208
- {
209
- if ( targetSchema . Properties . ContainsKey ( sourceSchemaProperty . Key ) )
210
- {
211
- WalkAndCompare (
212
- comparisonContext ,
213
- sourceSchemaProperty . Key ,
214
- ( ) => comparisonContext
215
- . GetComparer < OpenApiSchema > ( )
216
- . Compare ( sourceSchemaProperty . Value ,
217
- targetSchema . Properties [ sourceSchemaProperty . Key ] , comparisonContext ) ) ;
218
- }
219
- else
220
- {
221
- WalkAndAddOpenApiDifference (
222
- comparisonContext ,
223
- sourceSchemaProperty . Key ,
224
- new OpenApiDifference
225
- {
226
- OpenApiDifferenceOperation = OpenApiDifferenceOperation . Remove ,
227
- SourceValue = sourceSchemaProperty ,
228
- OpenApiComparedElementType = typeof ( KeyValuePair < string , OpenApiSchema > )
229
- } ) ;
230
- }
231
- }
232
- } ) ;
233
- }
163
+ WalkAndCompare (
164
+ comparisonContext ,
165
+ OpenApiConstants . Example ,
166
+ ( ) => comparisonContext
167
+ . GetComparer < IOpenApiAny > ( )
168
+ . Compare ( sourceSchema . Example , targetSchema . Example , comparisonContext ) ) ;
234
169
235
170
// To Do Compare schema.AllOf
236
171
// To Do Compare schema.AnyOf
0 commit comments