Does not handle multiple types properly, yet supplied example covers both null or string
joe-oli opened this issue · 2 comments
joe-oli commented
When given an array with two objects examples, it considers only the first example to infer the type;
{
"CustomerNumber": "ABC123",
"contactPersons": [{
"PersonFirstName": "Mindi",
"PersonLastName": "Mink",
"ContactLevel": "ORG",
"PartySiteNumber": null
},
{
"PersonFirstName": "Kendra",
"PersonLastName": "Spade",
"ContactLevel": "SITE",
"PartySiteNumber": "S444666"
}
]
}
The inferred type is
{
"PartySiteNumber": {
"$id": "#/properties/contactPersons/items/anyOf/0/properties/PartySiteNumber",
"type": "null",
"title": "The PartySiteNumber schema",
"description": "An explanation about the purpose of this instance.",
"default": null,
"examples": [
null
]
}
}
when it should have been:
"type" : ["null", "string"]
jackwootton commented
Thanks for taking the time to report this @joe-oli . You're right. I stripped back your example to
[
{
"PartySiteNumber": null
},
{
"PartySiteNumber": "S444666"
}
]
And also removed a few keywords
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "array",
"default": [],
"examples": [
[
{
"PartySiteNumber": null
},
{
"PartySiteNumber": "S444666"
}
]
],
"items": {
"anyOf": [
{
"type": "object",
"default": {},
"examples": [
{
"PartySiteNumber": null
}
],
"required": [
"PartySiteNumber"
],
"properties": {
"PartySiteNumber": {
"type": "null",
"default": null,
"examples": [
null
]
}
}
}
]
}
}
jackwootton commented
This has been fixed in the new version.