Ed-XCF / protobuf2pydantic

generate pydantic model by protobuf.pb2 file
MIT License
60 stars 13 forks source link

Make use of message enum number instead of index. #6

Open Shlomigreen opened 12 months ago

Shlomigreen commented 12 months ago

In the below reference, you make the value number in the generated Pydantic model equal to the index of the elements in enum. This can cause problems when enum set in the proto file is not in a running number.

It can be solved by placing value.number instead of value.index.

https://github.com/Ed-XCF/protobuf2pydantic/blob/d184c118eac463af22bc762519edf5086cb654ac/protobuf2pydantic/biz.py#L53C13-L53C78