react-jsonschema-form
react-jsonschema-form copied to clipboard
Adding different display name to enum with ui-Schema
Prerequisites
- [X] I have read the documentation
What theme are you using?
core
What is your question?
We are auto-generating our base json-schema files directly from a (graphql) API schema. So enums there are not meant for human consumption and need labels.
We use ui-Schema to augment the generated json-schema files with all necessary presentation layer things (titles, order, etc). The only thing that we dont manage to do is give enums new labels.
How can we approach this?
I don't think you can do that today, the only ways to label an enum are using oneOf/title or the deprecated & nonstandard enumNames property in the JSON Schema (docs).
The reason we deprecated enumNames is because it's a nonstandard JSON Schema field. I think it could be useful to have a similar feature added to the uiSchema. We'd be happy to review a PR if you are interested in contributing this feature!
Late reply, sorry.
I found that it does seem possible somehow to attach a title to a any/oneOf somehow. But there are other issues keeping me :) https://github.com/rjsf-team/react-jsonschema-form/issues/4260 thanks anyway!
Glad you have a workaround for this issue @perelin . If you don't mind, I want to re-open this ticket because I think we'll want to do this eventually. We will plan to keep enumNames in the library until we provide some way to override enum display values via the uiSchema. This issue can track that new feature (and also indicate to us that we can remove enumNames once we release the following major version)
Fixed with https://github.com/rjsf-team/react-jsonschema-form/pull/4263