You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thank you for all of the work on this library. I really appreciate the ability to use typescript with protobufs (and I'm using Deno which all seems to work well).
I have a message type that has a oneof field. When serializing that message type to wire-format, I'm leveraging the Confluent Schema Registry's protobuf solution, which is using this https://www.npmjs.com/package/protobufjs. The problem is the way protobufjs converts a message's oneof field to wire-format and back again doesn't seem to work with the protobuf-ts method.
// using protobuf-ts
const example = Test.create({
innerField: {
oneofKind: "innerMessageA",
innerMessageA: {}
});
// using protobufjs
const example = Test.create({
innerMessageA: {}
});
I've worked around the encoding problem by converting the protobuf-ts to JSON, then providing to protobufjs. However, how can I convert from protobufjs to protobuf-ts? Should I also use a JSON intermediate step?
TYIA for your help, please let me know if you need any additional info here.
The text was updated successfully, but these errors were encountered:
The problem is the way protobufjs converts a message's oneof field to wire-format and back again doesn't seem to work with the protobuf-ts method.
Just to be completely clear the wire-format is binary (e.g. the input to decode() or fromBinary()), not the input to create().
The interfaces of a deserialized protobuf message are significantly different between protobuf.js and protobuf-ts. There is not going to be any support for being able to call the respective create() methods with the other one's expected input. Your best bet is to either serialize to the canonical JSON representation or the binary representation with one library and then deserialize with the other. But even that may not be perfect as protobuf.js only passes 36.5% of the required protobuf conformance tests while protobuf-ts on the other hand passes 100% of them1.
You can see all the required protobuf conformance tests that protobuf.js is failing here. I count 339 failing JSON tests and 944 failing protobuf (binary) tests. Unfortunately I'm not sure how many total tests there are of each type so it's hard to say which serialization format would yield fewer issues when doing round-trips.
Hello,
First off, thank you for all of the work on this library. I really appreciate the ability to use typescript with protobufs (and I'm using Deno which all seems to work well).
I have a message type that has a
oneof
field. When serializing that message type to wire-format, I'm leveraging the Confluent Schema Registry's protobuf solution, which is using this https://www.npmjs.com/package/protobufjs. The problem is the way protobufjs converts a message's oneof field to wire-format and back again doesn't seem to work with the protobuf-ts method.Message:
I've worked around the encoding problem by converting the protobuf-ts to JSON, then providing to protobufjs. However, how can I convert from protobufjs to protobuf-ts? Should I also use a JSON intermediate step?
TYIA for your help, please let me know if you need any additional info here.
The text was updated successfully, but these errors were encountered: