Skip to content

codegen: format-aware type mapping (date-time, uri, uuid, decimal) #13

Description

@bokelley

Follow-up from #12 review.

PropertyResolver.kt ignores JSON Schema format and always types number as Double. This is wire-correct but lossy for two categories of field:

Monetary fields (CPM, bid, budget, price) — Double round-trips most values but isn't bit-exact and will fail strict storyboard equality checks. Both reference SDKs handle this differently:

  • @adcp/sdk (TS) lives with number precision loss
  • adcp (Python) uses Decimal

Recommend BigDecimal for any property with format: decimal or in a curated property-name allowlist (*_price, cpm, bid, budget, floor).

Datetime / URI / UUID fieldsstring is always typed as java.lang.String, even though AdcpObjectMapperFactory registers JavaTimeModule. The generated type tells the caller nothing about format; round-tripping through String works but loses type safety.

Suggested mapping:

  • format: date-timejava.time.OffsetDateTime
  • format: datejava.time.LocalDate
  • format: uri / uri-referencejava.net.URI
  • format: uuidjava.util.UUID
  • format: emailString (no good JDK type)

Acceptance: PropertyResolver.resolve() returns the format-appropriate type, round-trip tests added in CodegenRoundTripTest, generated Instant/OffsetDateTime fields deserialize via the already-registered JavaTimeModule.

Refs:

  • build-logic/src/main/kotlin/codegen/PropertyResolver.kt:75-82
  • adcp/src/main/java/org/adcontextprotocol/adcp/schema/AdcpObjectMapperFactory.java:46-51

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions