omissis / go-jsonschema

A tool to generate Go data types from JSON Schema definitions.
MIT License
563 stars 90 forks source link

Fix non-nullable type with two options #205

Closed jagregory closed 5 months ago

jagregory commented 6 months ago

If you have a type with exactly two options, neither of which is null, then the null-checking logic incorrectly uses the last item in the list as the type instead of interface{}.

e.g. "type": ["string", "boolean"] becomes *bool instead of interface{} because the generation logic is assuming a two item type is only used when setting a type to null.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.28%. Comparing base (d963216) to head (d9668fc). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #205 +/- ## ========================================== + Coverage 76.58% 78.28% +1.69% ========================================== Files 24 24 Lines 1892 1515 -377 ========================================== - Hits 1449 1186 -263 + Misses 354 240 -114 Partials 89 89 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.