my form contains several time dropdown list with same enumerations
for example, the form ask for your birth country, the birth country of your mother, the birth country of your father…
the country list has 195 items : I’d like to to have to repeat that each time in the schema.json (to easily be able to update the list)
what i the most efficient way (in term of display overhead and easy to implement) to do that ?
should I use a custom renderer ? in this case, how to populate the enum ?
should I use a kind of include in the schema.json ?
Thanks !
[i’ll have different basic questions during the following days to be sure to use in the best way jsonforms. I’ve prefer to ask them separately ; as is, other persons will be more easily be able to reuse the replies !]
the renderer component is correctly displayed with the enum list BUT the label is not correctly displayed : T 01 is displayed instead of the title
Should I open a bug in github?
It’s more of a missing feature. In older JSON Schema specs $ref was defined to exclusively link to subschemas and no other properties were allowed next to it.
That changed at some point, but our code mostly did not. So whenever we encounter a $ref we usually just resolve it and don’t keep the “caller” context. That’s the case here too which is why the title is lost.
If you or someone else is interested, we would welcome contributions to implement some form of resolving context resolution.
You linked to a special resolving case which we no longer use. findAllRefs is only there for backward compatibility and will be removed at some point.
Here you can find our generic $ref resolver. It just follows the pointer without considering any overriding mechanism.
To enable the use case of overriding properties via $ref I see two potential approaches:
Instead of just returning the pointed to schema, we could use a merge approach as you suggested. However the returned schema is then no longer part of the original schema handed in. This will break in cases where object identity is expected.
Alternatively we could return a tuple instead of just the resolved schema, e.g. the schema and a context containing all the overriding properties, or the resolved schema and a “projectedSchema”
Perhaps we could have a third approach in this case. (Not sure to have integrally understood so don’t hesitate to tell that what I’m saying is just stupid!!)
As it seems that when it’s an array, everything is ok, I understand this situation like when we want to have a $ref parsed as a subschema with override properties, we could use a new keyword like “sub” in the schema?
Not sure how to explain that!
I don’t understand why array is correctly passing enum but not oneof for example as both are subschema…
Next Time, I’ll give you access to my brain, it will be easier!! Before that, I can give you a codesandbox link!!
To resume, I’ve a multi select component (the code I’ve provided on another message here) " compatible" with uniqueItems
And with this, the ref is working correctly inside array
in other terms, context is for me title and other params including my own ones
so with
“v09”: {
“title”: “Is the VENDOR currently member of the following professional organization ?”,
“description”: “if you’re member of others organisations’ section”,
“qU”: “member of :”,
“type”: “array”,
“uniqueItems”: true,
“items”: {
“type”: “string”,
“$ref”: “#/definitions/cyberOrg”
},
the title and description are correctly received by my (custom) component (and it’s seems ok with the default uniqueitems also)
if I replace array with oneOf (and remove uniqueItems), I’ve not been able to make it work