Consider two schemas:
foo-schema:
{
"$schema": "http://json-schema.org/schema#",
"required": [
"foo"
],
"type": "object",
"properties": {
"foo": {
"type": "integer"
}
}
}
and analoguous with bar field – bar-schema
{
"$schema": "http://json-schema.org/schema#",
"required": [
"bar"
],
"type": "object",
"properties": {
"bar": {
"type": "integer"
}
}
}
When we attempt to merge them, all fields becomes optional. It seems that genson tries to optimize that case by omitting "required": [].
/tmp> genson -s foo-schema -s bar-schema | jq
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"foo": {
"type": "integer"
},
"bar": {
"type": "integer"
}
}
}
Let's save it as foobar-schema. If we try to merge it once again with foo-schema, we should expect no change (because merge(foo, bar, foo) should be equivalent to merge(foo, bar)), but for our surprise, we see that foo field is marked as required!
/tmp> genson -s foobar-schema -s foo-schema | jq
{
"$schema": "http://json-schema.org/schema#",
"required": [
"foo"
],
"type": "object",
"properties": {
"foo": {
"type": "integer"
},
"bar": {
"type": "integer"
}
}
}
I'm not sure whether lack of required field should be interpreted as "we don't know what's required" or "nothing is required" (I guess the latter though), but it'd be great for genson to handle it consistently :)
Consider two schemas:
foo-schema:
{ "$schema": "http://json-schema.org/schema#", "required": [ "foo" ], "type": "object", "properties": { "foo": { "type": "integer" } } }and analoguous with bar field – bar-schema
{ "$schema": "http://json-schema.org/schema#", "required": [ "bar" ], "type": "object", "properties": { "bar": { "type": "integer" } } }When we attempt to merge them, all fields becomes optional. It seems that genson tries to optimize that case by omitting
"required": [].Let's save it as foobar-schema. If we try to merge it once again with foo-schema, we should expect no change (because merge(foo, bar, foo) should be equivalent to merge(foo, bar)), but for our surprise, we see that
foofield is marked as required!I'm not sure whether lack of
requiredfield should be interpreted as "we don't know what's required" or "nothing is required" (I guess the latter though), but it'd be great for genson to handle it consistently :)