Kreya
Kreya copied to clipboard
Failed to import all methods from protobuf file due to option in method
Describe the bug When importing methods from protobuf file which includes multiple option parameters, only the first method is imported all other methods after the first imported method are not imported.
To Reproduce Steps to reproduce the behavior: Import a protobuf.proto as described below and Kreya will only import the Health method and not the HealthMore method.
syntax = "proto3";
package testhealth;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
message Request {
string message = 1;
}
message ResponseCode {
string message = 1;
int32 code = 2;
}
service TestService {
rpc Health(Request) returns (ResponseCode) {
option (google.api.http) = {
post: "/bulk-payment/pay"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {
security_requirement: {
key: "Bearer";
value: {}
}
};
};
}
rpc HealthMore(Request) returns (ResponseCode) {
option (google.api.http) = {
post: "/bulk-payment/pay"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {
security_requirement: {
key: "Bearer";
value: {}
}
};
};
}
}
Expected behavior Import all methods from protobuf file
Screenshots If applicable, add screenshots to help explain your problem.
Environment (if possible, copy the information from the error dialog or the About menu):
- Tested on 1.6.0 and tested on alpha with same result
Additional context test.proto.txt
Add any other context about the problem here.
Sadly, this is a bug in one of our dependencies: https://github.com/protobuf-net/protobuf-net/issues/833. It fails to parse the protobuf definition correctly.
As a workaround, you could remove the options from the protobuf definitions. Another option would be to use the gRPC proto file descriptor set
importer, but then you need to pre-compile your protobuf definition like this:
protoc -I googleapis -I grpc-gateway -I . --include_imports -o output.bin test.proto
This works well if your protobuf definitions are "stable". We understand that this can be very annoying, since you need to do this each time your protobuf definitions change.
We just released Kreya 1.9, which contains a fix for this bug.