equinix-labs / metal-go

[Deprecated] Golang client for Equinix Metal
https://deploy.equinix.com/labs/equinix-sdk-go/
MIT License
3 stars 2 forks source link

fix: return errors when JSON responses contain fields of wrong type #149

Closed ctreatma closed 1 year ago

ctreatma commented 1 year ago

The Go generator we are using generates code that ignores errors while unmarshalling JSON responses from the API into Go structs. This means that if the API spec says a field will be an integer but the field in the API response is a string, the Go SDK will return a struct with nil values for all fields instead of returning an error.

This updates the model_simple.mustache template to make the unmarshal function return errors when they happen rather than ignoring them.

displague commented 1 year ago

It would be easier to review to have the manual changes and automated changes in separate commits.

displague commented 1 year ago

A separate commit that adds the stock template, before changing it, would also help in review.

ctreatma commented 1 year ago

I've updated the PR to split out commits for adding the template, updating the template, and regenerating code from it. In addition, the v7.0.0 upgrade has been merged and this was rebased on it, so the only changes in this PR are related to the template change.

github-actions[bot] commented 1 year ago

This PR is included in version 0.21.0 :tada: