-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow multiple types #157
base: main
Are you sure you want to change the base?
allow multiple types #157
Conversation
@samlown @alonsopf This is what I was looking for, do we have a timeline for when this will be merged?
https://platform.openai.com/docs/guides/structured-outputs#all-fields-must-be-required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great start! Thanks! I don't think breaking changes should be made however without careful consideration.
Also, the tests have been updated with the new structure, but I don't see any actual tests for the new functionality, specifically the parsing the output of the type arrays. There would need to be full test coverage for this PR to be accepted.
@@ -40,7 +40,7 @@ type Schema struct { | |||
AdditionalProperties *Schema `json:"additionalProperties,omitempty"` // section 10.3.2.3 | |||
PropertyNames *Schema `json:"propertyNames,omitempty"` // section 10.3.2.4 | |||
// RFC draft-bhutton-json-schema-validation-00, section 6 | |||
Type string `json:"type,omitempty"` // section 6.1.1 | |||
Type []string `json:"type,omitempty"` // section 6.1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is a significant breaking change for anyone using the Type
field directly, and as such, I'm not convinced this is the correct approach.
I'm wondering if an alternative approach, given how rare this field is even used, might be to automatically handle a comma or semicolon separated list of types alongside the automatic conversion in the JSON marshalling methods.
A definition would effectively look like:
jsonschema.Schema{
Type: "string,null",
}
or in a struct:
type Object struct {
Text string `jsonschema:"type=string,null"`
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the structure, we could even get it from the property type or the json tag. If it is a pointer or the json tag has the omitempty
the null
could be added to the jsonchema array
No description provided.