File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
src/Microsoft.OpenApi/Validations/Rules Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ public static bool IsEmailAddress(this string input)
4040 }
4141
4242 public static void ValidateDataTypeMismatch (
43- IValidationContext context ,
44- string ruleName ,
45- IOpenApiAny value ,
43+ IValidationContext context ,
44+ string ruleName ,
45+ IOpenApiAny value ,
4646 OpenApiSchema schema )
4747 {
4848 if ( schema == null )
@@ -52,6 +52,17 @@ public static void ValidateDataTypeMismatch(
5252
5353 var type = schema . Type ;
5454 var format = schema . Format ;
55+ var nullable = schema . Nullable ;
56+
57+ // Before checking the type, check first if the schema allows null.
58+ // If so and the data given is also null, this is allowed for any type.
59+ if ( nullable )
60+ {
61+ if ( value is OpenApiNull )
62+ {
63+ return ;
64+ }
65+ }
5566
5667 if ( type == "object" )
5768 {
You can’t perform that action at this time.
0 commit comments