Skip to content
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

fix: jsonschema integer validation #852

Merged

Conversation

WeiAnAn
Copy link
Contributor

@WeiAnAn WeiAnAn commented Sep 17, 2024

Describe the change
Fix the jsonschema validation failed failure on the integer field.

Provide OpenAI documentation link

Describe your solution
Follow the #837 instruction. Because go unmarshalls all numbers as float64, we should check the value is an integer.

Tests
Add jsonschema.Integer cases, include a success and a failed case.

Additional context
Add any other context or screenshots or logs about your pull request here. If the pull request relates to an open issue, please link to it.

Issue: #837

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.01%. Comparing base (774fc9d) to head (7831bde).
Report is 50 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #852      +/-   ##
==========================================
+ Coverage   98.46%   99.01%   +0.55%     
==========================================
  Files          24       26       +2     
  Lines        1364     1422      +58     
==========================================
+ Hits         1343     1408      +65     
+ Misses         15        8       -7     
  Partials        6        6              

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

@sashabaranov
Copy link
Owner

Thank you for the PR! Looks good, and here's a minimal example validating the float64 argument https://go.dev/play/p/VRMIyt9Zjqz

@@ -94,6 +94,10 @@ func TestUnmarshal(t *testing.T) {
String string `json:"string"`
Number float64 `json:"number"`
}
var result3 struct {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe inline all these result1,2,3 please?

Copy link
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!!

@sashabaranov sashabaranov merged commit 1ec8c24 into sashabaranov:master Sep 20, 2024
3 checks passed
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.

2 participants