Fix: handle uuid in all types of duplicated item (nested, oneOf.)#1696
Open
dianeCdrPix wants to merge 4 commits into
Open
Fix: handle uuid in all types of duplicated item (nested, oneOf.)#1696dianeCdrPix wants to merge 4 commits into
dianeCdrPix wants to merge 4 commits into
Conversation
Introduce `regenerateUUIDs(value, schema)` in utilities.js that walks value and schema together to regenerate all UUID fields at any nesting depth. Use it in both array.js and table.js `_createCopyButton`, replacing the previous one-level-deep logic and shallow spread copy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a nested-object schema to uuid.html (uuidNestedObjectArray) and five new test scenarios covering UUID regeneration on copy for: - array editor: uuid string item, flat object, nested object - table editor: uuid string item, flat object Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When copying array items whose schema uses oneOf or anyOf (e.g. a discriminated union), find the matching sub-schema by checking that all enum-constrained properties of the candidate match the value, then recurse into it. Without this, UUID regeneration silently fell back to a plain deep-copy for any oneOf/anyOf item. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a uuidOneOfArray schema (two discriminated sub-schemas typeA/typeB) to uuid.html and a test scenario that copies a oneOf item and verifies the uuid field is regenerated, covering the oneOf/anyOf branch of regenerateUUIDs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
@germanbisurgi, can you tell me if this PR is ok for you? This feature can fix an issue on the project where my team uses json-editor. Regards. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New PR to generate a new uuid when the duplicated object is a nested element, or in a oneOf/anyOf subdivision in the json-schema.
(It replaces those PR (that I have closed) : #1694 #1695 )