Skip to content

Commit df3cbf7

Browse files
committed
rewrite $ref in top-level oneOf/anyOf branches during variant generation
1 parent a79c66e commit df3cbf7

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

preprocess_schemas.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,15 @@ def _create_single_variant(
381381

382382
variant["properties"] = new_props
383383
variant["required"] = new_required
384+
385+
# Rewrite $refs in top-level oneOf/anyOf branches (e.g. fulfillment_destination
386+
# has no properties, only oneOf with external $refs that need variant rewriting).
387+
for poly_key in ["oneOf", "anyOf"]:
388+
if poly_key in variant:
389+
rewrite_refs_to_variants(
390+
variant[poly_key], op, file_path, global_variant_requirements
391+
)
392+
384393
return variant
385394

386395

src/ucp_sdk/models/schemas/shopping/types/fulfillment_destination_create_request.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@
2020

2121
from pydantic import ConfigDict, Field, RootModel
2222

23-
from . import retail_location, shipping_destination
23+
from . import (
24+
retail_location_create_request,
25+
shipping_destination_create_request,
26+
)
2427

2528

2629
class FulfillmentDestinationCreateRequest(
2730
RootModel[
28-
shipping_destination.ShippingDestination
29-
| retail_location.RetailLocation
31+
shipping_destination_create_request.ShippingDestinationCreateRequest
32+
| retail_location_create_request.RetailLocationCreateRequest
3033
]
3134
):
3235
model_config = ConfigDict(
3336
frozen=True,
3437
)
3538
root: (
36-
shipping_destination.ShippingDestination
37-
| retail_location.RetailLocation
39+
shipping_destination_create_request.ShippingDestinationCreateRequest
40+
| retail_location_create_request.RetailLocationCreateRequest
3841
) = Field(..., title="Fulfillment Destination Create Request")
3942
"""
4043
A destination for fulfillment.

src/ucp_sdk/models/schemas/shopping/types/fulfillment_destination_update_request.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@
2020

2121
from pydantic import ConfigDict, Field, RootModel
2222

23-
from . import retail_location, shipping_destination
23+
from . import (
24+
retail_location_update_request,
25+
shipping_destination_update_request,
26+
)
2427

2528

2629
class FulfillmentDestinationUpdateRequest(
2730
RootModel[
28-
shipping_destination.ShippingDestination
29-
| retail_location.RetailLocation
31+
shipping_destination_update_request.ShippingDestinationUpdateRequest
32+
| retail_location_update_request.RetailLocationUpdateRequest
3033
]
3134
):
3235
model_config = ConfigDict(
3336
frozen=True,
3437
)
3538
root: (
36-
shipping_destination.ShippingDestination
37-
| retail_location.RetailLocation
39+
shipping_destination_update_request.ShippingDestinationUpdateRequest
40+
| retail_location_update_request.RetailLocationUpdateRequest
3841
) = Field(..., title="Fulfillment Destination Update Request")
3942
"""
4043
A destination for fulfillment.

0 commit comments

Comments
 (0)