-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Go] generated API code swallows decoding errors #10434
Comments
kevinawoo
added a commit
to armory/spin
that referenced
this issue
Aug 18, 2020
This also removes "*malformed" test cases since 2.14.4 doesn't return parsing errors swagger-api/swagger-codegen#10434 reports the issue. hopefully swagger-api/swagger-codegen#10429 be merged will add that ability back in.
kevinawoo
changed the title
[Go] generated API code hides decoding errors
[Go] generated API code swallows decoding errors
Aug 18, 2020
mergify bot
pushed a commit
to spinnaker/spin
that referenced
this issue
Aug 18, 2020
* chore(gateapi): update gateapi from 5c625da5 using swagger 2.4.14 * feat(contribution): add instructions on how to generate gateapi using 2.4.1 * refact(gateapi): swagger 2.4.14 query params are typed now * tests(gateapi): gateapi generated code expects valid JSON and headers This also removes "*malformed" test cases since 2.14.4 doesn't return parsing errors swagger-api/swagger-codegen#10434 reports the issue. hopefully swagger-api/swagger-codegen#10429 be merged will add that ability back in. * refactor(imports): fixed import styling * chore(gateapi): use swagger-cli 2.4.15
gsapkal
pushed a commit
to gsapkal/spin
that referenced
this issue
Sep 10, 2020
…#292) * chore(gateapi): update gateapi from 5c625da5 using swagger 2.4.14 * feat(contribution): add instructions on how to generate gateapi using 2.4.1 * refact(gateapi): swagger 2.4.14 query params are typed now * tests(gateapi): gateapi generated code expects valid JSON and headers This also removes "*malformed" test cases since 2.14.4 doesn't return parsing errors swagger-api/swagger-codegen#10434 reports the issue. hopefully swagger-api/swagger-codegen#10429 be merged will add that ability back in. * refactor(imports): fixed import styling * chore(gateapi): use swagger-cli 2.4.15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
If the API returns a 200, but the JSON payload is malformed, then the code Go code generated hides the decoding errors. It's more useful to surface these errors to the developer to handle.
Generated template currently with 2.4.15:
Proposed change:
Swagger-codegen version
2.4.15.
Technically, it's not a regression since 2.3.x returned generic
interface{}
s. That version required you to do your own decoding.Swagger declaration file content or url
not needed, it's with all Go generated code
Command line used for generation
swagger-cli generate
Steps to reproduce
You can generate any code.
Related issues/PRs
I opened #10429
Suggest a fix/enhancement
#10429
The text was updated successfully, but these errors were encountered: