Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ontypeskips the node. The OpenAI provider'sensure_strict_schemais one: its object handling is gated onis_object_type(map.get("type")).Every literal now carries a type inferred from its JSON value, so
version 1emits{"type": "integer", "const": 1}. An all-literal union whose members share a type keeps theenumform and gains that type; one mixing integers and floats widens tonumber.A union of unrelated literal types cannot be described by one
type, so it becomes ananyOfof typed constants instead of an untypedenum:value "foo"|"bar"|42was{"enum": ["foo", "bar", 42]}. Both forms accept exactly the same documents. The new one also says which type each value has.