3
votes

I'm trying to create a json schema for a field that contains an enum, and I want the enum values to be the uuids of the options, but still provide display titles for the user to actually select from. I don't see how to do this within the json schema spec, am I missing something? My initial instinct is to just make the enum property a map instead of an array, but the spec seems pretty clear about it being an array.

1

1 Answers

4
votes

To convert a json-schema into a form requires more data than fits in the specification of json-schema, but there are ways to tweak it within the specification.

You could use oneOf instead of enum, and give each oneOf object a title.

Else, you could add a property enumNames, being a map of enum value to name. (The specification allows extra properties.)

For more complex forms, you will probably still need a form specification outside of the json-schema. You could look at form generators like Angular Schema Form that uses one schema and one form-definition.