Skip to content

schemas: restructure core/format.json outer assets oneOf to be discriminated #3935

Description

@bokelley

Background

Follow-up from #3917 / #3928 / #3934. The outer oneOf at `core/format.json` `#/properties/assets/items` (15 variants) cannot be cleanly discriminated by a single key today.

  • Variants 0–13 (`Individual{Image,Video,Audio,...}Asset`) declare `item_type: "individual"` and `asset_type: ""`
  • Variant 14 (`RepeatableGroupAsset`) declares `item_type: "repeatable_group"` and has no `asset_type`

Adding `discriminator.propertyName="asset_type"` fails because variant 14 doesn't have it. Adding `discriminator.propertyName="item_type"` doesn't help downstream codegen because 14 of the 15 variants share the same `item_type` value.

Proposed restructure

Split the union into two tiers:

```json
{
"discriminator": { "propertyName": "item_type" },
"oneOf": [
{
"properties": { "item_type": { "const": "individual" } },
"required": ["item_type"],
"discriminator": { "propertyName": "asset_type" },
"oneOf": [ ...14 individual variants... ]
},
{
"properties": { "item_type": { "const": "repeatable_group" } },
"required": ["item_type"],
// RepeatableGroupAsset shape
}
]
}
```

This produces a TypeScript codegen output along the lines of:

```ts
type Item =
| (IndividualAssetCommon & ({ asset_type: 'image'; ... } | { asset_type: 'video'; ... } | ...))
| RepeatableGroupAsset;
```

instead of today's flat 15-way structurally-overlapping union.

Acceptance

  • `core/format.json` outer oneOf classifies as ✓ in `scripts/audit-oneof.mjs` without the variant-14-misses-asset_type error
  • `npm run test:json-schema`, `test:schemas`, `test:composed` all pass
  • `scripts/oneof-discriminators.baseline.json` ratchets to remove the outer oneOf entry
  • adcp-client / adcp-py codegen for `Format.assets[]` produces a discriminated union

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-triagedIssue has been triaged by the Claude Code triage routine. Remove to re-triage.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions