Skip to content

Fully support allOf#25

Merged
jviotti merged 1 commit intomainfrom
allof
Apr 16, 2026
Merged

Fully support allOf#25
jviotti merged 1 commit intomainfrom
allof

Conversation

@jviotti
Copy link
Copy Markdown
Member

@jviotti jviotti commented Apr 16, 2026

Fixes: sourcemeta/jsonschema#619
Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Fixes: sourcemeta/jsonschema#619
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 15 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/e2e/typescript/2020-12/allof_intersection/schema.json">

<violation number="1" location="test/e2e/typescript/2020-12/allof_intersection/schema.json:10">
P2: These closed `allOf` branches make the schema unsatisfiable; the fixture never admits an object with both `name` and `age`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@@ -0,0 +1,21 @@
{
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: These closed allOf branches make the schema unsatisfiable; the fixture never admits an object with both name and age.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/e2e/typescript/2020-12/allof_intersection/schema.json, line 10:

<comment>These closed `allOf` branches make the schema unsatisfiable; the fixture never admits an object with both `name` and `age`.</comment>

<file context>
@@ -0,0 +1,21 @@
+        "name": { "type": "string" }
+      },
+      "required": [ "name" ],
+      "additionalProperties": false
+    },
+    {
</file context>
Fix with Cubic

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 16, 2026

🤖 Augment PR Summary

Summary: This PR completes support for the JSON Schema (2020-12) allOf applicator by exercising it end-to-end and at the IR layer.

Changes:

  • Marks allOf as supported in the README feature matrix.
  • Adds TypeScript e2e fixtures for allOf intersections of object schemas.
  • Adds TypeScript e2e coverage for allOf composed via $ref to $defs.
  • Adds a TypeScript e2e case for single-element allOf behaving like its lone subschema.
  • Introduces a new IR assertion helper macro: EXPECT_IR_INTERSECTION.
  • Adds IR tests validating that multi-branch allOf compiles to an IRIntersection node.
  • Adds IR coverage for mixed compositions (e.g., $ref + inline object in allOf).
  • Validates pointer/target relationships for referenced $defs branches in allOf.

Technical Notes: The TypeScript expected outputs demonstrate that allOf is emitted as an intersection type (&) and that referenced branches are preserved as references.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

"name": { "type": "string" }
},
"required": [ "name" ],
"additionalProperties": false
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionalProperties: false inside each allOf subschema makes objects containing both name and age invalid under JSON Schema semantics (each branch rejects the other branch’s property), so the “valid” instances in the TypeScript tests wouldn’t validate at runtime.

Severity: medium

Other Locations
  • test/e2e/typescript/2020-12/allof_intersection/schema.json:18
  • test/e2e/typescript/2020-12/allof_refs/schema.json:10
  • test/e2e/typescript/2020-12/allof_refs/schema.json:18

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

using namespace sourcemeta::codegen;

ASSERT_EQ(result.size(), 7);
EXPECT_IR_INTERSECTION(result, 6, "", 2);
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test hard-codes the intersection node at index 6 (and size 7), which can become brittle if the IR gains additional entries or the sort order changes; using a relative index like other tests would make it less sensitive to unrelated IR changes.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@jviotti jviotti merged commit 6c8870e into main Apr 16, 2026
13 checks passed
@jviotti jviotti deleted the allof branch April 16, 2026 22:24
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.

codegen: Support for allOf intersections

1 participant