protobuf2pydantic
protobuf2pydantic copied to clipboard
generate pydantic model by protobuf.pb2 file
protobuf2pydantic
Generate a file which include pydantic models by using protobuf.pb2 file
Installation
pip3 install protobuf2pydantic
Getting Started
in CLI
pb2py ../test_pb2.py > wow.py
in Python
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