protobuf_to_pydantic icon indicating copy to clipboard operation
protobuf_to_pydantic copied to clipboard

Document how to convert objects between proto and pydantic and reverse

Open jankatins opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe.

I tried to find if there is an easy way to convert objects form one format into another. The easiest I found is using dicts as a intermediate format.

Describe the solution you'd like

  • Something documented in the readme showcasing the conversion in both directions
  • Maybe: a nice <PydanticType>.from_proto(msg: <ProtoType>) -> <PydanticType> class method and <PydanticType>.to_proto() -> <ProtoType> method.

Describe alternatives you've considered

The dict method: convert proto/pydantic to dict, use that dict with two stars as input.

jankatins avatar Apr 15 '24 10:04 jankatins

@jankatins Are you talking about something similar to this Issue? #11

so1n avatar Apr 15 '24 11:04 so1n