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

Add support extended google.api.annotations with response field #39

Merged
merged 12 commits into from
Aug 6, 2018

Conversation

doroginin
Copy link
Contributor

@doroginin doroginin commented Jul 26, 2018

After this changes you can add binding with request/response mapping to repeated fields.

syntax = "proto3";

import "github.com/doroginin/grpc-gateway/third_party/googleapis/google/api/annotations.proto";

service Strings {
    rpc ToUpper (String) returns (String) {
        option (google.api.http) = {
            post: "/strings/to_upper"
            body: "str"
            response_body: "str"
        };
    }
}

message String {
    repeated string str = 1;
}

And in the result your request body will be: ["test","boo"] and response body will be: ["TEST","BOO"]

Copy link
Contributor

@mwf mwf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need CI fix and a decision about running subtests individually.

go build -o main main.go
vgo build -o main main.go

test: build pwd clean protoc build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - build is used as first target

@@ -11,7 +7,7 @@ clean:
find . -regex "\.\/.*\/.*\.go" -exec rm {} +
rm -f main

protoc:
protoc: protoc-build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this protoc-build in every sub-test - maybe it's better to run them once in the core Makefile.

And if you want to run a single test individually - just prepare your environment manually running make protoc-build and then run make test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we could do even better and make 2 targets.
test would explicitly run protoc-build - you would use it in manuall run
test-ci won't call protoc-build - it would be used in the core Makefile to run all tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed verbally

@@ -4,7 +4,7 @@ import (
"github.com/golang/glog"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
"github.com/utrack/grpc-gateway/protoc-gen-swagger/genswagger"
"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, then the swagger would break if clay consumers won't use github.com/utrack/grpc-gateway explicitly.
Maybe it's better to keep it as it is.

@doroginin
Copy link
Contributor Author

Now also supported repeated field in GET
See: integration/binding_with_body_and_response/pb/strings.proto
GET request like this: /strings/to_upper/v2?str=test&str=boo

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

Successfully merging this pull request may close these issues.

3 participants