[Go] return errors that happen while unmarshalling objects#16525
[Go] return errors that happen while unmarshalling objects#16525wing328 merged 4 commits intoOpenAPITools:masterfrom
Conversation
|
CI says samples are not up-to-date, but the changes it's finding are unrelated to my PR; I'm not sure how to address this. Example diff reported by CI job: |
|
CircleCI reported the following errors: Can you please take a look when you've time? |
|
for the updated samples, can you please merge the latest master into your branch and regenerate the samples again? |
452e416 to
10e0e85
Compare
| // https://github.com/OpenAPITools/openapi-generator/issues/1292 | ||
| if regexp. | ||
| MustCompile(`^parsing time.+cannot parse "\+0000"" as "Z07:00"$`). | ||
| MustCompile(`as "Z07:00"$`). |
There was a problem hiding this comment.
This change matches a change that was made in November 2022 in samples/client/petstore/go/store_api_test.go.
I wouldn't expect my template change to impact this test...was this broken before or did my template change break it?
There was a problem hiding this comment.
It was working before. To run the tests locally, please refer to https://github.com/OpenAPITools/openapi-generator/wiki/Integration-Tests#how-to-add-integration-tests-for-new-petstore-samples
There was a problem hiding this comment.
I did run the tests locally to fix the issue but hadn't run them against master locally to confirm the initial state. It took me a minute to connect the new test failure to my change because I didn't change anything about time parsing. The test was passing before because errors weren't being returned at all, so there was no time parse error to ignore; with my change to return errors, the test started failing because the regex it was using to identify time parse errors was wrong. (Go playground example for posterity)
There was a problem hiding this comment.
@ctreatma thanks for the details. Can you please PM me vis Slack when you've time?
https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g
This updates the Go client templates so that the
UnmarshalJSONfunction for a model always returns errors that occur during unmarshalling.Given the following spec (pseudocode, not necessarily a fully-valid spec):
and the following JSON for an Item:
{ "type": "invalid" }The generated Go model should throw an error in
UnmarshalJSONbecause the value of thetypefield does not match the spec.cc/ Go committe: @antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @lwj5
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(7.0.1 - patch release),7.1.x(minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)