In json schema, I can simply define a code list using "enum" with a list of code that is available, for example:
{
"type": "object",
"properties": {
"group": {
"type":"string",
"$ref": "#/definitions/Group"
}
},
"definitions": {
"Group": {
"enum": ["A","B"]
}
}
}
And the following payload would be valid:
{
"group": "B"
}
However, I try to provide the description in the schema to the user where "A" = "Group A", "B" = "Group B". Something like:
{
"type": "object",
"properties": {
"group": {
"type":"string",
"$ref": "#/definitions/Group"
}
},
"definitions": {
"Group": {
"enum": [
{"code":"A",
"description": "Group A"
},
{"code":"B",
"description": "Group B"
}
]
}
}
}
But I don't want to change the structure of the payload (no "description" field needed) The description is more for documentation purposes that users can refer to. Is there a good practice that can be used here?
Thank you