Skip to content

Commit

Permalink
Merge pull request #600 from PierreBtz/pbeitz/dev
Browse files Browse the repository at this point in the history
Make the generated schema compliant with draft04
  • Loading branch information
jetersen committed Oct 17, 2020
2 parents d472269 + cec9072 commit 8cc6d94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion bin/generate-schema.js
Expand Up @@ -13,7 +13,13 @@ const jsonSchema = {
}

// template is only required after deep merged, should not be required in the JSON schema
jsonSchema.required = jsonSchema.required.filter((item) => item !== 'template')
// we should also remove the required field in case nothing remains after the filtering to keep draft04 compatibility
const requiredField = jsonSchema.required.filter((item) => item !== 'template')
if (requiredField.length) {
jsonSchema.required = requiredField
} else {
delete jsonSchema.required
}

if (args[0] === 'print') {
fs.writeFileSync('./schema.json', `${JSON.stringify(jsonSchema, null, 2)}\n`)
Expand Down
3 changes: 1 addition & 2 deletions schema.json
Expand Up @@ -209,6 +209,5 @@
}
},
"additionalProperties": false,
"patterns": [],
"required": []
"patterns": []
}

0 comments on commit 8cc6d94

Please sign in to comment.