I have a directory called 'schemas' that holds various JSON files containing different schemas.
For instance,
/schemas/banana-schema.json
{
"$schema": "http://json-schema.org/draft-06/schema",
"type": "object",
"properties": {
"banana_name": {
"type": "string"
},
"id": {
"type": "integer"
},
"banana_weight": {
"type": "number"
},
"timestamp": {
"type": "string",
"format": "date-time"
},
"required": ["id"]
}
}
/schemas/orange-schema.json
{
"$schema": "http://json-schema.org/draft-06/schema",
"type": "object",
"properties": {
"orange_name": {
"type": "string"
},
"id": {
"type": "integer"
},
"orange_sweetness": {
"type": "number"
},
"orange_timestamp": {
"type": "string",
"format": "date-time"
},
"required": ["id"]
}
}
Each schema has different attributes. My aim is to validate the following:
All keys (e.g. banana_name, id, timestamp, orange_name, orange_sweetness, and so on) across all schemas adhere to the same naming convention (lowercase with an underscore: 'xxx' or 'xxx_yyy').
Any key containing the word 'timestamp' must be in 'date-time' format.
Every schema must include the 'id' key. ('id' is mandatory for all schemas)
Is it feasible to create a unit test that imports all JSON schemas and performs these validations?