clean-night-52582
08/03/2021, 12:21 AMproto3
is very relaxed for the sake of compatibility, but am looking for a way not to have to write validation into the endpoints. I'm looking for something that after we deserialize the proto we can check for what we consider a valid message that is a subset of what proto would allow, string not being empty, int's not being 0 etc. Something like a jsonschema
validator layer for JSON. I was looking at protoc-gen-validate
but it seems like I would have to swap out the whole proto
compiler and give it access to some go
resources. https://github.com/envoyproxy/protoc-gen-validate wondering if anyone else has found a good solution.fast-nail-55400
08/03/2021, 12:36 AM--descriptor_set_out=FILE
option to protoc
will write metadata about the protobufs to FILE (in protobuf format of course)fast-nail-55400
08/03/2021, 12:36 AMWrites a FileDescriptorSet (a protocol buffer,
defined in descriptor.proto) containing all of the input files to FILE.
fast-nail-55400
08/03/2021, 12:37 AMhundreds-father-404
08/03/2021, 12:41 AMthe --descriptor_set_out=FILE option to protoc will write metadata about the protobufs to FILELike the
./pants export-codegen
goal? Not sure how automated you mean by "deserialize"fast-nail-55400
08/03/2021, 12:48 AMProtobufMetadataLintRequest
using a union rule where particular metadata linters can register.
3. in a particular repo, add a pants plugin to hook ProtobufMetadataLintRequest
via UnionRule
and process any of its`ProtobufMetadataLintRequest` subclass that come to it,fast-nail-55400
08/03/2021, 12:49 AMclean-night-52582
08/03/2021, 12:53 AMproto
files such that I don't have to write a bunch of code to check fields are not the default. Trying to get grpc off the ground but switching from json with a schema validator to proto if we have to have to hand write the validation might be a tough sell.fast-nail-55400
08/03/2021, 12:56 AMBasically was asking if there is a way to add annotations tonot that I know of. this is a general problem with any user of protobuf.files such that I don’t have to write a bunch of code to check fields are not the default.proto
fast-nail-55400
08/03/2021, 12:57 AMgoogle.protobuf.*
wrapper typesfast-nail-55400
08/03/2021, 12:57 AMOption<T>
instead of just T
for whatever Tfast-nail-55400
08/03/2021, 12:58 AMprost
crate that we use in the Rust parts of Pants does that.fast-nail-55400
08/03/2021, 1:02 AMfast-nail-55400
08/03/2021, 1:04 AM