Skip to content

Commit 3151932

Browse files
bokelleyclaude
andcommitted
fix: update all tests for AdCP v2.4.0 schema changes
Updated all failing tests to work with the new schema structure generated by datamodel-code-generator. Key changes include: - Updated discriminated union tests to use numbered type variants (ActivateSignalResponse1/2, Destination1/2, etc.) - Fixed field names: activation_keys → removed, type → asset_type, property_type - Updated asset handling to use Pydantic models (ImageAsset, UrlAsset, etc.) instead of plain strings - Fixed PreviewCreativeRequest to include request_type discriminator - Updated preview response structures with proper renders and input fields - Fixed RootModel access patterns (using .root for PropertyId, etc.) - Implemented previously skipped integration tests for fetch_adagents and verify_agent_for_property with proper httpx mocking All 199 tests now passing with 0 skipped. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8233bec commit 3151932

File tree

113 files changed

+5175
-14969
lines changed

Some content is hidden

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

113 files changed

+5175
-14969
lines changed

CHANGELOG.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
#### Migration to datamodel-code-generator
88

9-
This release completes the migration from custom type generation to the industry-standard `datamodel-code-generator` tool. This brings improved type safety, better Pydantic v2 support, and alignment with JSON Schema specifications.
9+
This release completes the migration from custom type generation to the industry-standard `datamodel-code-generator` tool. This brings improved type safety, better Pydantic v2 support, proper discriminated union support, and alignment with JSON Schema specifications.
10+
11+
**Discriminated Union Support**: Upstream AdCP schemas (v2.4.0) now properly enforce mutual exclusivity using discriminated unions (`selection_type`, `authorization_type`). The type generator now correctly generates these as separate Pydantic model variants, providing compile-time type safety for mutually exclusive fields. Runtime validation has been updated to support both old and new discriminated union formats for backward compatibility.
1012

1113
**Breaking Changes:**
1214

@@ -41,14 +43,27 @@ This release completes the migration from custom type generation to the industry
4143

4244
### Features
4345

44-
* **Runtime Validation** - Added validation utilities for constraints not enforced by upstream JSON schemas:
45-
- `validate_adagents()` - Validates mutual exclusivity in adagents.json authorization fields
46+
* **Improved Type Generation** - Migrated to `datamodel-code-generator` with automatic post-processing:
47+
- Automatic $ref path rewriting for compatibility
48+
- Forward reference fixing for correct module imports
49+
- Self-reference cleanup for proper type resolution
50+
- Union type generation for anyOf schema patterns
51+
- New `scripts/generate_types.py` with comprehensive preprocessing pipeline
52+
53+
* **Discriminated Union Support** - Full support for AdCP v2.4.0 discriminated unions:
54+
- Proper type variants for `authorization_type` (property_ids, property_tags, inline_properties, publisher_properties)
55+
- Proper type variants for `selection_type` (by_id, by_tag)
56+
- Compile-time type checking for mutually exclusive fields
57+
- Pydantic validates discriminator constraints automatically
58+
59+
* **Enhanced Runtime Validation** - Updated validation utilities support both old and new formats:
60+
- `validate_adagents()` - Validates authorization discriminated unions and backward compatibility
4661
- `validate_product()` - Validates publisher_properties mutual exclusivity
47-
- `validate_agent_authorization()` - Validates agent authorization field constraints
48-
- `validate_publisher_properties_item()` - Validates property_ids/property_tags mutual exclusivity
62+
- `validate_agent_authorization()` - Validates authorization_type discriminator and field constraints
63+
- `validate_publisher_properties_item()` - Validates selection_type discriminator and mutual exclusivity
4964
- These validators are automatically applied by `fetch_adagents()` but can also be used standalone
5065

51-
* **Schema Validation Gap Documentation** - Added `SCHEMA_VALIDATION_GAPS.md` documenting upstream schema issues where mutual exclusivity is documented but not enforced
66+
* **Documentation** - Added `UPSTREAM_SCHEMA_ISSUES.md` documenting historical schema validation gaps (now fixed in v2.4.0)
5267

5368
### Migration Guide
5469

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dev = [
4444
"mypy>=1.0.0",
4545
"black>=23.0.0",
4646
"ruff>=0.1.0",
47+
"datamodel-code-generator>=0.25.0",
4748
]
4849

4950
[project.urls]

scripts/consolidate_exports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def extract_exports_from_module(module_path: Path) -> set[str]:
2626

2727
exports = set()
2828

29-
for node in ast.walk(tree):
29+
# Only look at module-level nodes (not inside classes)
30+
for node in tree.body:
3031
# Class definitions
3132
if isinstance(node, ast.ClassDef):
3233
if not node.name.startswith("_"):

0 commit comments

Comments
 (0)