File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
test/Microsoft.OpenApi.Tests/Validations Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -268,5 +268,60 @@ public void ValidateSchemaRequiredFieldListMustContainThePropertySpecifiedInTheD
268
268
"schema1" , "property1" ) )
269
269
} ) ;
270
270
}
271
+
272
+ [ Fact ]
273
+ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscriminator ( )
274
+ {
275
+ // Arrange
276
+ var components = new OpenApiComponents
277
+ {
278
+ Schemas =
279
+ {
280
+ {
281
+ "Person" ,
282
+ new OpenApiSchema
283
+ {
284
+ Type = "array" ,
285
+ Discriminator = new OpenApiDiscriminator
286
+ {
287
+ PropertyName = "type"
288
+ } ,
289
+ OneOf = new List < OpenApiSchema >
290
+ {
291
+ new OpenApiSchema
292
+ {
293
+ Properties =
294
+ {
295
+ {
296
+ "type" ,
297
+ new OpenApiSchema
298
+ {
299
+ Type = "array"
300
+ }
301
+ }
302
+ } ,
303
+ Reference = new OpenApiReference
304
+ {
305
+ Type = ReferenceType . Schema ,
306
+ Id = "Person"
307
+ }
308
+ }
309
+ } ,
310
+ Reference = new OpenApiReference { Id = "Person" }
311
+ }
312
+ }
313
+ }
314
+ } ;
315
+
316
+ // Act
317
+ var validator = new OpenApiValidator ( ValidationRuleSet . GetDefaultRuleSet ( ) ) ;
318
+ var walker = new OpenApiWalker ( validator ) ;
319
+ walker . Walk ( components ) ;
320
+
321
+ var errors = validator . Errors ;
322
+
323
+ //Assert
324
+ errors . Should ( ) . BeEmpty ( ) ;
325
+ }
271
326
}
272
327
}
You can’t perform that action at this time.
0 commit comments