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
Very nice pkg, I was testing it and quickly (for my use case [1]) I needed to convert from proto instance to pydantic, then I was wondering what do you think about adding a helper method to the generated classes such .from_proto? if you agree in the idea I can jump in in the implementation (or if you prefer implementing all good) .
[1] just playing in a proof of concept project that from a proto definition I generate the following services rpc (grpc), rest(fastapi), graphql, I basically 1) compile the proto and add the grpc server 2) use your lib to generate pydantic that empowers fastapi 3) from the generated pydantic I use pydantic2graphene to expose for graphql
from protobuf2pydantic import msg2py
from pydantic import validator
import transaction_pb2
class AmountResponse(msg2py(transaction_pb2.AmountResponse)):
@validator("amount")
def non_negative(cls, v):
assert v >= 0
return v
msg_proto = transaction_pb2.AmountResponse(amount=10.01, currency="USD")
amount_pydantic = AmountResponse.from_proto(msg_proto)
The text was updated successfully, but these errors were encountered:
Hi there,
Very nice pkg, I was testing it and quickly (for my use case [1]) I needed to convert from
proto
instance topydantic
, then I was wondering what do you think about adding a helper method to the generated classes such.from_proto
? if you agree in the idea I can jump in in the implementation (or if you prefer implementing all good) .[1] just playing in a proof of concept project that from a
proto
definition I generate the following servicesrpc
(grpc),rest
(fastapi), graphql, I basically 1) compile theproto
and add the grpc server 2) use your lib to generate pydantic that empowers fastapi 3) from the generatedpydantic
I usepydantic2graphene
to expose for graphqlThe text was updated successfully, but these errors were encountered: