Skip to content

Conversation

eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Jul 31, 2025

Fix #661.

Microsoft Reviewers: Open in CodeFlow

@eiriktsarpalis eiriktsarpalis requested a review from a team as a code owner July 31, 2025 16:50
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Jul 31, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 accept ParameterInfo 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

Copy link
Member

@stephentoub stephentoub left a 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]>
@eiriktsarpalis eiriktsarpalis enabled auto-merge (squash) July 31, 2025 17:13
@eiriktsarpalis eiriktsarpalis disabled auto-merge July 31, 2025 17:14
@eiriktsarpalis eiriktsarpalis enabled auto-merge (squash) July 31, 2025 17:15
This was referenced Aug 27, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[2.0 Verification] Fix doc comment
2 participants