Commit ebd6fc8
fix(preprocess): rename dotted $defs to keep generated paths flat (#29)
* fix(preprocess): flatten dotted $defs names to prevent path-leak codegen
Upstream UCP uses reverse-DNS extension mount points such as
"dev.ucp.shopping.checkout" in $defs. datamodel-codegen treats dots in
def names as path separators, so those defs were being emitted as nested
directory trees (e.g. shopping/fulfillment/dev/ucp/shopping.py) instead
of inline classes in the parent schema's module.
This added a normalization pass that renames such keys before codegen.
Strategy: prefer the last dotted component (giving a clean class name
like "Checkout"); fall back to dot-replaced-with-underscore if the bare
tail would collide with an existing def in the same file (the
fulfillment.json case, where the dotted key shares its tail with a
sibling "fulfillment" def).
Local $ref pointers to renamed defs are rewritten in the same pass so
no internal references break. No upstream schemas currently reference
the dotted defs by $ref; the rewrite is a safety net.
Effect on regen: extension classes return to their natural import paths.
For example, ucp_sdk.models.schemas.shopping.fulfillment.Checkout was
being relocated to ucp_sdk.models.schemas.shopping.fulfillment.dev.ucp.
shopping.Checkout under current upstream; this restores the flat path.
* fix(preprocess): handle cross-file references for renamed $defs
Address review comments by collecting all renames and rewriting external references in a separate pass. Regenerated models using UCP version 2026-04-08.
* Update preprocess_schemas.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* style: fix end of file newlines in generated __init__.py files
* chore: bump version to 0.4.1
---------
Co-authored-by: damaz91 <federico.damato91@gmail.com>1 parent ee3a15c commit ebd6fc8
23 files changed
Lines changed: 230 additions & 402 deletions
File tree
- src/ucp_sdk/models/schemas
- common
- identity_linking/dev
- ucp
- shopping
- ap2_mandate/dev
- ucp
- buyer_consent/dev
- ucp
- discount/dev
- ucp
- fulfillment/dev
- ucp
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
270 | 371 | | |
271 | 372 | | |
272 | 373 | | |
| |||
532 | 633 | | |
533 | 634 | | |
534 | 635 | | |
535 | | - | |
| 636 | + | |
| 637 | + | |
536 | 638 | | |
537 | 639 | | |
538 | 640 | | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
539 | 644 | | |
540 | | - | |
541 | | - | |
542 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
543 | 657 | | |
544 | 658 | | |
545 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 56 deletions
This file was deleted.
0 commit comments