-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Summary
In Corvus.JsonSchema, a property that is missing but has a default value can cause validation to pass, even when that property is listed in required.
But per JSON Schema, default is an annotation and must not be used during validation.
Reference (JSON Schema annotations):
https://json-schema.org/understanding-json-schema/reference/annotations
Expected
If a property is in required, validation should fail when the property is not present in the instance JSON - regardless of default.
Actual
If the missing required property has a default, validation passes (as if it were optional).
This makes: required + default behave like optional + default
Reproduction Scenarios
- Not required, no default values
Request:
{
"externalProperties": {}
}
✅ Validation passes
✅ External Properties empty
✔️ Correct behavior
- Not required, with default values
Request:
{
"externalProperties": {}
}
✅ Validation passes
✅ External Properties empty
✔️ Correct behavior
- Required, no default values
Request:
{
"externalProperties": {}
}
❌ Validation fails
❌ External Properties not created
✔️ Correct behavior
- Required, with default values
Request:
{
"externalProperties": {}
}
✅ Validation passes
❌ External Properties empty
❌ Incorrect behavior
Scenario 4 behaves the same as scenario 2, but it should behave the same as scenario 3.
Why this matters
This breaks JSON Schema semantics because default should be documentation-only and must not change validation behavior.
Scenarios with screenshots:
Scenario 3
Scenario 4
