Skip to content

AIJsonUtilities.CreateJsonSchema with serializerOptions: new() throws #6347

Description

@rogerbarreto

Description

Attempting to use CreateJsonSchema with a new() instance, throws.

Would be ideal that the new() instance had a DefualtOptions for the typeresolver to avoid the exception or better approach.

[Fact]
public static void CreateJsonSchema_NewSerializerOptions_ShouldNotThrow()
{
    JsonElement expected = JsonDocument.Parse("""{"type":"integer"}""").RootElement;
    JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(int), serializerOptions: new());
    Assert.Equal(expected, actual);
}

Reproduction Steps

AIJsonUtilities.CreateJsonSchema(typeof(int), serializerOptions: new());

Expected behavior

Not throw

Actual behavior

Throwing for a new() serializerOptions instance.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-aiMicrosoft.Extensions.AI librariesbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions