-
Notifications
You must be signed in to change notification settings - Fork 827
Add resolution of function parameter level data annotation attributes. #6671
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
Add resolution of function parameter level data annotation attributes. #6671
Conversation
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 adds support for resolving data annotation attributes at the function parameter level when creating JSON schemas. Previously, only type-level attributes were considered, but now parameter-specific annotations like [Range]
and [StringLength]
are properly applied to the generated schema.
Key changes:
- Modified
CreateJsonSchemaCore
to acceptParameterInfo
instead of just the parameter name - Updated data annotation resolution to check both parameter-level and type-level attributes
- Added comprehensive test coverage for parameter-level data annotations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
AIJsonUtilities.Schema.Create.cs | Modified schema creation logic to resolve attributes from both parameter info and type context |
AIJsonUtilitiesTests.cs | Added test to verify parameter-level data annotation attributes are properly applied to JSON schema |
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
Outdated
Show resolved
Hide resolved
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.
Thanks
…ities/AIJsonUtilitiesTests.cs Co-authored-by: Stephen Toub <[email protected]>
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs
Show resolved
Hide resolved
…ities/AIJsonUtilitiesTests.cs
Fix #661.
Microsoft Reviewers: Open in CodeFlow