react-jsonschema-form
react-jsonschema-form copied to clipboard
Default Enum Values in OneOf Definitions do not appear in form data submissions
Prerequisites
- [x] I have read the documentation;
- [x] In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [x] Ideally, I'm providing a sample JSFiddle or a shared playground link demonstrating the issue.
Description
When submitting an enum value from a field contained in a oneOf definition, the default value is not included in the formData property after submission.
Steps to Reproduce
- Use the following schema in the Playground / JS Fiddle:
{
"title": "OneOf Enum Bug",
"type": "object",
"additionalProperties": false,
"properties": {
"Name": {
"type": "string"
},
"one-of-example-field": {
"oneOf": [
{
"$ref": "#/definitions/MyDefinition",
"title": "My Choice"
}
]
}
},
"required": [
"Name"
],
"definitions": {
"MyDefinition": {
"type": "object",
"additionalProperties": false,
"properties": {
"this default enum will not be in the submitted form data": {
"type": "string",
"enum": [
"foo-bar"
],
"default": "foo-bar"
},
"Header Key": {
"type": "string"
},
"Header Value": {
"type": "string"
}
},
"required": []
}
}
}
- Fill in any fields
- Submit the form
Expected behavior
Form data should contain all fields, including the default enum value described in MyDefinition
Actual behavior
The default value is not present
Version
2.5.1