Commit f5911d3
Support enhanced JSON Schema features in Google Gemini 2.5+ models
Google announced in November 2025 that Gemini 2.5+ models now support
enhanced JSON Schema features including title, $ref/$defs, anyOf/oneOf,
minimum/maximum, additionalProperties, prefixItems, and property ordering.
This removes workarounds in GoogleJsonSchemaTransformer and allows native
$ref and oneOf support instead of forced inlining and conversion.
Key findings from empirical testing:
- Native $ref/$defs support confirmed (no inlining needed)
- Both anyOf and oneOf work natively (no conversion needed)
- exclusiveMinimum/exclusiveMaximum NOT yet supported by Google SDK
Changes:
- Set prefer_inlined_defs=False to use native $ref/$defs instead of inlining
- Remove oneOf→anyOf conversion (both work natively now)
- Remove adapter code that stripped title, additionalProperties, and prefixItems
- Keep stripping exclusiveMinimum/exclusiveMaximum (not yet supported)
- Remove code that raised errors for $ref schemas
- Update GoogleJsonSchemaTransformer docstring to document all supported features
- Update test_json_def_recursive to verify recursive schemas work with $ref
- Add comprehensive test suite for new JSON Schema capabilities
- Add documentation section highlighting enhanced JSON Schema support with examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 4cc4f35 commit f5911d3
File tree
4 files changed
+327
-64
lines changed- docs/models
- pydantic_ai_slim/pydantic_ai/profiles
- tests/models
4 files changed
+327
-64
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
204 | 268 | | |
205 | 269 | | |
206 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 3 | | |
8 | 4 | | |
9 | 5 | | |
| |||
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
26 | | - | |
27 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 40 | + | |
55 | 41 | | |
56 | 42 | | |
57 | 43 | | |
58 | 44 | | |
59 | 45 | | |
60 | 46 | | |
61 | 47 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 48 | | |
68 | 49 | | |
69 | 50 | | |
70 | 51 | | |
71 | 52 | | |
72 | 53 | | |
73 | 54 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | 55 | | |
81 | 56 | | |
82 | 57 | | |
83 | 58 | | |
84 | 59 | | |
85 | 60 | | |
86 | 61 | | |
87 | | - | |
88 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
89 | 67 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
105 | 72 | | |
106 | 73 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
| 449 | + | |
448 | 450 | | |
449 | 451 | | |
450 | 452 | | |
| |||
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
491 | 496 | | |
492 | 497 | | |
493 | 498 | | |
| |||
0 commit comments