carvalhorr / protoc-gen-mock

47 stars 11 forks source link

oneof field is ignored #27

Closed jfgosselin closed 3 years ago

jfgosselin commented 4 years ago

I did a test with the following proto:

service Greeter {
  rpc Hello(Request) returns(Response) {}
}

message Request {

  string name = 1;

  oneof input {
    string first = 2;
    string last = 3;
  }
}

message Response { string greeting = 1; }

If I push the following stubs:

{
    "fullMethod": "/carvalhorr.greeter.Greeter/Hello",
    "request": {
        "match": "partial",
        "content": {
            "last": "Smith"
        }
    },
    "response": {
        "type": "success",
        "content": {
            "greeting": "Hello, John"
        }
    }
}

I get this error:

    "errors": [
        "Field 'request.content.last' does not exist"
    ],

I think you skip the oneof when you parse the proto. https://github.com/carvalhorr/protoc-gen-mock/blob/791aff6a1f9febcccf1258ab1e5c3b6969aec906/stub/validation.go#L64

Thanks

carvalhorr commented 4 years ago

Thanks for your comment. I am reviewing the module to support oneof and map for example. I am reviewing the protobuf specification to make sure all features of the language are supported.

carvalhorr commented 3 years ago

Could you please verify if the issue is resolved in v1.3.0, @jfgosselin ?