-
Notifications
You must be signed in to change notification settings - Fork 798
Enable Nullable options for CreateSchemaJson to use OpenAPI recommendation. #6306
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
Comments
### Motivation and Context - Fix #10296 This problem arises when `KernelSchema` uses the `AIJsonUtilities.CreateJsonSchema`, where it generates a schema that does not comply with OpenAPI 3.0 for nullables that Google API uses. - dotnet/extensions#6306
Using arrays in the Is there a strong need for supporting older versions of OpenAPI? |
@eiriktsarpalis We do have Google API using the old way, would be desireable to have a |
I'd be reluctant to do this, we did something similar to cater to OpenAI requirements and we're now in the process of rolling this back because of the ripple effect it causes to unrelated services. I suspect it should be possible to achieve this using a transformer delegate, would it be possible to give that a go? |
Tagging @captainsafia @darrelmiller who are more familiar with OpenAPI than me. Do you believe generating schemas using the |
Not sure if this ideal, requiring all the callers to implement a delegate, to understand how it works. Much simplier would be a tag for conformity (version) or a new flag for how handling nullables vs types convention. Were it would default to latest in which would not cause any breaking change in existing code. |
Using conformance modes for schema generation is something I've been discussing with @stephentoub but it hasn't gained traction so far. We've instead resorted to users opting in to whatever transformations they need to apply themselves. |
Thank you both. We won't try to fix this in a release for this/next week. But we need to resolve this issue in some way before going GA, even if we just have a workaround available without an MEAI change to add a flag or conformance mode. |
Description
Currently when a schema is generated for nullable properties, the
type
is defined as an array["null","<property_type>"]
.This does not follow the standard for OpenAPI 3.0 spec:
type - Value MUST be a string. Multiple types via an array are not supported.
4.7.24.2 Fixed Fields - Should have an additional field name "nullable": boolead
This becomes a problem when API's for Structured Outputs follows the OpenAPI 3.0 standard and some workarounds needs to be put in place as in this PR, having a setting, would be ideal.
Reproduction Steps
Reproduction Code
Output:
Expected behavior
A SchemaGeneration option that comply with OpenAPI 3.0 spec, generating one type and an additional Nullable boolean field in the schema.
Following the RFC (https://spec.openapis.org/oas/v3.0.3#schema-object)
Output:
Actual behavior
Output:
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
When using other types (not string) this gets trickier as the array contains multiple types for the same property.
Using
int?
example:The text was updated successfully, but these errors were encountered: