Skip to content

enhance(cli): Declare the type of every schema literal - #991

Merged
JeanMertz merged 2 commits into
mainfrom
fix-dsl2
Aug 23, 2026
Merged

enhance(cli): Declare the type of every schema literal#991
JeanMertz merged 2 commits into
mainfrom
fix-dsl2

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

A literal in the schema DSL emitted {"const": 1}, and an all-literal union emitted {"enum": [1, 2]}. Both leave the type implicit, so a consumer that keys on type skips the node. The OpenAI provider's ensure_strict_schema is one: its object handling is gated on is_object_type(map.get("type")).

Every literal now carries a type inferred from its JSON value, so version 1 emits {"type": "integer", "const": 1}. An all-literal union whose members share a type keeps the enum form and gains that type; one mixing integers and floats widens to number.

A union of unrelated literal types cannot be described by one type, so it becomes an anyOf of typed constants instead of an untyped enum: value "foo"|"bar"|42 was {"enum": ["foo", "bar", 42]}. Both forms accept exactly the same documents. The new one also says which type each value has.

A literal in the schema DSL emitted `{"const": 1}`, and an all-literal
union emitted `{"enum": [1, 2]}`. Both leave the type implicit, so a
consumer that keys on `type` skips the node. The OpenAI provider's
`ensure_strict_schema` is one: its object handling is gated on
`is_object_type(map.get("type"))`.

Every literal now carries a type inferred from its JSON value, so
`version 1` emits `{"type": "integer", "const": 1}`. An all-literal
union whose members share a type keeps the `enum` form and gains that
type; one mixing integers and floats widens to `number`.

A union of unrelated literal types cannot be described by one `type`,
so it becomes an `anyOf` of typed constants instead of an untyped
`enum`: `value "foo"|"bar"|42` was `{"enum": ["foo", "bar", 42]}`.
Both forms accept exactly the same documents. The new one also says
which type each value has.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz
JeanMertz merged commit 3769537 into main Aug 23, 2026
16 checks passed
@JeanMertz
JeanMertz deleted the fix-dsl2 branch August 23, 2026 21:39
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.

1 participant