Closed elgalu closed 6 years ago
For now I switched to https://pypi.python.org/pypi/genson/ as it correctly generates the required fields.
@elgalu thanks for raising the issue, have planned a fix for this
Has been fixed as of 2.5.1:
> [{"name":"leo"},{"name":"mike","age":"30"},{"name":"laura","age":"33"}]
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "string"
}
},
"required": [
"name",
"age"
]
}
}
Any updates? I don't get any required fields.
Thanks for the project! it got me started on JSON schema generation for exercising some form of contract testing.
The
required
fields logic seem to only take into account the last 2 examples?How to reproduce
By providing this JSON test data:
Run
Got
Got
name
andage
fields as required.Expected
Expected only the
name
field as required.I guess to improve it, would need to take a look at https://github.com/nijikokun/generate-schema/blob/edacf92cbc4242840770f9249b6cee40d5b36547/src/schemas/json.js#L41