Closed haf closed 8 years ago
"type": "enum"
is what's causing the error here. When you use enum, you usually want to set it as type "string", as that's what will be on the output.
I guess in a future version we could throw a error message that describes possible problems with user's schema.
Here is how your schema should look like. I also changed the mainCategory enum values, to make "misc" a valid value.
{
title: "Repro Form",
description: "Repro for error",
type: "object",
properties : {
selection: {
"title": "Choose Category",
"type": "object",
"properties": {
"mainCategory": {
"title": "Choose the main category",
"type": "string",
"enum": [
"-",
"misc"
],
"enumNames": [
"Select one of the below",
"Misc"
]
}
},
"oneOf": [
{},
{
"properties": {
"mainCategory": {
"enum": [
"misc"
]
},
"people": {
"title": "Misc Category",
"type": "string",
"enum": [
"a",
"b",
"c"
],
"enumNames": [
"Something",
"Something else",
"A third option"
]
}
}
}
],
"x-hints": {
"form": {
"selector": "mainCategory"
}
}
}
}
}
Thank you, that worked! Any chance of a better error message?
Sure. I will probably make it throw an error when the schema as an invalid type. I think that makes sense and is the expected behaviour.
Can I add a third level, e.g. misc.a.third
?
I haven't been able to at all. Neither with "x-hints": { "form": { "selector": "peopleCategory" } }
nor with enum
+ array position.
Using latest from npm
Repro JSON schema:
Choose the third option in the form to reproduce.