Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
test(json-schema): drive strict-mode cases from a shared corpus
jkomyno3ca07210d3e2
diff --git a/python/tests/fixtures/json-schema-conversion/strict-cases.json b/python/tests/fixtures/json-schema-conversion/strict-cases.jsonnew file mode 100644index 000000000..9c9b67954--- /dev/null+++ b/python/tests/fixtures/json-schema-conversion/strict-cases.json@@ -0,0 +1,1835 @@+{+ "cases": [+ {+ "id": "flat-all-required-unchanged",+ "description": "An already-strict schema is returned unchanged with no changes.",+ "schema": {+ "type": "object",+ "properties": {+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "additionalProperties": false+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "nested-optional-property-widened",+ "description": "Optional properties stay, become required and accept null at every depth.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": "string",+ "description": "optional note"+ }+ },+ "required": ["url"]+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": ["string", "null"],+ "description": "optional note"+ }+ },+ "required": ["url", "note"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.cfg.properties.note",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "cfg": {+ "url": "u",+ "note": null+ }+ },+ "output": {+ "cfg": {+ "url": "u"+ }+ }+ }+ ]+ },+ {+ "id": "no-required-array-widens-every-property",+ "description": "An object without `required` requires and widens every property.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ },+ "b": {+ "type": "number"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["string", "null"]+ },+ "b": {+ "type": ["number", "null"]+ }+ },+ "required": ["a", "b"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.b",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "a": null,+ "b": 1,+ "unknown": null+ },+ "output": {+ "b": 1,+ "unknown": null+ }+ }+ ]+ },+ {+ "id": "required-empty-array-widens-every-property",+ "description": "An empty `required` array is the same as an absent one.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": []+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "nullable-type-array-kept",+ "description": "A `type` array with null is accepted by the API and left alone.",+ "schema": {+ "type": "object",+ "properties": {+ "id": {+ "type": ["string", "null"],+ "description": "identifier"+ }+ },+ "required": ["id"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "id": {+ "type": ["string", "null"],+ "description": "identifier"+ }+ },+ "required": ["id"],+ "additionalProperties": false+ }+ },+ "arguments": [+ {+ "input": {+ "id": null+ },+ "output": {+ "id": null+ }+ }+ ]+ },+ {+ "id": "nullable-object-stays-nullable",+ "description": "A nullable object keeps its type array; only its own properties are closed.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": ["object", "null"],+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"]+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": ["object", "null"],+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "arguments": [+ {+ "input": {+ "cfg": null+ },+ "output": {+ "cfg": null+ }+ },+ {+ "input": {+ "cfg": {+ "a": "x"+ }+ },+ "output": {+ "cfg": {+ "a": "x"+ }+ }+ }+ ]+ },+ {+ "id": "nullable-array-kept",+ "description": "A nullable array keeps its type array and items.",+ "schema": {+ "type": "object",+ "properties": {+ "xs": {+ "type": ["array", "null"],+ "items": {+ "type": "string"+ }+ }+ },+ "required": ["xs"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "xs": {+ "type": ["array", "null"],+ "items": {+ "type": "string"+ }+ }+ },+ "required": ["xs"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "optional-any-of-gets-null-branch",+ "description": "An optional composition gains a null branch instead of a sibling type.",+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ }+ ]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["value"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.value",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "any-of-already-nullable-unchanged",+ "description": "A composition that already accepts null is not widened twice.",+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["value"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.value",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "value": null+ },+ "output": {+ "value": null+ }+ }+ ]+ },+ {+ "id": "optional-enum-only-wrapped",+ "description": "An enum-only property is wrapped so the annotation stays outside the anyOf.",+ "schema": {+ "type": "object",+ "properties": {+ "choice": {+ "enum": ["a", "b"],+ "description": "pick one",+ "title": "Choice"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "choice": {+ "description": "pick one",+ "title": "Choice",+ "anyOf": [+ {+ "enum": ["a", "b"]+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["choice"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.choice",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "choice": null+ },+ "output": {}+ }+ ]+ },+ {+ "id": "optional-const-wrapped",+ "description": "A const-only property is wrapped in an anyOf with a null branch.",+ "schema": {+ "type": "object",+ "properties": {+ "kind": {+ "const": "fixed"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "kind": {+ "anyOf": [+ {+ "const": "fixed"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["kind"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.kind",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "optional-empty-schema-unchanged",+ "description": "An empty schema already accepts null and is left alone.",+ "schema": {+ "type": "object",+ "properties": {+ "anything": {}+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "anything": {}+ },+ "required": ["anything"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.anything",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "multi-type-array-gains-null",+ "description": "A multi-type array gains null instead of being converted to anyOf.",+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "type": ["string", "number"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "type": ["string", "number", "null"]+ }+ },+ "required": ["value"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.value",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "one-of-converted-to-any-of",+ "description": "oneOf is unsupported and becomes anyOf.",+ "schema": {+ "type": "object",+ "properties": {+ "either": {+ "oneOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ }+ ]+ }+ },+ "required": ["either"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "either": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ }+ ]+ }+ },+ "required": ["either"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.either",+ "reason": "one-of-converted"+ }+ ]+ },+ {+ "id": "array-items-object-normalized",+ "description": "Objects inside array items are closed and widened.",+ "schema": {+ "type": "object",+ "properties": {+ "rows": {+ "type": "array",+ "items": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string"+ },+ "tag": {+ "type": "string"+ }+ },+ "required": ["id"]+ }+ }+ },+ "required": ["rows"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "rows": {+ "type": "array",+ "items": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string"+ },+ "tag": {+ "type": ["string", "null"]+ }+ },+ "required": ["id", "tag"],+ "additionalProperties": false+ }+ }+ },+ "required": ["rows"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.rows.items.properties.tag",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "rows": [+ {+ "id": "1",+ "tag": null+ },+ null+ ]+ },+ "output": {+ "rows": [+ {+ "id": "1"+ },+ null+ ]+ }+ }+ ]+ },+ {+ "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.",+ "schema": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string",+ "examples": ["a"],+ "default": "x"+ }+ },+ "required": ["name"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string"+ }+ },+ "required": ["name"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.name",+ "reason": "unsupported-keyword-stripped"+ },+ {+ "path": "properties.name",+ "reason": "unsupported-keyword-stripped"+ }+ ]+ },+ {+ "id": "enum-values-are-data-not-keywords",+ "description": "Keys inside enum/const values are data and must not be treated as keywords.",+ "schema": {+ "type": "object",+ "properties": {+ "opts": {+ "enum": [+ {+ "default": 1,+ "properties": {}+ },+ null+ ]+ }+ },+ "required": ["opts"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "opts": {+ "enum": [+ {+ "default": 1,+ "properties": {}+ },+ null+ ]+ }+ },+ "required": ["opts"],+ "additionalProperties": false+ }+ },+ "arguments": [+ {+ "input": {+ "opts": null+ },+ "output": {+ "opts": null+ }+ }+ ]+ },+ {+ "id": "property-names-are-not-keywords",+ "description": "Properties named like keywords are ordinary properties.",+ "schema": {+ "type": "object",+ "properties": {+ "default": {+ "type": "string"+ },+ "$ref": {+ "type": "string"+ },+ "type": {+ "type": "string"+ },+ "properties": {+ "type": "object",+ "properties": {+ "x": {+ "type": "string"+ }+ }+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "default": {+ "type": ["string", "null"]+ },+ "$ref": {+ "type": ["string", "null"]+ },+ "type": {+ "type": ["string", "null"]+ },+ "properties": {+ "type": ["object", "null"],+ "properties": {+ "x": {+ "type": ["string", "null"]+ }+ },+ "required": ["x"],+ "additionalProperties": false+ }+ },+ "required": ["default", "$ref", "type", "properties"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.properties.properties.x",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.default",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.$ref",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.type",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.properties",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "default": null,+ "$ref": "x",+ "type": null,+ "properties": {+ "x": null+ }+ },+ "output": {+ "$ref": "x",+ "properties": {}+ }+ }+ ]+ },+ {+ "id": "prototype-key-property-name",+ "description": "A property named __proto__ or constructor is handled as a plain name.",+ "schema": {+ "type": "object",+ "properties": {+ "__proto__": {+ "type": "string"+ },+ "constructor": {+ "type": "number"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "__proto__": {+ "type": ["string", "null"]+ },+ "constructor": {+ "type": ["number", "null"]+ }+ },+ "required": ["__proto__", "constructor"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.__proto__",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.constructor",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "schema-valued-additional-properties-unsupported",+ "description": "A map-style object cannot be expressed and is reported, not closed.",+ "schema": {+ "type": "object",+ "properties": {+ "headers": {+ "type": "object",+ "additionalProperties": {+ "type": "string"+ }+ }+ },+ "required": ["headers"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.headers",+ "keyword": "additionalProperties"+ }+ ]+ }+ },+ {+ "id": "additional-properties-true-unsupported",+ "description": "An explicitly open object is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "open": {+ "type": "object",+ "additionalProperties": true+ }+ },+ "required": ["open"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.open",+ "keyword": "additionalProperties"+ }+ ]+ }+ },+ {+ "id": "additional-properties-empty-schema-unsupported",+ "description": "An empty-schema additionalProperties accepts anything and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "open": {+ "type": "object",+ "additionalProperties": {}+ }+ },+ "required": ["open"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.open",+ "keyword": "additionalProperties"+ }+ ]+ }+ },+ {+ "id": "free-form-object-unsupported",+ "description": "A property-less object accepts arbitrary keys and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "meta": {+ "type": "object",+ "description": "any json"+ }+ },+ "required": ["meta"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.meta",+ "keyword": "properties"+ }+ ]+ }+ },+ {+ "id": "pattern-properties-unsupported",+ "description": "patternProperties cannot be expressed and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "tagged": {+ "type": "object",+ "patternProperties": {+ "^x-": {+ "type": "string"+ }+ }+ }+ },+ "required": ["tagged"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.tagged",+ "keyword": "patternProperties"+ }+ ]+ }+ },+ {+ "id": "empty-closed-object-representable",+ "description": "An object closed with no properties is representable.",+ "schema": {+ "type": "object",+ "properties": {+ "empty": {+ "type": "object",+ "additionalProperties": false+ }+ },+ "required": ["empty"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "empty": {+ "type": "object",+ "additionalProperties": false,+ "properties": {},+ "required": []+ }+ },+ "required": ["empty"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "all-of-unsupported",+ "description": "allOf has no lossless rewrite and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "all": {+ "allOf": [+ {+ "type": "string"+ }+ ]+ }+ },+ "required": ["all"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.all",+ "keyword": "allOf"+ }+ ]+ }+ },+ {+ "id": "prefix-items-unsupported",+ "description": "prefixItems has no lossless rewrite and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "pair": {+ "type": "array",+ "prefixItems": [+ {+ "type": "number"+ }+ ]+ }+ },+ "required": ["pair"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.pair",+ "keyword": "prefixItems"+ }+ ]+ }+ },+ {+ "id": "defs-ref-kept-and-definition-normalized",+ "description": "Local $refs are kept and the definition is normalized where it is declared.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Config"+ }+ },+ "required": ["cfg"],+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": "string"+ }+ },+ "required": ["url"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Config"+ }+ },+ "required": ["cfg"],+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": ["string", "null"]+ }+ },+ "required": ["url", "note"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "$defs.Config.properties.note",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "cfg": {+ "url": "u",+ "note": null+ }+ },+ "output": {+ "cfg": {+ "url": "u"+ }+ }+ }+ ]+ },+ {+ "id": "optional-ref-widened-with-null-branch",+ "description": "An optional $ref property is widened with an anyOf null branch.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Config",+ "description": "optional"+ }+ },+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ }+ },+ "required": ["url"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "description": "optional",+ "anyOf": [+ {+ "$ref": "#/$defs/Config"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ }+ },+ "required": ["url"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.cfg",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "cfg": null+ },+ "output": {}+ }+ ]+ },+ {+ "id": "recursive-defs-kept",+ "description": "Self-recursive definitions are representable.",+ "schema": {+ "type": "object",+ "properties": {+ "node": {+ "$ref": "#/$defs/Node"+ }+ },+ "required": ["node"],+ "$defs": {+ "Node": {+ "type": "object",+ "properties": {+ "child": {+ "$ref": "#/$defs/Node"+ },+ "label": {+ "type": "string"+ }+ },+ "required": ["label"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "node": {+ "$ref": "#/$defs/Node"+ }+ },+ "required": ["node"],+ "$defs": {+ "Node": {+ "type": "object",+ "properties": {+ "child": {+ "anyOf": [+ {+ "$ref": "#/$defs/Node"+ },+ {+ "type": "null"+ }+ ]+ },+ "label": {+ "type": "string"+ }+ },+ "required": ["child", "label"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "$defs.Node.properties.child",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "node": {+ "label": "a",+ "child": {+ "label": "b",+ "child": null+ }+ }+ },+ "output": {+ "node": {+ "label": "a",+ "child": {+ "label": "b"+ }+ }+ }+ }+ ]+ },+ {+ "id": "mutually-recursive-defs-kept",+ "description": "Mutually recursive definitions are representable.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "$ref": "#/$defs/A"+ }+ },+ "required": ["a"],+ "$defs": {+ "A": {+ "type": "object",+ "properties": {+ "b": {+ "$ref": "#/$defs/B"+ }+ }+ },+ "B": {+ "type": "object",+ "properties": {+ "a": {+ "$ref": "#/$defs/A"+ }+ }+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "$ref": "#/$defs/A"+ }+ },+ "required": ["a"],+ "$defs": {+ "A": {+ "type": "object",+ "properties": {+ "b": {+ "anyOf": [+ {+ "$ref": "#/$defs/B"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["b"],+ "additionalProperties": false+ },+ "B": {+ "type": "object",+ "properties": {+ "a": {+ "anyOf": [+ {+ "$ref": "#/$defs/A"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "$defs.A.properties.b",+ "reason": "optional-property-nullable"+ },+ {+ "path": "$defs.B.properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "legacy-definitions-ref-kept",+ "description": "Legacy definitions are supported like $defs.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/definitions/Config"+ }+ },+ "required": ["cfg"],+ "definitions": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ }+ }+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/definitions/Config"+ }+ },+ "required": ["cfg"],+ "definitions": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": ["string", "null"]+ }+ },+ "required": ["url"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "definitions.Config.properties.url",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "ref-into-properties-kept",+ "description": "A local $ref outside $defs resolves and is kept.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "object",+ "properties": {+ "x": {+ "type": "string"+ }+ },+ "required": ["x"]+ },+ "b": {+ "$ref": "#/properties/a"+ }+ },+ "required": ["a", "b"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "object",+ "properties": {+ "x": {+ "type": "string"+ }+ },+ "required": ["x"],+ "additionalProperties": false+ },+ "b": {+ "$ref": "#/properties/a"+ }+ },+ "required": ["a", "b"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "dangling-ref-unsupported",+ "description": "A $ref without a target is reported at its own path.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Nope"+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.cfg",+ "keyword": "$ref"+ }+ ]+ }+ },+ {+ "id": "external-ref-unsupported",+ "description": "A $ref outside the document is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "https://example.com/schema.json"+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.cfg",+ "keyword": "$ref"+ }+ ]+ }+ },+ {+ "id": "duplicate-required-deduped",+ "description": "Duplicate required entries are removed.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a", "a"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "required-unknown-names-dropped",+ "description": "Required names without a property are dropped from required.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a", "ghost"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "required-not-an-array-ignored",+ "description": "A malformed required is treated as absent.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": "a"+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "description-kept-on-widened-node",+ "description": "Annotations survive widening.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "integer",+ "description": "count",+ "title": "Count",+ "minimum": 0+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["integer", "null"],+ "description": "count",+ "title": "Count",+ "minimum": 0+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "non-object-root-unsupported",+ "description": "The root must be an object.",+ "schema": {+ "type": "string"+ },+ "strict": {+ "unsupported": [+ {+ "path": "",+ "keyword": "type"+ }+ ]+ }+ },+ {+ "id": "nullable-root-unsupported",+ "description": "The root must not be nullable.",+ "schema": {+ "type": ["object", "null"],+ "properties": {+ "a": {+ "type": "string"+ }+ }+ },+ "strict": {+ "unsupported": [+ {+ "path": "",+ "keyword": "type"+ }+ ]+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "properties-without-type-become-object",+ "description": "A node with properties but no type is treated as an object.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "properties": {+ "a": {+ "type": "string"+ }+ }+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "type": "object",+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.cfg.properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "root-without-type-become-object",+ "description": "A root with properties but no type is treated as an object.",+ "schema": {+ "properties": {+ "a": {+ "type": "string"+ }+ }+ },+ "strict": {+ "schema": {+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "type": "object",+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ }+ ]+}diff --git a/python/tests/fixtures/json_schema_conversion_corpus.py b/python/tests/fixtures/json_schema_conversion_corpus.pyindex 1331079d7..fea81b4ab 100644--- a/python/tests/fixtures/json_schema_conversion_corpus.py+++ b/python/tests/fixtures/json_schema_conversion_corpus.py@@ -13,6 +13,9 @@ from pathlib import Pathfrom pydantic import BaseModel, ConfigDict, FieldCORPUS_PATH = Path(__file__).parent / "json-schema-conversion" / "object-cases.json"+STRICT_CORPUS_PATH = (+ Path(__file__).parent / "json-schema-conversion" / "strict-cases.json"+)Language = t.Literal["zod", "effect", "python"]LANGUAGES: t.Tuple[Language, ...] = ("zod", "effect", "python")@@ -125,3 +128,73 @@ def find_case(case_id: str) -> CorpusCase:if case.id == case_id:return caseraise LookupError(f"Corpus is missing the {case_id} case")+++class StrictIncompatibility(BaseModel):+ model_config = ConfigDict(extra="forbid")++ path: str+ keyword: str = Field(min_length=1)+++class StrictChange(BaseModel):+ model_config = ConfigDict(extra="forbid")++ path: str+ reason: str = Field(min_length=1)+++class StrictArguments(BaseModel):+ model_config = ConfigDict(extra="forbid")++ input: t.Dict[str, t.Any]+ output: t.Dict[str, t.Any]+++class StrictExpectation(BaseModel):+ """Either the exact strict schema, or the constructs reported as unsupported."""++ model_config = ConfigDict(extra="forbid")++ schema_: t.Optional[t.Dict[str, t.Any]] = Field(default=None, alias="schema")+ unsupported: t.Optional[t.List[StrictIncompatibility]] = Field(+ default=None, min_length=1+ )+++class StrictCase(BaseModel):+ model_config = ConfigDict(extra="forbid")++ id: str = Field(min_length=1)+ description: t.Optional[str] = None+ schema_: t.Dict[str, t.Any] = Field(alias="schema")+ strict: StrictExpectation+ changes: t.Optional[t.List[StrictChange]] = None+ arguments: t.Optional[t.List[StrictArguments]] = None+++class StrictCorpus(BaseModel):+ model_config = ConfigDict(extra="forbid")++ cases: t.List[StrictCase] = Field(min_length=1)+++_cached_strict: t.Optional[t.List[StrictCase]] = None+++def load_strict_cases() -> t.List[StrictCase]:+ """Decode the shared strict-mode corpus (byte-identical copy per language)."""+ global _cached_strict+ if _cached_strict is None:+ cases = StrictCorpus.model_validate(+ json.loads(STRICT_CORPUS_PATH.read_text())+ ).cases+ seen: t.Set[str] = set()+ for case in cases:+ if case.id in seen:+ raise ValueError(f"Duplicate strict case id: {case.id}")+ seen.add(case.id)+ if (case.strict.schema_ is None) == (case.strict.unsupported is None):+ raise ValueError(f"Strict case {case.id} must pin exactly one outcome")+ _cached_strict = cases+ return _cached_strictdiff --git a/python/tests/test_strict_schema_corpus.py b/python/tests/test_strict_schema_corpus.pynew file mode 100644index 000000000..e5a2caa83--- /dev/null+++ b/python/tests/test_strict_schema_corpus.py@@ -0,0 +1,80 @@+"""Drive to_strict_json_schema from the shared strict-mode corpus.++The corpus pins the exact output of the TypeScript implementation, so this+suite is the cross-SDK parity check for strict normalization.+"""++import copy++import pytest++from composio.utils.strict_schema import omit_null_tool_arguments, to_strict_json_schema+from tests.fixtures.json_schema_conversion_corpus import load_strict_cases+++def assert_strict_shape(node, path=""):+ """Structural invariants OpenAI enforces on every node of a strict schema."""+ if isinstance(node, list):+ for index, item in enumerate(node):+ assert_strict_shape(item, f"{path}[{index}]")+ return+ if not isinstance(node, dict):+ return+ if "anyOf" in node:+ assert "type" not in node, f"{path}: type beside anyOf"+ for keyword in (+ "default",+ "examples",+ "oneOf",+ "patternProperties",+ "allOf",+ "prefixItems",+ ):+ assert keyword not in node, f"{path}: {keyword}"+ node_type = node.get("type")+ is_object = node_type == "object" or (+ isinstance(node_type, list) and "object" in node_type+ )+ if is_object or "properties" in node:+ properties = node.get("properties") or {}+ assert node.get("required") == list(properties.keys()), f"{path}: required"+ assert node.get("additionalProperties") is False, (+ f"{path}: additionalProperties"+ )+ for key, child in node.items():+ if key in ("enum", "const"):+ continue+ child_path = f"{path}.{key}" if path else key+ if key in ("properties", "$defs", "definitions") and isinstance(child, dict):+ # Keys of these maps are names, not keywords.+ for name, sub in child.items():+ assert_strict_shape(sub, f"{child_path}.{name}")+ continue+ assert_strict_shape(child, child_path)++[email protected]("case", load_strict_cases(), ids=lambda case: case.id)+def test_strict_corpus_case(case):+ snapshot = copy.deepcopy(case.schema_)+ result = to_strict_json_schema(case.schema_)++ assert case.schema_ == snapshot, "input mutated"+ if case.strict.unsupported is not None:+ assert [(e.path, e.keyword) for e in result.unsupported] == [+ (e.path, e.keyword) for e in case.strict.unsupported+ ]+ else:+ assert result.unsupported == []+ assert result.schema == case.strict.schema_+ assert_strict_shape(result.schema)+ again = to_strict_json_schema(result.schema)+ assert again.schema == result.schema, "not idempotent"+ assert again.changes == []+ assert [(c.path, c.reason) for c in result.changes] == [+ (c.path, c.reason) for c in (case.changes or [])+ ]+ assert result.total_changes == len(result.changes)+ for arguments in case.arguments or []:+ assert (+ omit_null_tool_arguments(arguments.input, result.source) == arguments.output+ )diff --git a/ts/packages/core/test/fixtures/json-schema-conversion/corpus.ts b/ts/packages/core/test/fixtures/json-schema-conversion/corpus.tsindex 9ab2dc4d4..72d55a691 100644--- a/ts/packages/core/test/fixtures/json-schema-conversion/corpus.ts+++ b/ts/packages/core/test/fixtures/json-schema-conversion/corpus.ts@@ -10,6 +10,7 @@import * as z from 'zod';import corpusDocument from './object-cases.json';+import strictDocument from './strict-cases.json';const JsonObject = z.record(z.string(), z.unknown());@@ -83,3 +84,43 @@ export const loadObjectCases = (): ReadonlyArray<CorpusCase> => {/** Acceptance for one language: the shared flag unless a declared divergence overrides it. */export const acceptedFor = (instance: CorpusInstance, language: CorpusLanguage): boolean =>instance[language]?.accepted ?? instance.accepted;++const StrictIncompatibility = z.object({ path: z.string(), keyword: z.string().min(1) });+const StrictChange = z.object({ path: z.string(), reason: z.string().min(1) });+const StrictArguments = z.object({ input: JsonObject, output: JsonObject });++/**+ * One strict-mode normalization case: either the exact strict schema the+ * rewrite must produce, or the constructs it must report as unsupported.+ */+const StrictCase = z.object({+ id: z.string().min(1),+ description: z.string().optional(),+ schema: JsonObject,+ strict: z.union([+ z.object({ schema: JsonObject }),+ z.object({ unsupported: z.array(StrictIncompatibility).min(1) }),+ ]),+ changes: z.array(StrictChange).optional(),+ arguments: z.array(StrictArguments).optional(),+});++const StrictCorpus = z.object({ cases: z.array(StrictCase).min(1) });++export type StrictCase = z.infer<typeof StrictCase>;++let cachedStrict: ReadonlyArray<StrictCase> | undefined;++/** Decode the shared strict-mode corpus (byte-identical copy per language). */+export const loadStrictCases = (): ReadonlyArray<StrictCase> => {+ if (!cachedStrict) {+ const { cases } = StrictCorpus.parse(strictDocument);+ const seen = new Set<string>();+ for (const testCase of cases) {+ if (seen.has(testCase.id)) throw new Error(`Duplicate strict case id: ${testCase.id}`);+ seen.add(testCase.id);+ }+ cachedStrict = cases;+ }+ return cachedStrict;+};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.jsonnew file mode 100644index 000000000..9c9b67954--- /dev/null+++ b/ts/packages/core/test/fixtures/json-schema-conversion/strict-cases.json@@ -0,0 +1,1835 @@+{+ "cases": [+ {+ "id": "flat-all-required-unchanged",+ "description": "An already-strict schema is returned unchanged with no changes.",+ "schema": {+ "type": "object",+ "properties": {+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "additionalProperties": false+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "nested-optional-property-widened",+ "description": "Optional properties stay, become required and accept null at every depth.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": "string",+ "description": "optional note"+ }+ },+ "required": ["url"]+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": ["string", "null"],+ "description": "optional note"+ }+ },+ "required": ["url", "note"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.cfg.properties.note",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "cfg": {+ "url": "u",+ "note": null+ }+ },+ "output": {+ "cfg": {+ "url": "u"+ }+ }+ }+ ]+ },+ {+ "id": "no-required-array-widens-every-property",+ "description": "An object without `required` requires and widens every property.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ },+ "b": {+ "type": "number"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["string", "null"]+ },+ "b": {+ "type": ["number", "null"]+ }+ },+ "required": ["a", "b"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.b",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "a": null,+ "b": 1,+ "unknown": null+ },+ "output": {+ "b": 1,+ "unknown": null+ }+ }+ ]+ },+ {+ "id": "required-empty-array-widens-every-property",+ "description": "An empty `required` array is the same as an absent one.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": []+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "nullable-type-array-kept",+ "description": "A `type` array with null is accepted by the API and left alone.",+ "schema": {+ "type": "object",+ "properties": {+ "id": {+ "type": ["string", "null"],+ "description": "identifier"+ }+ },+ "required": ["id"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "id": {+ "type": ["string", "null"],+ "description": "identifier"+ }+ },+ "required": ["id"],+ "additionalProperties": false+ }+ },+ "arguments": [+ {+ "input": {+ "id": null+ },+ "output": {+ "id": null+ }+ }+ ]+ },+ {+ "id": "nullable-object-stays-nullable",+ "description": "A nullable object keeps its type array; only its own properties are closed.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": ["object", "null"],+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"]+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "type": ["object", "null"],+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "arguments": [+ {+ "input": {+ "cfg": null+ },+ "output": {+ "cfg": null+ }+ },+ {+ "input": {+ "cfg": {+ "a": "x"+ }+ },+ "output": {+ "cfg": {+ "a": "x"+ }+ }+ }+ ]+ },+ {+ "id": "nullable-array-kept",+ "description": "A nullable array keeps its type array and items.",+ "schema": {+ "type": "object",+ "properties": {+ "xs": {+ "type": ["array", "null"],+ "items": {+ "type": "string"+ }+ }+ },+ "required": ["xs"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "xs": {+ "type": ["array", "null"],+ "items": {+ "type": "string"+ }+ }+ },+ "required": ["xs"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "optional-any-of-gets-null-branch",+ "description": "An optional composition gains a null branch instead of a sibling type.",+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ }+ ]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["value"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.value",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "any-of-already-nullable-unchanged",+ "description": "A composition that already accepts null is not widened twice.",+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["value"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.value",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "value": null+ },+ "output": {+ "value": null+ }+ }+ ]+ },+ {+ "id": "optional-enum-only-wrapped",+ "description": "An enum-only property is wrapped so the annotation stays outside the anyOf.",+ "schema": {+ "type": "object",+ "properties": {+ "choice": {+ "enum": ["a", "b"],+ "description": "pick one",+ "title": "Choice"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "choice": {+ "description": "pick one",+ "title": "Choice",+ "anyOf": [+ {+ "enum": ["a", "b"]+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["choice"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.choice",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "choice": null+ },+ "output": {}+ }+ ]+ },+ {+ "id": "optional-const-wrapped",+ "description": "A const-only property is wrapped in an anyOf with a null branch.",+ "schema": {+ "type": "object",+ "properties": {+ "kind": {+ "const": "fixed"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "kind": {+ "anyOf": [+ {+ "const": "fixed"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["kind"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.kind",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "optional-empty-schema-unchanged",+ "description": "An empty schema already accepts null and is left alone.",+ "schema": {+ "type": "object",+ "properties": {+ "anything": {}+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "anything": {}+ },+ "required": ["anything"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.anything",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "multi-type-array-gains-null",+ "description": "A multi-type array gains null instead of being converted to anyOf.",+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "type": ["string", "number"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "value": {+ "type": ["string", "number", "null"]+ }+ },+ "required": ["value"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.value",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "one-of-converted-to-any-of",+ "description": "oneOf is unsupported and becomes anyOf.",+ "schema": {+ "type": "object",+ "properties": {+ "either": {+ "oneOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ }+ ]+ }+ },+ "required": ["either"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "either": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ }+ ]+ }+ },+ "required": ["either"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.either",+ "reason": "one-of-converted"+ }+ ]+ },+ {+ "id": "array-items-object-normalized",+ "description": "Objects inside array items are closed and widened.",+ "schema": {+ "type": "object",+ "properties": {+ "rows": {+ "type": "array",+ "items": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string"+ },+ "tag": {+ "type": "string"+ }+ },+ "required": ["id"]+ }+ }+ },+ "required": ["rows"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "rows": {+ "type": "array",+ "items": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string"+ },+ "tag": {+ "type": ["string", "null"]+ }+ },+ "required": ["id", "tag"],+ "additionalProperties": false+ }+ }+ },+ "required": ["rows"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.rows.items.properties.tag",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "rows": [+ {+ "id": "1",+ "tag": null+ },+ null+ ]+ },+ "output": {+ "rows": [+ {+ "id": "1"+ },+ null+ ]+ }+ }+ ]+ },+ {+ "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.",+ "schema": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string",+ "examples": ["a"],+ "default": "x"+ }+ },+ "required": ["name"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string"+ }+ },+ "required": ["name"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.name",+ "reason": "unsupported-keyword-stripped"+ },+ {+ "path": "properties.name",+ "reason": "unsupported-keyword-stripped"+ }+ ]+ },+ {+ "id": "enum-values-are-data-not-keywords",+ "description": "Keys inside enum/const values are data and must not be treated as keywords.",+ "schema": {+ "type": "object",+ "properties": {+ "opts": {+ "enum": [+ {+ "default": 1,+ "properties": {}+ },+ null+ ]+ }+ },+ "required": ["opts"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "opts": {+ "enum": [+ {+ "default": 1,+ "properties": {}+ },+ null+ ]+ }+ },+ "required": ["opts"],+ "additionalProperties": false+ }+ },+ "arguments": [+ {+ "input": {+ "opts": null+ },+ "output": {+ "opts": null+ }+ }+ ]+ },+ {+ "id": "property-names-are-not-keywords",+ "description": "Properties named like keywords are ordinary properties.",+ "schema": {+ "type": "object",+ "properties": {+ "default": {+ "type": "string"+ },+ "$ref": {+ "type": "string"+ },+ "type": {+ "type": "string"+ },+ "properties": {+ "type": "object",+ "properties": {+ "x": {+ "type": "string"+ }+ }+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "default": {+ "type": ["string", "null"]+ },+ "$ref": {+ "type": ["string", "null"]+ },+ "type": {+ "type": ["string", "null"]+ },+ "properties": {+ "type": ["object", "null"],+ "properties": {+ "x": {+ "type": ["string", "null"]+ }+ },+ "required": ["x"],+ "additionalProperties": false+ }+ },+ "required": ["default", "$ref", "type", "properties"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.properties.properties.x",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.default",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.$ref",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.type",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.properties",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "default": null,+ "$ref": "x",+ "type": null,+ "properties": {+ "x": null+ }+ },+ "output": {+ "$ref": "x",+ "properties": {}+ }+ }+ ]+ },+ {+ "id": "prototype-key-property-name",+ "description": "A property named __proto__ or constructor is handled as a plain name.",+ "schema": {+ "type": "object",+ "properties": {+ "__proto__": {+ "type": "string"+ },+ "constructor": {+ "type": "number"+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "__proto__": {+ "type": ["string", "null"]+ },+ "constructor": {+ "type": ["number", "null"]+ }+ },+ "required": ["__proto__", "constructor"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.__proto__",+ "reason": "optional-property-nullable"+ },+ {+ "path": "properties.constructor",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "schema-valued-additional-properties-unsupported",+ "description": "A map-style object cannot be expressed and is reported, not closed.",+ "schema": {+ "type": "object",+ "properties": {+ "headers": {+ "type": "object",+ "additionalProperties": {+ "type": "string"+ }+ }+ },+ "required": ["headers"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.headers",+ "keyword": "additionalProperties"+ }+ ]+ }+ },+ {+ "id": "additional-properties-true-unsupported",+ "description": "An explicitly open object is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "open": {+ "type": "object",+ "additionalProperties": true+ }+ },+ "required": ["open"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.open",+ "keyword": "additionalProperties"+ }+ ]+ }+ },+ {+ "id": "additional-properties-empty-schema-unsupported",+ "description": "An empty-schema additionalProperties accepts anything and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "open": {+ "type": "object",+ "additionalProperties": {}+ }+ },+ "required": ["open"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.open",+ "keyword": "additionalProperties"+ }+ ]+ }+ },+ {+ "id": "free-form-object-unsupported",+ "description": "A property-less object accepts arbitrary keys and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "meta": {+ "type": "object",+ "description": "any json"+ }+ },+ "required": ["meta"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.meta",+ "keyword": "properties"+ }+ ]+ }+ },+ {+ "id": "pattern-properties-unsupported",+ "description": "patternProperties cannot be expressed and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "tagged": {+ "type": "object",+ "patternProperties": {+ "^x-": {+ "type": "string"+ }+ }+ }+ },+ "required": ["tagged"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.tagged",+ "keyword": "patternProperties"+ }+ ]+ }+ },+ {+ "id": "empty-closed-object-representable",+ "description": "An object closed with no properties is representable.",+ "schema": {+ "type": "object",+ "properties": {+ "empty": {+ "type": "object",+ "additionalProperties": false+ }+ },+ "required": ["empty"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "empty": {+ "type": "object",+ "additionalProperties": false,+ "properties": {},+ "required": []+ }+ },+ "required": ["empty"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "all-of-unsupported",+ "description": "allOf has no lossless rewrite and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "all": {+ "allOf": [+ {+ "type": "string"+ }+ ]+ }+ },+ "required": ["all"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.all",+ "keyword": "allOf"+ }+ ]+ }+ },+ {+ "id": "prefix-items-unsupported",+ "description": "prefixItems has no lossless rewrite and is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "pair": {+ "type": "array",+ "prefixItems": [+ {+ "type": "number"+ }+ ]+ }+ },+ "required": ["pair"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.pair",+ "keyword": "prefixItems"+ }+ ]+ }+ },+ {+ "id": "defs-ref-kept-and-definition-normalized",+ "description": "Local $refs are kept and the definition is normalized where it is declared.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Config"+ }+ },+ "required": ["cfg"],+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": "string"+ }+ },+ "required": ["url"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Config"+ }+ },+ "required": ["cfg"],+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ },+ "note": {+ "type": ["string", "null"]+ }+ },+ "required": ["url", "note"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "$defs.Config.properties.note",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "cfg": {+ "url": "u",+ "note": null+ }+ },+ "output": {+ "cfg": {+ "url": "u"+ }+ }+ }+ ]+ },+ {+ "id": "optional-ref-widened-with-null-branch",+ "description": "An optional $ref property is widened with an anyOf null branch.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Config",+ "description": "optional"+ }+ },+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ }+ },+ "required": ["url"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "description": "optional",+ "anyOf": [+ {+ "$ref": "#/$defs/Config"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "$defs": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ }+ },+ "required": ["url"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.cfg",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "cfg": null+ },+ "output": {}+ }+ ]+ },+ {+ "id": "recursive-defs-kept",+ "description": "Self-recursive definitions are representable.",+ "schema": {+ "type": "object",+ "properties": {+ "node": {+ "$ref": "#/$defs/Node"+ }+ },+ "required": ["node"],+ "$defs": {+ "Node": {+ "type": "object",+ "properties": {+ "child": {+ "$ref": "#/$defs/Node"+ },+ "label": {+ "type": "string"+ }+ },+ "required": ["label"]+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "node": {+ "$ref": "#/$defs/Node"+ }+ },+ "required": ["node"],+ "$defs": {+ "Node": {+ "type": "object",+ "properties": {+ "child": {+ "anyOf": [+ {+ "$ref": "#/$defs/Node"+ },+ {+ "type": "null"+ }+ ]+ },+ "label": {+ "type": "string"+ }+ },+ "required": ["child", "label"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "$defs.Node.properties.child",+ "reason": "optional-property-nullable"+ }+ ],+ "arguments": [+ {+ "input": {+ "node": {+ "label": "a",+ "child": {+ "label": "b",+ "child": null+ }+ }+ },+ "output": {+ "node": {+ "label": "a",+ "child": {+ "label": "b"+ }+ }+ }+ }+ ]+ },+ {+ "id": "mutually-recursive-defs-kept",+ "description": "Mutually recursive definitions are representable.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "$ref": "#/$defs/A"+ }+ },+ "required": ["a"],+ "$defs": {+ "A": {+ "type": "object",+ "properties": {+ "b": {+ "$ref": "#/$defs/B"+ }+ }+ },+ "B": {+ "type": "object",+ "properties": {+ "a": {+ "$ref": "#/$defs/A"+ }+ }+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "$ref": "#/$defs/A"+ }+ },+ "required": ["a"],+ "$defs": {+ "A": {+ "type": "object",+ "properties": {+ "b": {+ "anyOf": [+ {+ "$ref": "#/$defs/B"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["b"],+ "additionalProperties": false+ },+ "B": {+ "type": "object",+ "properties": {+ "a": {+ "anyOf": [+ {+ "$ref": "#/$defs/A"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "$defs.A.properties.b",+ "reason": "optional-property-nullable"+ },+ {+ "path": "$defs.B.properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "legacy-definitions-ref-kept",+ "description": "Legacy definitions are supported like $defs.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/definitions/Config"+ }+ },+ "required": ["cfg"],+ "definitions": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string"+ }+ }+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/definitions/Config"+ }+ },+ "required": ["cfg"],+ "definitions": {+ "Config": {+ "type": "object",+ "properties": {+ "url": {+ "type": ["string", "null"]+ }+ },+ "required": ["url"],+ "additionalProperties": false+ }+ },+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "definitions.Config.properties.url",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "ref-into-properties-kept",+ "description": "A local $ref outside $defs resolves and is kept.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "object",+ "properties": {+ "x": {+ "type": "string"+ }+ },+ "required": ["x"]+ },+ "b": {+ "$ref": "#/properties/a"+ }+ },+ "required": ["a", "b"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "object",+ "properties": {+ "x": {+ "type": "string"+ }+ },+ "required": ["x"],+ "additionalProperties": false+ },+ "b": {+ "$ref": "#/properties/a"+ }+ },+ "required": ["a", "b"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "dangling-ref-unsupported",+ "description": "A $ref without a target is reported at its own path.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "#/$defs/Nope"+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.cfg",+ "keyword": "$ref"+ }+ ]+ }+ },+ {+ "id": "external-ref-unsupported",+ "description": "A $ref outside the document is reported.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "$ref": "https://example.com/schema.json"+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "unsupported": [+ {+ "path": "properties.cfg",+ "keyword": "$ref"+ }+ ]+ }+ },+ {+ "id": "duplicate-required-deduped",+ "description": "Duplicate required entries are removed.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a", "a"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "required-unknown-names-dropped",+ "description": "Required names without a property are dropped from required.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a", "ghost"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ }+ },+ {+ "id": "required-not-an-array-ignored",+ "description": "A malformed required is treated as absent.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "string"+ }+ },+ "required": "a"+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "description-kept-on-widened-node",+ "description": "Annotations survive widening.",+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": "integer",+ "description": "count",+ "title": "Count",+ "minimum": 0+ }+ }+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "a": {+ "type": ["integer", "null"],+ "description": "count",+ "title": "Count",+ "minimum": 0+ }+ },+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "non-object-root-unsupported",+ "description": "The root must be an object.",+ "schema": {+ "type": "string"+ },+ "strict": {+ "unsupported": [+ {+ "path": "",+ "keyword": "type"+ }+ ]+ }+ },+ {+ "id": "nullable-root-unsupported",+ "description": "The root must not be nullable.",+ "schema": {+ "type": ["object", "null"],+ "properties": {+ "a": {+ "type": "string"+ }+ }+ },+ "strict": {+ "unsupported": [+ {+ "path": "",+ "keyword": "type"+ }+ ]+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "properties-without-type-become-object",+ "description": "A node with properties but no type is treated as an object.",+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "properties": {+ "a": {+ "type": "string"+ }+ }+ }+ },+ "required": ["cfg"]+ },+ "strict": {+ "schema": {+ "type": "object",+ "properties": {+ "cfg": {+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "type": "object",+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "required": ["cfg"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.cfg.properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ },+ {+ "id": "root-without-type-become-object",+ "description": "A root with properties but no type is treated as an object.",+ "schema": {+ "properties": {+ "a": {+ "type": "string"+ }+ }+ },+ "strict": {+ "schema": {+ "properties": {+ "a": {+ "type": ["string", "null"]+ }+ },+ "type": "object",+ "required": ["a"],+ "additionalProperties": false+ }+ },+ "changes": [+ {+ "path": "properties.a",+ "reason": "optional-property-nullable"+ }+ ]+ }+ ]+}diff --git a/ts/packages/core/test/utils/jsonSchema.strict.corpus.test.ts b/ts/packages/core/test/utils/jsonSchema.strict.corpus.test.tsnew file mode 100644index 000000000..5adf20717--- /dev/null+++ b/ts/packages/core/test/utils/jsonSchema.strict.corpus.test.ts@@ -0,0 +1,79 @@+import { describe, it, expect } from 'vitest';+import { omitNullToolArguments, toStrictJsonSchema } from '../../src/utils/jsonSchema';+import { loadStrictCases } from '../fixtures/json-schema-conversion/corpus';++/** Structural invariants OpenAI enforces on every node of a strict schema. */+function assertStrictShape(node: unknown, path = ''): void {+ if (Array.isArray(node)) {+ node.forEach((item, index) => assertStrictShape(item, `${path}[${index}]`));+ return;+ }+ if (!node || typeof node !== 'object') return;+ const record = node as Record<string, unknown>;+ if (record.anyOf !== undefined) {+ expect(record.type, `${path}: type beside anyOf`).toBeUndefined();+ }+ for (const keyword of [+ 'default',+ 'examples',+ 'oneOf',+ 'patternProperties',+ 'allOf',+ 'prefixItems',+ ]) {+ expect(record[keyword], `${path}: ${keyword}`).toBeUndefined();+ }+ const isObject =+ record.type === 'object' || (Array.isArray(record.type) && record.type.includes('object'));+ if (isObject || record.properties !== undefined) {+ const properties = (record.properties ?? {}) as Record<string, unknown>;+ expect(record.required, `${path}: required`).toEqual(Object.keys(properties));+ expect(record.additionalProperties, `${path}: additionalProperties`).toBe(false);+ }+ for (const [key, child] of Object.entries(record)) {+ if (key === 'enum' || key === 'const') continue;+ const childPath = path ? `${path}.${key}` : key;+ if (+ (key === 'properties' || key === '$defs' || key === 'definitions') &&+ child &&+ typeof child === 'object'+ ) {+ // Keys of these maps are names, not keywords.+ for (const [name, sub] of Object.entries(child as Record<string, unknown>)) {+ assertStrictShape(sub, `${childPath}.${name}`);+ }+ continue;+ }+ assertStrictShape(child, childPath);+ }+}++describe('toStrictJsonSchema (shared corpus)', () => {+ for (const testCase of loadStrictCases()) {+ it(testCase.id, () => {+ const snapshot = JSON.parse(JSON.stringify(testCase.schema));+ const result = toStrictJsonSchema(testCase.schema);++ expect(testCase.schema, 'input mutated').toEqual(snapshot);+ if ('unsupported' in testCase.strict) {+ expect(result.unsupported.map(({ path, keyword }) => ({ path, keyword }))).toEqual(+ testCase.strict.unsupported+ );+ } else {+ expect(result.unsupported).toEqual([]);+ expect(result.schema).toEqual(testCase.strict.schema);+ assertStrictShape(result.schema);+ const again = toStrictJsonSchema(result.schema);+ expect(again.schema, 'not idempotent').toEqual(result.schema);+ expect(again.changes).toEqual([]);+ }+ expect(result.changes.map(({ path, reason }) => ({ path, reason }))).toEqual(+ testCase.changes ?? []+ );+ expect(result.totalChanges).toBe(result.changes.length);+ for (const { input, output } of testCase.arguments ?? []) {+ expect(omitNullToolArguments(input, result.source)).toEqual(output);+ }+ });+ }+});