Closed Anand-Moghe closed 6 years ago
I have a JSON instance like below:
{ "a": [ { "MyName": "Ron" }, { "lastName": "Aron" } ] }
When I generate the new schema of this JSON above it is created as below:
import jsonSchemaGenerator from 'generate-schema'; const mySchema = jsonSchemaGenerator.json("CustomLegend1", this.sectionSchemaInstance); console.log(" ***** JSON Schema = " + JSON.stringify(mySchema)); { "$schema": "http://json-schema.org/draft-04/schema#", "title": "CustomLegend1", "type": "object", "properties": { "a": { "type": "array", "items": { "type": "object", "properties": { "MyName": { "type": "string" }, "lastName": { "type": "string" } }, "required": [] } } } }
Why there are no required[] fields ("required": []) ?
Because you don't use a field in every array element:
{ "a": [ { "MyName": "Ron" }, { "MyName": "Dave", "lastName": "Aron" } ] }
Oh! Thanks.
I have a JSON instance like below:
When I generate the new schema of this JSON above it is created as below:
Why there are no required[] fields ("required": []) ?