From 2fd4c1e7e127e0cf60d7b65dd0c7d0c9da205a2d Mon Sep 17 00:00:00 2001 From: "wangjun.111" Date: Wed, 5 Aug 2026 21:40:28 +0800 Subject: [PATCH 1/4] fix: preserve fragments when rewriting variant refs --- preprocess_schemas.py | 25 +++++++++++++++---------- tests/test_codegen_pipeline.py | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/preprocess_schemas.py b/preprocess_schemas.py index 6346ccf..0b7f76f 100644 --- a/preprocess_schemas.py +++ b/preprocess_schemas.py @@ -449,16 +449,21 @@ def rewrite_refs_to_variants(root, op, file_path, variant_needs): for node in iter_nodes(root): if isinstance(node, dict) and "$ref" in node: ref = node["$ref"] - if "#" not in ref: # External file reference - abs_target = (file_path.parent / ref).resolve() - if ( - str(abs_target) in variant_needs - and op in variant_needs[str(abs_target)] - ): - ref_path = Path(ref) - node["$ref"] = str( - ref_path.parent / f"{ref_path.stem}_{op}_request.json" - ) + ref_file, separator, fragment = ref.partition("#") + if not ref_file: + continue + abs_target = (file_path.parent / ref_file).resolve() + if ( + str(abs_target) in variant_needs + and op in variant_needs[str(abs_target)] + ): + ref_path = Path(ref_file) + variant_ref = str( + ref_path.parent / f"{ref_path.stem}_{op}_request.json" + ) + node["$ref"] = variant_ref + ( + separator + fragment if separator else "" + ) def _apply_request_rules_to_object( diff --git a/tests/test_codegen_pipeline.py b/tests/test_codegen_pipeline.py index 0e87272..86554e9 100644 --- a/tests/test_codegen_pipeline.py +++ b/tests/test_codegen_pipeline.py @@ -247,6 +247,33 @@ def test_eval_prop_inclusion_applies_operation_overrides(self) -> None: class VariantGenerationTest(unittest.TestCase): """Tests request variant construction and output.""" + def test_rewrite_external_ref_preserves_fragment(self) -> None: + """External refs target variants without losing their fragments.""" + schema = { + "properties": { + "child": {"$ref": "nested/child.json#/$defs/item"}, + "local": {"$ref": "#/$defs/local"}, + } + } + file_path = Path("/schemas/parent.json") + child_path = str((file_path.parent / "nested" / "child.json").resolve()) + + preprocess_schemas.rewrite_refs_to_variants( + schema, + "create", + file_path, + {child_path: {"create"}}, + ) + + self.assertEqual( + schema["properties"]["child"]["$ref"], + "nested/child_create_request.json#/$defs/item", + ) + self.assertEqual( + schema["properties"]["local"]["$ref"], + "#/$defs/local", + ) + def test_object_variant_filters_fields_and_rewrites_refs(self) -> None: """Object variants filter fields and target child variants.""" schema = { From ae596fc48b5b5822dd1fb1a63a07e7da693e1dbe Mon Sep 17 00:00:00 2001 From: damaz91 Date: Mon, 10 Aug 2026 08:40:34 +0000 Subject: [PATCH 2/4] fix: propagate variant needs for refs with fragments --- preprocess_schemas.py | 5 +- tests/test_codegen_pipeline.py | 87 ++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/preprocess_schemas.py b/preprocess_schemas.py index 0b7f76f..14d0464 100644 --- a/preprocess_schemas.py +++ b/preprocess_schemas.py @@ -597,8 +597,9 @@ def extract_external_refs(schema, path): for node in iter_nodes(data): if isinstance(node, dict) and "$ref" in node: ref = node["$ref"] - if "#" not in ref: - abs_path = str((path.parent / ref).resolve()) + ref_file, _, _ = ref.partition("#") + if ref_file: + abs_path = str((path.parent / ref_file).resolve()) refs.append((name, abs_path)) return refs diff --git a/tests/test_codegen_pipeline.py b/tests/test_codegen_pipeline.py index 7b37460..011c9f1 100644 --- a/tests/test_codegen_pipeline.py +++ b/tests/test_codegen_pipeline.py @@ -591,6 +591,93 @@ def test_main_preprocesses_schema_tree_end_to_end(self) -> None: self.assertEqual(set(parent_variant["required"]), {"id", "child"}) self.assertEqual(child_variant["required"], ["value"]) + def test_propagation_with_fragment(self) -> None: + """Propagation should work even if the reference has a fragment.""" + with tempfile.TemporaryDirectory() as temp_dir: + root = Path(temp_dir) + preprocess_schemas.save_json( + { + "$defs": { + "entity": { + "type": "object", + "properties": {"id": {"type": "string"}}, + "required": ["id"], + } + } + }, + root / "ucp.json", + ) + preprocess_schemas.save_json( + { + "$id": "https://ucp.dev/schemas/child.json", + "title": "Child", + "type": "object", + "$defs": { + "item": { + "type": "object", + "properties": { + "grandchild": { + "$ref": "grandchild.json" + } + } + } + }, + "properties": { + "dummy": {"type": "string"} + } + }, + root / "child.json", + ) + preprocess_schemas.save_json( + { + "$id": "https://ucp.dev/schemas/grandchild.json", + "title": "Grandchild", + "type": "object", + "properties": { + "value": { + "type": "string", + "ucp_request": {"create": "required"}, + } + }, + }, + root / "grandchild.json", + ) + preprocess_schemas.save_json( + { + "$id": "https://ucp.dev/schemas/parent.json", + "title": "Parent", + "allOf": [{"$ref": "ucp.json#/$defs/entity"}], + "properties": { + "child_item": { + "$ref": "child.json#/$defs/item", + "ucp_request": {"create": "required"}, + } + }, + }, + root / "parent.json", + ) + + with ( + mock.patch.object( + sys, + "argv", + ["preprocess_schemas.py", str(root)], + ), + contextlib.redirect_stdout(io.StringIO()), + ): + preprocess_schemas.main() + + self.assertTrue((root / "child_create_request.json").exists(), "child_create_request.json was not generated") + self.assertTrue((root / "grandchild_create_request.json").exists(), "grandchild_create_request.json was not generated") + + parent_variant = preprocess_schemas.load_json( + root / "parent_create_request.json" + ) + self.assertEqual( + parent_variant["properties"]["child_item"]["$ref"], + "child_create_request.json#/$defs/item", + ) + class MetadataUnionTest(unittest.TestCase): """The UcpMetadata root union is derived from ucp.json $defs.""" From 0c231bfb77a2642995f228d911f92fb19ab97403 Mon Sep 17 00:00:00 2001 From: damaz91 Date: Mon, 10 Aug 2026 08:50:02 +0000 Subject: [PATCH 3/4] fix: regenerate models to reflect fixed propagation --- src/ucp_sdk/models/schemas/__init__.py | 1 + src/ucp_sdk/models/schemas/common/__init__.py | 1 + .../models/schemas/shopping/__init__.py | 1 + .../shopping/payment_complete_request.py | 9 ++- .../shopping/payment_create_request.py | 8 +- .../shopping/payment_update_request.py | 8 +- .../models/schemas/shopping/types/__init__.py | 1 + .../payment_credential_complete_request.py | 35 +++++++++ .../payment_credential_create_request.py | 35 +++++++++ .../payment_credential_update_request.py | 35 +++++++++ .../payment_instrument_complete_request.py | 78 +++++++++++++++++++ .../payment_instrument_create_request.py | 74 ++++++++++++++++++ .../payment_instrument_update_request.py | 74 ++++++++++++++++++ .../types/postal_address_complete_request.py | 63 +++++++++++++++ .../models/schemas/transports/__init__.py | 1 + tests/test_codegen_pipeline.py | 22 +++--- 16 files changed, 424 insertions(+), 22 deletions(-) create mode 100644 src/ucp_sdk/models/schemas/shopping/types/payment_credential_complete_request.py create mode 100644 src/ucp_sdk/models/schemas/shopping/types/payment_credential_create_request.py create mode 100644 src/ucp_sdk/models/schemas/shopping/types/payment_credential_update_request.py create mode 100644 src/ucp_sdk/models/schemas/shopping/types/payment_instrument_complete_request.py create mode 100644 src/ucp_sdk/models/schemas/shopping/types/payment_instrument_create_request.py create mode 100644 src/ucp_sdk/models/schemas/shopping/types/payment_instrument_update_request.py create mode 100644 src/ucp_sdk/models/schemas/shopping/types/postal_address_complete_request.py diff --git a/src/ucp_sdk/models/schemas/__init__.py b/src/ucp_sdk/models/schemas/__init__.py index 1252d6b..421dc21 100644 --- a/src/ucp_sdk/models/schemas/__init__.py +++ b/src/ucp_sdk/models/schemas/__init__.py @@ -15,3 +15,4 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable + diff --git a/src/ucp_sdk/models/schemas/common/__init__.py b/src/ucp_sdk/models/schemas/common/__init__.py index 1252d6b..421dc21 100644 --- a/src/ucp_sdk/models/schemas/common/__init__.py +++ b/src/ucp_sdk/models/schemas/common/__init__.py @@ -15,3 +15,4 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable + diff --git a/src/ucp_sdk/models/schemas/shopping/__init__.py b/src/ucp_sdk/models/schemas/shopping/__init__.py index 1252d6b..421dc21 100644 --- a/src/ucp_sdk/models/schemas/shopping/__init__.py +++ b/src/ucp_sdk/models/schemas/shopping/__init__.py @@ -15,3 +15,4 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable + diff --git a/src/ucp_sdk/models/schemas/shopping/payment_complete_request.py b/src/ucp_sdk/models/schemas/shopping/payment_complete_request.py index 0c9415b..392cd20 100644 --- a/src/ucp_sdk/models/schemas/shopping/payment_complete_request.py +++ b/src/ucp_sdk/models/schemas/shopping/payment_complete_request.py @@ -20,7 +20,7 @@ from pydantic import BaseModel, ConfigDict -from .types import payment_instrument +from .types import payment_instrument_complete_request class PaymentCompleteRequest(BaseModel): @@ -31,9 +31,10 @@ class PaymentCompleteRequest(BaseModel): model_config = ConfigDict( extra="allow", ) - instruments: list[payment_instrument.SelectedPaymentInstrument] | None = ( - None - ) + instruments: ( + list[payment_instrument_complete_request.SelectedPaymentInstrument] + | None + ) = None """ The payment instruments available for this payment. Each instrument is associated with a specific handler via the handler_id field. Handlers can extend the base payment_instrument schema to add handler-specific fields. """ diff --git a/src/ucp_sdk/models/schemas/shopping/payment_create_request.py b/src/ucp_sdk/models/schemas/shopping/payment_create_request.py index 4bd95d6..5219f5f 100644 --- a/src/ucp_sdk/models/schemas/shopping/payment_create_request.py +++ b/src/ucp_sdk/models/schemas/shopping/payment_create_request.py @@ -20,7 +20,7 @@ from pydantic import BaseModel, ConfigDict -from .types import payment_instrument +from .types import payment_instrument_create_request class PaymentCreateRequest(BaseModel): @@ -31,9 +31,9 @@ class PaymentCreateRequest(BaseModel): model_config = ConfigDict( extra="allow", ) - instruments: list[payment_instrument.SelectedPaymentInstrument] | None = ( - None - ) + instruments: ( + list[payment_instrument_create_request.SelectedPaymentInstrument] | None + ) = None """ The payment instruments available for this payment. Each instrument is associated with a specific handler via the handler_id field. Handlers can extend the base payment_instrument schema to add handler-specific fields. """ diff --git a/src/ucp_sdk/models/schemas/shopping/payment_update_request.py b/src/ucp_sdk/models/schemas/shopping/payment_update_request.py index a63bbfa..59c926a 100644 --- a/src/ucp_sdk/models/schemas/shopping/payment_update_request.py +++ b/src/ucp_sdk/models/schemas/shopping/payment_update_request.py @@ -20,7 +20,7 @@ from pydantic import BaseModel, ConfigDict -from .types import payment_instrument +from .types import payment_instrument_update_request class PaymentUpdateRequest(BaseModel): @@ -31,9 +31,9 @@ class PaymentUpdateRequest(BaseModel): model_config = ConfigDict( extra="allow", ) - instruments: list[payment_instrument.SelectedPaymentInstrument] | None = ( - None - ) + instruments: ( + list[payment_instrument_update_request.SelectedPaymentInstrument] | None + ) = None """ The payment instruments available for this payment. Each instrument is associated with a specific handler via the handler_id field. Handlers can extend the base payment_instrument schema to add handler-specific fields. """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/__init__.py b/src/ucp_sdk/models/schemas/shopping/types/__init__.py index 1252d6b..421dc21 100644 --- a/src/ucp_sdk/models/schemas/shopping/types/__init__.py +++ b/src/ucp_sdk/models/schemas/shopping/types/__init__.py @@ -15,3 +15,4 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable + diff --git a/src/ucp_sdk/models/schemas/shopping/types/payment_credential_complete_request.py b/src/ucp_sdk/models/schemas/shopping/types/payment_credential_complete_request.py new file mode 100644 index 0000000..0fe4d9c --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/payment_credential_complete_request.py @@ -0,0 +1,35 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from pydantic import BaseModel, ConfigDict + + +class PaymentCredentialCompleteRequest(BaseModel): + """ + The base definition for any payment credential. Handlers define specific credential types. + """ + + model_config = ConfigDict( + extra="allow", + ) + type: str + """ + The credential type discriminator. Specific schemas will constrain this to a constant value. + """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/payment_credential_create_request.py b/src/ucp_sdk/models/schemas/shopping/types/payment_credential_create_request.py new file mode 100644 index 0000000..0c79bf1 --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/payment_credential_create_request.py @@ -0,0 +1,35 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from pydantic import BaseModel, ConfigDict + + +class PaymentCredentialCreateRequest(BaseModel): + """ + The base definition for any payment credential. Handlers define specific credential types. + """ + + model_config = ConfigDict( + extra="allow", + ) + type: str + """ + The credential type discriminator. Specific schemas will constrain this to a constant value. + """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/payment_credential_update_request.py b/src/ucp_sdk/models/schemas/shopping/types/payment_credential_update_request.py new file mode 100644 index 0000000..9a6eb10 --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/payment_credential_update_request.py @@ -0,0 +1,35 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from pydantic import BaseModel, ConfigDict + + +class PaymentCredentialUpdateRequest(BaseModel): + """ + The base definition for any payment credential. Handlers define specific credential types. + """ + + model_config = ConfigDict( + extra="allow", + ) + type: str + """ + The credential type discriminator. Specific schemas will constrain this to a constant value. + """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_complete_request.py b/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_complete_request.py new file mode 100644 index 0000000..2aac44e --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_complete_request.py @@ -0,0 +1,78 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from typing import Any + +from pydantic import BaseModel, ConfigDict + +from . import ( + payment_credential_complete_request, + postal_address_complete_request, +) + + +class PaymentInstrumentCompleteRequest(BaseModel): + """ + The base definition for any payment instrument. It links the instrument to a specific payment handler. + """ + + model_config = ConfigDict( + extra="allow", + ) + id: str + """ + A unique identifier for this instrument instance, assigned by the platform. + """ + handler_id: str + """ + The unique identifier for the handler instance that produced this instrument. This corresponds to the 'id' field in the Payment Handler definition. + """ + type: str + """ + The broad category of the instrument (e.g., 'card', 'tokenized_card'). Specific schemas will constrain this to a constant value. + """ + billing_address: ( + postal_address_complete_request.PostalAddressCompleteRequest | None + ) = None + """ + The billing address associated with this payment method. + """ + credential: ( + payment_credential_complete_request.PaymentCredentialCompleteRequest + | None + ) = None + display: dict[str, Any] | None = None + """ + Display information for this payment instrument. Each payment instrument schema defines its specific display properties, as outlined by the payment handler. + """ + + +class SelectedPaymentInstrument(PaymentInstrumentCompleteRequest): + """ + A payment instrument with selection state. + """ + + model_config = ConfigDict( + extra="allow", + ) + selected: bool | None = None + """ + Whether this instrument is selected by the user. + """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_create_request.py b/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_create_request.py new file mode 100644 index 0000000..4d7117e --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_create_request.py @@ -0,0 +1,74 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from typing import Any + +from pydantic import BaseModel, ConfigDict + +from . import payment_credential_create_request, postal_address_create_request + + +class PaymentInstrumentCreateRequest(BaseModel): + """ + The base definition for any payment instrument. It links the instrument to a specific payment handler. + """ + + model_config = ConfigDict( + extra="allow", + ) + id: str + """ + A unique identifier for this instrument instance, assigned by the platform. + """ + handler_id: str + """ + The unique identifier for the handler instance that produced this instrument. This corresponds to the 'id' field in the Payment Handler definition. + """ + type: str + """ + The broad category of the instrument (e.g., 'card', 'tokenized_card'). Specific schemas will constrain this to a constant value. + """ + billing_address: ( + postal_address_create_request.PostalAddressCreateRequest | None + ) = None + """ + The billing address associated with this payment method. + """ + credential: ( + payment_credential_create_request.PaymentCredentialCreateRequest | None + ) = None + display: dict[str, Any] | None = None + """ + Display information for this payment instrument. Each payment instrument schema defines its specific display properties, as outlined by the payment handler. + """ + + +class SelectedPaymentInstrument(PaymentInstrumentCreateRequest): + """ + A payment instrument with selection state. + """ + + model_config = ConfigDict( + extra="allow", + ) + selected: bool | None = None + """ + Whether this instrument is selected by the user. + """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_update_request.py b/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_update_request.py new file mode 100644 index 0000000..0a72443 --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/payment_instrument_update_request.py @@ -0,0 +1,74 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from typing import Any + +from pydantic import BaseModel, ConfigDict + +from . import payment_credential_update_request, postal_address_update_request + + +class PaymentInstrumentUpdateRequest(BaseModel): + """ + The base definition for any payment instrument. It links the instrument to a specific payment handler. + """ + + model_config = ConfigDict( + extra="allow", + ) + id: str + """ + A unique identifier for this instrument instance, assigned by the platform. + """ + handler_id: str + """ + The unique identifier for the handler instance that produced this instrument. This corresponds to the 'id' field in the Payment Handler definition. + """ + type: str + """ + The broad category of the instrument (e.g., 'card', 'tokenized_card'). Specific schemas will constrain this to a constant value. + """ + billing_address: ( + postal_address_update_request.PostalAddressUpdateRequest | None + ) = None + """ + The billing address associated with this payment method. + """ + credential: ( + payment_credential_update_request.PaymentCredentialUpdateRequest | None + ) = None + display: dict[str, Any] | None = None + """ + Display information for this payment instrument. Each payment instrument schema defines its specific display properties, as outlined by the payment handler. + """ + + +class SelectedPaymentInstrument(PaymentInstrumentUpdateRequest): + """ + A payment instrument with selection state. + """ + + model_config = ConfigDict( + extra="allow", + ) + selected: bool | None = None + """ + Whether this instrument is selected by the user. + """ diff --git a/src/ucp_sdk/models/schemas/shopping/types/postal_address_complete_request.py b/src/ucp_sdk/models/schemas/shopping/types/postal_address_complete_request.py new file mode 100644 index 0000000..c282a9d --- /dev/null +++ b/src/ucp_sdk/models/schemas/shopping/types/postal_address_complete_request.py @@ -0,0 +1,63 @@ +# Copyright 2026 UCP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generated by datamodel-codegen +# pylint: disable=all +# pyformat: disable + +from __future__ import annotations + +from pydantic import BaseModel, ConfigDict + + +class PostalAddressCompleteRequest(BaseModel): + model_config = ConfigDict( + extra="allow", + ) + extended_address: str | None = None + """ + An address extension such as an apartment number, C/O or alternative name. + """ + street_address: str | None = None + """ + The street address. + """ + address_locality: str | None = None + """ + The locality in which the street address is, and which is in the region. For example, Mountain View. + """ + address_region: str | None = None + """ + The region in which the locality is, and which is in the country. Required for applicable countries (i.e. state in US, province in CA). For example, California or another appropriate first-level Administrative division. + """ + address_country: str | None = None + """ + The country. Recommended to be in 2-letter ISO 3166-1 alpha-2 format, for example "US". For backward compatibility, a 3-letter ISO 3166-1 alpha-3 country code such as "SGP" or a full country name such as "Singapore" can also be used. + """ + postal_code: str | None = None + """ + The postal code. For example, 94043. + """ + first_name: str | None = None + """ + Optional. First name of the contact associated with the address. + """ + last_name: str | None = None + """ + Optional. Last name of the contact associated with the address. + """ + phone_number: str | None = None + """ + Optional. Phone number of the contact associated with the address. + """ diff --git a/src/ucp_sdk/models/schemas/transports/__init__.py b/src/ucp_sdk/models/schemas/transports/__init__.py index 1252d6b..421dc21 100644 --- a/src/ucp_sdk/models/schemas/transports/__init__.py +++ b/src/ucp_sdk/models/schemas/transports/__init__.py @@ -15,3 +15,4 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable + diff --git a/tests/test_codegen_pipeline.py b/tests/test_codegen_pipeline.py index 011c9f1..df79a6d 100644 --- a/tests/test_codegen_pipeline.py +++ b/tests/test_codegen_pipeline.py @@ -616,15 +616,11 @@ def test_propagation_with_fragment(self) -> None: "item": { "type": "object", "properties": { - "grandchild": { - "$ref": "grandchild.json" - } - } + "grandchild": {"$ref": "grandchild.json"} + }, } }, - "properties": { - "dummy": {"type": "string"} - } + "properties": {"dummy": {"type": "string"}}, }, root / "child.json", ) @@ -667,9 +663,15 @@ def test_propagation_with_fragment(self) -> None: ): preprocess_schemas.main() - self.assertTrue((root / "child_create_request.json").exists(), "child_create_request.json was not generated") - self.assertTrue((root / "grandchild_create_request.json").exists(), "grandchild_create_request.json was not generated") - + self.assertTrue( + (root / "child_create_request.json").exists(), + "child_create_request.json was not generated", + ) + self.assertTrue( + (root / "grandchild_create_request.json").exists(), + "grandchild_create_request.json was not generated", + ) + parent_variant = preprocess_schemas.load_json( root / "parent_create_request.json" ) From 0c046288db278b9650f5dd59b24c27db5079e911 Mon Sep 17 00:00:00 2001 From: damaz91 Date: Mon, 10 Aug 2026 08:53:46 +0000 Subject: [PATCH 4/4] style: format __init__.py files with pre-commit --- src/ucp_sdk/models/schemas/__init__.py | 1 - src/ucp_sdk/models/schemas/common/__init__.py | 1 - src/ucp_sdk/models/schemas/shopping/__init__.py | 1 - src/ucp_sdk/models/schemas/shopping/types/__init__.py | 1 - src/ucp_sdk/models/schemas/transports/__init__.py | 1 - 5 files changed, 5 deletions(-) diff --git a/src/ucp_sdk/models/schemas/__init__.py b/src/ucp_sdk/models/schemas/__init__.py index 421dc21..1252d6b 100644 --- a/src/ucp_sdk/models/schemas/__init__.py +++ b/src/ucp_sdk/models/schemas/__init__.py @@ -15,4 +15,3 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable - diff --git a/src/ucp_sdk/models/schemas/common/__init__.py b/src/ucp_sdk/models/schemas/common/__init__.py index 421dc21..1252d6b 100644 --- a/src/ucp_sdk/models/schemas/common/__init__.py +++ b/src/ucp_sdk/models/schemas/common/__init__.py @@ -15,4 +15,3 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable - diff --git a/src/ucp_sdk/models/schemas/shopping/__init__.py b/src/ucp_sdk/models/schemas/shopping/__init__.py index 421dc21..1252d6b 100644 --- a/src/ucp_sdk/models/schemas/shopping/__init__.py +++ b/src/ucp_sdk/models/schemas/shopping/__init__.py @@ -15,4 +15,3 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable - diff --git a/src/ucp_sdk/models/schemas/shopping/types/__init__.py b/src/ucp_sdk/models/schemas/shopping/types/__init__.py index 421dc21..1252d6b 100644 --- a/src/ucp_sdk/models/schemas/shopping/types/__init__.py +++ b/src/ucp_sdk/models/schemas/shopping/types/__init__.py @@ -15,4 +15,3 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable - diff --git a/src/ucp_sdk/models/schemas/transports/__init__.py b/src/ucp_sdk/models/schemas/transports/__init__.py index 421dc21..1252d6b 100644 --- a/src/ucp_sdk/models/schemas/transports/__init__.py +++ b/src/ucp_sdk/models/schemas/transports/__init__.py @@ -15,4 +15,3 @@ # generated by datamodel-codegen # pylint: disable=all # pyformat: disable -