protocol-buffersproto

protobuf options - how to enforce "use only these data types" in the .proto file


I want to enforce that a .proto file uses only "approved" data types (custom-defined types are valid).

QUESTION
Is there a .proto-file level option where I can say use only: fixed32, fixed64, and any custom messages

Also, I would want to enforce that all bytes types use fixed_length = true

I know I can do this by parsing each file using Python but I'd prefer a builtin option.


Solution

  • The only way this could be enforced is through some form of style-enforcement (linting) when protos are checked in to your source control or prior to protoc compilation.

    I don't use it but buf lint may help.