-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
@rjsf/react-bootstrap
Version
5.24.8
Current Behavior
I'm trying to use $defs
and $ref
to consolidate my schemas. However, $ref
does not work as expected when used in a oneOf
construct.
This works (can select another protocol)
{
"type": "object",
"$defs": {
"protocol": {
"type": "string",
"enum": [
"fast",
"balanced",
"stringent"
],
"default": "fast"
}
},
"properties": {
"protocol": {
"$ref": "#/$defs/protocol"
}
}
}
but this does not (can't switch protocols)
{
"type": "object",
"$defs": {
"protocol": {
"type": "string",
"enum": [
"fast",
"balanced",
"stringent"
],
"default": "fast"
}
},
"oneOf": [
{
"properties": {
"protocol": {
"$ref": "#/$defs/protocol"
}
}
}
]
}
Also tested allOf
, which works fine.
What am I missing?
Expected Behavior
Being able to switch between protocols
Steps To Reproduce
- Go to shared playground
- Try to select another protocol
Environment
Playground
Anything else?
The following construct again works, but is not ideal for my use case
{
"type": "object",
"$defs": {
"protocol": {
"type": "object",
"properties": {
"value": {
"type": "string",
"enum": [
"fast",
"balanced",
"stringent"
],
"default": "fast"
}
}
}
},
"oneOf": [
{
"properties": {
"protocol": {
"$ref": "#/$defs/protocol"
}
}
}
]
}