-
Notifications
You must be signed in to change notification settings - Fork 349
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
Support JSON wire format for well-known types #571
Comments
@oyvindwe ah sure, that sounds like a good idea. I was initially a little hesitant b/c our well-known types support is good but also pretty complicated, but I think what you're asking only touch the "types only" output, so hopefully not too be too bad. A PR would be great! |
That was s good point, so I made the new option requiring
Done! :) |
* New option 'useJsonWireFormat'. Fixes issue #571 * Added test. * Formatting.
We have a webapp for a gRPC backend with a lot of types. In our scenario, using
fromPartial
is not desired, as this would add thousands of lines to our webapp client. Instead we are maintaining a fork ofts-proto
that generates types that can be sent and received directly over HTTP, but over time several of the changes we have made in our fork have been included as various options, so we are now trying to move to vanillats-proto
. The support is 90% in place using the following options:forceLong=string,env=browser,useOptionals=all,outputEncodeMethods=false,outputJsonMethods=false,outputClientImpl=false,onlyTypes=true,stringEnums=true,useDate=string
However, we struggle with support for some well known types, e.g.:
google.protobuf.FieldMask
is a comma separated string in JSON, not a string arraygoogle.protobuf.Duration
is a special formatted string in JSONWe considered supporting
Duration
by addingstring
as a type alias, but forFieldMask
the original type is lost.For us it would make sense to add an option to generate types that are directly compatible with the JSON representation of well-known types. We are happy to provide a PR for this, but we would like some feedback on the idea before putting in the effort.
The text was updated successfully, but these errors were encountered: