How to generate OpenAPI 3 documentation from protobuf files
I searched for the answer recently and found this package: protobuf2swagger It can be run in CLI with a js config file required. This packaged solved my problem.
I searched for the answer recently and found this package: protobuf2swagger It can be run in CLI with a js config file required. This packaged solved my problem.
No, there is no fixed 1-byte type. Fixed length has 4 and 8 byte variants only. Most other numeric values are encoded as “varint”s, which is variable length depending on magnitude (and sign, but “zigzag” comes into play there). So you can store bytes with value 0-127 in one byte, and 128-255 in two bytes. … Read more
The following applies for ‘proto2’ syntax, not ‘proto3’ : The notion of a field being set or not is a core feature of Protobuf. If you set a field to a value (any value), then the corresponding has_xxx method must return true, otherwise you have a bug in the API. If you do not set … Read more
I would suggest storing the .proto files in a separate project. These are the contract between your two projects, and they are not necessarily “owned” by either one. Storing them in a separate project provides neutral ground for both project members to negotiate changes to the files – for example through a pull/merge request process … Read more
For large binary transfers, the standard approach is chunking. Chunking can serve two purposes: reduce the maximum amount of memory required to process each message provide a boundary for recovering partial uploads. For your use-case #2 probably isn’t very necessary. In gRPC, a client-streaming call allows for fairly natural chunking since it has flow control, … Read more
No, you cannot use a primitive type as either the request or response. You must use a message type. This is important because a message type can be extended later, in case you decide you want to add a new parameter or return some additional data.
TL;DR: It’s possible, but it does not generate a compiler warning. Consider to use field-level deprecation. It looks like it’s possible to add a deprecated option to a service, just like on a message and enum like: service MyService { rpc GetThings(GetThingsRequest) returns (GetThingsResponse) { option deprecated = true; }; } Found this in: https://github.com/google/protobuf/issues/1734 … Read more
I would recommend using the writeDelimitedTo(OutputStream) and parseDelimitedFrom(InputStream) methods on Message objects. writeDelimitedTo writes the length of the message before the message itself; parseDelimitedFrom then uses that length to read only one message and no farther. This allows multiple messages to be written to a single OutputStream to then be parsed separately. For more information, … Read more
Unfortunately, there is no common practice, although the main goal that you should achieve is to store proto files in one version control repository. During my investigation, I’ve found some interesting blog posts about that subject: https://www.bugsnag.com/blog/libraries-for-grpc-services https://www.crowdstrike.com/blog/improving-performance-and-reliability-of-microservices-communication-with-grpc/ https://medium.com/namely-labs/how-we-build-grpc-services-at-namely-52a3ae9e7c35 They covers much of gRPC workflow considerations. Hope that helps!
Install protoc for Linux and Mac Linux PROTOC_ZIP=protoc-3.15.8-linux-x86_64.zip curl -OL https://github.com/google/protobuf/releases/download/v3.15.8/$PROTOC_ZIP sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc sudo unzip -o $PROTOC_ZIP -d /usr/local include/* rm -f $PROTOC_ZIP Mac OS X brew install protobuf Alternately, if you don’t have Homebrew. PROTOC_ZIP=protoc-3.15.8-osx-x86_64.zip curl -OL https://github.com/google/protobuf/releases/download/v3.15.8/$PROTOC_ZIP sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc sudo unzip -o $PROTOC_ZIP … Read more