utrack / clay

Proto-first minimal server platform for gRPС+REST+Swagger APIs
MIT License
289 stars 39 forks source link

proto gen: support optionals in proto syntax 3 #104

Closed aadedamola closed 2 years ago

aadedamola commented 2 years ago

Anytime I use this plugin to generate code from a proto file, I get this error message:

example.proto is a proto3 file that contains optional fields, but code generator protoc-gen-goclay hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--goclay_out:

Since this update supports optionals by default, we should support optionals during code generation?

bullgare commented 2 years ago

Do you have a simple proto file as an example?

aadedamola commented 2 years ago

Thanks @bullgare. Here is a sample proto.



package example;

option go_package = "./pkg/example;exampleservice";

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-swagger/options/annotations.proto";

service ExampleService {
  // Add two nullables
  rpc Add(Request) returns (Response) {
    option (google.api.http) = {
      post: "/api/v1/add"
      body: "*"
    };
  }
}

message Request {
  optional int64 value1 = 1;
  optional int64 value2 = 2;
}

message Response {
  int64 sum = 1;
}
utrack commented 2 years ago

Thanks a lot! Published with v3.1.0