Closed nick-jones closed 1 year ago
All modified lines are covered by tests :white_check_mark:
Comparison is base (
0f951fd
) 78.14% compared to head (5f48a22
) 78.14%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
As reported in #86, minItems validation is being applied even when a non-required field is omitted from the input json.
A json schema like
should pass against an empty object input
(can be tested at https://www.jsonschemavalidator.net/)
Instead the generated code will result in an error during unmarshal. The proposed solution is to just add a
nil
check - non-required slices useomitempty
, which means they end upnil
if not supplied. If the field is required, the earlier field presence check will catch these - but also they'll never benil
becauseomitempty
is not used under such circumstances. So overall this additional constraint seems safe to add. Happy to take direction on other approaches.