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

[BREAKING CHANGES] Changes Definition.Type from DataType to []DataType #916

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

blwsh
Copy link

@blwsh blwsh commented Dec 26, 2024

Describe the change

  • Allows for more fine-grained control of types
  • Allows for pointers to be treated as nullable
  • Fixes issue with empty properties object being omitted when marshaling

Provide OpenAI documentation link

You can see in the Open AI docs here an example of types array being used. I've also tested this myself and it works. I was unable to find a formal schema.

Describe your solution

Simply changes Definition.Type from DataType to []DataType. Adjusts reflectSchema in json.go to set d.Type to equal array of DataType instead of simply just the type. If a pointer is seen we also append "null" to the array. Validate function has been adjusted to iterate of d.Type.

Tests

Still need to add a test for pointers.

Why?

* Allows for more fine-grained control of types
* Allows for pointers to be treated as nullable
* Fixes issue with empty properties object being omitted when marshaling
@blwsh blwsh changed the title Changes Definition.Type from DataType to []DataType [BREAKING CHANGES] Changes Definition.Type from DataType to []DataType Dec 26, 2024
Copy link

codecov bot commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.69%. Comparing base (774fc9d) to head (6fc2bd2).
Report is 77 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #916      +/-   ##
==========================================
+ Coverage   98.46%   98.69%   +0.23%     
==========================================
  Files          24       26       +2     
  Lines        1364     1761     +397     
==========================================
+ Hits         1343     1738     +395     
- Misses         15       16       +1     
- Partials        6        7       +1     

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

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.

1 participant