Commit bcda715
committed
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.1 parent a79c66e commit bcda715
1 file changed
Lines changed: 64 additions & 0 deletions
| 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 | + | |
270 | 333 | | |
271 | 334 | | |
272 | 335 | | |
| |||
530 | 593 | | |
531 | 594 | | |
532 | 595 | | |
| 596 | + | |
533 | 597 | | |
534 | 598 | | |
535 | 599 | | |
| |||
0 commit comments