Skip to content

Fix: handle uuid in all types of duplicated item (nested, oneOf.)#1696

Open
dianeCdrPix wants to merge 4 commits into
json-editor:masterfrom
1024pix:fix-copy-element
Open

Fix: handle uuid in all types of duplicated item (nested, oneOf.)#1696
dianeCdrPix wants to merge 4 commits into
json-editor:masterfrom
1024pix:fix-copy-element

Conversation

@dianeCdrPix

@dianeCdrPix dianeCdrPix commented May 19, 2026

Copy link
Copy Markdown
Contributor

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 )

Q A
Is bugfix? ✔️
New feature?
Is backward-compatible? ✔️
Tests pass? ✔️
Fixed issues Continue to fix issue #1481
Updated README/docs?
Added CHANGELOG entry? ✔️

dianeCdrPix and others added 4 commits May 19, 2026 16:12
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>
@dianeCdrPix dianeCdrPix changed the title Fix: handle uuid in all type of duplicated item Fix: handle uuid in all types of duplicated item (nested, oneOf.) May 19, 2026
@dianeCdrPix dianeCdrPix marked this pull request as ready for review May 19, 2026 15:47
@dianeCdrPix

Copy link
Copy Markdown
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.

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.

1 participant