-
-
Notifications
You must be signed in to change notification settings - Fork 6.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] Serialize multipart array of complex objects as JSON #2965
[go] Serialize multipart array of complex objects as JSON #2965
Conversation
4446cb4
to
4123156
Compare
@wing328: the bot didn't label this one (probably because I've edited the title to include after the fact). Can you add the |
modules/openapi-generator/src/main/resources/go/client.mustache
Outdated
Show resolved
Hide resolved
@@ -138,6 +138,10 @@ func parameterToString(obj interface{}, collectionFormat string) string { | |||
delimiter = "\t" | |||
case "csv": | |||
delimiter = "," | |||
case "json": { | |||
jsonBuf, _ := json.Marshal(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antihax: changed as per your suggestion. Question: do you think we need to check err
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function may need to be altered to return the error but it would be a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to add error handling. Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antihax can you please have another look when you've time?
7553f4f
to
1a0543f
Compare
Friendly bump: can we merge this? |
@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? |
1a0543f
to
70ff797
Compare
🎉 |
PR checklist
./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.master
,4.1.x
,5.0.x
. Default:master
.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