openapi2proto
openapi2proto copied to clipboard
Support for non-200/201 status
In the README, the following caveat is stated:
Only "200" and "201" responses are inspected for determining the expected return value for RPC endpoints.
Are there plans to support responses from other statuses?
I believe this can be achieved using the oneof construct. For example, instead of:
message FindPetsByIdsResponse {
message PetsMessage {
int64 id = 1;
string name = 2;
string tag = 3;
}
repeated PetsMessage pets = 1;
}
Assuming there's no $ref on the status code 404, this will become:
message FindPetsByIdsResponse {
message Message200 {
int64 id = 1;
string name = 2;
string tag = 3;
}
message Message404 {
}
oneof responses {
repeated Message200 pets = 1;
Message404 = 2;
}
}
Thoughts?
I don't think your suggestion is compatible with grpc-gateway implementation. How will you parse the response so it will be translated to your proposed structure?
Hi @elyashivlavi ,
...compatible with grpc-gateway implementation.
~I'm not sure what you mean. Is grpc-gateway dependent on this (or vice versa)? If so, why are they dependent?~
I saw the -annotate option (disabled by default), which is meant for grpc-gateway. Are you saying that this project is tied to grpc-gateway (and thus cannot freely make changes)?
...parse the response so it will be translated to your proposed structure?
What do you mean by response? I am under the impression that this project simply relies on an openapi file, and not a running gRPC server. Am I missing something?