I'm looking if it's possible to reference property names as enum
values in AJV definitions.
Here is an example:
{
"$id": "modes.json",
"description": "Example modes",
"type": "object",
"properties": {
"MODE_WALK": { "$ref": "walk.json" },
"MODE_BICYCLE": { "$ref": "bicycle.json" },
}
}
Then I have another file with:
{
"$id": "another.json",
"description": "Example object",
"type": "object",
"properties": {
"text": {
"type": "string",
"maxLength": 128
},
"mode": {
"description": "Allowed modes",
"type": "string",
"enum": [
"MODE_WALK",
"MODE_BICYCLE"
]
},
},
"additionalProperties": false,
"required": ["text", "mode"]
}
Right now, enum
has hardcoded values: MODE_WALK
and MODE_BICYCLE
- can I reference property names from the first file?