EnumAsOneOf

@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class EnumAsOneOf

Marks an enum class so that each constant's JsonPropertyDescription reaches the model as a per-constant description in the generated JSON Schema.

Without this annotation, Embabel emits the enum as a bare list of allowed values:

{ "type": "string", "enum": ["URGENT", "NORMAL", "OTHER"] }

With this annotation, each constant gets its own const+description entry inside oneOf:

{ "type": "string", "oneOf": [
{ "const": "URGENT", "description": "Needs same-day response" },
{ "const": "NORMAL", "description": "Standard turnaround" },
{ "const": "OTHER" }
]}

Trade-off: the oneOf keyword is not accepted by OpenAI's strict structured-output mode. Embabel detects this and falls back to sending the schema as prompt text for that call. The description string from each constant's JsonPropertyDescription still reaches the model via that prompt text.

This annotation is processed by EnumConstantDescriptionProvider, which is wired into the schema generator by ChatClientLlmOperations. Annotating an enum without wiring the provider has no effect.

Usage (Kotlin):

@EnumAsOneOf
enum class Priority {
@JsonPropertyDescription("Needs same-day response") URGENT,
@JsonPropertyDescription("Standard turnaround") NORMAL,
OTHER,
}

Usage (Java):

@EnumAsOneOf
public enum Priority {
@JsonPropertyDescription("Needs same-day response") URGENT,
@JsonPropertyDescription("Standard turnaround") NORMAL,
OTHER
}