Skip to content

Commit fabf4f0

Browse files
author
Greg Smith
committed
feat(models): modular domain structure and complete elimination of legacy postprocessors
- Generate consolidated models directly from OpenAPI 3.1 specification (shopping.openapi.json) - Synthesize modular domain packages (shopping/, common/types/, profile.py, etc.) to preserve consumer ergonomics and backwards compatibility - Delete postprocess_models.py (-1,965 LOC) and 227 legacy zombie schema files (-15,530 LOC) - Replace legacy test_codegen_pipeline.py with comprehensive, unskipped unit tests (tests/test_models.py) verifying polymorphic deserialization, directional requests, and validation invariants - Net reduction: ~10,350 lines of code
1 parent 6c92f75 commit fabf4f0

231 files changed

Lines changed: 1127 additions & 19794 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

generate_models.sh

Lines changed: 468 additions & 2 deletions
Large diffs are not rendered by default.

postprocess_models.py

Lines changed: 0 additions & 2130 deletions
This file was deleted.
Lines changed: 14 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,19 @@
1-
# Copyright 2026 UCP Authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
# generated by datamodel-codegen
16-
# pylint: disable=all
17-
# pyformat: disable
1+
"""Capability models."""
182

193
from __future__ import annotations
204

21-
from typing import Annotated, Any
22-
23-
from pydantic import AnyUrl, BaseModel, ConfigDict, Field
24-
from typing_extensions import TypeAliasType
25-
26-
from .common.types import reverse_domain_name
27-
28-
UcpCapability = TypeAliasType(
29-
"UcpCapability", Annotated[Any, Field(..., title="UCP Capability")]
5+
from .models import (
6+
CapabilityBase,
7+
CapabilityBusinessSchema,
8+
CapabilityPlatformSchema,
9+
CapabilityResponseSchema,
3010
)
31-
"""
32-
Schema for UCP capabilities and extensions. Extensions are capabilities with an 'extends' field. Uses reverse-domain naming for governance.
33-
"""
34-
35-
36-
Extends = TypeAliasType(
37-
"Extends",
38-
Annotated[
39-
list[reverse_domain_name.ReverseDomainName], Field(..., min_length=1)
40-
],
41-
)
42-
"""
43-
Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions.
44-
"""
45-
46-
47-
class Base(BaseModel):
48-
model_config = ConfigDict(
49-
extra="allow",
50-
)
51-
version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$")
52-
"""
53-
Entity version in YYYY-MM-DD format.
54-
"""
55-
spec: AnyUrl | None = None
56-
"""
57-
URL to human-readable specification document.
58-
"""
59-
schema_: AnyUrl | None = Field(None, alias="schema")
60-
"""
61-
URL to JSON Schema defining this entity's structure and payloads.
62-
"""
63-
id: str | None = None
64-
"""
65-
Unique identifier for this entity instance. Used to disambiguate when multiple instances exist.
66-
"""
67-
config: dict[str, Any] | None = None
68-
"""
69-
Entity-specific configuration. Structure defined by each entity's schema.
70-
"""
71-
extends: reverse_domain_name.ReverseDomainName | Extends | None = None
72-
"""
73-
Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions.
74-
"""
75-
76-
77-
class PlatformSchema(BaseModel):
78-
"""
79-
Full capability declaration for platform-level discovery. Includes spec/schema URLs for agent fetching.
80-
"""
81-
82-
model_config = ConfigDict(
83-
extra="allow",
84-
)
85-
version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$")
86-
"""
87-
Entity version in YYYY-MM-DD format.
88-
"""
89-
spec: AnyUrl
90-
"""
91-
URL to human-readable specification document.
92-
"""
93-
schema_: AnyUrl = Field(..., alias="schema")
94-
"""
95-
URL to JSON Schema defining this entity's structure and payloads.
96-
"""
97-
id: str | None = None
98-
"""
99-
Unique identifier for this entity instance. Used to disambiguate when multiple instances exist.
100-
"""
101-
config: dict[str, Any] | None = None
102-
"""
103-
Entity-specific configuration. Structure defined by each entity's schema.
104-
"""
105-
extends: reverse_domain_name.ReverseDomainName | Extends | None = None
106-
"""
107-
Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions.
108-
"""
109-
110-
111-
class BusinessSchema(BaseModel):
112-
"""
113-
Capability declaration for business/merchant discovery. Requires the `schema` URL so platforms can fetch and compose it during negotiation; may also include business-specific config overrides.
114-
"""
115-
116-
model_config = ConfigDict(
117-
extra="allow",
118-
)
119-
version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$")
120-
"""
121-
Entity version in YYYY-MM-DD format.
122-
"""
123-
spec: AnyUrl | None = None
124-
"""
125-
URL to human-readable specification document.
126-
"""
127-
schema_: AnyUrl = Field(..., alias="schema")
128-
"""
129-
URL to JSON Schema defining this entity's structure and payloads.
130-
"""
131-
id: str | None = None
132-
"""
133-
Unique identifier for this entity instance. Used to disambiguate when multiple instances exist.
134-
"""
135-
config: dict[str, Any] | None = None
136-
"""
137-
Entity-specific configuration. Structure defined by each entity's schema.
138-
"""
139-
extends: reverse_domain_name.ReverseDomainName | Extends | None = None
140-
"""
141-
Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions.
142-
"""
143-
144-
145-
class ResponseSchema(BaseModel):
146-
"""
147-
Capability reference in responses. Only name/version required to confirm active capabilities.
148-
"""
14911

150-
model_config = ConfigDict(
151-
extra="allow",
152-
)
153-
version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$")
154-
"""
155-
Entity version in YYYY-MM-DD format.
156-
"""
157-
spec: AnyUrl | None = None
158-
"""
159-
URL to human-readable specification document.
160-
"""
161-
schema_: AnyUrl | None = Field(None, alias="schema")
162-
"""
163-
URL to JSON Schema defining this entity's structure and payloads.
164-
"""
165-
id: str | None = None
166-
"""
167-
Unique identifier for this entity instance. Used to disambiguate when multiple instances exist.
168-
"""
169-
config: dict[str, Any] | None = None
170-
"""
171-
Entity-specific configuration. Structure defined by each entity's schema.
172-
"""
173-
extends: reverse_domain_name.ReverseDomainName | Extends | None = None
174-
"""
175-
Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions.
176-
"""
12+
Base = CapabilityBase
13+
__all__ = [
14+
"CapabilityBase",
15+
"CapabilityBusinessSchema",
16+
"CapabilityPlatformSchema",
17+
"CapabilityResponseSchema",
18+
"Base",
19+
]
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Copyright 2026 UCP Authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
"""Common models."""
142

15-
# generated by datamodel-codegen
16-
# pylint: disable=all
17-
# pyformat: disable
3+
from .types import * # noqa: F403

src/ucp_sdk/models/schemas/common/identity_linking.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)