Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for non-200/201 status #123

Open
devcsrj opened this issue Jan 6, 2020 · 2 comments
Open

Support for non-200/201 status #123

devcsrj opened this issue Jan 6, 2020 · 2 comments

Comments

@devcsrj
Copy link

devcsrj commented Jan 6, 2020

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?

@elyashivlavi
Copy link

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?

@devcsrj
Copy link
Author

devcsrj commented Jan 8, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants