@devries-cameron20 / composio Mirror · read-only / commits / 8fe03eff4
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 14:45 UTC

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

Extends strict-cases.json to 68 cases with shapes enumerated independently (single-element and three-member type arrays, null-only and null-carrying enum/const properties, nested compositions, nullable objects in arrays, tuple and boolean items, conditional and dependency keywords, oneOf beside anyOf, boolean and malformed properties, $ref siblings and chains, legacy definitions next to $defs, non-string required entries, ten-level nesting) plus null-omission pairs for nullable, composed and $ref-typed arguments. Checks in the generator that derives the pinned JSON. Co-authored-by: AseemPrasad <aseemprasad0520@gmail.com> Claude-Session: https://claude.ai/code/session_01TDrxCHn2hg51HmxVstSUgs

jkomyno committed Aug 26, 2026 at 17:59 UTC 8fe03eff47ad3ba4cddc1b6e2f7b1762bd19f059
3 files changed +2895 -120
python/tests/fixtures/json-schema-conversion/strict-cases.json
+1172 -60
@@ -90,6 +90,26 @@
90 "url": "u"
91 }
92 }
93 + },
94 + {
95 + "input": {
96 + "cfg": null
97 + },
98 + "output": {}
99 + },
100 + {
101 + "input": {
102 + "cfg": {
103 + "url": "u",
104 + "extra": null
105 + }
106 + },
107 + "output": {
108 + "cfg": {
109 + "url": "u",
110 + "extra": null
111 + }
112 + }
113 }
114 ]
115 },
@@ -303,7 +323,25 @@
323 "required": ["xs"],
324 "additionalProperties": false
325 }
306 - }
326 + },
327 + "arguments": [
328 + {
329 + "input": {
330 + "xs": null
331 + },
332 + "output": {
333 + "xs": null
334 + }
335 + },
336 + {
337 + "input": {
338 + "xs": [null]
339 + },
340 + "output": {
341 + "xs": [null]
342 + }
343 + }
344 + ]
345 },
346 {
347 "id": "optional-any-of-gets-null-branch",
@@ -670,65 +708,6 @@
708 }
709 ]
710 },
673 - {
674 - "id": "tuple-items-normalized",
675 - "description": "Objects inside tuple-form items are normalized too.",
676 - "schema": {
677 - "type": "object",
678 - "properties": {
679 - "pair": {
680 - "type": "array",
681 - "items": [
682 - {
683 - "type": "object",
684 - "properties": {
685 - "x": {
686 - "type": "number"
687 - }
688 - }
689 - },
690 - {
691 - "type": "string"
692 - }
693 - ]
694 - }
695 - },
696 - "required": ["pair"]
697 - },
698 - "strict": {
699 - "schema": {
700 - "type": "object",
701 - "properties": {
702 - "pair": {
703 - "type": "array",
704 - "items": [
705 - {
706 - "type": "object",
707 - "properties": {
708 - "x": {
709 - "type": ["number", "null"]
710 - }
711 - },
712 - "required": ["x"],
713 - "additionalProperties": false
714 - },
715 - {
716 - "type": "string"
717 - }
718 - ]
719 - }
720 - },
721 - "required": ["pair"],
722 - "additionalProperties": false
723 - }
724 - },
725 - "changes": [
726 - {
727 - "path": "properties.pair.items[0].properties.x",
728 - "reason": "optional-property-nullable"
729 - }
730 - ]
731 - },
711 {
712 "id": "default-and-examples-stripped",
713 "description": "Annotation keywords the API rejects are stripped and reported.",
@@ -1830,6 +1809,1139 @@
1809 "reason": "optional-property-nullable"
1810 }
1811 ]
1812 + },
1813 + {
1814 + "id": "root-single-element-type-array-accepted",
1815 + "description": "A root typed [\"object\"] is an object root.",
1816 + "schema": {
1817 + "type": ["object"],
1818 + "properties": {
1819 + "a": {
1820 + "type": "string"
1821 + }
1822 + },
1823 + "required": ["a"]
1824 + },
1825 + "strict": {
1826 + "schema": {
1827 + "type": ["object"],
1828 + "properties": {
1829 + "a": {
1830 + "type": "string"
1831 + }
1832 + },
1833 + "required": ["a"],
1834 + "additionalProperties": false
1835 + }
1836 + }
1837 + },
1838 + {
1839 + "id": "three-member-type-array-gains-null",
1840 + "description": "A three-member type array gains null once.",
1841 + "schema": {
1842 + "type": "object",
1843 + "properties": {
1844 + "v": {
1845 + "type": ["string", "number", "boolean"]
1846 + }
1847 + }
1848 + },
1849 + "strict": {
1850 + "schema": {
1851 + "type": "object",
1852 + "properties": {
1853 + "v": {
1854 + "type": ["string", "number", "boolean", "null"]
1855 + }
1856 + },
1857 + "required": ["v"],
1858 + "additionalProperties": false
1859 + }
1860 + },
1861 + "changes": [
1862 + {
1863 + "path": "properties.v",
1864 + "reason": "optional-property-nullable"
1865 + }
1866 + ]
1867 + },
1868 + {
1869 + "id": "optional-null-only-property-unchanged",
1870 + "description": "A property typed null already accepts null.",
1871 + "schema": {
1872 + "type": "object",
1873 + "properties": {
1874 + "nothing": {
1875 + "type": "null"
1876 + }
1877 + }
1878 + },
1879 + "strict": {
1880 + "schema": {
1881 + "type": "object",
1882 + "properties": {
1883 + "nothing": {
1884 + "type": "null"
1885 + }
1886 + },
1887 + "required": ["nothing"],
1888 + "additionalProperties": false
1889 + }
1890 + },
1891 + "changes": [
1892 + {
1893 + "path": "properties.nothing",
1894 + "reason": "optional-property-nullable"
1895 + }
1896 + ],
1897 + "arguments": [
1898 + {
1899 + "input": {
1900 + "nothing": null
1901 + },
1902 + "output": {
1903 + "nothing": null
1904 + }
1905 + }
1906 + ]
1907 + },
1908 + {
1909 + "id": "optional-enum-with-null-not-rewrapped",
1910 + "description": "An enum that already lists null is not wrapped again.",
1911 + "schema": {
1912 + "type": "object",
1913 + "properties": {
1914 + "choice": {
1915 + "enum": ["a", null]
1916 + }
1917 + }
1918 + },
1919 + "strict": {
1920 + "schema": {
1921 + "type": "object",
1922 + "properties": {
1923 + "choice": {
1924 + "enum": ["a", null]
1925 + }
1926 + },
1927 + "required": ["choice"],
1928 + "additionalProperties": false
1929 + }
1930 + },
1931 + "changes": [
1932 + {
1933 + "path": "properties.choice",
1934 + "reason": "optional-property-nullable"
1935 + }
1936 + ],
1937 + "arguments": [
1938 + {
1939 + "input": {
1940 + "choice": null
1941 + },
1942 + "output": {
1943 + "choice": null
1944 + }
1945 + }
1946 + ]
1947 + },
1948 + {
1949 + "id": "optional-const-null-not-rewrapped",
1950 + "description": "A const null already accepts null.",
1951 + "schema": {
1952 + "type": "object",
1953 + "properties": {
1954 + "nothing": {
1955 + "const": null
1956 + }
1957 + }
1958 + },
1959 + "strict": {
1960 + "schema": {
1961 + "type": "object",
1962 + "properties": {
1963 + "nothing": {
1964 + "const": null
1965 + }
1966 + },
1967 + "required": ["nothing"],
1968 + "additionalProperties": false
1969 + }
1970 + },
1971 + "changes": [
1972 + {
1973 + "path": "properties.nothing",
1974 + "reason": "optional-property-nullable"
1975 + }
1976 + ],
1977 + "arguments": [
1978 + {
1979 + "input": {
1980 + "nothing": null
1981 + },
1982 + "output": {
1983 + "nothing": null
1984 + }
1985 + }
1986 + ]
1987 + },
1988 + {
1989 + "id": "nested-any-of-branch-widened",
1990 + "description": "Optional properties inside anyOf branches are widened.",
1991 + "schema": {
1992 + "type": "object",
1993 + "properties": {
1994 + "v": {
1995 + "anyOf": [
1996 + {
1997 + "type": "object",
1998 + "properties": {
1999 + "a": {
2000 + "type": "string"
2001 + }
2002 + }
2003 + },
2004 + {
2005 + "type": "string"
2006 + }
2007 + ]
2008 + }
2009 + },
2010 + "required": ["v"]
2011 + },
2012 + "strict": {
2013 + "schema": {
2014 + "type": "object",
2015 + "properties": {
2016 + "v": {
2017 + "anyOf": [
2018 + {
2019 + "type": "object",
2020 + "properties": {
2021 + "a": {
2022 + "type": ["string", "null"]
2023 + }
2024 + },
2025 + "required": ["a"],
2026 + "additionalProperties": false
2027 + },
2028 + {
2029 + "type": "string"
2030 + }
2031 + ]
2032 + }
2033 + },
2034 + "required": ["v"],
2035 + "additionalProperties": false
2036 + }
2037 + },
2038 + "changes": [
2039 + {
2040 + "path": "properties.v.anyOf[0].properties.a",
2041 + "reason": "optional-property-nullable"
2042 + }
2043 + ],
2044 + "arguments": [
2045 + {
2046 + "input": {
2047 + "v": {
2048 + "a": null
2049 + }
2050 + },
2051 + "output": {
2052 + "v": {}
2053 + }
2054 + },
2055 + {
2056 + "input": {
2057 + "v": null
2058 + },
2059 + "output": {}
2060 + }
2061 + ]
2062 + },
2063 + {
2064 + "id": "array-of-nullable-objects-closed",
2065 + "description": "Nullable objects inside array items are closed and stay nullable.",
2066 + "schema": {
2067 + "type": "object",
2068 + "properties": {
2069 + "rows": {
2070 + "type": "array",
2071 + "items": {
2072 + "type": ["object", "null"],
2073 + "properties": {
2074 + "id": {
2075 + "type": "string"
2076 + }
2077 + }
2078 + }
2079 + }
2080 + },
2081 + "required": ["rows"]
2082 + },
2083 + "strict": {
2084 + "schema": {
2085 + "type": "object",
2086 + "properties": {
2087 + "rows": {
2088 + "type": "array",
2089 + "items": {
2090 + "type": ["object", "null"],
2091 + "properties": {
2092 + "id": {
2093 + "type": ["string", "null"]
2094 + }
2095 + },
2096 + "required": ["id"],
2097 + "additionalProperties": false
2098 + }
2099 + }
2100 + },
2101 + "required": ["rows"],
2102 + "additionalProperties": false
2103 + }
2104 + },
2105 + "changes": [
2106 + {
2107 + "path": "properties.rows.items.properties.id",
2108 + "reason": "optional-property-nullable"
2109 + }
2110 + ],
2111 + "arguments": [
2112 + {
2113 + "input": {
2114 + "rows": [
2115 + null,
2116 + {
2117 + "id": null
2118 + }
2119 + ]
2120 + },
2121 + "output": {
2122 + "rows": [null, {}]
2123 + }
2124 + }
2125 + ]
2126 + },
2127 + {
2128 + "id": "tuple-form-items-unsupported",
2129 + "description": "Draft-4 tuple items have no strict-mode equivalent.",
2130 + "schema": {
2131 + "type": "object",
2132 + "properties": {
2133 + "pair": {
2134 + "type": "array",
2135 + "items": [
2136 + {
2137 + "type": "number"
2138 + },
2139 + {
2140 + "type": "string"
2141 + }
2142 + ]
2143 + }
2144 + },
2145 + "required": ["pair"]
2146 + },
2147 + "strict": {
2148 + "unsupported": [
2149 + {
2150 + "path": "properties.pair",
2151 + "keyword": "items"
2152 + }
2153 + ]
2154 + }
2155 + },
2156 + {
2157 + "id": "boolean-items-unsupported",
2158 + "description": "A boolean items subschema is reported.",
2159 + "schema": {
2160 + "type": "object",
2161 + "properties": {
2162 + "xs": {
2163 + "type": "array",
2164 + "items": true
2165 + }
2166 + },
2167 + "required": ["xs"]
2168 + },
2169 + "strict": {
2170 + "unsupported": [
2171 + {
2172 + "path": "properties.xs",
2173 + "keyword": "items"
2174 + }
2175 + ]
2176 + }
2177 + },
2178 + {
2179 + "id": "not-keyword-unsupported",
2180 + "description": "not has no strict-mode equivalent.",
2181 + "schema": {
2182 + "type": "object",
2183 + "properties": {
2184 + "v": {
2185 + "not": {
2186 + "type": "string"
2187 + }
2188 + }
2189 + },
2190 + "required": ["v"]
2191 + },
2192 + "strict": {
2193 + "unsupported": [
2194 + {
2195 + "path": "properties.v",
2196 + "keyword": "not"
2197 + }
2198 + ]
2199 + }
2200 + },
2201 + {
2202 + "id": "if-then-else-unsupported",
2203 + "description": "Conditional keywords have no strict-mode equivalent.",
2204 + "schema": {
2205 + "type": "object",
2206 + "properties": {
2207 + "v": {
2208 + "type": "string",
2209 + "if": {
2210 + "minLength": 1
2211 + },
2212 + "then": {
2213 + "maxLength": 5
2214 + },
2215 + "else": {
2216 + "const": ""
2217 + }
2218 + }
2219 + },
2220 + "required": ["v"]
2221 + },
2222 + "strict": {
2223 + "unsupported": [
2224 + {
2225 + "path": "properties.v",
2226 + "keyword": "else"
2227 + },
2228 + {
2229 + "path": "properties.v",
2230 + "keyword": "if"
2231 + },
2232 + {
2233 + "path": "properties.v",
2234 + "keyword": "then"
2235 + }
2236 + ]
2237 + }
2238 + },
2239 + {
2240 + "id": "dependent-schemas-unsupported",
2241 + "description": "dependentSchemas has no strict-mode equivalent.",
2242 + "schema": {
2243 + "type": "object",
2244 + "properties": {
2245 + "a": {
2246 + "type": "string"
2247 + }
2248 + },
2249 + "required": ["a"],
2250 + "dependentSchemas": {
2251 + "a": {
2252 + "type": "object",
2253 + "properties": {
2254 + "b": {
2255 + "type": "string"
2256 + }
2257 + }
2258 + }
2259 + }
2260 + },
2261 + "strict": {
2262 + "unsupported": [
2263 + {
2264 + "path": "",
2265 + "keyword": "dependentSchemas"
2266 + }
2267 + ]
2268 + },
2269 + "changes": [
2270 + {
2271 + "path": "dependentSchemas.a.properties.b",
2272 + "reason": "optional-property-nullable"
2273 + }
2274 + ]
2275 + },
2276 + {
2277 + "id": "property-names-keyword-unsupported",
2278 + "description": "propertyNames has no strict-mode equivalent.",
2279 + "schema": {
2280 + "type": "object",
2281 + "properties": {
2282 + "a": {
2283 + "type": "string"
2284 + }
2285 + },
2286 + "required": ["a"],
2287 + "propertyNames": {
2288 + "pattern": "^a"
2289 + }
2290 + },
2291 + "strict": {
2292 + "unsupported": [
2293 + {
2294 + "path": "",
2295 + "keyword": "propertyNames"
2296 + }
2297 + ]
2298 + }
2299 + },
2300 + {
2301 + "id": "one-of-beside-any-of-unsupported",
2302 + "description": "oneOf next to anyOf cannot be merged and is reported.",
2303 + "schema": {
2304 + "type": "object",
2305 + "properties": {
2306 + "v": {
2307 + "anyOf": [
2308 + {
2309 + "type": "string"
2310 + }
2311 + ],
2312 + "oneOf": [
2313 + {
2314 + "type": "number"
2315 + }
2316 + ]
2317 + }
2318 + },
2319 + "required": ["v"]
2320 + },
2321 + "strict": {
2322 + "unsupported": [
2323 + {
2324 + "path": "properties.v",
2325 + "keyword": "oneOf"
2326 + }
2327 + ]
2328 + }
2329 + },
2330 + {
2331 + "id": "boolean-property-subschema-unsupported",
2332 + "description": "A boolean property subschema is reported.",
2333 + "schema": {
2334 + "type": "object",
2335 + "properties": {
2336 + "anything": true,
2337 + "nothing": false
2338 + },
2339 + "required": ["anything", "nothing"]
2340 + },
2341 + "strict": {
2342 + "unsupported": [
2343 + {
2344 + "path": "properties.anything",
2345 + "keyword": "properties"
2346 + },
2347 + {
2348 + "path": "properties.nothing",
2349 + "keyword": "properties"
2350 + }
2351 + ]
2352 + }
2353 + },
2354 + {
2355 + "id": "properties-not-an-object-unsupported",
2356 + "description": "A malformed properties value is reported instead of emptied.",
2357 + "schema": {
2358 + "type": "object",
2359 + "properties": "not-a-map",
2360 + "required": ["a"]
2361 + },
2362 + "strict": {
2363 + "unsupported": [
2364 + {
2365 + "path": "",
2366 + "keyword": "properties"
2367 + }
2368 + ]
2369 + }
2370 + },
2371 + {
2372 + "id": "ref-with-siblings-kept",
2373 + "description": "Sibling keywords next to a $ref are kept.",
2374 + "schema": {
2375 + "type": "object",
2376 + "properties": {
2377 + "cfg": {
2378 + "$ref": "#/$defs/Config",
2379 + "description": "cfg",
2380 + "title": "Config"
2381 + }
2382 + },
2383 + "required": ["cfg"],
2384 + "$defs": {
2385 + "Config": {
2386 + "type": "object",
2387 + "properties": {
2388 + "a": {
2389 + "type": "string"
2390 + }
2391 + },
2392 + "required": ["a"]
2393 + }
2394 + }
2395 + },
2396 + "strict": {
2397 + "schema": {
2398 + "type": "object",
2399 + "properties": {
2400 + "cfg": {
2401 + "$ref": "#/$defs/Config",
2402 + "description": "cfg",
2403 + "title": "Config"
2404 + }
2405 + },
2406 + "required": ["cfg"],
2407 + "$defs": {
2408 + "Config": {
2409 + "type": "object",
2410 + "properties": {
2411 + "a": {
2412 + "type": "string"
2413 + }
2414 + },
2415 + "required": ["a"],
2416 + "additionalProperties": false
2417 + }
2418 + },
2419 + "additionalProperties": false
2420 + }
2421 + }
2422 + },
2423 + {
2424 + "id": "required-non-string-entries-ignored",
2425 + "description": "Non-string required entries are ignored.",
2426 + "schema": {
2427 + "type": "object",
2428 + "properties": {
2429 + "a": {
2430 + "type": "string"
2431 + },
2432 + "b": {
2433 + "type": "string"
2434 + }
2435 + },
2436 + "required": ["a", 1, null]
2437 + },
2438 + "strict": {
2439 + "schema": {
2440 + "type": "object",
2441 + "properties": {
2442 + "a": {
2443 + "type": "string"
2444 + },
2445 + "b": {
2446 + "type": ["string", "null"]
2447 + }
2448 + },
2449 + "required": ["a", "b"],
2450 + "additionalProperties": false
2451 + }
2452 + },
2453 + "changes": [
2454 + {
2455 + "path": "properties.b",
2456 + "reason": "optional-property-nullable"
2457 + }
2458 + ]
2459 + },
2460 + {
2461 + "id": "dynamic-keys-reported-once-with-pattern-properties",
2462 + "description": "additionalProperties and patternProperties on one node report additionalProperties.",
2463 + "schema": {
2464 + "type": "object",
2465 + "properties": {
2466 + "m": {
2467 + "type": "object",
2468 + "additionalProperties": {
2469 + "type": "string"
2470 + },
2471 + "patternProperties": {
2472 + "^x": {
2473 + "type": "string"
2474 + }
2475 + }
2476 + }
2477 + },
2478 + "required": ["m"]
2479 + },
2480 + "strict": {
2481 + "unsupported": [
2482 + {
2483 + "path": "properties.m",
2484 + "keyword": "additionalProperties"
2485 + }
2486 + ]
2487 + }
2488 + },
2489 + {
2490 + "id": "empty-properties-open-object-unsupported",
2491 + "description": "An object with empty properties and no closing is free-form.",
2492 + "schema": {
2493 + "type": "object",
2494 + "properties": {
2495 + "m": {
2496 + "type": "object",
2497 + "properties": {}
2498 + }
2499 + },
2500 + "required": ["m"]
2501 + },
2502 + "strict": {
2503 + "unsupported": [
2504 + {
2505 + "path": "properties.m",
2506 + "keyword": "properties"
2507 + }
2508 + ]
2509 + }
2510 + },
2511 + {
2512 + "id": "default-stripped-then-widened",
2513 + "description": "Stripping default and widening compose.",
2514 + "schema": {
2515 + "type": "object",
2516 + "properties": {
2517 + "a": {
2518 + "type": "string",
2519 + "default": "x"
2520 + }
2521 + }
2522 + },
2523 + "strict": {
2524 + "schema": {
2525 + "type": "object",
2526 + "properties": {
2527 + "a": {
2528 + "type": ["string", "null"]
2529 + }
2530 + },
2531 + "required": ["a"],
2532 + "additionalProperties": false
2533 + }
2534 + },
2535 + "changes": [
2536 + {
2537 + "path": "properties.a",
2538 + "reason": "unsupported-keyword-stripped"
2539 + },
2540 + {
2541 + "path": "properties.a",
2542 + "reason": "optional-property-nullable"
2543 + }
2544 + ]
2545 + },
2546 + {
2547 + "id": "nested-any-of-in-any-of-kept",
2548 + "description": "A composition nested inside a composition is normalized branch by branch.",
2549 + "schema": {
2550 + "type": "object",
2551 + "properties": {
2552 + "v": {
2553 + "anyOf": [
2554 + {
2555 + "anyOf": [
2556 + {
2557 + "type": "object",
2558 + "properties": {
2559 + "a": {
2560 + "type": "string"
2561 + }
2562 + }
2563 + },
2564 + {
2565 + "type": "number"
2566 + }
2567 + ]
2568 + },
2569 + {
2570 + "type": "string"
2571 + }
2572 + ]
2573 + }
2574 + },
2575 + "required": ["v"]
2576 + },
2577 + "strict": {
2578 + "schema": {
2579 + "type": "object",
2580 + "properties": {
2581 + "v": {
2582 + "anyOf": [
2583 + {
2584 + "anyOf": [
2585 + {
2586 + "type": "object",
2587 + "properties": {
2588 + "a": {
2589 + "type": ["string", "null"]
2590 + }
2591 + },
2592 + "required": ["a"],
2593 + "additionalProperties": false
2594 + },
2595 + {
2596 + "type": "number"
2597 + }
2598 + ]
2599 + },
2600 + {
2601 + "type": "string"
2602 + }
2603 + ]
2604 + }
2605 + },
2606 + "required": ["v"],
2607 + "additionalProperties": false
2608 + }
2609 + },
2610 + "changes": [
2611 + {
2612 + "path": "properties.v.anyOf[0].anyOf[0].properties.a",
2613 + "reason": "optional-property-nullable"
2614 + }
2615 + ],
2616 + "arguments": [
2617 + {
2618 + "input": {
2619 + "v": {
2620 + "a": null
2621 + }
2622 + },
2623 + "output": {
2624 + "v": {}
2625 + }
2626 + }
2627 + ]
2628 + },
2629 + {
2630 + "id": "definitions-and-defs-both-normalized",
2631 + "description": "Legacy definitions and $defs coexist and both are normalized.",
2632 + "schema": {
2633 + "type": "object",
2634 + "properties": {
2635 + "a": {
2636 + "$ref": "#/$defs/A"
2637 + },
2638 + "b": {
2639 + "$ref": "#/definitions/B"
2640 + }
2641 + },
2642 + "required": ["a", "b"],
2643 + "$defs": {
2644 + "A": {
2645 + "type": "object",
2646 + "properties": {
2647 + "x": {
2648 + "type": "string"
2649 + }
2650 + }
2651 + }
2652 + },
2653 + "definitions": {
2654 + "B": {
2655 + "type": "object",
2656 + "properties": {
2657 + "y": {
2658 + "type": "string"
2659 + }
2660 + }
2661 + }
2662 + }
2663 + },
2664 + "strict": {
2665 + "schema": {
2666 + "type": "object",
2667 + "properties": {
2668 + "a": {
2669 + "$ref": "#/$defs/A"
2670 + },
2671 + "b": {
2672 + "$ref": "#/definitions/B"
2673 + }
2674 + },
2675 + "required": ["a", "b"],
2676 + "$defs": {
2677 + "A": {
2678 + "type": "object",
2679 + "properties": {
2680 + "x": {
2681 + "type": ["string", "null"]
2682 + }
2683 + },
2684 + "required": ["x"],
2685 + "additionalProperties": false
2686 + }
2687 + },
2688 + "definitions": {
2689 + "B": {
2690 + "type": "object",
2691 + "properties": {
2692 + "y": {
2693 + "type": ["string", "null"]
2694 + }
2695 + },
2696 + "required": ["y"],
2697 + "additionalProperties": false
2698 + }
2699 + },
2700 + "additionalProperties": false
2701 + }
2702 + },
2703 + "changes": [
2704 + {
2705 + "path": "$defs.A.properties.x",
2706 + "reason": "optional-property-nullable"
2707 + },
2708 + {
2709 + "path": "definitions.B.properties.y",
2710 + "reason": "optional-property-nullable"
2711 + }
2712 + ]
2713 + },
2714 + {
2715 + "id": "deep-nesting-normalized-fully",
2716 + "description": "Ten levels of nested objects are normalized at every level.",
2717 + "schema": {
2718 + "type": "object",
2719 + "properties": {
2720 + "child": {
2721 + "type": "object",
2722 + "properties": {
2723 + "child": {
2724 + "type": "object",
2725 + "properties": {
2726 + "child": {
2727 + "type": "object",
2728 + "properties": {
2729 + "child": {
2730 + "type": "object",
2731 + "properties": {
2732 + "child": {
2733 + "type": "object",
2734 + "properties": {
2735 + "child": {
2736 + "type": "object",
2737 + "properties": {
2738 + "child": {
2739 + "type": "object",
2740 + "properties": {
2741 + "child": {
2742 + "type": "object",
2743 + "properties": {
2744 + "child": {
2745 + "type": "object",
2746 + "properties": {
2747 + "child": {
2748 + "type": "object",
2749 + "properties": {
2750 + "leaf": {
2751 + "type": "string"
2752 + }
2753 + }
2754 + }
2755 + },
2756 + "required": ["child"]
2757 + }
2758 + },
2759 + "required": ["child"]
2760 + }
2761 + },
2762 + "required": ["child"]
2763 + }
2764 + },
2765 + "required": ["child"]
2766 + }
2767 + },
2768 + "required": ["child"]
2769 + }
2770 + },
2771 + "required": ["child"]
2772 + }
2773 + },
2774 + "required": ["child"]
2775 + }
2776 + },
2777 + "required": ["child"]
2778 + }
2779 + },
2780 + "required": ["child"]
2781 + }
2782 + },
2783 + "required": ["child"]
2784 + },
2785 + "strict": {
2786 + "schema": {
2787 + "type": "object",
2788 + "properties": {
2789 + "child": {
2790 + "type": "object",
2791 + "properties": {
2792 + "child": {
2793 + "type": "object",
2794 + "properties": {
2795 + "child": {
2796 + "type": "object",
2797 + "properties": {
2798 + "child": {
2799 + "type": "object",
2800 + "properties": {
2801 + "child": {
2802 + "type": "object",
2803 + "properties": {
2804 + "child": {
2805 + "type": "object",
2806 + "properties": {
2807 + "child": {
2808 + "type": "object",
2809 + "properties": {
2810 + "child": {
2811 + "type": "object",
2812 + "properties": {
2813 + "child": {
2814 + "type": "object",
2815 + "properties": {
2816 + "child": {
2817 + "type": "object",
2818 + "properties": {
2819 + "leaf": {
2820 + "type": ["string", "null"]
2821 + }
2822 + },
2823 + "required": ["leaf"],
2824 + "additionalProperties": false
2825 + }
2826 + },
2827 + "required": ["child"],
2828 + "additionalProperties": false
2829 + }
2830 + },
2831 + "required": ["child"],
2832 + "additionalProperties": false
2833 + }
2834 + },
2835 + "required": ["child"],
2836 + "additionalProperties": false
2837 + }
2838 + },
2839 + "required": ["child"],
2840 + "additionalProperties": false
2841 + }
2842 + },
2843 + "required": ["child"],
2844 + "additionalProperties": false
2845 + }
2846 + },
2847 + "required": ["child"],
2848 + "additionalProperties": false
2849 + }
2850 + },
2851 + "required": ["child"],
2852 + "additionalProperties": false
2853 + }
2854 + },
2855 + "required": ["child"],
2856 + "additionalProperties": false
2857 + }
2858 + },
2859 + "required": ["child"],
2860 + "additionalProperties": false
2861 + }
2862 + },
2863 + "required": ["child"],
2864 + "additionalProperties": false
2865 + }
2866 + },
2867 + "changes": [
2868 + {
2869 + "path": "properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.leaf",
2870 + "reason": "optional-property-nullable"
2871 + }
2872 + ]
2873 + },
2874 + {
2875 + "id": "chained-refs-resolved",
2876 + "description": "A $ref to a $ref resolves to the final definition.",
2877 + "schema": {
2878 + "type": "object",
2879 + "properties": {
2880 + "a": {
2881 + "$ref": "#/$defs/Alias"
2882 + }
2883 + },
2884 + "required": ["a"],
2885 + "$defs": {
2886 + "Alias": {
2887 + "$ref": "#/$defs/Real"
2888 + },
2889 + "Real": {
2890 + "type": "object",
2891 + "properties": {
2892 + "x": {
2893 + "type": "string"
2894 + }
2895 + },
2896 + "required": ["x"]
2897 + }
2898 + }
2899 + },
2900 + "strict": {
2901 + "schema": {
2902 + "type": "object",
2903 + "properties": {
2904 + "a": {
2905 + "$ref": "#/$defs/Alias"
2906 + }
2907 + },
2908 + "required": ["a"],
2909 + "$defs": {
2910 + "Alias": {
2911 + "$ref": "#/$defs/Real"
2912 + },
2913 + "Real": {
2914 + "type": "object",
2915 + "properties": {
2916 + "x": {
2917 + "type": "string"
2918 + }
2919 + },
2920 + "required": ["x"],
2921 + "additionalProperties": false
2922 + }
2923 + },
2924 + "additionalProperties": false
2925 + }
2926 + },
2927 + "arguments": [
2928 + {
2929 + "input": {
2930 + "a": {
2931 + "x": null
2932 + }
2933 + },
2934 + "output": {
2935 + "a": {}
2936 + }
2937 + },
2938 + {
2939 + "input": {
2940 + "a": null
2941 + },
2942 + "output": {}
2943 + }
2944 + ]
2945 }
2946 ]
2947 }
ts/packages/core/test/fixtures/json-schema-conversion/generate-strict-cases.mjs new
+551
@@ -0,0 +1,551 @@
1 +/**
2 + * Regenerates strict-cases.json (both language copies) from the case inputs
3 + * below, using the built @composio/core. Run from the repository root after
4 + * `pnpm --filter @composio/core build`:
5 + *
6 + * node ts/packages/core/test/fixtures/json-schema-conversion/generate-strict-cases.mjs
7 + *
8 + * The JSON is the pinned contract; this script only derives it so both SDK
9 + * test suites assert against identical expectations. Format the TypeScript
10 + * copy with prettier before copying (the pre-commit hook would otherwise
11 + * make the copies differ).
12 + */
13 +import fs from 'node:fs';
14 +import path from 'node:path';
15 +import { fileURLToPath } from 'node:url';
16 +
17 +const here = path.dirname(fileURLToPath(import.meta.url));
18 +const repoRoot = path.resolve(here, '../../../../../..');
19 +const { toStrictJsonSchema, omitNullToolArguments } = await import(
20 + path.join(repoRoot, 'ts/packages/core/dist/index.mjs')
21 +);
22 +const obj = (properties, required, extra = {}) => ({
23 + type: 'object',
24 + properties,
25 + ...(required ? { required } : {}),
26 + ...extra,
27 +});
28 +const cases = [
29 + [
30 + 'flat-all-required-unchanged',
31 + 'An already-strict schema is returned unchanged with no changes.',
32 + obj({ query: { type: 'string' } }, ['query'], { additionalProperties: false }),
33 + ],
34 + [
35 + 'nested-optional-property-widened',
36 + 'Optional properties stay, become required and accept null at every depth.',
37 + obj(
38 + {
39 + cfg: obj(
40 + { url: { type: 'string' }, note: { type: 'string', description: 'optional note' } },
41 + ['url']
42 + ),
43 + },
44 + ['cfg']
45 + ),
46 + ],
47 + [
48 + 'no-required-array-widens-every-property',
49 + 'An object without `required` requires and widens every property.',
50 + obj({ a: { type: 'string' }, b: { type: 'number' } }),
51 + ],
52 + [
53 + 'required-empty-array-widens-every-property',
54 + 'An empty `required` array is the same as an absent one.',
55 + obj({ a: { type: 'string' } }, []),
56 + ],
57 + [
58 + 'nullable-type-array-kept',
59 + 'A `type` array with null is accepted by the API and left alone.',
60 + obj({ id: { type: ['string', 'null'], description: 'identifier' } }, ['id']),
61 + ],
62 + [
63 + 'nullable-object-stays-nullable',
64 + 'A nullable object keeps its type array; only its own properties are closed.',
65 + obj(
66 + { cfg: { type: ['object', 'null'], properties: { a: { type: 'string' } }, required: ['a'] } },
67 + ['cfg']
68 + ),
69 + ],
70 + [
71 + 'nullable-array-kept',
72 + 'A nullable array keeps its type array and items.',
73 + obj({ xs: { type: ['array', 'null'], items: { type: 'string' } } }, ['xs']),
74 + ],
75 + [
76 + 'optional-any-of-gets-null-branch',
77 + 'An optional composition gains a null branch instead of a sibling type.',
78 + obj({ value: { anyOf: [{ type: 'string' }, { type: 'number' }] } }),
79 + ],
80 + [
81 + 'any-of-already-nullable-unchanged',
82 + 'A composition that already accepts null is not widened twice.',
83 + obj({ value: { anyOf: [{ type: 'string' }, { type: 'null' }] } }),
84 + ],
85 + [
86 + 'optional-enum-only-wrapped',
87 + 'An enum-only property is wrapped so the annotation stays outside the anyOf.',
88 + obj({ choice: { enum: ['a', 'b'], description: 'pick one', title: 'Choice' } }),
89 + ],
90 + [
91 + 'optional-const-wrapped',
92 + 'A const-only property is wrapped in an anyOf with a null branch.',
93 + obj({ kind: { const: 'fixed' } }),
94 + ],
95 + [
96 + 'optional-empty-schema-unchanged',
97 + 'An empty schema already accepts null and is left alone.',
98 + obj({ anything: {} }),
99 + ],
100 + [
101 + 'multi-type-array-gains-null',
102 + 'A multi-type array gains null instead of being converted to anyOf.',
103 + obj({ value: { type: ['string', 'number'] } }),
104 + ],
105 + [
106 + 'one-of-converted-to-any-of',
107 + 'oneOf is unsupported and becomes anyOf.',
108 + obj({ either: { oneOf: [{ type: 'string' }, { type: 'number' }] } }, ['either']),
109 + ],
110 + [
111 + 'array-items-object-normalized',
112 + 'Objects inside array items are closed and widened.',
113 + obj(
114 + {
115 + rows: {
116 + type: 'array',
117 + items: obj({ id: { type: 'string' }, tag: { type: 'string' } }, ['id']),
118 + },
119 + },
120 + ['rows']
121 + ),
122 + ],
123 + [
124 + 'default-and-examples-stripped',
125 + 'Annotation keywords the API rejects are stripped and reported.',
126 + obj({ name: { type: 'string', examples: ['a'], default: 'x' } }, ['name']),
127 + ],
128 + [
129 + 'enum-values-are-data-not-keywords',
130 + 'Keys inside enum/const values are data and must not be treated as keywords.',
131 + obj({ opts: { enum: [{ default: 1, properties: {} }, null] } }, ['opts']),
132 + ],
133 + [
134 + 'property-names-are-not-keywords',
135 + 'Properties named like keywords are ordinary properties.',
136 + obj({
137 + default: { type: 'string' },
138 + $ref: { type: 'string' },
139 + type: { type: 'string' },
140 + properties: obj({ x: { type: 'string' } }),
141 + }),
142 + ],
143 + [
144 + 'prototype-key-property-name',
145 + 'A property named __proto__ or constructor is handled as a plain name.',
146 + JSON.parse(
147 + '{"type":"object","properties":{"__proto__":{"type":"string"},"constructor":{"type":"number"}}}'
148 + ),
149 + ],
150 + [
151 + 'schema-valued-additional-properties-unsupported',
152 + 'A map-style object cannot be expressed and is reported, not closed.',
153 + obj({ headers: { type: 'object', additionalProperties: { type: 'string' } } }, ['headers']),
154 + ],
155 + [
156 + 'additional-properties-true-unsupported',
157 + 'An explicitly open object is reported.',
158 + obj({ open: { type: 'object', additionalProperties: true } }, ['open']),
159 + ],
160 + [
161 + 'additional-properties-empty-schema-unsupported',
162 + 'An empty-schema additionalProperties accepts anything and is reported.',
163 + obj({ open: { type: 'object', additionalProperties: {} } }, ['open']),
164 + ],
165 + [
166 + 'free-form-object-unsupported',
167 + 'A property-less object accepts arbitrary keys and is reported.',
168 + obj({ meta: { type: 'object', description: 'any json' } }, ['meta']),
169 + ],
170 + [
171 + 'pattern-properties-unsupported',
172 + 'patternProperties cannot be expressed and is reported.',
173 + obj({ tagged: { type: 'object', patternProperties: { '^x-': { type: 'string' } } } }, [
174 + 'tagged',
175 + ]),
176 + ],
177 + [
178 + 'empty-closed-object-representable',
179 + 'An object closed with no properties is representable.',
180 + obj({ empty: { type: 'object', additionalProperties: false } }, ['empty']),
181 + ],
182 + [
183 + 'all-of-unsupported',
184 + 'allOf has no lossless rewrite and is reported.',
185 + obj({ all: { allOf: [{ type: 'string' }] } }, ['all']),
186 + ],
187 + [
188 + 'prefix-items-unsupported',
189 + 'prefixItems has no lossless rewrite and is reported.',
190 + obj({ pair: { type: 'array', prefixItems: [{ type: 'number' }] } }, ['pair']),
191 + ],
192 + [
193 + 'defs-ref-kept-and-definition-normalized',
194 + 'Local $refs are kept and the definition is normalized where it is declared.',
195 + obj({ cfg: { $ref: '#/$defs/Config' } }, ['cfg'], {
196 + $defs: { Config: obj({ url: { type: 'string' }, note: { type: 'string' } }, ['url']) },
197 + }),
198 + ],
199 + [
200 + 'optional-ref-widened-with-null-branch',
201 + 'An optional $ref property is widened with an anyOf null branch.',
202 + obj({ cfg: { $ref: '#/$defs/Config', description: 'optional' } }, undefined, {
203 + $defs: { Config: obj({ url: { type: 'string' } }, ['url']) },
204 + }),
205 + ],
206 + [
207 + 'recursive-defs-kept',
208 + 'Self-recursive definitions are representable.',
209 + obj({ node: { $ref: '#/$defs/Node' } }, ['node'], {
210 + $defs: {
211 + Node: obj({ child: { $ref: '#/$defs/Node' }, label: { type: 'string' } }, ['label']),
212 + },
213 + }),
214 + ],
215 + [
216 + 'mutually-recursive-defs-kept',
217 + 'Mutually recursive definitions are representable.',
218 + obj({ a: { $ref: '#/$defs/A' } }, ['a'], {
219 + $defs: { A: obj({ b: { $ref: '#/$defs/B' } }), B: obj({ a: { $ref: '#/$defs/A' } }) },
220 + }),
221 + ],
222 + [
223 + 'legacy-definitions-ref-kept',
224 + 'Legacy definitions are supported like $defs.',
225 + obj({ cfg: { $ref: '#/definitions/Config' } }, ['cfg'], {
226 + definitions: { Config: obj({ url: { type: 'string' } }) },
227 + }),
228 + ],
229 + [
230 + 'ref-into-properties-kept',
231 + 'A local $ref outside $defs resolves and is kept.',
232 + obj({ a: obj({ x: { type: 'string' } }, ['x']), b: { $ref: '#/properties/a' } }, ['a', 'b']),
233 + ],
234 + [
235 + 'dangling-ref-unsupported',
236 + 'A $ref without a target is reported at its own path.',
237 + obj({ cfg: { $ref: '#/$defs/Nope' } }, ['cfg']),
238 + ],
239 + [
240 + 'external-ref-unsupported',
241 + 'A $ref outside the document is reported.',
242 + obj({ cfg: { $ref: 'https://example.com/schema.json' } }, ['cfg']),
243 + ],
244 + [
245 + 'duplicate-required-deduped',
246 + 'Duplicate required entries are removed.',
247 + obj({ a: { type: 'string' } }, ['a', 'a']),
248 + ],
249 + [
250 + 'required-unknown-names-dropped',
251 + 'Required names without a property are dropped from required.',
252 + obj({ a: { type: 'string' } }, ['a', 'ghost']),
253 + ],
254 + [
255 + 'required-not-an-array-ignored',
256 + 'A malformed required is treated as absent.',
257 + obj({ a: { type: 'string' } }, 'a'),
258 + ],
259 + [
260 + 'description-kept-on-widened-node',
261 + 'Annotations survive widening.',
262 + obj({ a: { type: 'integer', description: 'count', title: 'Count', minimum: 0 } }),
263 + ],
264 + ['non-object-root-unsupported', 'The root must be an object.', { type: 'string' }],
265 + [
266 + 'nullable-root-unsupported',
267 + 'The root must not be nullable.',
268 + { type: ['object', 'null'], properties: { a: { type: 'string' } } },
269 + ],
270 + [
271 + 'properties-without-type-become-object',
272 + 'A node with properties but no type is treated as an object.',
273 + obj({ cfg: { properties: { a: { type: 'string' } } } }, ['cfg']),
274 + ],
275 + [
276 + 'root-without-type-become-object',
277 + 'A root with properties but no type is treated as an object.',
278 + { properties: { a: { type: 'string' } } },
279 + ],
280 + // Edge cases enumerated independently with a second model.
281 + [
282 + 'root-single-element-type-array-accepted',
283 + 'A root typed ["object"] is an object root.',
284 + { type: ['object'], properties: { a: { type: 'string' } }, required: ['a'] },
285 + ],
286 + [
287 + 'three-member-type-array-gains-null',
288 + 'A three-member type array gains null once.',
289 + obj({ v: { type: ['string', 'number', 'boolean'] } }),
290 + ],
291 + [
292 + 'optional-null-only-property-unchanged',
293 + 'A property typed null already accepts null.',
294 + obj({ nothing: { type: 'null' } }),
295 + ],
296 + [
297 + 'optional-enum-with-null-not-rewrapped',
298 + 'An enum that already lists null is not wrapped again.',
299 + obj({ choice: { enum: ['a', null] } }),
300 + ],
301 + [
302 + 'optional-const-null-not-rewrapped',
303 + 'A const null already accepts null.',
304 + obj({ nothing: { const: null } }),
305 + ],
306 + [
307 + 'nested-any-of-branch-widened',
308 + 'Optional properties inside anyOf branches are widened.',
309 + obj({ v: { anyOf: [obj({ a: { type: 'string' } }), { type: 'string' }] } }, ['v']),
310 + ],
311 + [
312 + 'array-of-nullable-objects-closed',
313 + 'Nullable objects inside array items are closed and stay nullable.',
314 + obj(
315 + {
316 + rows: {
317 + type: 'array',
318 + items: { type: ['object', 'null'], properties: { id: { type: 'string' } } },
319 + },
320 + },
321 + ['rows']
322 + ),
323 + ],
324 + [
325 + 'tuple-form-items-unsupported',
326 + 'Draft-4 tuple items have no strict-mode equivalent.',
327 + obj({ pair: { type: 'array', items: [{ type: 'number' }, { type: 'string' }] } }, ['pair']),
328 + ],
329 + [
330 + 'boolean-items-unsupported',
331 + 'A boolean items subschema is reported.',
332 + obj({ xs: { type: 'array', items: true } }, ['xs']),
333 + ],
334 + [
335 + 'not-keyword-unsupported',
336 + 'not has no strict-mode equivalent.',
337 + obj({ v: { not: { type: 'string' } } }, ['v']),
338 + ],
339 + [
340 + 'if-then-else-unsupported',
341 + 'Conditional keywords have no strict-mode equivalent.',
342 + obj(
343 + { v: { type: 'string', if: { minLength: 1 }, then: { maxLength: 5 }, else: { const: '' } } },
344 + ['v']
345 + ),
346 + ],
347 + [
348 + 'dependent-schemas-unsupported',
349 + 'dependentSchemas has no strict-mode equivalent.',
350 + obj({ a: { type: 'string' } }, ['a'], {
351 + dependentSchemas: { a: obj({ b: { type: 'string' } }) },
352 + }),
353 + ],
354 + [
355 + 'property-names-keyword-unsupported',
356 + 'propertyNames has no strict-mode equivalent.',
357 + obj({ a: { type: 'string' } }, ['a'], { propertyNames: { pattern: '^a' } }),
358 + ],
359 + [
360 + 'one-of-beside-any-of-unsupported',
361 + 'oneOf next to anyOf cannot be merged and is reported.',
362 + obj({ v: { anyOf: [{ type: 'string' }], oneOf: [{ type: 'number' }] } }, ['v']),
363 + ],
364 + [
365 + 'boolean-property-subschema-unsupported',
366 + 'A boolean property subschema is reported.',
367 + obj({ anything: true, nothing: false }, ['anything', 'nothing']),
368 + ],
369 + [
370 + 'properties-not-an-object-unsupported',
371 + 'A malformed properties value is reported instead of emptied.',
372 + obj('not-a-map', ['a']),
373 + ],
374 + [
375 + 'ref-with-siblings-kept',
376 + 'Sibling keywords next to a $ref are kept.',
377 + obj({ cfg: { $ref: '#/$defs/Config', description: 'cfg', title: 'Config' } }, ['cfg'], {
378 + $defs: { Config: obj({ a: { type: 'string' } }, ['a']) },
379 + }),
380 + ],
381 + [
382 + 'required-non-string-entries-ignored',
383 + 'Non-string required entries are ignored.',
384 + obj({ a: { type: 'string' }, b: { type: 'string' } }, ['a', 1, null]),
385 + ],
386 + [
387 + 'dynamic-keys-reported-once-with-pattern-properties',
388 + 'additionalProperties and patternProperties on one node report additionalProperties.',
389 + obj(
390 + {
391 + m: {
392 + type: 'object',
393 + additionalProperties: { type: 'string' },
394 + patternProperties: { '^x': { type: 'string' } },
395 + },
396 + },
397 + ['m']
398 + ),
399 + ],
400 + [
401 + 'empty-properties-open-object-unsupported',
402 + 'An object with empty properties and no closing is free-form.',
403 + obj({ m: { type: 'object', properties: {} } }, ['m']),
404 + ],
405 + [
406 + 'default-stripped-then-widened',
407 + 'Stripping default and widening compose.',
408 + obj({ a: { type: 'string', default: 'x' } }),
409 + ],
410 + [
411 + 'nested-any-of-in-any-of-kept',
412 + 'A composition nested inside a composition is normalized branch by branch.',
413 + obj(
414 + {
415 + v: {
416 + anyOf: [
417 + { anyOf: [obj({ a: { type: 'string' } }), { type: 'number' }] },
418 + { type: 'string' },
419 + ],
420 + },
421 + },
422 + ['v']
423 + ),
424 + ],
425 + [
426 + 'definitions-and-defs-both-normalized',
427 + 'Legacy definitions and $defs coexist and both are normalized.',
428 + obj({ a: { $ref: '#/$defs/A' }, b: { $ref: '#/definitions/B' } }, ['a', 'b'], {
429 + $defs: { A: obj({ x: { type: 'string' } }) },
430 + definitions: { B: obj({ y: { type: 'string' } }) },
431 + }),
432 + ],
433 + [
434 + 'deep-nesting-normalized-fully',
435 + 'Ten levels of nested objects are normalized at every level.',
436 + (() => {
437 + let node = { type: 'object', properties: { leaf: { type: 'string' } } };
438 + for (let i = 0; i < 10; i++)
439 + node = { type: 'object', properties: { child: node }, required: ['child'] };
440 + return node;
441 + })(),
442 + ],
443 + [
444 + 'chained-refs-resolved',
445 + 'A $ref to a $ref resolves to the final definition.',
446 + obj({ a: { $ref: '#/$defs/Alias' } }, ['a'], {
447 + $defs: { Alias: { $ref: '#/$defs/Real' }, Real: obj({ x: { type: 'string' } }, ['x']) },
448 + }),
449 + ],
450 +];
451 +const argumentCases = {
452 + 'nested-optional-property-widened': [
453 + { input: { cfg: { url: 'u', note: null } }, output: { cfg: { url: 'u' } } },
454 + ],
455 + 'nullable-type-array-kept': [{ input: { id: null }, output: { id: null } }],
456 + 'nullable-object-stays-nullable': [
457 + { input: { cfg: null }, output: { cfg: null } },
458 + { input: { cfg: { a: 'x' } }, output: { cfg: { a: 'x' } } },
459 + ],
460 + 'any-of-already-nullable-unchanged': [{ input: { value: null }, output: { value: null } }],
461 + 'optional-enum-only-wrapped': [{ input: { choice: null }, output: {} }],
462 + 'array-items-object-normalized': [
463 + { input: { rows: [{ id: '1', tag: null }, null] }, output: { rows: [{ id: '1' }, null] } },
464 + ],
465 + 'enum-values-are-data-not-keywords': [{ input: { opts: null }, output: { opts: null } }],
466 + 'property-names-are-not-keywords': [
467 + {
468 + input: { default: null, $ref: 'x', type: null, properties: { x: null } },
469 + output: { $ref: 'x', properties: {} },
470 + },
471 + ],
472 + 'defs-ref-kept-and-definition-normalized': [
473 + { input: { cfg: { url: 'u', note: null } }, output: { cfg: { url: 'u' } } },
474 + ],
475 + 'optional-ref-widened-with-null-branch': [{ input: { cfg: null }, output: {} }],
476 + 'recursive-defs-kept': [
477 + {
478 + input: { node: { label: 'a', child: { label: 'b', child: null } } },
479 + output: { node: { label: 'a', child: { label: 'b' } } },
480 + },
481 + ],
482 + 'no-required-array-widens-every-property': [
483 + { input: { a: null, b: 1, unknown: null }, output: { b: 1, unknown: null } },
484 + ],
485 + 'optional-null-only-property-unchanged': [
486 + { input: { nothing: null }, output: { nothing: null } },
487 + ],
488 + 'optional-enum-with-null-not-rewrapped': [{ input: { choice: null }, output: { choice: null } }],
489 + 'optional-const-null-not-rewrapped': [{ input: { nothing: null }, output: { nothing: null } }],
490 + 'array-of-nullable-objects-closed': [
491 + { input: { rows: [null, { id: null }] }, output: { rows: [null, {}] } },
492 + ],
493 + 'nested-any-of-branch-widened': [
494 + { input: { v: { a: null } }, output: { v: {} } },
495 + { input: { v: null }, output: {} },
496 + ],
497 + 'nested-any-of-in-any-of-kept': [{ input: { v: { a: null } }, output: { v: {} } }],
498 + 'chained-refs-resolved': [
499 + { input: { a: { x: null } }, output: { a: {} } },
500 + { input: { a: null }, output: {} },
501 + ],
502 + 'nullable-array-kept': [
503 + { input: { xs: null }, output: { xs: null } },
504 + { input: { xs: [null] }, output: { xs: [null] } },
505 + ],
506 + 'nested-optional-property-widened': [
507 + { input: { cfg: { url: 'u', note: null } }, output: { cfg: { url: 'u' } } },
508 + { input: { cfg: null }, output: {} },
509 + { input: { cfg: { url: 'u', extra: null } }, output: { cfg: { url: 'u', extra: null } } },
510 + ],
511 +};
512 +const out = { cases: [] };
513 +for (const [id, description, schema] of cases) {
514 + const snapshot = JSON.stringify(schema);
515 + const r = toStrictJsonSchema(schema);
516 + if (JSON.stringify(schema) !== snapshot) throw new Error(`mutated: ${id}`);
517 + const entry = { id, description, schema };
518 + if (r.unsupported.length)
519 + entry.strict = { unsupported: r.unsupported.map(u => ({ path: u.path, keyword: u.keyword })) };
520 + else {
521 + const again = toStrictJsonSchema(r.schema);
522 + if (JSON.stringify(again.schema) !== JSON.stringify(r.schema) || again.changes.length)
523 + throw new Error(`not idempotent: ${id}`);
524 + entry.strict = { schema: r.schema };
525 + }
526 + if (r.changes.length) entry.changes = r.changes.map(c => ({ path: c.path, reason: c.reason }));
527 + if (argumentCases[id]) {
528 + entry.arguments = argumentCases[id].map(({ input, output }) => {
529 + const actual = omitNullToolArguments(input, r.source);
530 + if (JSON.stringify(actual) !== JSON.stringify(output))
531 + throw new Error(
532 + `arguments mismatch ${id}: ${JSON.stringify(actual)} vs ${JSON.stringify(output)}`
533 + );
534 + return { input, output };
535 + });
536 + }
537 + out.cases.push(entry);
538 +}
539 +const json = JSON.stringify(out, null, 2) + '\n';
540 +fs.writeFileSync(path.join(here, 'strict-cases.json'), json);
541 +fs.writeFileSync(
542 + path.join(repoRoot, 'python/tests/fixtures/json-schema-conversion/strict-cases.json'),
543 + json
544 +);
545 +for (const c of out.cases)
546 + console.log(
547 + c.id.padEnd(50),
548 + c.strict.unsupported
549 + ? 'UNSUPPORTED ' + JSON.stringify(c.strict.unsupported)
550 + : 'ok' + (c.changes ? ' changes=' + c.changes.map(x => x.reason.split('-')[0]).join(',') : '')
551 + );
ts/packages/core/test/fixtures/json-schema-conversion/strict-cases.json
+1172 -60
@@ -90,6 +90,26 @@
90 "url": "u"
91 }
92 }
93 + },
94 + {
95 + "input": {
96 + "cfg": null
97 + },
98 + "output": {}
99 + },
100 + {
101 + "input": {
102 + "cfg": {
103 + "url": "u",
104 + "extra": null
105 + }
106 + },
107 + "output": {
108 + "cfg": {
109 + "url": "u",
110 + "extra": null
111 + }
112 + }
113 }
114 ]
115 },
@@ -303,7 +323,25 @@
323 "required": ["xs"],
324 "additionalProperties": false
325 }
306 - }
326 + },
327 + "arguments": [
328 + {
329 + "input": {
330 + "xs": null
331 + },
332 + "output": {
333 + "xs": null
334 + }
335 + },
336 + {
337 + "input": {
338 + "xs": [null]
339 + },
340 + "output": {
341 + "xs": [null]
342 + }
343 + }
344 + ]
345 },
346 {
347 "id": "optional-any-of-gets-null-branch",
@@ -670,65 +708,6 @@
708 }
709 ]
710 },
673 - {
674 - "id": "tuple-items-normalized",
675 - "description": "Objects inside tuple-form items are normalized too.",
676 - "schema": {
677 - "type": "object",
678 - "properties": {
679 - "pair": {
680 - "type": "array",
681 - "items": [
682 - {
683 - "type": "object",
684 - "properties": {
685 - "x": {
686 - "type": "number"
687 - }
688 - }
689 - },
690 - {
691 - "type": "string"
692 - }
693 - ]
694 - }
695 - },
696 - "required": ["pair"]
697 - },
698 - "strict": {
699 - "schema": {
700 - "type": "object",
701 - "properties": {
702 - "pair": {
703 - "type": "array",
704 - "items": [
705 - {
706 - "type": "object",
707 - "properties": {
708 - "x": {
709 - "type": ["number", "null"]
710 - }
711 - },
712 - "required": ["x"],
713 - "additionalProperties": false
714 - },
715 - {
716 - "type": "string"
717 - }
718 - ]
719 - }
720 - },
721 - "required": ["pair"],
722 - "additionalProperties": false
723 - }
724 - },
725 - "changes": [
726 - {
727 - "path": "properties.pair.items[0].properties.x",
728 - "reason": "optional-property-nullable"
729 - }
730 - ]
731 - },
711 {
712 "id": "default-and-examples-stripped",
713 "description": "Annotation keywords the API rejects are stripped and reported.",
@@ -1830,6 +1809,1139 @@
1809 "reason": "optional-property-nullable"
1810 }
1811 ]
1812 + },
1813 + {
1814 + "id": "root-single-element-type-array-accepted",
1815 + "description": "A root typed [\"object\"] is an object root.",
1816 + "schema": {
1817 + "type": ["object"],
1818 + "properties": {
1819 + "a": {
1820 + "type": "string"
1821 + }
1822 + },
1823 + "required": ["a"]
1824 + },
1825 + "strict": {
1826 + "schema": {
1827 + "type": ["object"],
1828 + "properties": {
1829 + "a": {
1830 + "type": "string"
1831 + }
1832 + },
1833 + "required": ["a"],
1834 + "additionalProperties": false
1835 + }
1836 + }
1837 + },
1838 + {
1839 + "id": "three-member-type-array-gains-null",
1840 + "description": "A three-member type array gains null once.",
1841 + "schema": {
1842 + "type": "object",
1843 + "properties": {
1844 + "v": {
1845 + "type": ["string", "number", "boolean"]
1846 + }
1847 + }
1848 + },
1849 + "strict": {
1850 + "schema": {
1851 + "type": "object",
1852 + "properties": {
1853 + "v": {
1854 + "type": ["string", "number", "boolean", "null"]
1855 + }
1856 + },
1857 + "required": ["v"],
1858 + "additionalProperties": false
1859 + }
1860 + },
1861 + "changes": [
1862 + {
1863 + "path": "properties.v",
1864 + "reason": "optional-property-nullable"
1865 + }
1866 + ]
1867 + },
1868 + {
1869 + "id": "optional-null-only-property-unchanged",
1870 + "description": "A property typed null already accepts null.",
1871 + "schema": {
1872 + "type": "object",
1873 + "properties": {
1874 + "nothing": {
1875 + "type": "null"
1876 + }
1877 + }
1878 + },
1879 + "strict": {
1880 + "schema": {
1881 + "type": "object",
1882 + "properties": {
1883 + "nothing": {
1884 + "type": "null"
1885 + }
1886 + },
1887 + "required": ["nothing"],
1888 + "additionalProperties": false
1889 + }
1890 + },
1891 + "changes": [
1892 + {
1893 + "path": "properties.nothing",
1894 + "reason": "optional-property-nullable"
1895 + }
1896 + ],
1897 + "arguments": [
1898 + {
1899 + "input": {
1900 + "nothing": null
1901 + },
1902 + "output": {
1903 + "nothing": null
1904 + }
1905 + }
1906 + ]
1907 + },
1908 + {
1909 + "id": "optional-enum-with-null-not-rewrapped",
1910 + "description": "An enum that already lists null is not wrapped again.",
1911 + "schema": {
1912 + "type": "object",
1913 + "properties": {
1914 + "choice": {
1915 + "enum": ["a", null]
1916 + }
1917 + }
1918 + },
1919 + "strict": {
1920 + "schema": {
1921 + "type": "object",
1922 + "properties": {
1923 + "choice": {
1924 + "enum": ["a", null]
1925 + }
1926 + },
1927 + "required": ["choice"],
1928 + "additionalProperties": false
1929 + }
1930 + },
1931 + "changes": [
1932 + {
1933 + "path": "properties.choice",
1934 + "reason": "optional-property-nullable"
1935 + }
1936 + ],
1937 + "arguments": [
1938 + {
1939 + "input": {
1940 + "choice": null
1941 + },
1942 + "output": {
1943 + "choice": null
1944 + }
1945 + }
1946 + ]
1947 + },
1948 + {
1949 + "id": "optional-const-null-not-rewrapped",
1950 + "description": "A const null already accepts null.",
1951 + "schema": {
1952 + "type": "object",
1953 + "properties": {
1954 + "nothing": {
1955 + "const": null
1956 + }
1957 + }
1958 + },
1959 + "strict": {
1960 + "schema": {
1961 + "type": "object",
1962 + "properties": {
1963 + "nothing": {
1964 + "const": null
1965 + }
1966 + },
1967 + "required": ["nothing"],
1968 + "additionalProperties": false
1969 + }
1970 + },
1971 + "changes": [
1972 + {
1973 + "path": "properties.nothing",
1974 + "reason": "optional-property-nullable"
1975 + }
1976 + ],
1977 + "arguments": [
1978 + {
1979 + "input": {
1980 + "nothing": null
1981 + },
1982 + "output": {
1983 + "nothing": null
1984 + }
1985 + }
1986 + ]
1987 + },
1988 + {
1989 + "id": "nested-any-of-branch-widened",
1990 + "description": "Optional properties inside anyOf branches are widened.",
1991 + "schema": {
1992 + "type": "object",
1993 + "properties": {
1994 + "v": {
1995 + "anyOf": [
1996 + {
1997 + "type": "object",
1998 + "properties": {
1999 + "a": {
2000 + "type": "string"
2001 + }
2002 + }
2003 + },
2004 + {
2005 + "type": "string"
2006 + }
2007 + ]
2008 + }
2009 + },
2010 + "required": ["v"]
2011 + },
2012 + "strict": {
2013 + "schema": {
2014 + "type": "object",
2015 + "properties": {
2016 + "v": {
2017 + "anyOf": [
2018 + {
2019 + "type": "object",
2020 + "properties": {
2021 + "a": {
2022 + "type": ["string", "null"]
2023 + }
2024 + },
2025 + "required": ["a"],
2026 + "additionalProperties": false
2027 + },
2028 + {
2029 + "type": "string"
2030 + }
2031 + ]
2032 + }
2033 + },
2034 + "required": ["v"],
2035 + "additionalProperties": false
2036 + }
2037 + },
2038 + "changes": [
2039 + {
2040 + "path": "properties.v.anyOf[0].properties.a",
2041 + "reason": "optional-property-nullable"
2042 + }
2043 + ],
2044 + "arguments": [
2045 + {
2046 + "input": {
2047 + "v": {
2048 + "a": null
2049 + }
2050 + },
2051 + "output": {
2052 + "v": {}
2053 + }
2054 + },
2055 + {
2056 + "input": {
2057 + "v": null
2058 + },
2059 + "output": {}
2060 + }
2061 + ]
2062 + },
2063 + {
2064 + "id": "array-of-nullable-objects-closed",
2065 + "description": "Nullable objects inside array items are closed and stay nullable.",
2066 + "schema": {
2067 + "type": "object",
2068 + "properties": {
2069 + "rows": {
2070 + "type": "array",
2071 + "items": {
2072 + "type": ["object", "null"],
2073 + "properties": {
2074 + "id": {
2075 + "type": "string"
2076 + }
2077 + }
2078 + }
2079 + }
2080 + },
2081 + "required": ["rows"]
2082 + },
2083 + "strict": {
2084 + "schema": {
2085 + "type": "object",
2086 + "properties": {
2087 + "rows": {
2088 + "type": "array",
2089 + "items": {
2090 + "type": ["object", "null"],
2091 + "properties": {
2092 + "id": {
2093 + "type": ["string", "null"]
2094 + }
2095 + },
2096 + "required": ["id"],
2097 + "additionalProperties": false
2098 + }
2099 + }
2100 + },
2101 + "required": ["rows"],
2102 + "additionalProperties": false
2103 + }
2104 + },
2105 + "changes": [
2106 + {
2107 + "path": "properties.rows.items.properties.id",
2108 + "reason": "optional-property-nullable"
2109 + }
2110 + ],
2111 + "arguments": [
2112 + {
2113 + "input": {
2114 + "rows": [
2115 + null,
2116 + {
2117 + "id": null
2118 + }
2119 + ]
2120 + },
2121 + "output": {
2122 + "rows": [null, {}]
2123 + }
2124 + }
2125 + ]
2126 + },
2127 + {
2128 + "id": "tuple-form-items-unsupported",
2129 + "description": "Draft-4 tuple items have no strict-mode equivalent.",
2130 + "schema": {
2131 + "type": "object",
2132 + "properties": {
2133 + "pair": {
2134 + "type": "array",
2135 + "items": [
2136 + {
2137 + "type": "number"
2138 + },
2139 + {
2140 + "type": "string"
2141 + }
2142 + ]
2143 + }
2144 + },
2145 + "required": ["pair"]
2146 + },
2147 + "strict": {
2148 + "unsupported": [
2149 + {
2150 + "path": "properties.pair",
2151 + "keyword": "items"
2152 + }
2153 + ]
2154 + }
2155 + },
2156 + {
2157 + "id": "boolean-items-unsupported",
2158 + "description": "A boolean items subschema is reported.",
2159 + "schema": {
2160 + "type": "object",
2161 + "properties": {
2162 + "xs": {
2163 + "type": "array",
2164 + "items": true
2165 + }
2166 + },
2167 + "required": ["xs"]
2168 + },
2169 + "strict": {
2170 + "unsupported": [
2171 + {
2172 + "path": "properties.xs",
2173 + "keyword": "items"
2174 + }
2175 + ]
2176 + }
2177 + },
2178 + {
2179 + "id": "not-keyword-unsupported",
2180 + "description": "not has no strict-mode equivalent.",
2181 + "schema": {
2182 + "type": "object",
2183 + "properties": {
2184 + "v": {
2185 + "not": {
2186 + "type": "string"
2187 + }
2188 + }
2189 + },
2190 + "required": ["v"]
2191 + },
2192 + "strict": {
2193 + "unsupported": [
2194 + {
2195 + "path": "properties.v",
2196 + "keyword": "not"
2197 + }
2198 + ]
2199 + }
2200 + },
2201 + {
2202 + "id": "if-then-else-unsupported",
2203 + "description": "Conditional keywords have no strict-mode equivalent.",
2204 + "schema": {
2205 + "type": "object",
2206 + "properties": {
2207 + "v": {
2208 + "type": "string",
2209 + "if": {
2210 + "minLength": 1
2211 + },
2212 + "then": {
2213 + "maxLength": 5
2214 + },
2215 + "else": {
2216 + "const": ""
2217 + }
2218 + }
2219 + },
2220 + "required": ["v"]
2221 + },
2222 + "strict": {
2223 + "unsupported": [
2224 + {
2225 + "path": "properties.v",
2226 + "keyword": "else"
2227 + },
2228 + {
2229 + "path": "properties.v",
2230 + "keyword": "if"
2231 + },
2232 + {
2233 + "path": "properties.v",
2234 + "keyword": "then"
2235 + }
2236 + ]
2237 + }
2238 + },
2239 + {
2240 + "id": "dependent-schemas-unsupported",
2241 + "description": "dependentSchemas has no strict-mode equivalent.",
2242 + "schema": {
2243 + "type": "object",
2244 + "properties": {
2245 + "a": {
2246 + "type": "string"
2247 + }
2248 + },
2249 + "required": ["a"],
2250 + "dependentSchemas": {
2251 + "a": {
2252 + "type": "object",
2253 + "properties": {
2254 + "b": {
2255 + "type": "string"
2256 + }
2257 + }
2258 + }
2259 + }
2260 + },
2261 + "strict": {
2262 + "unsupported": [
2263 + {
2264 + "path": "",
2265 + "keyword": "dependentSchemas"
2266 + }
2267 + ]
2268 + },
2269 + "changes": [
2270 + {
2271 + "path": "dependentSchemas.a.properties.b",
2272 + "reason": "optional-property-nullable"
2273 + }
2274 + ]
2275 + },
2276 + {
2277 + "id": "property-names-keyword-unsupported",
2278 + "description": "propertyNames has no strict-mode equivalent.",
2279 + "schema": {
2280 + "type": "object",
2281 + "properties": {
2282 + "a": {
2283 + "type": "string"
2284 + }
2285 + },
2286 + "required": ["a"],
2287 + "propertyNames": {
2288 + "pattern": "^a"
2289 + }
2290 + },
2291 + "strict": {
2292 + "unsupported": [
2293 + {
2294 + "path": "",
2295 + "keyword": "propertyNames"
2296 + }
2297 + ]
2298 + }
2299 + },
2300 + {
2301 + "id": "one-of-beside-any-of-unsupported",
2302 + "description": "oneOf next to anyOf cannot be merged and is reported.",
2303 + "schema": {
2304 + "type": "object",
2305 + "properties": {
2306 + "v": {
2307 + "anyOf": [
2308 + {
2309 + "type": "string"
2310 + }
2311 + ],
2312 + "oneOf": [
2313 + {
2314 + "type": "number"
2315 + }
2316 + ]
2317 + }
2318 + },
2319 + "required": ["v"]
2320 + },
2321 + "strict": {
2322 + "unsupported": [
2323 + {
2324 + "path": "properties.v",
2325 + "keyword": "oneOf"
2326 + }
2327 + ]
2328 + }
2329 + },
2330 + {
2331 + "id": "boolean-property-subschema-unsupported",
2332 + "description": "A boolean property subschema is reported.",
2333 + "schema": {
2334 + "type": "object",
2335 + "properties": {
2336 + "anything": true,
2337 + "nothing": false
2338 + },
2339 + "required": ["anything", "nothing"]
2340 + },
2341 + "strict": {
2342 + "unsupported": [
2343 + {
2344 + "path": "properties.anything",
2345 + "keyword": "properties"
2346 + },
2347 + {
2348 + "path": "properties.nothing",
2349 + "keyword": "properties"
2350 + }
2351 + ]
2352 + }
2353 + },
2354 + {
2355 + "id": "properties-not-an-object-unsupported",
2356 + "description": "A malformed properties value is reported instead of emptied.",
2357 + "schema": {
2358 + "type": "object",
2359 + "properties": "not-a-map",
2360 + "required": ["a"]
2361 + },
2362 + "strict": {
2363 + "unsupported": [
2364 + {
2365 + "path": "",
2366 + "keyword": "properties"
2367 + }
2368 + ]
2369 + }
2370 + },
2371 + {
2372 + "id": "ref-with-siblings-kept",
2373 + "description": "Sibling keywords next to a $ref are kept.",
2374 + "schema": {
2375 + "type": "object",
2376 + "properties": {
2377 + "cfg": {
2378 + "$ref": "#/$defs/Config",
2379 + "description": "cfg",
2380 + "title": "Config"
2381 + }
2382 + },
2383 + "required": ["cfg"],
2384 + "$defs": {
2385 + "Config": {
2386 + "type": "object",
2387 + "properties": {
2388 + "a": {
2389 + "type": "string"
2390 + }
2391 + },
2392 + "required": ["a"]
2393 + }
2394 + }
2395 + },
2396 + "strict": {
2397 + "schema": {
2398 + "type": "object",
2399 + "properties": {
2400 + "cfg": {
2401 + "$ref": "#/$defs/Config",
2402 + "description": "cfg",
2403 + "title": "Config"
2404 + }
2405 + },
2406 + "required": ["cfg"],
2407 + "$defs": {
2408 + "Config": {
2409 + "type": "object",
2410 + "properties": {
2411 + "a": {
2412 + "type": "string"
2413 + }
2414 + },
2415 + "required": ["a"],
2416 + "additionalProperties": false
2417 + }
2418 + },
2419 + "additionalProperties": false
2420 + }
2421 + }
2422 + },
2423 + {
2424 + "id": "required-non-string-entries-ignored",
2425 + "description": "Non-string required entries are ignored.",
2426 + "schema": {
2427 + "type": "object",
2428 + "properties": {
2429 + "a": {
2430 + "type": "string"
2431 + },
2432 + "b": {
2433 + "type": "string"
2434 + }
2435 + },
2436 + "required": ["a", 1, null]
2437 + },
2438 + "strict": {
2439 + "schema": {
2440 + "type": "object",
2441 + "properties": {
2442 + "a": {
2443 + "type": "string"
2444 + },
2445 + "b": {
2446 + "type": ["string", "null"]
2447 + }
2448 + },
2449 + "required": ["a", "b"],
2450 + "additionalProperties": false
2451 + }
2452 + },
2453 + "changes": [
2454 + {
2455 + "path": "properties.b",
2456 + "reason": "optional-property-nullable"
2457 + }
2458 + ]
2459 + },
2460 + {
2461 + "id": "dynamic-keys-reported-once-with-pattern-properties",
2462 + "description": "additionalProperties and patternProperties on one node report additionalProperties.",
2463 + "schema": {
2464 + "type": "object",
2465 + "properties": {
2466 + "m": {
2467 + "type": "object",
2468 + "additionalProperties": {
2469 + "type": "string"
2470 + },
2471 + "patternProperties": {
2472 + "^x": {
2473 + "type": "string"
2474 + }
2475 + }
2476 + }
2477 + },
2478 + "required": ["m"]
2479 + },
2480 + "strict": {
2481 + "unsupported": [
2482 + {
2483 + "path": "properties.m",
2484 + "keyword": "additionalProperties"
2485 + }
2486 + ]
2487 + }
2488 + },
2489 + {
2490 + "id": "empty-properties-open-object-unsupported",
2491 + "description": "An object with empty properties and no closing is free-form.",
2492 + "schema": {
2493 + "type": "object",
2494 + "properties": {
2495 + "m": {
2496 + "type": "object",
2497 + "properties": {}
2498 + }
2499 + },
2500 + "required": ["m"]
2501 + },
2502 + "strict": {
2503 + "unsupported": [
2504 + {
2505 + "path": "properties.m",
2506 + "keyword": "properties"
2507 + }
2508 + ]
2509 + }
2510 + },
2511 + {
2512 + "id": "default-stripped-then-widened",
2513 + "description": "Stripping default and widening compose.",
2514 + "schema": {
2515 + "type": "object",
2516 + "properties": {
2517 + "a": {
2518 + "type": "string",
2519 + "default": "x"
2520 + }
2521 + }
2522 + },
2523 + "strict": {
2524 + "schema": {
2525 + "type": "object",
2526 + "properties": {
2527 + "a": {
2528 + "type": ["string", "null"]
2529 + }
2530 + },
2531 + "required": ["a"],
2532 + "additionalProperties": false
2533 + }
2534 + },
2535 + "changes": [
2536 + {
2537 + "path": "properties.a",
2538 + "reason": "unsupported-keyword-stripped"
2539 + },
2540 + {
2541 + "path": "properties.a",
2542 + "reason": "optional-property-nullable"
2543 + }
2544 + ]
2545 + },
2546 + {
2547 + "id": "nested-any-of-in-any-of-kept",
2548 + "description": "A composition nested inside a composition is normalized branch by branch.",
2549 + "schema": {
2550 + "type": "object",
2551 + "properties": {
2552 + "v": {
2553 + "anyOf": [
2554 + {
2555 + "anyOf": [
2556 + {
2557 + "type": "object",
2558 + "properties": {
2559 + "a": {
2560 + "type": "string"
2561 + }
2562 + }
2563 + },
2564 + {
2565 + "type": "number"
2566 + }
2567 + ]
2568 + },
2569 + {
2570 + "type": "string"
2571 + }
2572 + ]
2573 + }
2574 + },
2575 + "required": ["v"]
2576 + },
2577 + "strict": {
2578 + "schema": {
2579 + "type": "object",
2580 + "properties": {
2581 + "v": {
2582 + "anyOf": [
2583 + {
2584 + "anyOf": [
2585 + {
2586 + "type": "object",
2587 + "properties": {
2588 + "a": {
2589 + "type": ["string", "null"]
2590 + }
2591 + },
2592 + "required": ["a"],
2593 + "additionalProperties": false
2594 + },
2595 + {
2596 + "type": "number"
2597 + }
2598 + ]
2599 + },
2600 + {
2601 + "type": "string"
2602 + }
2603 + ]
2604 + }
2605 + },
2606 + "required": ["v"],
2607 + "additionalProperties": false
2608 + }
2609 + },
2610 + "changes": [
2611 + {
2612 + "path": "properties.v.anyOf[0].anyOf[0].properties.a",
2613 + "reason": "optional-property-nullable"
2614 + }
2615 + ],
2616 + "arguments": [
2617 + {
2618 + "input": {
2619 + "v": {
2620 + "a": null
2621 + }
2622 + },
2623 + "output": {
2624 + "v": {}
2625 + }
2626 + }
2627 + ]
2628 + },
2629 + {
2630 + "id": "definitions-and-defs-both-normalized",
2631 + "description": "Legacy definitions and $defs coexist and both are normalized.",
2632 + "schema": {
2633 + "type": "object",
2634 + "properties": {
2635 + "a": {
2636 + "$ref": "#/$defs/A"
2637 + },
2638 + "b": {
2639 + "$ref": "#/definitions/B"
2640 + }
2641 + },
2642 + "required": ["a", "b"],
2643 + "$defs": {
2644 + "A": {
2645 + "type": "object",
2646 + "properties": {
2647 + "x": {
2648 + "type": "string"
2649 + }
2650 + }
2651 + }
2652 + },
2653 + "definitions": {
2654 + "B": {
2655 + "type": "object",
2656 + "properties": {
2657 + "y": {
2658 + "type": "string"
2659 + }
2660 + }
2661 + }
2662 + }
2663 + },
2664 + "strict": {
2665 + "schema": {
2666 + "type": "object",
2667 + "properties": {
2668 + "a": {
2669 + "$ref": "#/$defs/A"
2670 + },
2671 + "b": {
2672 + "$ref": "#/definitions/B"
2673 + }
2674 + },
2675 + "required": ["a", "b"],
2676 + "$defs": {
2677 + "A": {
2678 + "type": "object",
2679 + "properties": {
2680 + "x": {
2681 + "type": ["string", "null"]
2682 + }
2683 + },
2684 + "required": ["x"],
2685 + "additionalProperties": false
2686 + }
2687 + },
2688 + "definitions": {
2689 + "B": {
2690 + "type": "object",
2691 + "properties": {
2692 + "y": {
2693 + "type": ["string", "null"]
2694 + }
2695 + },
2696 + "required": ["y"],
2697 + "additionalProperties": false
2698 + }
2699 + },
2700 + "additionalProperties": false
2701 + }
2702 + },
2703 + "changes": [
2704 + {
2705 + "path": "$defs.A.properties.x",
2706 + "reason": "optional-property-nullable"
2707 + },
2708 + {
2709 + "path": "definitions.B.properties.y",
2710 + "reason": "optional-property-nullable"
2711 + }
2712 + ]
2713 + },
2714 + {
2715 + "id": "deep-nesting-normalized-fully",
2716 + "description": "Ten levels of nested objects are normalized at every level.",
2717 + "schema": {
2718 + "type": "object",
2719 + "properties": {
2720 + "child": {
2721 + "type": "object",
2722 + "properties": {
2723 + "child": {
2724 + "type": "object",
2725 + "properties": {
2726 + "child": {
2727 + "type": "object",
2728 + "properties": {
2729 + "child": {
2730 + "type": "object",
2731 + "properties": {
2732 + "child": {
2733 + "type": "object",
2734 + "properties": {
2735 + "child": {
2736 + "type": "object",
2737 + "properties": {
2738 + "child": {
2739 + "type": "object",
2740 + "properties": {
2741 + "child": {
2742 + "type": "object",
2743 + "properties": {
2744 + "child": {
2745 + "type": "object",
2746 + "properties": {
2747 + "child": {
2748 + "type": "object",
2749 + "properties": {
2750 + "leaf": {
2751 + "type": "string"
2752 + }
2753 + }
2754 + }
2755 + },
2756 + "required": ["child"]
2757 + }
2758 + },
2759 + "required": ["child"]
2760 + }
2761 + },
2762 + "required": ["child"]
2763 + }
2764 + },
2765 + "required": ["child"]
2766 + }
2767 + },
2768 + "required": ["child"]
2769 + }
2770 + },
2771 + "required": ["child"]
2772 + }
2773 + },
2774 + "required": ["child"]
2775 + }
2776 + },
2777 + "required": ["child"]
2778 + }
2779 + },
2780 + "required": ["child"]
2781 + }
2782 + },
2783 + "required": ["child"]
2784 + },
2785 + "strict": {
2786 + "schema": {
2787 + "type": "object",
2788 + "properties": {
2789 + "child": {
2790 + "type": "object",
2791 + "properties": {
2792 + "child": {
2793 + "type": "object",
2794 + "properties": {
2795 + "child": {
2796 + "type": "object",
2797 + "properties": {
2798 + "child": {
2799 + "type": "object",
2800 + "properties": {
2801 + "child": {
2802 + "type": "object",
2803 + "properties": {
2804 + "child": {
2805 + "type": "object",
2806 + "properties": {
2807 + "child": {
2808 + "type": "object",
2809 + "properties": {
2810 + "child": {
2811 + "type": "object",
2812 + "properties": {
2813 + "child": {
2814 + "type": "object",
2815 + "properties": {
2816 + "child": {
2817 + "type": "object",
2818 + "properties": {
2819 + "leaf": {
2820 + "type": ["string", "null"]
2821 + }
2822 + },
2823 + "required": ["leaf"],
2824 + "additionalProperties": false
2825 + }
2826 + },
2827 + "required": ["child"],
2828 + "additionalProperties": false
2829 + }
2830 + },
2831 + "required": ["child"],
2832 + "additionalProperties": false
2833 + }
2834 + },
2835 + "required": ["child"],
2836 + "additionalProperties": false
2837 + }
2838 + },
2839 + "required": ["child"],
2840 + "additionalProperties": false
2841 + }
2842 + },
2843 + "required": ["child"],
2844 + "additionalProperties": false
2845 + }
2846 + },
2847 + "required": ["child"],
2848 + "additionalProperties": false
2849 + }
2850 + },
2851 + "required": ["child"],
2852 + "additionalProperties": false
2853 + }
2854 + },
2855 + "required": ["child"],
2856 + "additionalProperties": false
2857 + }
2858 + },
2859 + "required": ["child"],
2860 + "additionalProperties": false
2861 + }
2862 + },
2863 + "required": ["child"],
2864 + "additionalProperties": false
2865 + }
2866 + },
2867 + "changes": [
2868 + {
2869 + "path": "properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.child.properties.leaf",
2870 + "reason": "optional-property-nullable"
2871 + }
2872 + ]
2873 + },
2874 + {
2875 + "id": "chained-refs-resolved",
2876 + "description": "A $ref to a $ref resolves to the final definition.",
2877 + "schema": {
2878 + "type": "object",
2879 + "properties": {
2880 + "a": {
2881 + "$ref": "#/$defs/Alias"
2882 + }
2883 + },
2884 + "required": ["a"],
2885 + "$defs": {
2886 + "Alias": {
2887 + "$ref": "#/$defs/Real"
2888 + },
2889 + "Real": {
2890 + "type": "object",
2891 + "properties": {
2892 + "x": {
2893 + "type": "string"
2894 + }
2895 + },
2896 + "required": ["x"]
2897 + }
2898 + }
2899 + },
2900 + "strict": {
2901 + "schema": {
2902 + "type": "object",
2903 + "properties": {
2904 + "a": {
2905 + "$ref": "#/$defs/Alias"
2906 + }
2907 + },
2908 + "required": ["a"],
2909 + "$defs": {
2910 + "Alias": {
2911 + "$ref": "#/$defs/Real"
2912 + },
2913 + "Real": {
2914 + "type": "object",
2915 + "properties": {
2916 + "x": {
2917 + "type": "string"
2918 + }
2919 + },
2920 + "required": ["x"],
2921 + "additionalProperties": false
2922 + }
2923 + },
2924 + "additionalProperties": false
2925 + }
2926 + },
2927 + "arguments": [
2928 + {
2929 + "input": {
2930 + "a": {
2931 + "x": null
2932 + }
2933 + },
2934 + "output": {
2935 + "a": {}
2936 + }
2937 + },
2938 + {
2939 + "input": {
2940 + "a": null
2941 + },
2942 + "output": {}
2943 + }
2944 + ]
2945 }
2946 ]
2947 }