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)
40
40
}
41
41
42
42
public static void ValidateDataTypeMismatch (
43
- IValidationContext context ,
44
- string ruleName ,
45
- IOpenApiAny value ,
43
+ IValidationContext context ,
44
+ string ruleName ,
45
+ IOpenApiAny value ,
46
46
OpenApiSchema schema )
47
47
{
48
48
if ( schema == null )
@@ -52,6 +52,17 @@ public static void ValidateDataTypeMismatch(
52
52
53
53
var type = schema . Type ;
54
54
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
+ }
55
66
56
67
if ( type == "object" )
57
68
{
You can’t perform that action at this time.
0 commit comments