brandur/json_schema

require for all parameters?

panSarin opened this issue · 2 comments

Hey i can't find it anywhere in JSON Schema documentations, so I decided to ask it here.
So, can i define that all my parameters defined in json schema are required?
Since i define json schema and then i want to validate my response with json_schema gem, i expect all fields that i defined to exists in my response. So is there any way to do something like

  "required": [all] 

or

  "required": [*]

so i don't need to copy all parameters names to the required array ?

Hey @panSarin,

This is indeed kind of a hole in the V4 spec in that there isn't really a good way of doing that.

The next iteration of the specification, V5, will like include a new property called strictProperties that does what you need.

The good news is that this gem supports strictProperties out of the box because we wanted it for our schemas. The bad news is that it's not technically part of the current specification so it probably won't be widely supported by other validators. Hopefully this will change soon, but the last time I checked, V5 was still in limbo.

Closing this out, but lemme know if you have anymore questions about it!

Thank you for you help! Greetings!