"fooString" : {
"type" : "string"
}This is consistent with schema generated by Jackson/JAXB. One of the consumers of my service is complaining that null is not a valid value for this field. It breaks his python json deserializer.He suggests (Option B): "fooString" : {"type": ["string", "null"]
}
Personally, to me, it is implied that any non-primitive data type can be null. It seems like in the json schema world this needs to be explicitly stated. This makes the schema verbose and, to me, redundant.Here are some references where this format is recommended:
http://stackoverflow.com/questions/16241333/specify-a-value-can-be-a-string-or-null-with-json-schema
https://groups.google.com/forum/#!topic/jsonschema/mD6GDca4zN8
Now my questions:
a) Is the Option A schema wrong? Should I inform the Jackson team? Or is this a parsing issue in my client's third party python json library?
b) Does it follow that for all other data types that can be null their schemas would need to be:
"fooInteger" : {"type": ["integer", "null"]}"fooObject" : {"type": ["object", "null"],"properties" : { BLAH }}"fooArray" : {{"type": ["array", "null"]},"items" : { BLAH }}"fooEnum" : { "type" : [ "string", "null" ], "enum" : [ BLAH ] }c) For completeness, let me also ask if an empty list needs any special treatment? Though I think not.tia,rouble
json schema gurus,When I generate the schema for a string object field I do this (Option A):"fooString" : { "type" : "string" }This is consistent with schema generated by Jackson/JAXB. One of the consumers of my service is complaining that null is not a valid value for this field. It breaks his python json deserializer.He suggests (Option B):"fooString" : {"type": ["string", "null"]}Personally, to me, it is implied that any non-primitive data type can be null. It seems like in the json schema world this needs to be explicitly stated. This makes the schema verbose and, to me, redundant.Here are some references where this format is recommended:http://stackoverflow.com/questions/16241333/specify-a-value-can-be-a-string-or-null-with-json-schemahttps://groups.google.com/forum/#!topic/jsonschema/mD6GDca4zN8
Now my questions:a) Is the Option A schema wrong? Should I inform the Jackson team? Or is this a parsing issue in my client's third party python json library?
b) Does it follow that for all other data types that can be null their schemas would need to be:"fooInteger" : {"type": ["integer", "null"]}"fooObject" : {"type": ["object", "null"],"properties" : { BLAH }}"fooArray" : {{"type": ["array", "null"]},"items" : { BLAH }}"fooEnum" : { "type" : [ "string", "null" ], "enum" : [ BLAH ] }
c) For completeness, let me also ask if an empty list needs any special treatment? Though I think not.
tia,rouble