bitwalker / exprotobuf

Protocol Buffers in Elixir made easy!
Apache License 2.0
486 stars 69 forks source link

Imported proto definitions? #62

Closed alexander-alvarez closed 7 years ago

alexander-alvarez commented 7 years ago

Hey -- I'm trying to import a proto definition, and what I'm trying to do isn't covered by an existing test case, so I couldn't model it off of that.

Basically I want to import the struct definition from google.protobuf

// have tried "google.protobuf", "google.protobuf.struct",  "google.protobuf.struct.proto"
// "google/protobuf/struct" to no avail
import "google.protobuf";

message Response {
    enum StatusCode {
        SUCCESS = 0;
        FAILURE = 1;
        CANCELLED = 2;
    }

    StatusCode status = 1;
    // I've tried permutations of `Struct`, `google.protobuf.Struct` to no avail
    repeated Struct data = 2; 
}

But when I call mix grpc.gen I get Reference to undefined message Struct... I would expect the import to throw an exception if it was invalid, so I'm having trouble figuring out if my import is wrong or my proto3 type definition is wrong.

similar to this test case, except I want to use WrongAuthorizationHttpMessage inside of the WebsocketServerContainer message, for example.

Any thoughts or guidance?

alexander-alvarez commented 7 years ago

https://github.com/tony612/grpc-elixir/issues/8

and correct syntax is:

import "google/protobuf/struct.proto";

message Response {
    repeated google.protobuf.Struct data = 1; 
}