-
Notifications
You must be signed in to change notification settings - Fork 839
Fix mapping of MinLength/MaxLength/Length attribute mapping in nullable string properties. #6812
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
Conversation
…le string properties.
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.
Pull Request Overview
This PR fixes a bug in the JSON schema generation where MinLength/MaxLength/Length attributes were incorrectly mapped to minItems
/maxItems
instead of minLength
/maxLength
for nullable string properties.
Key Changes:
- Fixed attribute mapping logic to properly handle nullable string types
- Added a helper method to correctly identify string schema types in union types
- Updated test expectations to reflect the correct JSON schema property names
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
AIJsonUtilities.Schema.Create.cs |
Implements the core fix by adding TryGetSchemaType helper method and updating attribute mapping logic |
AIJsonUtilitiesTests.cs |
Updates existing test expectations and adds new test case for nullable string properties with length constraints |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs
Show resolved
Hide resolved
Thanks |
Fix #6676
Microsoft Reviewers: Open in CodeFlow