Fields marked as required using schema.path('x').required(true) are not marked as required.
makinde opened this issue · 3 comments
makinde commented
If you have a schema, then add a field as being required programmatically, the resulting jsonschema doesn't mark the field as required.
DScheglov commented
Fixed in v1.3.0
VdeVentura commented
Hello @DScheglov, I haven't dig too deep into this, however I don't think the current behaviour is correct:
I assume that when we say "programmatically required" we are talking about something like: required: () => someLogic
Then if a field is programmatically required, we can't tell at build time what will be the value of required, so I'd argue that it should default to the field being optional.
DScheglov commented
@irvingv8 , actually it makes sense.
So, if required
is a function let's treat it as optional.
What do you think?