omissis / go-jsonschema

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

fix: yaml unmarshal does not implement the interface correctly #113

Closed AlbertoBarba closed 1 year ago

AlbertoBarba commented 1 year ago

The generated UnmarshalYAML method currently doesn't implement the unmarshal interface defined in the YAML package and therefore never invoked while working with it. Since I've found some tests related to the 2 versions of the YAML package i did implement the obsolete one which is supported by both.

codecov[bot] commented 1 year ago

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (8c546e6) 78.14% compared to head (7207dac) 77.31%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #113 +/- ## ========================================== - Coverage 78.14% 77.31% -0.84% ========================================== Files 10 12 +2 Lines 1446 1512 +66 ========================================== + Hits 1130 1169 +39 - Misses 244 267 +23 - Partials 72 76 +4 ``` | [Files](https://app.codecov.io/gh/omissis/go-jsonschema/pull/113?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Claudio+Beatrice) | Coverage Δ | | |---|---|---| | [pkg/generator/generate.go](https://app.codecov.io/gh/omissis/go-jsonschema/pull/113?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Claudio+Beatrice#diff-cGtnL2dlbmVyYXRvci9nZW5lcmF0ZS5nbw==) | `75.30% <100.00%> (-0.39%)` | :arrow_down: | | [tests/data/extraImports/gopkgYAMLv3.go](https://app.codecov.io/gh/omissis/go-jsonschema/pull/113?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Claudio+Beatrice#diff-dGVzdHMvZGF0YS9leHRyYUltcG9ydHMvZ29wa2dZQU1MdjMuZ28=) | `20.00% <33.33%> (ø)` | | | [pkg/generator/formatter.go](https://app.codecov.io/gh/omissis/go-jsonschema/pull/113?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Claudio+Beatrice#diff-cGtnL2dlbmVyYXRvci9mb3JtYXR0ZXIuZ28=) | `93.87% <93.87%> (ø)` | |

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

omissis commented 1 year ago

After discussing the matter on slack, we agreed upon dropping yaml.v2 support and only support v3. We also reworked tests to cover generated code unmarshalling.