I have already looked at:
- Properties based on enum value in JSON Schema
- JSON schema for dynamic properties
- JSON Schema $ref for properties
I need my JSON schema to enforce that an object has all properties from an enum and I cannot puzzle out how. I have no idea what the next step is from this point.
stuff.list.json
Note: Imagine this, but much longer.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "ListOfStuff",
"description": "List of stuff",
"enum": [
"Thing1",
"Thing2",
"Thing3"
],
"uniqueItems": true
}
stuff.schema.json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "Stuff Defined",
"description": "Stuff in detail",
"type": "object",
"properties": {
/* a property for each enum value of stuff.list.json */: { <----- ???
"type": "array",
"items": { /* Schema for each item */ }
}
},
"required": [ /* $ref: ./stuff.list.json ?? */ ]
}
The output I'm aiming for it to enforce is:
{
"Thing1": [],
"Thing2": [],
"Thing3": []
}