Skip to content

Support discriminated merge-patch model hierarchies - #286

Merged
kdubb merged 2 commits into
mainfrom
codex/issue-285-discriminated-patches
Oct 20, 2026
Merged

kdubb merged 2 commits into
mainfrom
codex/issue-285-discriminated-patches

Conversation

@kdubb

@kdubb kdubb commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Discriminated object schemas used in merge-patch request bodies previously failed generation. They now produce companion hierarchies such as AnimalPatch, CatPatch, and DogPatch, with a required, non-null discriminator and omission-aware ordinary fields.

The shared IR preserves discriminator mappings and original deletion permissions. Kotlin/JAX-RS, Kotlin clients, Swift, TypeScript, and Python reject missing/null/unknown tags and fields belonging to another variant while retaining permitted extension fields. Snapshot and difference helpers retain the tag, and merge helpers reject subtype changes (or prevent them through Swift's concrete parameter types). Ordinary model contracts remain unchanged.

Compiler-backed runtime coverage includes OpenAPI, RAML, AsyncAPI, composed sources, explicit annotations with automatic promotion disabled, renamed discriminator wire names, response tolerance, required-nullable fields, decoding/encoding, and conversion/merge. Documentation describes the discriminator contract and the service's responsibility to compare it with the persisted resource.

Validation:

  • Generator lint and test compilation passed.
  • 142 patch/IR/snapshot-invariant regression tests passed.
  • 53 Quarkus integration tests passed.

Closes #285.

Project companion hierarchies with required immutable discriminators across Kotlin, Swift, TypeScript, and Python. Preserve deletion permissions and subtype validation, retain tags in conversion helpers, and reject cross-subtype merges. Add compile-backed frontend/runtime regressions and document the typed patch contract.
@kdubb
kdubb marked this pull request as ready for review October 20, 2026 17:35
@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes since the previous review appear safe to merge.

Summary

Adds discriminated merge-patch companions across Kotlin, Swift, TypeScript, and Python.

  • Discriminated models now generate matching patch hierarchies.
  • Generated models now decode the matching patch variant.
  • Patch helpers keep the tag when comparing and merging models.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Discriminated object schema] --> B[Ordinary model hierarchy]
  A --> C[Patch companion hierarchy]
  C --> D[Required discriminator]
  C --> E[Omission-aware ordinary fields]
  C --> F[Variant-only field exclusions]
  B --> G[Snapshot, difference, and merge helpers]
  C --> G
Loading

Reviews (2) 路 Last reviewed commit: "Keep discriminated patch field exclusion..." 路 Reviewed by Greptile

Separate variant exclusions from inherited schema patterns, override Python wire validators for patch descendants, and add three-level compiler-backed regression coverage. Document the new IR metadata.
@kdubb
kdubb enabled auto-merge October 20, 2026 18:07
@sonarqubecloud

Copy link
Copy Markdown

@kdubb
kdubb merged commit 5ff1f62 into main Oct 20, 2026
14 checks passed
@kdubb
kdubb deleted the codex/issue-285-discriminated-patches branch October 20, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support discriminated merge-patch hierarchies with a required immutable discriminator

1 participant