Skip to content

createDefaultValue doesn't follow anyOf, oneOf, allOf #2401

@kchobantonov

Description

@kchobantonov

Describe the bug

  1. createDefaultValue returns empty object in the "anyOf" example when new element is added in "Addresses or Users (AnyOf Array Items)"
  2. createDefaultValue should also pass the rootSchema when it tries to resolve the the schema based on schema.$ref

Expected behavior

the createDefaultValue should have returned empty array rather than empty object

we get

{
  "addressOrUser": {
    "street_address": "1600 Pennsylvania Avenue NW",
    "city": "Washington",
    "state": "DC"
  },
  "addressesOrUsersAnyOfItems": [
    {}
  ]
}

instead of

{
  "addressOrUser": {
    "street_address": "1600 Pennsylvania Avenue NW",
    "city": "Washington",
    "state": "DC"
  },
  "addressesOrUsersAnyOfItems": [
    []
  ]
}

Steps to reproduce the issue

  1. Go to generated example app
  2. Select Example 'anyOf'
  3. Scroll down to 'Addresses or Users (AnyOf Array Items)'
  4. Click on the '+' to add new element in "Addresses or Users (AnyOf Array Items)" array
  5. See that added element under addressesOrUsersAnyOfItems is an empty object rather than empty array

Screenshots

No response

Which Version of JSON Forms are you using?

3.4.1

Package

Core

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions