Skip to content

Conversation

@majiayu000
Copy link

Fixes #1006

Changes

  • Add MaxLength field to jsonschema.Definition struct with JSON tag maxLength
  • Add test case to verify MaxLength serialization

Add MaxLength field to the Definition struct in the jsonschema package.
This allows users to specify the maximum length constraint for string
types when defining JSON schemas.

Closes sashabaranov#1006

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: majiayu000 <[email protected]>
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.61%. Comparing base (5d7a276) to head (2185b63).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1097      +/-   ##
==========================================
+ Coverage   99.59%   99.61%   +0.02%     
==========================================
  Files          34       34              
  Lines        2209     1841     -368     
==========================================
- Hits         2200     1834     -366     
+ Misses          6        4       -2     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

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 the maxLength JSON Schema constraint by adding a MaxLength field to the jsonschema.Definition struct. This addresses issue #1006 and enables users to specify maximum string length constraints in their JSON schemas.

Changes:

  • Added MaxLength integer field to jsonschema.Definition struct with proper JSON marshaling support
  • Added test case to verify MaxLength field serialization to JSON

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
jsonschema/json.go Adds MaxLength field to Definition struct with appropriate JSON tag and documentation
jsonschema/json_test.go Adds test case verifying MaxLength field correctly serializes to JSON with value 100

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

why dont add MaxLength field in jsonschema.Definition?

1 participant