Skip to content

feat(core): select combinator branches structurally instead of compiling them with Ajv - #2643

Open
gigibiffi84 wants to merge 1 commit into
eclipsesource:masterfrom
gigibiffi84:feat/structural-combinator-selection
Open

gigibiffi84 wants to merge 1 commit into
eclipsesource:masterfrom
gigibiffi84:feat/structural-combinator-selection

Conversation

@gigibiffi84

Copy link
Copy Markdown

Part of #1498

What changed

Combinator tab selection (mapStateToCombinatorRendererProps, used for oneOf, anyOf and allOf) compiled every branch with Ajv and then ignored all errors except the structural keywords required, additionalProperties, type, enum and const.

This PR adds isStructuralMatch in @jsonforms/core, which evaluates exactly those keywords itself, recursively through properties, patternProperties, items, $ref, nested combinators and if/then/else, and uses it for branch selection. No Ajv instance and no code generation are involved anymore, so tab selection also works under a Content Security Policy without unsafe-eval, and it no longer depends on state.ajv being present.

For adopters

Branch selection behaves as before: keywords outside the structural set never influenced it, because their errors were filtered out. Two differences: unresolvable $refs no longer log a console.debug, and selection works even when no Ajv instance is in state. isStructuralMatch and structuralKeywords are new public exports.

Tests

  • test/util/structural.test.ts: 38 cases comparing isStructuralMatch with the previous filtered-Ajv behaviour keyword by keyword, plus boolean schemas, unresolvable and recursive $refs, invalid regexes and undefined values.
  • test/mappers/renderer.test.ts: the two existing combinator tests unchanged, plus required, additionalProperties: false, primitive type, $ref branches, a state without Ajv, and the no-match case.

🤖 Generated with Claude Code

…ing them with Ajv

Combinator tab selection compiled every oneOf/anyOf/allOf branch with
Ajv and then ignored all errors except the structural keywords
required, additionalProperties, type, enum and const. The new
isStructuralMatch evaluates exactly those keywords itself, recursively
through properties, patternProperties, items, $ref, nested combinators
and if/then/else.

Tab selection therefore no longer depends on an Ajv instance or on
code generation, so it also works under a Content Security Policy
without unsafe-eval. Equivalence with the previous filtered-Ajv
behaviour is covered by tests comparing both approaches keyword by
keyword.

Part of eclipsesource#1498

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit ea98a3c
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/6ac67ef7e3610000081091ac
😎 Deploy Preview https://deploy-preview-2643--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant

CLAassistant commented Oct 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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