Skip to content

Generate forward-compatible enums (open value + known/value pair) #54

Description

@OmarAlJarrah

Problem

Closed enums throw on an unrecognised server value.

Proposed change

Generate enums as an open class over the four-state string field, with a closed Known enum and a Value enum that adds an unknown sentinel. Deserialization never throws; a known()/value() accessor throws on unknown; the raw string is preserved. Lint-clean names (no underscore-prefixed sentinel).

Prior art: openai-java's two-enum pattern (ReasoningEffort.kt). Realises the forward-compatible-enum direction already noted in docs/refs-comparison.md.

Acceptance

  • Enum codegen template
  • Unknown value deserializes without throwing
  • Test

Dependencies


Priority: high · Effort: medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenfuture KotlinPoet codegenenhancementNew feature or request

    Type

    No type

    Fields

    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