Skip to content
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] Serialize multipart array of complex objects as JSON #2965

Merged
merged 3 commits into from Jun 28, 2019

Conversation

Projects
None yet
3 participants
@thiagoarrais
Copy link
Contributor

commented May 21, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

cc @antihax @bvwells @grokify @kemokemo

Description of the PR

Fixes #2964 by forcing multipart items that are complex objects to be rendered as json.

I'm not really sure this is the correct approach architecturally. Just let me know if you need any changes. And please also help me see the many hidden edge cases I'm not finding.

Update: Fixes #3043

@thiagoarrais thiagoarrais force-pushed the thiagoarrais:multipart-part-as-json branch from 4446cb4 to 4123156 May 21, 2019

@thiagoarrais thiagoarrais changed the title Serialize multipart array of complex objects as JSON [go] Serialize multipart array of complex objects as JSON May 23, 2019

@thiagoarrais

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2019

@wing328: the bot didn't label this one (probably because I've edited the title to include after the fact). Can you add the Client: Go label please?

@@ -138,6 +138,10 @@ func parameterToString(obj interface{}, collectionFormat string) string {
delimiter = "\t"
case "csv":
delimiter = ","
case "json": {
jsonBuf, _ := json.Marshal(obj)

This comment has been minimized.

Copy link
@thiagoarrais

thiagoarrais May 24, 2019

Author Contributor

@antihax: changed as per your suggestion. Question: do you think we need to check err here?

This comment has been minimized.

Copy link
@wing328

wing328 May 29, 2019

Member

If checking the err here will result in better error handling (e.g. users get notified of the errors instead of errors being silently discarded), then please do so.

This comment has been minimized.

Copy link
@antihax

antihax May 29, 2019

Contributor

The function may need to be altered to return the error but it would be a good idea.

This comment has been minimized.

Copy link
@thiagoarrais

thiagoarrais May 29, 2019

Author Contributor

Ok. I will add the error handling.

And since this is the only case that needs error handling (and this function was already being distorted anyway), I will also move JSON serialization code to the point of call instead of changing parameterToString.

This comment has been minimized.

Copy link
@thiagoarrais

thiagoarrais May 30, 2019

Author Contributor

I've updated the code to add error handling. Please let me know what you think.

This comment has been minimized.

Copy link
@wing328

wing328 May 30, 2019

Member

@antihax can you please have another look when you've time?

@wing328 wing328 added the Client: Go label May 29, 2019

@wing328 wing328 added this to the 4.0.1 milestone May 29, 2019

@thiagoarrais thiagoarrais force-pushed the thiagoarrais:multipart-part-as-json branch 2 times, most recently from 7553f4f to 1a0543f May 29, 2019

@wing328 wing328 modified the milestones: 4.0.1, 4.0.2 May 31, 2019

@thiagoarrais

This comment has been minimized.

Copy link
Contributor Author

commented Jun 10, 2019

Friendly bump: can we merge this?

@wing328 wing328 modified the milestones: 4.0.2, 4.0.3 Jun 20, 2019

@wing328

This comment has been minimized.

Copy link
Member

commented Jun 25, 2019

@thiagoarrais sorry for the delay as we were busy with another release.

Can you please resolve the merge conflicts and I'll merge this PR into accordingly?

@thiagoarrais thiagoarrais force-pushed the thiagoarrais:multipart-part-as-json branch from 1a0543f to 70ff797 Jun 25, 2019

@thiagoarrais

This comment has been minimized.

Copy link
Contributor Author

commented Jun 25, 2019

@wing328: 70ff797 should be good to go

@wing328 wing328 merged commit e46bd7d into OpenAPITools:master Jun 28, 2019

4 checks passed

Shippable Run 8779 status is SUCCESS.
Details
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@thiagoarrais

This comment has been minimized.

Copy link
Contributor Author

commented Jun 28, 2019

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.