Skip to content

Commit

Permalink
Upgrade to swagger-codegen 2.3.2
Browse files Browse the repository at this point in the history
Also fix a regex-o in .travis.yml. + needed to be escaped.
  • Loading branch information
achew22 committed Feb 10, 2018
1 parent 6658b3a commit 93c1dea
Show file tree
Hide file tree
Showing 29 changed files with 2,928 additions and 1,138 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ cache:
- ${TRAVIS_BUILD_DIR}/examples/browser/node_modules
before_install:
- ./.travis/install-protoc.sh 3.1.0
- ./.travis/install-swagger-codegen.sh 2.2.2
- ./.travis/install-swagger-codegen.sh 2.3.2
- nvm install v6.1 && nvm use v6.1 && node --version
- go get github.com/golang/lint/golint
- go get github.com/dghubble/sling
- go get github.com/go-resty/resty
- go get golang.org/x/oauth2
- go get golang.org/x/net/context
install:
- go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
- go get github.com/grpc-ecosystem/grpc-gateway/runtime
Expand All @@ -35,7 +37,7 @@ after_success:
env:
global:
- "PATH=$PATH:$HOME/local/bin"
- GO_VERSION_TO_DIFF_TEST="go version go1\.9\.[0-9]+ linux/amd64"
- GO_VERSION_TO_DIFF_TEST="go version go1\.9\.[0-9]\+ linux/amd64"
matrix:
- GATEWAY_PLUGIN_FLAGS=
- GATEWAY_PLUGIN_FLAGS=request_context=false
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,22 @@ $(EXAMPLE_SWAGGERSRCS): $(SWAGGER_PLUGIN) $(SWAGGER_EXAMPLES)
$(ECHO_EXAMPLE_SRCS): $(ECHO_EXAMPLE_SPEC)
$(SWAGGER_CODEGEN) generate -i $(ECHO_EXAMPLE_SPEC) \
-l go -o examples/clients/echo --additional-properties packageName=echo
@rm -f $(EXAMPLE_CLIENT_DIR)/echo/README.md \
@rm -rf $(EXAMPLE_CLIENT_DIR)/echo/README.md \
$(EXAMPLE_CLIENT_DIR)/echo/docs \
$(EXAMPLE_CLIENT_DIR)/echo/git_push.sh \
$(EXAMPLE_CLIENT_DIR)/echo/.gitignore \
$(EXAMPLE_CLIENT_DIR)/echo/.swagger-codegen \
$(EXAMPLE_CLIENT_DIR)/echo/.swagger-codegen-ignore \
$(EXAMPLE_CLIENT_DIR)/echo/.travis.yml
$(ABE_EXAMPLE_SRCS): $(ABE_EXAMPLE_SPEC)
$(SWAGGER_CODEGEN) generate -i $(ABE_EXAMPLE_SPEC) \
-l go -o examples/clients/abe --additional-properties packageName=abe
@rm -f $(EXAMPLE_CLIENT_DIR)/abe/README.md \
@rm -rf $(EXAMPLE_CLIENT_DIR)/abe/README.md \
$(EXAMPLE_CLIENT_DIR)/abe/docs \
$(EXAMPLE_CLIENT_DIR)/abe/git_push.sh \
$(EXAMPLE_CLIENT_DIR)/abe/.gitignore \
$(EXAMPLE_CLIENT_DIR)/abe/.swagger-codegen \
$(EXAMPLE_CLIENT_DIR)/abe/.swagger-codegen-ignore \
$(EXAMPLE_CLIENT_DIR)/abe/.travis.yml

examples: $(EXAMPLE_SVCSRCS) $(EXAMPLE_GWSRCS) $(EXAMPLE_DEPSRCS) $(EXAMPLE_SWAGGERSRCS) $(EXAMPLE_CLIENT_SRCS)
Expand Down
35 changes: 22 additions & 13 deletions examples/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"reflect"
"testing"

"golang.org/x/net/context"

"github.com/grpc-ecosystem/grpc-gateway/examples/clients/abe"
"github.com/grpc-ecosystem/grpc-gateway/examples/clients/echo"
)
Expand All @@ -17,10 +19,12 @@ func TestEchoClient(t *testing.T) {
return
}

cl := echo.NewEchoServiceApiWithBasePath("http://localhost:8080")
resp, _, err := cl.Echo("foo")
config := echo.NewConfiguration()
config.BasePath = "http://localhost:8080"
cl := echo.NewAPIClient(config)
resp, _, err := cl.EchoServiceApi.Echo(context.Background(), "foo")
if err != nil {
t.Errorf(`cl.Echo("foo") failed with %v; want success`, err)
t.Errorf(`cl.EchoServiceApi.Echo("foo") failed with %v; want success`, err)
}
if got, want := resp.Id, "foo"; got != want {
t.Errorf("resp.Id = %q; want %q", got, want)
Expand All @@ -33,11 +37,13 @@ func TestEchoBodyClient(t *testing.T) {
return
}

cl := echo.NewEchoServiceApiWithBasePath("http://localhost:8080")
config := echo.NewConfiguration()
config.BasePath = "http://localhost:8080"
cl := echo.NewAPIClient(config)
req := echo.ExamplepbSimpleMessage{Id: "foo"}
resp, _, err := cl.EchoBody(req)
resp, _, err := cl.EchoServiceApi.EchoBody(context.Background(), req)
if err != nil {
t.Errorf("cl.EchoBody(%#v) failed with %v; want success", req, err)
t.Errorf("cl.EchoServiceApi.EchoBody(%#v) failed with %v; want success", req, err)
}
if got, want := resp.Id, "foo"; got != want {
t.Errorf("resp.Id = %q; want %q", got, want)
Expand All @@ -50,12 +56,14 @@ func TestAbitOfEverythingClient(t *testing.T) {
return
}

cl := abe.NewABitOfEverythingServiceApiWithBasePath("http://localhost:8080")
config := abe.NewConfiguration()
config.BasePath = "http://localhost:8080"
cl := abe.NewAPIClient(config)
testABEClientCreate(t, cl)
testABEClientCreateBody(t, cl)
}

func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
func testABEClientCreate(t *testing.T, cl *abe.APIClient) {
want := &abe.ExamplepbABitOfEverything{
FloatValue: 1.5,
DoubleValue: 2.5,
Expand All @@ -73,7 +81,8 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
Sint64Value: "4611686018427387903",
NonConventionalNameValue: "camelCase",
}
resp, _, err := cl.Create(
resp, _, err := cl.ABitOfEverythingServiceApi.Create(
context.Background(),
want.FloatValue,
want.DoubleValue,
want.Int64Value,
Expand All @@ -91,7 +100,7 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
want.NonConventionalNameValue,
)
if err != nil {
t.Errorf("cl.Create(%#v) failed with %v; want success", want, err)
t.Errorf("cl.EchoServiceApi.Create(%#v) failed with %v; want success", want, err)
}
if resp.Uuid == "" {
t.Errorf("resp.Uuid is empty; want not empty")
Expand All @@ -102,7 +111,7 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
}
}

func testABEClientCreateBody(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
func testABEClientCreateBody(t *testing.T, cl *abe.APIClient) {
t.Log("TODO: support enum")
return

Expand Down Expand Up @@ -148,9 +157,9 @@ func testABEClientCreateBody(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
"b": {Name: "y", Amount: 2},
},
}
resp, _, err := cl.CreateBody(want)
resp, _, err := cl.ABitOfEverythingServiceApi.CreateBody(context.Background(), want)
if err != nil {
t.Errorf("cl.CreateBody(%#v) failed with %v; want success", want, err)
t.Errorf("cl.ABitOfEverythingServiceApi.CreateBody(%#v) failed with %v; want success", want, err)
}
if resp.Uuid == "" {
t.Errorf("resp.Uuid is empty; want not empty")
Expand Down
1 change: 0 additions & 1 deletion examples/clients/abe/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/clients/abe/.swagger-codegen-ignore

This file was deleted.

10 changes: 0 additions & 10 deletions examples/clients/abe/ProtobufDuration.go

This file was deleted.

8 changes: 4 additions & 4 deletions examples/clients/abe/a_bit_of_everything_nested.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
/*
* A Bit of Everything
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 1.0
* API version: 1.0
* Contact: [email protected]
* Generated by: https://github.com/swagger-api/swagger-codegen.git
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package abe
Expand All @@ -18,5 +18,5 @@ type ABitOfEverythingNested struct {

Amount int64 `json:"amount,omitempty"`

Ok NestedDeepEnum `json:"ok,omitempty"`
Ok *NestedDeepEnum `json:"ok,omitempty"`
}
Loading

0 comments on commit 93c1dea

Please sign in to comment.