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

Generated Code for sending JSON requests is not in the sending path #371

Closed
cloudsinmycoffee opened this issue Nov 9, 2022 · 3 comments
Closed

Comments

@cloudsinmycoffee
Copy link

Hello there! We're using the twirp library at work for sending/receiving JSON requests via http. It has come to our attention that the omitempty flag is not supported when it comes to sending JSON requests. For now, our solution is to patch it manually after the code is being generated. The bug seems to be in protoc-gen-twirp/generator.go at func doJSONRequest and should be adapted in line 824 from

	t.P(`  marshaler := &`, t.pkgs["protojson"], `.MarshalOptions{UseProtoNames: true}`)

to

	t.P(`  marshaler := &`, t.pkgs["protojson"], `.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}`)

Thanks in advance!

@wmatveyenko
Copy link
Contributor

Hi, we happily accept pull requests if you would like to fix it.

cloudsinmycoffee pushed a commit to cloudsinmycoffee/twirp that referenced this issue Nov 16, 2022
@cloudsinmycoffee
Copy link
Author

Sure thing, I created a pull request :)

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label / comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants