Skip to content

jupyter-naas/protobuf2pydantic

 
 

Repository files navigation

protobuf2pydantic

GitHub Build Status codecov PyPI Language grade: Python

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

* Required proto file syntax = "proto3";

About

generate pydantic model by protobuf.pb2 file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.2%
  • Makefile 3.8%