generate-schema
generate-schema copied to clipboard
[Issue] Nested object under an array returns wrong number of items
Basic Object
const sampleObj = {
randomnumber: 2,
arr: [
1,
2,
"hello"
]
};
console.log(JSON.stringify(GenerateSchema.json(sampleObj), null, 2));
Above returns wrong validation for the array, I have 3 items in the array and it returns 4... am I missing something obvious here?
Output of the above:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"randomnumber": {
"type": "number"
},
"arr": {
"type": "array",
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "string"
}
]
}
}
}
}
Thanks