Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

test(json-schema): add strict-mode edge cases enumerated with a second model

jkomyno8fe03eff47ad
diff --git a/python/tests/fixtures/json-schema-conversion/strict-cases.json b/python/tests/fixtures/json-schema-conversion/strict-cases.json
index 9c9b67954..4cf465516 100644
--- a/python/tests/fixtures/json-schema-conversion/strict-cases.json
+++ b/python/tests/fixtures/json-schema-conversion/strict-cases.json
@@ -90,6 +90,26 @@
"url": "u"
}
}
+ },
+ {
+ "input": {
+ "cfg": null
+ },
+ "output": {}
+ },
+ {
+ "input": {
+ "cfg": {
+ "url": "u",
+ "extra": null
+ }
+ },
+ "output": {
+ "cfg": {
+ "url": "u",
+ "extra": null
+ }
+ }
}
]
},
@@ -303,7 +323,25 @@
"required": ["xs"],
"additionalProperties": false
}
- }
+ },
+ "arguments": [
+ {
+ "input": {
+ "xs": null
+ },
+ "output": {
+ "xs": null
+ }
+ },
+ {
+ "input": {
+ "xs": [null]
+ },
+ "output": {
+ "xs": [null]
+ }
+ }
+ ]
},
{
"id": "optional-any-of-gets-null-branch",
@@ -670,65 +708,6 @@
}
]
},
- {
- "id": "tuple-items-normalized",
- "description": "Objects inside tuple-form items are normalized too.",
- "schema": {
- "type": "object",
- "properties": {
- "pair": {
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "x": {
- "type": "number"
- }
- }
- },
- {
- "type": "string"
- }
- ]
- }
- },
- "required": ["pair"]
- },
- "strict": {
- "schema": {
- "type": "object",
- "properties": {
- "pair": {
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "x": {
- "type": ["number", "null"]
- }
- },
- "required": ["x"],
- "additionalProperties": false
- },
- {
- "type": "string"
- }
- ]
- }
- },
- "required": ["pair"],
- "additionalProperties": false
- }
- },
- "changes": [
- {
- "path": "properties.pair.items[0].properties.x",
- "reason": "optional-property-nullable"
- }
- ]
- },
{
"id": "default-and-examples-stripped",
"description": "Annotation keywords the API rejects are stripped and reported.",
@@ -1830,6 +1809,1139 @@
"reason": "optional-property-nullable"
}
]
+ },
+ {
+ "id": "root-single-element-type-array-accepted",
+ "description": "A root typed [\"object\"] is an object root.",
+ "schema": {
+ "type": ["object"],
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"]
+ },
+ "strict": {
+ "schema": {
+ "type": ["object"],
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ }
+ },
+ {
+ "id": "three-member-type-array-gains-null",
+ "description": "A three-member type array gains null once.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "type": ["string", "number", "boolean"]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "type": ["string", "number", "boolean", "null"]
+ }
+ },
+ "required": ["v"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.v",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "optional-null-only-property-unchanged",
+ "description": "A property typed null already accepts null.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "type": "null"
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "type": "null"
+ }
+ },
+ "required": ["nothing"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.nothing",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "nothing": null
+ },
+ "output": {
+ "nothing": null
+ }
+ }
+ ]
+ },
+ {
+ "id": "optional-enum-with-null-not-rewrapped",
+ "description": "An enum that already lists null is not wrapped again.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "choice": {
+ "enum": ["a", null]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "choice": {
+ "enum": ["a", null]
+ }
+ },
+ "required": ["choice"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.choice",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "choice": null
+ },
+ "output": {
+ "choice": null
+ }
+ }
+ ]
+ },
+ {
+ "id": "optional-const-null-not-rewrapped",
+ "description": "A const null already accepts null.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "const": null
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "const": null
+ }
+ },
+ "required": ["nothing"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.nothing",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "nothing": null
+ },
+ "output": {
+ "nothing": null
+ }
+ }
+ ]
+ },
+ {
+ "id": "nested-any-of-branch-widened",
+ "description": "Optional properties inside anyOf branches are widened.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.v.anyOf[0].properties.a",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "v": {
+ "a": null
+ }
+ },
+ "output": {
+ "v": {}
+ }
+ },
+ {
+ "input": {
+ "v": null
+ },
+ "output": {}
+ }
+ ]
+ },
+ {
+ "id": "array-of-nullable-objects-closed",
+ "description": "Nullable objects inside array items are closed and stay nullable.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "rows": {
+ "type": "array",
+ "items": {
+ "type": ["object", "null"],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "required": ["rows"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "rows": {
+ "type": "array",
+ "items": {
+ "type": ["object", "null"],
+ "properties": {
+ "id": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["id"],
+ "additionalProperties": false
+ }
+ }
+ },
+ "required": ["rows"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.rows.items.properties.id",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "rows": [
+ null,
+ {
+ "id": null
+ }
+ ]
+ },
+ "output": {
+ "rows": [null, {}]
+ }
+ }
+ ]
+ },
+ {
+ "id": "tuple-form-items-unsupported",
+ "description": "Draft-4 tuple items have no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "pair": {
+ "type": "array",
+ "items": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["pair"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.pair",
+ "keyword": "items"
+ }
+ ]
+ }
+ },
+ {
+ "id": "boolean-items-unsupported",
+ "description": "A boolean items subschema is reported.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "xs": {
+ "type": "array",
+ "items": true
+ }
+ },
+ "required": ["xs"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.xs",
+ "keyword": "items"
+ }
+ ]
+ }
+ },
+ {
+ "id": "not-keyword-unsupported",
+ "description": "not has no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "not": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.v",
+ "keyword": "not"
+ }
+ ]
+ }
+ },
+ {
+ "id": "if-then-else-unsupported",
+ "description": "Conditional keywords have no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "type": "string",
+ "if": {
+ "minLength": 1
+ },
+ "then": {
+ "maxLength": 5
+ },
+ "else": {
+ "const": ""
+ }
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.v",
+ "keyword": "else"
+ },
+ {
+ "path": "properties.v",
+ "keyword": "if"
+ },
+ {
+ "path": "properties.v",
+ "keyword": "then"
+ }
+ ]
+ }
+ },
+ {
+ "id": "dependent-schemas-unsupported",
+ "description": "dependentSchemas has no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "dependentSchemas": {
+ "a": {
+ "type": "object",
+ "properties": {
+ "b": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "",
+ "keyword": "dependentSchemas"
+ }
+ ]
+ },
+ "changes": [
+ {
+ "path": "dependentSchemas.a.properties.b",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "property-names-keyword-unsupported",
+ "description": "propertyNames has no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "propertyNames": {
+ "pattern": "^a"
+ }
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "",
+ "keyword": "propertyNames"
+ }
+ ]
+ }
+ },
+ {
+ "id": "one-of-beside-any-of-unsupported",
+ "description": "oneOf next to anyOf cannot be merged and is reported.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "type": "string"
+ }
+ ],
+ "oneOf": [
+ {
+ "type": "number"
+ }
+ ]
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.v",
+ "keyword": "oneOf"
+ }
+ ]
+ }
+ },
+ {
+ "id": "boolean-property-subschema-unsupported",
+ "description": "A boolean property subschema is reported.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "anything": true,
+ "nothing": false
+ },
+ "required": ["anything", "nothing"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.anything",
+ "keyword": "properties"
+ },
+ {
+ "path": "properties.nothing",
+ "keyword": "properties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "properties-not-an-object-unsupported",
+ "description": "A malformed properties value is reported instead of emptied.",
+ "schema": {
+ "type": "object",
+ "properties": "not-a-map",
+ "required": ["a"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "",
+ "keyword": "properties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "ref-with-siblings-kept",
+ "description": "Sibling keywords next to a $ref are kept.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "cfg": {
+ "$ref": "#/$defs/Config",
+ "description": "cfg",
+ "title": "Config"
+ }
+ },
+ "required": ["cfg"],
+ "$defs": {
+ "Config": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "cfg": {
+ "$ref": "#/$defs/Config",
+ "description": "cfg",
+ "title": "Config"
+ }
+ },
+ "required": ["cfg"],
+ "$defs": {
+ "Config": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ {
+ "id": "required-non-string-entries-ignored",
+ "description": "Non-string required entries are ignored.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ },
+ "b": {
+ "type": "string"
+ }
+ },
+ "required": ["a", 1, null]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ },
+ "b": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a", "b"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.b",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "dynamic-keys-reported-once-with-pattern-properties",
+ "description": "additionalProperties and patternProperties on one node report additionalProperties.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "m": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "patternProperties": {
+ "^x": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "required": ["m"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.m",
+ "keyword": "additionalProperties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "empty-properties-open-object-unsupported",
+ "description": "An object with empty properties and no closing is free-form.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "m": {
+ "type": "object",
+ "properties": {}
+ }
+ },
+ "required": ["m"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.m",
+ "keyword": "properties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "default-stripped-then-widened",
+ "description": "Stripping default and widening compose.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string",
+ "default": "x"
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.a",
+ "reason": "unsupported-keyword-stripped"
+ },
+ {
+ "path": "properties.a",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "nested-any-of-in-any-of-kept",
+ "description": "A composition nested inside a composition is normalized branch by branch.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "type": "number"
+ }
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ },
+ {
+ "type": "number"
+ }
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.v.anyOf[0].anyOf[0].properties.a",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "v": {
+ "a": null
+ }
+ },
+ "output": {
+ "v": {}
+ }
+ }
+ ]
+ },
+ {
+ "id": "definitions-and-defs-both-normalized",
+ "description": "Legacy definitions and $defs coexist and both are normalized.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/A"
+ },
+ "b": {
+ "$ref": "#/definitions/B"
+ }
+ },
+ "required": ["a", "b"],
+ "$defs": {
+ "A": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "definitions": {
+ "B": {
+ "type": "object",
+ "properties": {
+ "y": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/A"
+ },
+ "b": {
+ "$ref": "#/definitions/B"
+ }
+ },
+ "required": ["a", "b"],
+ "$defs": {
+ "A": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["x"],
+ "additionalProperties": false
+ }
+ },
+ "definitions": {
+ "B": {
+ "type": "object",
+ "properties": {
+ "y": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["y"],
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "$defs.A.properties.x",
+ "reason": "optional-property-nullable"
+ },
+ {
+ "path": "definitions.B.properties.y",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "deep-nesting-normalized-fully",
+ "description": "Ten levels of nested objects are normalized at every level.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "leaf": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "leaf": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["leaf"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.leaf",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "chained-refs-resolved",
+ "description": "A $ref to a $ref resolves to the final definition.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/Alias"
+ }
+ },
+ "required": ["a"],
+ "$defs": {
+ "Alias": {
+ "$ref": "#/$defs/Real"
+ },
+ "Real": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "string"
+ }
+ },
+ "required": ["x"]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/Alias"
+ }
+ },
+ "required": ["a"],
+ "$defs": {
+ "Alias": {
+ "$ref": "#/$defs/Real"
+ },
+ "Real": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "string"
+ }
+ },
+ "required": ["x"],
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "arguments": [
+ {
+ "input": {
+ "a": {
+ "x": null
+ }
+ },
+ "output": {
+ "a": {}
+ }
+ },
+ {
+ "input": {
+ "a": null
+ },
+ "output": {}
+ }
+ ]
}
]
}
diff --git a/ts/packages/core/test/fixtures/json-schema-conversion/generate-strict-cases.mjs b/ts/packages/core/test/fixtures/json-schema-conversion/generate-strict-cases.mjs
new file mode 100644
index 000000000..5483f77e7
--- /dev/null
+++ b/ts/packages/core/test/fixtures/json-schema-conversion/generate-strict-cases.mjs
@@ -0,0 +1,551 @@
+/**
+ * Regenerates strict-cases.json (both language copies) from the case inputs
+ * below, using the built @composio/core. Run from the repository root after
+ * `pnpm --filter @composio/core build`:
+ *
+ * node ts/packages/core/test/fixtures/json-schema-conversion/generate-strict-cases.mjs
+ *
+ * The JSON is the pinned contract; this script only derives it so both SDK
+ * test suites assert against identical expectations. Format the TypeScript
+ * copy with prettier before copying (the pre-commit hook would otherwise
+ * make the copies differ).
+ */
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const here = path.dirname(fileURLToPath(import.meta.url));
+const repoRoot = path.resolve(here, '../../../../../..');
+const { toStrictJsonSchema, omitNullToolArguments } = await import(
+ path.join(repoRoot, 'ts/packages/core/dist/index.mjs')
+);
+const obj = (properties, required, extra = {}) => ({
+ type: 'object',
+ properties,
+ ...(required ? { required } : {}),
+ ...extra,
+});
+const cases = [
+ [
+ 'flat-all-required-unchanged',
+ 'An already-strict schema is returned unchanged with no changes.',
+ obj({ query: { type: 'string' } }, ['query'], { additionalProperties: false }),
+ ],
+ [
+ 'nested-optional-property-widened',
+ 'Optional properties stay, become required and accept null at every depth.',
+ obj(
+ {
+ cfg: obj(
+ { url: { type: 'string' }, note: { type: 'string', description: 'optional note' } },
+ ['url']
+ ),
+ },
+ ['cfg']
+ ),
+ ],
+ [
+ 'no-required-array-widens-every-property',
+ 'An object without `required` requires and widens every property.',
+ obj({ a: { type: 'string' }, b: { type: 'number' } }),
+ ],
+ [
+ 'required-empty-array-widens-every-property',
+ 'An empty `required` array is the same as an absent one.',
+ obj({ a: { type: 'string' } }, []),
+ ],
+ [
+ 'nullable-type-array-kept',
+ 'A `type` array with null is accepted by the API and left alone.',
+ obj({ id: { type: ['string', 'null'], description: 'identifier' } }, ['id']),
+ ],
+ [
+ 'nullable-object-stays-nullable',
+ 'A nullable object keeps its type array; only its own properties are closed.',
+ obj(
+ { cfg: { type: ['object', 'null'], properties: { a: { type: 'string' } }, required: ['a'] } },
+ ['cfg']
+ ),
+ ],
+ [
+ 'nullable-array-kept',
+ 'A nullable array keeps its type array and items.',
+ obj({ xs: { type: ['array', 'null'], items: { type: 'string' } } }, ['xs']),
+ ],
+ [
+ 'optional-any-of-gets-null-branch',
+ 'An optional composition gains a null branch instead of a sibling type.',
+ obj({ value: { anyOf: [{ type: 'string' }, { type: 'number' }] } }),
+ ],
+ [
+ 'any-of-already-nullable-unchanged',
+ 'A composition that already accepts null is not widened twice.',
+ obj({ value: { anyOf: [{ type: 'string' }, { type: 'null' }] } }),
+ ],
+ [
+ 'optional-enum-only-wrapped',
+ 'An enum-only property is wrapped so the annotation stays outside the anyOf.',
+ obj({ choice: { enum: ['a', 'b'], description: 'pick one', title: 'Choice' } }),
+ ],
+ [
+ 'optional-const-wrapped',
+ 'A const-only property is wrapped in an anyOf with a null branch.',
+ obj({ kind: { const: 'fixed' } }),
+ ],
+ [
+ 'optional-empty-schema-unchanged',
+ 'An empty schema already accepts null and is left alone.',
+ obj({ anything: {} }),
+ ],
+ [
+ 'multi-type-array-gains-null',
+ 'A multi-type array gains null instead of being converted to anyOf.',
+ obj({ value: { type: ['string', 'number'] } }),
+ ],
+ [
+ 'one-of-converted-to-any-of',
+ 'oneOf is unsupported and becomes anyOf.',
+ obj({ either: { oneOf: [{ type: 'string' }, { type: 'number' }] } }, ['either']),
+ ],
+ [
+ 'array-items-object-normalized',
+ 'Objects inside array items are closed and widened.',
+ obj(
+ {
+ rows: {
+ type: 'array',
+ items: obj({ id: { type: 'string' }, tag: { type: 'string' } }, ['id']),
+ },
+ },
+ ['rows']
+ ),
+ ],
+ [
+ 'default-and-examples-stripped',
+ 'Annotation keywords the API rejects are stripped and reported.',
+ obj({ name: { type: 'string', examples: ['a'], default: 'x' } }, ['name']),
+ ],
+ [
+ 'enum-values-are-data-not-keywords',
+ 'Keys inside enum/const values are data and must not be treated as keywords.',
+ obj({ opts: { enum: [{ default: 1, properties: {} }, null] } }, ['opts']),
+ ],
+ [
+ 'property-names-are-not-keywords',
+ 'Properties named like keywords are ordinary properties.',
+ obj({
+ default: { type: 'string' },
+ $ref: { type: 'string' },
+ type: { type: 'string' },
+ properties: obj({ x: { type: 'string' } }),
+ }),
+ ],
+ [
+ 'prototype-key-property-name',
+ 'A property named __proto__ or constructor is handled as a plain name.',
+ JSON.parse(
+ '{"type":"object","properties":{"__proto__":{"type":"string"},"constructor":{"type":"number"}}}'
+ ),
+ ],
+ [
+ 'schema-valued-additional-properties-unsupported',
+ 'A map-style object cannot be expressed and is reported, not closed.',
+ obj({ headers: { type: 'object', additionalProperties: { type: 'string' } } }, ['headers']),
+ ],
+ [
+ 'additional-properties-true-unsupported',
+ 'An explicitly open object is reported.',
+ obj({ open: { type: 'object', additionalProperties: true } }, ['open']),
+ ],
+ [
+ 'additional-properties-empty-schema-unsupported',
+ 'An empty-schema additionalProperties accepts anything and is reported.',
+ obj({ open: { type: 'object', additionalProperties: {} } }, ['open']),
+ ],
+ [
+ 'free-form-object-unsupported',
+ 'A property-less object accepts arbitrary keys and is reported.',
+ obj({ meta: { type: 'object', description: 'any json' } }, ['meta']),
+ ],
+ [
+ 'pattern-properties-unsupported',
+ 'patternProperties cannot be expressed and is reported.',
+ obj({ tagged: { type: 'object', patternProperties: { '^x-': { type: 'string' } } } }, [
+ 'tagged',
+ ]),
+ ],
+ [
+ 'empty-closed-object-representable',
+ 'An object closed with no properties is representable.',
+ obj({ empty: { type: 'object', additionalProperties: false } }, ['empty']),
+ ],
+ [
+ 'all-of-unsupported',
+ 'allOf has no lossless rewrite and is reported.',
+ obj({ all: { allOf: [{ type: 'string' }] } }, ['all']),
+ ],
+ [
+ 'prefix-items-unsupported',
+ 'prefixItems has no lossless rewrite and is reported.',
+ obj({ pair: { type: 'array', prefixItems: [{ type: 'number' }] } }, ['pair']),
+ ],
+ [
+ 'defs-ref-kept-and-definition-normalized',
+ 'Local $refs are kept and the definition is normalized where it is declared.',
+ obj({ cfg: { $ref: '#/$defs/Config' } }, ['cfg'], {
+ $defs: { Config: obj({ url: { type: 'string' }, note: { type: 'string' } }, ['url']) },
+ }),
+ ],
+ [
+ 'optional-ref-widened-with-null-branch',
+ 'An optional $ref property is widened with an anyOf null branch.',
+ obj({ cfg: { $ref: '#/$defs/Config', description: 'optional' } }, undefined, {
+ $defs: { Config: obj({ url: { type: 'string' } }, ['url']) },
+ }),
+ ],
+ [
+ 'recursive-defs-kept',
+ 'Self-recursive definitions are representable.',
+ obj({ node: { $ref: '#/$defs/Node' } }, ['node'], {
+ $defs: {
+ Node: obj({ child: { $ref: '#/$defs/Node' }, label: { type: 'string' } }, ['label']),
+ },
+ }),
+ ],
+ [
+ 'mutually-recursive-defs-kept',
+ 'Mutually recursive definitions are representable.',
+ obj({ a: { $ref: '#/$defs/A' } }, ['a'], {
+ $defs: { A: obj({ b: { $ref: '#/$defs/B' } }), B: obj({ a: { $ref: '#/$defs/A' } }) },
+ }),
+ ],
+ [
+ 'legacy-definitions-ref-kept',
+ 'Legacy definitions are supported like $defs.',
+ obj({ cfg: { $ref: '#/definitions/Config' } }, ['cfg'], {
+ definitions: { Config: obj({ url: { type: 'string' } }) },
+ }),
+ ],
+ [
+ 'ref-into-properties-kept',
+ 'A local $ref outside $defs resolves and is kept.',
+ obj({ a: obj({ x: { type: 'string' } }, ['x']), b: { $ref: '#/properties/a' } }, ['a', 'b']),
+ ],
+ [
+ 'dangling-ref-unsupported',
+ 'A $ref without a target is reported at its own path.',
+ obj({ cfg: { $ref: '#/$defs/Nope' } }, ['cfg']),
+ ],
+ [
+ 'external-ref-unsupported',
+ 'A $ref outside the document is reported.',
+ obj({ cfg: { $ref: 'https://example.com/schema.json' } }, ['cfg']),
+ ],
+ [
+ 'duplicate-required-deduped',
+ 'Duplicate required entries are removed.',
+ obj({ a: { type: 'string' } }, ['a', 'a']),
+ ],
+ [
+ 'required-unknown-names-dropped',
+ 'Required names without a property are dropped from required.',
+ obj({ a: { type: 'string' } }, ['a', 'ghost']),
+ ],
+ [
+ 'required-not-an-array-ignored',
+ 'A malformed required is treated as absent.',
+ obj({ a: { type: 'string' } }, 'a'),
+ ],
+ [
+ 'description-kept-on-widened-node',
+ 'Annotations survive widening.',
+ obj({ a: { type: 'integer', description: 'count', title: 'Count', minimum: 0 } }),
+ ],
+ ['non-object-root-unsupported', 'The root must be an object.', { type: 'string' }],
+ [
+ 'nullable-root-unsupported',
+ 'The root must not be nullable.',
+ { type: ['object', 'null'], properties: { a: { type: 'string' } } },
+ ],
+ [
+ 'properties-without-type-become-object',
+ 'A node with properties but no type is treated as an object.',
+ obj({ cfg: { properties: { a: { type: 'string' } } } }, ['cfg']),
+ ],
+ [
+ 'root-without-type-become-object',
+ 'A root with properties but no type is treated as an object.',
+ { properties: { a: { type: 'string' } } },
+ ],
+ // Edge cases enumerated independently with a second model.
+ [
+ 'root-single-element-type-array-accepted',
+ 'A root typed ["object"] is an object root.',
+ { type: ['object'], properties: { a: { type: 'string' } }, required: ['a'] },
+ ],
+ [
+ 'three-member-type-array-gains-null',
+ 'A three-member type array gains null once.',
+ obj({ v: { type: ['string', 'number', 'boolean'] } }),
+ ],
+ [
+ 'optional-null-only-property-unchanged',
+ 'A property typed null already accepts null.',
+ obj({ nothing: { type: 'null' } }),
+ ],
+ [
+ 'optional-enum-with-null-not-rewrapped',
+ 'An enum that already lists null is not wrapped again.',
+ obj({ choice: { enum: ['a', null] } }),
+ ],
+ [
+ 'optional-const-null-not-rewrapped',
+ 'A const null already accepts null.',
+ obj({ nothing: { const: null } }),
+ ],
+ [
+ 'nested-any-of-branch-widened',
+ 'Optional properties inside anyOf branches are widened.',
+ obj({ v: { anyOf: [obj({ a: { type: 'string' } }), { type: 'string' }] } }, ['v']),
+ ],
+ [
+ 'array-of-nullable-objects-closed',
+ 'Nullable objects inside array items are closed and stay nullable.',
+ obj(
+ {
+ rows: {
+ type: 'array',
+ items: { type: ['object', 'null'], properties: { id: { type: 'string' } } },
+ },
+ },
+ ['rows']
+ ),
+ ],
+ [
+ 'tuple-form-items-unsupported',
+ 'Draft-4 tuple items have no strict-mode equivalent.',
+ obj({ pair: { type: 'array', items: [{ type: 'number' }, { type: 'string' }] } }, ['pair']),
+ ],
+ [
+ 'boolean-items-unsupported',
+ 'A boolean items subschema is reported.',
+ obj({ xs: { type: 'array', items: true } }, ['xs']),
+ ],
+ [
+ 'not-keyword-unsupported',
+ 'not has no strict-mode equivalent.',
+ obj({ v: { not: { type: 'string' } } }, ['v']),
+ ],
+ [
+ 'if-then-else-unsupported',
+ 'Conditional keywords have no strict-mode equivalent.',
+ obj(
+ { v: { type: 'string', if: { minLength: 1 }, then: { maxLength: 5 }, else: { const: '' } } },
+ ['v']
+ ),
+ ],
+ [
+ 'dependent-schemas-unsupported',
+ 'dependentSchemas has no strict-mode equivalent.',
+ obj({ a: { type: 'string' } }, ['a'], {
+ dependentSchemas: { a: obj({ b: { type: 'string' } }) },
+ }),
+ ],
+ [
+ 'property-names-keyword-unsupported',
+ 'propertyNames has no strict-mode equivalent.',
+ obj({ a: { type: 'string' } }, ['a'], { propertyNames: { pattern: '^a' } }),
+ ],
+ [
+ 'one-of-beside-any-of-unsupported',
+ 'oneOf next to anyOf cannot be merged and is reported.',
+ obj({ v: { anyOf: [{ type: 'string' }], oneOf: [{ type: 'number' }] } }, ['v']),
+ ],
+ [
+ 'boolean-property-subschema-unsupported',
+ 'A boolean property subschema is reported.',
+ obj({ anything: true, nothing: false }, ['anything', 'nothing']),
+ ],
+ [
+ 'properties-not-an-object-unsupported',
+ 'A malformed properties value is reported instead of emptied.',
+ obj('not-a-map', ['a']),
+ ],
+ [
+ 'ref-with-siblings-kept',
+ 'Sibling keywords next to a $ref are kept.',
+ obj({ cfg: { $ref: '#/$defs/Config', description: 'cfg', title: 'Config' } }, ['cfg'], {
+ $defs: { Config: obj({ a: { type: 'string' } }, ['a']) },
+ }),
+ ],
+ [
+ 'required-non-string-entries-ignored',
+ 'Non-string required entries are ignored.',
+ obj({ a: { type: 'string' }, b: { type: 'string' } }, ['a', 1, null]),
+ ],
+ [
+ 'dynamic-keys-reported-once-with-pattern-properties',
+ 'additionalProperties and patternProperties on one node report additionalProperties.',
+ obj(
+ {
+ m: {
+ type: 'object',
+ additionalProperties: { type: 'string' },
+ patternProperties: { '^x': { type: 'string' } },
+ },
+ },
+ ['m']
+ ),
+ ],
+ [
+ 'empty-properties-open-object-unsupported',
+ 'An object with empty properties and no closing is free-form.',
+ obj({ m: { type: 'object', properties: {} } }, ['m']),
+ ],
+ [
+ 'default-stripped-then-widened',
+ 'Stripping default and widening compose.',
+ obj({ a: { type: 'string', default: 'x' } }),
+ ],
+ [
+ 'nested-any-of-in-any-of-kept',
+ 'A composition nested inside a composition is normalized branch by branch.',
+ obj(
+ {
+ v: {
+ anyOf: [
+ { anyOf: [obj({ a: { type: 'string' } }), { type: 'number' }] },
+ { type: 'string' },
+ ],
+ },
+ },
+ ['v']
+ ),
+ ],
+ [
+ 'definitions-and-defs-both-normalized',
+ 'Legacy definitions and $defs coexist and both are normalized.',
+ obj({ a: { $ref: '#/$defs/A' }, b: { $ref: '#/definitions/B' } }, ['a', 'b'], {
+ $defs: { A: obj({ x: { type: 'string' } }) },
+ definitions: { B: obj({ y: { type: 'string' } }) },
+ }),
+ ],
+ [
+ 'deep-nesting-normalized-fully',
+ 'Ten levels of nested objects are normalized at every level.',
+ (() => {
+ let node = { type: 'object', properties: { leaf: { type: 'string' } } };
+ for (let i = 0; i < 10; i++)
+ node = { type: 'object', properties: { child: node }, required: ['child'] };
+ return node;
+ })(),
+ ],
+ [
+ 'chained-refs-resolved',
+ 'A $ref to a $ref resolves to the final definition.',
+ obj({ a: { $ref: '#/$defs/Alias' } }, ['a'], {
+ $defs: { Alias: { $ref: '#/$defs/Real' }, Real: obj({ x: { type: 'string' } }, ['x']) },
+ }),
+ ],
+];
+const argumentCases = {
+ 'nested-optional-property-widened': [
+ { input: { cfg: { url: 'u', note: null } }, output: { cfg: { url: 'u' } } },
+ ],
+ 'nullable-type-array-kept': [{ input: { id: null }, output: { id: null } }],
+ 'nullable-object-stays-nullable': [
+ { input: { cfg: null }, output: { cfg: null } },
+ { input: { cfg: { a: 'x' } }, output: { cfg: { a: 'x' } } },
+ ],
+ 'any-of-already-nullable-unchanged': [{ input: { value: null }, output: { value: null } }],
+ 'optional-enum-only-wrapped': [{ input: { choice: null }, output: {} }],
+ 'array-items-object-normalized': [
+ { input: { rows: [{ id: '1', tag: null }, null] }, output: { rows: [{ id: '1' }, null] } },
+ ],
+ 'enum-values-are-data-not-keywords': [{ input: { opts: null }, output: { opts: null } }],
+ 'property-names-are-not-keywords': [
+ {
+ input: { default: null, $ref: 'x', type: null, properties: { x: null } },
+ output: { $ref: 'x', properties: {} },
+ },
+ ],
+ 'defs-ref-kept-and-definition-normalized': [
+ { input: { cfg: { url: 'u', note: null } }, output: { cfg: { url: 'u' } } },
+ ],
+ 'optional-ref-widened-with-null-branch': [{ input: { cfg: null }, output: {} }],
+ 'recursive-defs-kept': [
+ {
+ input: { node: { label: 'a', child: { label: 'b', child: null } } },
+ output: { node: { label: 'a', child: { label: 'b' } } },
+ },
+ ],
+ 'no-required-array-widens-every-property': [
+ { input: { a: null, b: 1, unknown: null }, output: { b: 1, unknown: null } },
+ ],
+ 'optional-null-only-property-unchanged': [
+ { input: { nothing: null }, output: { nothing: null } },
+ ],
+ 'optional-enum-with-null-not-rewrapped': [{ input: { choice: null }, output: { choice: null } }],
+ 'optional-const-null-not-rewrapped': [{ input: { nothing: null }, output: { nothing: null } }],
+ 'array-of-nullable-objects-closed': [
+ { input: { rows: [null, { id: null }] }, output: { rows: [null, {}] } },
+ ],
+ 'nested-any-of-branch-widened': [
+ { input: { v: { a: null } }, output: { v: {} } },
+ { input: { v: null }, output: {} },
+ ],
+ 'nested-any-of-in-any-of-kept': [{ input: { v: { a: null } }, output: { v: {} } }],
+ 'chained-refs-resolved': [
+ { input: { a: { x: null } }, output: { a: {} } },
+ { input: { a: null }, output: {} },
+ ],
+ 'nullable-array-kept': [
+ { input: { xs: null }, output: { xs: null } },
+ { input: { xs: [null] }, output: { xs: [null] } },
+ ],
+ 'nested-optional-property-widened': [
+ { input: { cfg: { url: 'u', note: null } }, output: { cfg: { url: 'u' } } },
+ { input: { cfg: null }, output: {} },
+ { input: { cfg: { url: 'u', extra: null } }, output: { cfg: { url: 'u', extra: null } } },
+ ],
+};
+const out = { cases: [] };
+for (const [id, description, schema] of cases) {
+ const snapshot = JSON.stringify(schema);
+ const r = toStrictJsonSchema(schema);
+ if (JSON.stringify(schema) !== snapshot) throw new Error(`mutated: ${id}`);
+ const entry = { id, description, schema };
+ if (r.unsupported.length)
+ entry.strict = { unsupported: r.unsupported.map(u => ({ path: u.path, keyword: u.keyword })) };
+ else {
+ const again = toStrictJsonSchema(r.schema);
+ if (JSON.stringify(again.schema) !== JSON.stringify(r.schema) || again.changes.length)
+ throw new Error(`not idempotent: ${id}`);
+ entry.strict = { schema: r.schema };
+ }
+ if (r.changes.length) entry.changes = r.changes.map(c => ({ path: c.path, reason: c.reason }));
+ if (argumentCases[id]) {
+ entry.arguments = argumentCases[id].map(({ input, output }) => {
+ const actual = omitNullToolArguments(input, r.source);
+ if (JSON.stringify(actual) !== JSON.stringify(output))
+ throw new Error(
+ `arguments mismatch ${id}: ${JSON.stringify(actual)} vs ${JSON.stringify(output)}`
+ );
+ return { input, output };
+ });
+ }
+ out.cases.push(entry);
+}
+const json = JSON.stringify(out, null, 2) + '\n';
+fs.writeFileSync(path.join(here, 'strict-cases.json'), json);
+fs.writeFileSync(
+ path.join(repoRoot, 'python/tests/fixtures/json-schema-conversion/strict-cases.json'),
+ json
+);
+for (const c of out.cases)
+ console.log(
+ c.id.padEnd(50),
+ c.strict.unsupported
+ ? 'UNSUPPORTED ' + JSON.stringify(c.strict.unsupported)
+ : 'ok' + (c.changes ? ' changes=' + c.changes.map(x => x.reason.split('-')[0]).join(',') : '')
+ );
diff --git a/ts/packages/core/test/fixtures/json-schema-conversion/strict-cases.json b/ts/packages/core/test/fixtures/json-schema-conversion/strict-cases.json
index 9c9b67954..4cf465516 100644
--- a/ts/packages/core/test/fixtures/json-schema-conversion/strict-cases.json
+++ b/ts/packages/core/test/fixtures/json-schema-conversion/strict-cases.json
@@ -90,6 +90,26 @@
"url": "u"
}
}
+ },
+ {
+ "input": {
+ "cfg": null
+ },
+ "output": {}
+ },
+ {
+ "input": {
+ "cfg": {
+ "url": "u",
+ "extra": null
+ }
+ },
+ "output": {
+ "cfg": {
+ "url": "u",
+ "extra": null
+ }
+ }
}
]
},
@@ -303,7 +323,25 @@
"required": ["xs"],
"additionalProperties": false
}
- }
+ },
+ "arguments": [
+ {
+ "input": {
+ "xs": null
+ },
+ "output": {
+ "xs": null
+ }
+ },
+ {
+ "input": {
+ "xs": [null]
+ },
+ "output": {
+ "xs": [null]
+ }
+ }
+ ]
},
{
"id": "optional-any-of-gets-null-branch",
@@ -670,65 +708,6 @@
}
]
},
- {
- "id": "tuple-items-normalized",
- "description": "Objects inside tuple-form items are normalized too.",
- "schema": {
- "type": "object",
- "properties": {
- "pair": {
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "x": {
- "type": "number"
- }
- }
- },
- {
- "type": "string"
- }
- ]
- }
- },
- "required": ["pair"]
- },
- "strict": {
- "schema": {
- "type": "object",
- "properties": {
- "pair": {
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "x": {
- "type": ["number", "null"]
- }
- },
- "required": ["x"],
- "additionalProperties": false
- },
- {
- "type": "string"
- }
- ]
- }
- },
- "required": ["pair"],
- "additionalProperties": false
- }
- },
- "changes": [
- {
- "path": "properties.pair.items[0].properties.x",
- "reason": "optional-property-nullable"
- }
- ]
- },
{
"id": "default-and-examples-stripped",
"description": "Annotation keywords the API rejects are stripped and reported.",
@@ -1830,6 +1809,1139 @@
"reason": "optional-property-nullable"
}
]
+ },
+ {
+ "id": "root-single-element-type-array-accepted",
+ "description": "A root typed [\"object\"] is an object root.",
+ "schema": {
+ "type": ["object"],
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"]
+ },
+ "strict": {
+ "schema": {
+ "type": ["object"],
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ }
+ },
+ {
+ "id": "three-member-type-array-gains-null",
+ "description": "A three-member type array gains null once.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "type": ["string", "number", "boolean"]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "type": ["string", "number", "boolean", "null"]
+ }
+ },
+ "required": ["v"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.v",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "optional-null-only-property-unchanged",
+ "description": "A property typed null already accepts null.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "type": "null"
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "type": "null"
+ }
+ },
+ "required": ["nothing"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.nothing",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "nothing": null
+ },
+ "output": {
+ "nothing": null
+ }
+ }
+ ]
+ },
+ {
+ "id": "optional-enum-with-null-not-rewrapped",
+ "description": "An enum that already lists null is not wrapped again.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "choice": {
+ "enum": ["a", null]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "choice": {
+ "enum": ["a", null]
+ }
+ },
+ "required": ["choice"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.choice",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "choice": null
+ },
+ "output": {
+ "choice": null
+ }
+ }
+ ]
+ },
+ {
+ "id": "optional-const-null-not-rewrapped",
+ "description": "A const null already accepts null.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "const": null
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "nothing": {
+ "const": null
+ }
+ },
+ "required": ["nothing"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.nothing",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "nothing": null
+ },
+ "output": {
+ "nothing": null
+ }
+ }
+ ]
+ },
+ {
+ "id": "nested-any-of-branch-widened",
+ "description": "Optional properties inside anyOf branches are widened.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.v.anyOf[0].properties.a",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "v": {
+ "a": null
+ }
+ },
+ "output": {
+ "v": {}
+ }
+ },
+ {
+ "input": {
+ "v": null
+ },
+ "output": {}
+ }
+ ]
+ },
+ {
+ "id": "array-of-nullable-objects-closed",
+ "description": "Nullable objects inside array items are closed and stay nullable.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "rows": {
+ "type": "array",
+ "items": {
+ "type": ["object", "null"],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "required": ["rows"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "rows": {
+ "type": "array",
+ "items": {
+ "type": ["object", "null"],
+ "properties": {
+ "id": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["id"],
+ "additionalProperties": false
+ }
+ }
+ },
+ "required": ["rows"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.rows.items.properties.id",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "rows": [
+ null,
+ {
+ "id": null
+ }
+ ]
+ },
+ "output": {
+ "rows": [null, {}]
+ }
+ }
+ ]
+ },
+ {
+ "id": "tuple-form-items-unsupported",
+ "description": "Draft-4 tuple items have no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "pair": {
+ "type": "array",
+ "items": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["pair"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.pair",
+ "keyword": "items"
+ }
+ ]
+ }
+ },
+ {
+ "id": "boolean-items-unsupported",
+ "description": "A boolean items subschema is reported.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "xs": {
+ "type": "array",
+ "items": true
+ }
+ },
+ "required": ["xs"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.xs",
+ "keyword": "items"
+ }
+ ]
+ }
+ },
+ {
+ "id": "not-keyword-unsupported",
+ "description": "not has no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "not": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.v",
+ "keyword": "not"
+ }
+ ]
+ }
+ },
+ {
+ "id": "if-then-else-unsupported",
+ "description": "Conditional keywords have no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "type": "string",
+ "if": {
+ "minLength": 1
+ },
+ "then": {
+ "maxLength": 5
+ },
+ "else": {
+ "const": ""
+ }
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.v",
+ "keyword": "else"
+ },
+ {
+ "path": "properties.v",
+ "keyword": "if"
+ },
+ {
+ "path": "properties.v",
+ "keyword": "then"
+ }
+ ]
+ }
+ },
+ {
+ "id": "dependent-schemas-unsupported",
+ "description": "dependentSchemas has no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "dependentSchemas": {
+ "a": {
+ "type": "object",
+ "properties": {
+ "b": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "",
+ "keyword": "dependentSchemas"
+ }
+ ]
+ },
+ "changes": [
+ {
+ "path": "dependentSchemas.a.properties.b",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "property-names-keyword-unsupported",
+ "description": "propertyNames has no strict-mode equivalent.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "propertyNames": {
+ "pattern": "^a"
+ }
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "",
+ "keyword": "propertyNames"
+ }
+ ]
+ }
+ },
+ {
+ "id": "one-of-beside-any-of-unsupported",
+ "description": "oneOf next to anyOf cannot be merged and is reported.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "type": "string"
+ }
+ ],
+ "oneOf": [
+ {
+ "type": "number"
+ }
+ ]
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.v",
+ "keyword": "oneOf"
+ }
+ ]
+ }
+ },
+ {
+ "id": "boolean-property-subschema-unsupported",
+ "description": "A boolean property subschema is reported.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "anything": true,
+ "nothing": false
+ },
+ "required": ["anything", "nothing"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.anything",
+ "keyword": "properties"
+ },
+ {
+ "path": "properties.nothing",
+ "keyword": "properties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "properties-not-an-object-unsupported",
+ "description": "A malformed properties value is reported instead of emptied.",
+ "schema": {
+ "type": "object",
+ "properties": "not-a-map",
+ "required": ["a"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "",
+ "keyword": "properties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "ref-with-siblings-kept",
+ "description": "Sibling keywords next to a $ref are kept.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "cfg": {
+ "$ref": "#/$defs/Config",
+ "description": "cfg",
+ "title": "Config"
+ }
+ },
+ "required": ["cfg"],
+ "$defs": {
+ "Config": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "cfg": {
+ "$ref": "#/$defs/Config",
+ "description": "cfg",
+ "title": "Config"
+ }
+ },
+ "required": ["cfg"],
+ "$defs": {
+ "Config": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ {
+ "id": "required-non-string-entries-ignored",
+ "description": "Non-string required entries are ignored.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ },
+ "b": {
+ "type": "string"
+ }
+ },
+ "required": ["a", 1, null]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ },
+ "b": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a", "b"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.b",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "dynamic-keys-reported-once-with-pattern-properties",
+ "description": "additionalProperties and patternProperties on one node report additionalProperties.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "m": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "patternProperties": {
+ "^x": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "required": ["m"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.m",
+ "keyword": "additionalProperties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "empty-properties-open-object-unsupported",
+ "description": "An object with empty properties and no closing is free-form.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "m": {
+ "type": "object",
+ "properties": {}
+ }
+ },
+ "required": ["m"]
+ },
+ "strict": {
+ "unsupported": [
+ {
+ "path": "properties.m",
+ "keyword": "properties"
+ }
+ ]
+ }
+ },
+ {
+ "id": "default-stripped-then-widened",
+ "description": "Stripping default and widening compose.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string",
+ "default": "x"
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.a",
+ "reason": "unsupported-keyword-stripped"
+ },
+ {
+ "path": "properties.a",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "nested-any-of-in-any-of-kept",
+ "description": "A composition nested inside a composition is normalized branch by branch.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "type": "number"
+ }
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "v": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ },
+ {
+ "type": "number"
+ }
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "required": ["v"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.v.anyOf[0].anyOf[0].properties.a",
+ "reason": "optional-property-nullable"
+ }
+ ],
+ "arguments": [
+ {
+ "input": {
+ "v": {
+ "a": null
+ }
+ },
+ "output": {
+ "v": {}
+ }
+ }
+ ]
+ },
+ {
+ "id": "definitions-and-defs-both-normalized",
+ "description": "Legacy definitions and $defs coexist and both are normalized.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/A"
+ },
+ "b": {
+ "$ref": "#/definitions/B"
+ }
+ },
+ "required": ["a", "b"],
+ "$defs": {
+ "A": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "definitions": {
+ "B": {
+ "type": "object",
+ "properties": {
+ "y": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/A"
+ },
+ "b": {
+ "$ref": "#/definitions/B"
+ }
+ },
+ "required": ["a", "b"],
+ "$defs": {
+ "A": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["x"],
+ "additionalProperties": false
+ }
+ },
+ "definitions": {
+ "B": {
+ "type": "object",
+ "properties": {
+ "y": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["y"],
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "$defs.A.properties.x",
+ "reason": "optional-property-nullable"
+ },
+ {
+ "path": "definitions.B.properties.y",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "deep-nesting-normalized-fully",
+ "description": "Ten levels of nested objects are normalized at every level.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "leaf": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ }
+ },
+ "required": ["child"]
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "child": {
+ "type": "object",
+ "properties": {
+ "leaf": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["leaf"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "required": ["child"],
+ "additionalProperties": false
+ }
+ },
+ "changes": [
+ {
+ "path": "properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.leaf",
+ "reason": "optional-property-nullable"
+ }
+ ]
+ },
+ {
+ "id": "chained-refs-resolved",
+ "description": "A $ref to a $ref resolves to the final definition.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/Alias"
+ }
+ },
+ "required": ["a"],
+ "$defs": {
+ "Alias": {
+ "$ref": "#/$defs/Real"
+ },
+ "Real": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "string"
+ }
+ },
+ "required": ["x"]
+ }
+ }
+ },
+ "strict": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/$defs/Alias"
+ }
+ },
+ "required": ["a"],
+ "$defs": {
+ "Alias": {
+ "$ref": "#/$defs/Real"
+ },
+ "Real": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "string"
+ }
+ },
+ "required": ["x"],
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "arguments": [
+ {
+ "input": {
+ "a": {
+ "x": null
+ }
+ },
+ "output": {
+ "a": {}
+ }
+ },
+ {
+ "input": {
+ "a": null
+ },
+ "output": {}
+ }
+ ]
}
]
}