Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: treat default field in additionalProperties #4199

Merged

Conversation

tomatommy-bs
Copy link
Contributor

Reasons for making this change

feat #3915

Before this PR, adding a 'default' field to 'additionalProperty' did not affect the functionality. With this change, label/value will be added with the value specified in 'default' of 'additionalProperty'.

// sample schema

const schema = {
  type: "object",
  additionalProperties: {
    type: "string",
    default: "sample default"
  }
}

⚠️ Note

If a default value that does not conform to the schema is provided, the label/value will be added with that default value.

const schema = {
  type: "object",
  additionalProperties: {
    type: "string",
    default: 1
  }
}

In the above example, if an item is added, a label/value with the value 1 will be added.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@tomatommy-bs tomatommy-bs changed the title treat default field in additionalProperties feat: treat default field in additionalProperties May 24, 2024
@heath-freenome heath-freenome merged commit ec932db into rjsf-team:main May 24, 2024
5 checks passed
@tomatommy-bs tomatommy-bs deleted the additinal-properties-default-value branch May 25, 2024 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants