Skip to content

test(codegen): lock deprecation-decorator generation on deprecated JSON Schema properties #778

@bokelley

Description

@bokelley

Filed in response to adcontextprotocol/adcp#4904 (the 3.1 additive-deprecate on `CreateMediaBuySuccess` / `UpdateMediaBuySuccess` body-level `status`). The expert review on that PR flagged that JSON Schema `deprecated: true` propagation through codegen is partially reliable across Python toolchains; the storyboard certification gate is doing the real enforcement work but the SDK side should lock its part of the contract.

What's needed

A unit test that asserts a deprecation surface (typically `deprecated=True` on `pydantic.Field(...)` for Pydantic v2, or a `warnings.warn`-style decorator on field accessors) is emitted on Python types regenerated from AdCP schemas where the source schema declares `deprecated: true` on a property.

Anchor case: `CreateMediaBuySuccess.status` and `UpdateMediaBuySuccess.status` in AdCP 3.1+. Both fields are marked `deprecated: true` (description-level + the JSON Schema 2020-12 `deprecated` keyword) on the source schema.

The test should:

  1. Regen types from the schema set that contains these properties (latest AdCP schemas).
  2. Inspect the generated model (e.g., via Pydantic's `model_fields` and the field's `json_schema_extra` or `deprecated` attribute).
  3. Assert that the `status` member on `CreateMediaBuySuccess` and `UpdateMediaBuySuccess` carries the deprecation marker.

Why the toolchain matters

The protocol-side expert review flagged `datamodel-code-generator` (a common JSON-Schema-to-Pydantic generator) as having uneven deprecation-keyword support — emits the marker only on v2+ recent releases; older pinned versions silently drop it. If `adcp-client-python` uses `datamodel-code-generator` or a similar tool, the version pin matters; if the test asserts deprecation surfaces in the generated output, regressions get caught at CI rather than in production.

This locks the contract that the JSON Schema deprecation marker continues to surface in generated types as the field rotates through 3.1 (additive) → 3.2 (legacy removal) → 4.0 (nested cascade renames).

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions