|
6 | 6 |
|
7 | 7 | #### Migration to datamodel-code-generator |
8 | 8 |
|
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. |
10 | 12 |
|
11 | 13 | **Breaking Changes:** |
12 | 14 |
|
@@ -41,14 +43,27 @@ This release completes the migration from custom type generation to the industry |
41 | 43 |
|
42 | 44 | ### Features |
43 | 45 |
|
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 |
46 | 61 | - `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 |
49 | 64 | - These validators are automatically applied by `fetch_adagents()` but can also be used standalone |
50 | 65 |
|
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) |
52 | 67 |
|
53 | 68 | ### Migration Guide |
54 | 69 |
|
|
0 commit comments