Skip to content

Default values are not set for oneOf + ref in schema #3633

Closed
@anthonycaron

Description

@anthonycaron

Prerequisites

What theme are you using?

antd

Version

5.6.0

Current Behavior

I have a schema of a oneOf with two options referencing two different objects.

Here is an example:

{
  "definitions": {
    "foo": {
      "type": "object",
      "properties": {
        "fooProp": {
          "type": "string"
        },
        "fooProp2": {
          "type": "string",
          "default": "fooProp2"
        }
      }
    },
    "bar": {
      "type": "object",
      "properties": {
        "barProp": {
          "type": "string"
        },
        "barProp2": {
          "type": "string",
          "default": "barProp2"
        }
      }
    }
  },
  "oneOf": [
    {
      "$ref": "#/definitions/foo"
    },
    {
      "$ref": "#/definitions/bar"
    }
  ]
}

You can try it out here.

Expected Behavior

I would expect to have a default prop set for the properties that define one.

Steps To Reproduce

  1. Just go to the playground link provided in the description
  2. You will be able to see that in the formData we don't have the default value set

Environment

- OS: MacOs
- Node: 18.7.0
- npm: 8.15.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions