-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"required" JSON keys are validated against "additionalProperties" if they are missing from "properties" #1029
"required" JSON keys are validated against "additionalProperties" if they are missing from "properties" #1029
Conversation
…t additionalProperties
|
||
if additional_properties is not False: | ||
if additional_properties is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a functional change -- this line is just no longer needed since _gen_json
can take bool schemas just fine
# "required" keys will be validated against "properties" if they're present, otherwise against "additionalProperties". | ||
# If "additionalProperties" is False, then required keys must be in "properties". | ||
if any(k not in properties for k in required) and additional_properties is False: | ||
raise ValueError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly necessary, as generating with a False
schema will raise an exception later. But this lets us give a more transparent error.
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1029 +/- ##
==========================================
- Coverage 70.16% 61.47% -8.69%
==========================================
Files 62 62
Lines 4471 4470 -1
==========================================
- Hits 3137 2748 -389
- Misses 1334 1722 +388 ☔ View full report in Codecov by Sentry. |
Rather than raising an exception when
required
properties don't have a schema inproperties
, validate againstadditionalProperties
(consistent with Draft202012)Somewhat arbitrarily set key order of resulting objects to:
properties
in orderrequired
properties mising fromproperties
in orderadditionalProperties