Skip to content

Commit

Permalink
Update test swagger generator to 2.4.8 (#1058)
Browse files Browse the repository at this point in the history
* generate files with swagger-codegen 2.4.8

* swagger-codegen 2.4.8 is now the base requirement

- had to update the makefile as the generated
file names have all moved around a little bit
- moved bazel forward to use go 1.13.1 as well
- test that was using a deep reflect to do equality
has changed to be per struct field equality (deep
reflect no longer works with the enum types).

* remove need for env var

* adds -e plus refactors tools to top

* Update .circleci/Dockerfile

Co-Authored-By: Johan Brandhorst <johan.brandhorst@gmail.com>
  • Loading branch information
zachgersh and johanbrandhorst committed Oct 4, 2019
1 parent 28a1cae commit c677e41
Show file tree
Hide file tree
Showing 87 changed files with 10,880 additions and 4,895 deletions.
33 changes: 18 additions & 15 deletions .circleci/Dockerfile
@@ -1,32 +1,35 @@
FROM golang:1.13.1

## Warm apt cache
RUN apt-get update
# Warm apt cache
RUN apt-get update && \
apt-get install -y wget unzip \
openjdk-11-jre \
bzip2

# Install swagger-codegen
ENV SWAGGER_CODEGEN_VERSION=2.2.2
RUN apt-get install -y openjdk-11-jre wget && \
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_CODEGEN_VERSION}/swagger-codegen-cli-${SWAGGER_CODEGEN_VERSION}.jar \
-O /usr/local/bin/swagger-codegen-cli.jar && \
apt-get remove -y wget
ENV SWAGGER_CODEGEN="java -jar /usr/local/bin/swagger-codegen-cli.jar"
ENV SWAGGER_CODEGEN_VERSION=2.4.8
RUN wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_CODEGEN_VERSION}/swagger-codegen-cli-${SWAGGER_CODEGEN_VERSION}.jar \
-O /usr/local/bin/swagger-codegen-cli.jar

# Wrap the jar for swagger-codgen
RUN echo -e '#!/bin/bash\njava -jar /usr/local/bin/swagger-codegen-cli.jar "$@"' > /usr/local/bin/swagger-codegen && \
chmod +x /usr/local/bin/swagger-codegen

# Install protoc
ENV PROTOC_VERSION=3.9.2
RUN apt-get install -y wget unzip && \
wget https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \
RUN wget https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \
-O /protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
unzip /protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local/ && \
rm -f /protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
apt-get remove -y unzip wget
rm -f /protoc-${PROTOC_VERSION}-linux-x86_64.zip

# Install node, used by NVM
ENV NODE_VERSION=v10.16.3
ENV NVM_VERSION=v0.35.0
RUN apt-get install -y wget bzip2 && \
wget -qO- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash && \
apt-get remove -y wget
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash

# Clean up
RUN apt-get autoremove -y && \
apt-get remove -y wget \
unzip \
bzip2 && \
rm -rf /var/lib/apt/lists/*
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -37,7 +37,7 @@ jobs:
steps:
- checkout
- run: make realclean
- run: make examples SWAGGER_CODEGEN="${SWAGGER_CODEGEN}" # Set in Docker image
- run: make examples
- run: go mod tidy
- run: git diff --exit-code
lint:
Expand Down
58 changes: 33 additions & 25 deletions Makefile
Expand Up @@ -83,38 +83,46 @@ EXAMPLE_DEPSRCS=$(EXAMPLE_DEPS:.proto=.pb.go)

EXAMPLE_CLIENT_DIR=examples/clients
ECHO_EXAMPLE_SPEC=examples/proto/examplepb/echo_service.swagger.json
ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/echo/api_client.go \
$(EXAMPLE_CLIENT_DIR)/echo/api_response.go \
ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/echo/client.go \
$(EXAMPLE_CLIENT_DIR)/echo/response.go \
$(EXAMPLE_CLIENT_DIR)/echo/configuration.go \
$(EXAMPLE_CLIENT_DIR)/echo/echo_service_api.go \
$(EXAMPLE_CLIENT_DIR)/echo/examplepb_simple_message.go \
$(EXAMPLE_CLIENT_DIR)/echo/examplepb_embedded.go
$(EXAMPLE_CLIENT_DIR)/echo/api_echo_service.go \
$(EXAMPLE_CLIENT_DIR)/echo/model_examplepb_simple_message.go \
$(EXAMPLE_CLIENT_DIR)/echo/model_examplepb_embedded.go
ABE_EXAMPLE_SPEC=examples/proto/examplepb/a_bit_of_everything.swagger.json
ABE_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/abe/a_bit_of_everything_nested.go \
$(EXAMPLE_CLIENT_DIR)/abe/a_bit_of_everything_service_api.go \
$(EXAMPLE_CLIENT_DIR)/abe/api_client.go \
$(EXAMPLE_CLIENT_DIR)/abe/api_response.go \
$(EXAMPLE_CLIENT_DIR)/abe/camel_case_service_name_api.go \
ABE_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/abe/model_a_bit_of_everything_nested.go \
$(EXAMPLE_CLIENT_DIR)/abe/api_a_bit_of_everything_service.go \
$(EXAMPLE_CLIENT_DIR)/abe/client.go \
$(EXAMPLE_CLIENT_DIR)/abe/api_camel_case_service_name.go \
$(EXAMPLE_CLIENT_DIR)/abe/configuration.go \
$(EXAMPLE_CLIENT_DIR)/abe/echo_rpc_api.go \
$(EXAMPLE_CLIENT_DIR)/abe/echo_service_api.go \
$(EXAMPLE_CLIENT_DIR)/abe/examplepb_a_bit_of_everything.go \
$(EXAMPLE_CLIENT_DIR)/abe/examplepb_body.go \
$(EXAMPLE_CLIENT_DIR)/abe/examplepb_numeric_enum.go \
$(EXAMPLE_CLIENT_DIR)/abe/nested_deep_enum.go \
$(EXAMPLE_CLIENT_DIR)/abe/sub_string_message.go
$(EXAMPLE_CLIENT_DIR)/abe/api_echo_rpc.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_a_bit_of_everything.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_a_bit_of_everything_repeated.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_body.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_numeric_enum.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_update_v2_request.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_message_path_enum_nested_path_enum.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_nested_deep_enum.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_pathenum_path_enum.go \
$(EXAMPLE_CLIENT_DIR)/abe/model_protobuf_field_mask.go \
$(EXAMPLE_CLIENT_DIR)/abe/response.go
UNANNOTATED_ECHO_EXAMPLE_SPEC=examples/proto/examplepb/unannotated_echo_service.swagger.json
UNANNOTATED_ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/unannotatedecho/api_client.go \
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/api_response.go \
UNANNOTATED_ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/unannotatedecho/client.go \
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/response.go \
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/configuration.go \
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/examplepb_unannotated_simple_message.go \
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/unannotated_echo_service_api.go
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/model_examplepb_unannotated_simple_message.go \
$(EXAMPLE_CLIENT_DIR)/unannotatedecho/api_unannotated_echo_service.go
RESPONSE_BODY_EXAMPLE_SPEC=examples/proto/examplepb/response_body_service.swagger.json
RESPONSE_BODY_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/responsebody/api_client.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/api_response.go \
RESPONSE_BODY_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/responsebody/client.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/response.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/configuration.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/examplepb_response_body.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/response_body_service_api.go
$(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_body_out.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_body_out_response.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_strings.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_response_body_out.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_response_body_out_response.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/model_response_response_type.go \
$(EXAMPLE_CLIENT_DIR)/responsebody/api_response_body_service.go

EXAMPLE_CLIENT_SRCS=$(ECHO_EXAMPLE_SRCS) $(ABE_EXAMPLE_SRCS) $(UNANNOTATED_ECHO_EXAMPLE_SRCS) $(RESPONSE_BODY_EXAMPLE_SRCS)
SWAGGER_CODEGEN=swagger-codegen
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Expand Up @@ -4,10 +4,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "8df59f11fb697743cbb3f26cfb8750395f30471e9eabde0d174c3aebc7a1cd39",
sha256 = "513c12397db1bc9aa46dd62f02dd94b49a9b5d17444d49b5a04c5a89f3053c1c",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.19.1/rules_go-0.19.1.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/0.19.1/rules_go-0.19.1.tar.gz",
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.19.5/rules_go-v0.19.5.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.19.5/rules_go-v0.19.5.tar.gz",
],
)

Expand Down
1 change: 1 addition & 0 deletions examples/clients/abe/.swagger-codegen/VERSION
@@ -0,0 +1 @@
2.4.8
36 changes: 18 additions & 18 deletions examples/clients/abe/BUILD.bazel
Expand Up @@ -5,31 +5,31 @@ package(default_visibility = ["//visibility:public"])
go_library(
name = "go_default_library",
srcs = [
"a_bit_of_everything_nested.go",
"a_bit_of_everything_service_api.go",
"api_client.go",
"api_response.go",
"camel_case_service_name_api.go",
"api_a_bit_of_everything_service.go",
"api_camel_case_service_name.go",
"api_echo_rpc.go",
"client.go",
"configuration.go",
"echo_rpc_api.go",
"echo_service_api.go",
"enum_helper.go",
"examplepb_a_bit_of_everything.go",
"examplepb_a_bit_of_everything_repeated.go",
"examplepb_body.go",
"examplepb_numeric_enum.go",
"examplepb_update_v2_request.go",
"message_path_enum_nested_path_enum.go",
"nested_deep_enum.go",
"pathenum_path_enum.go",
"protobuf_field_mask.go",
"sub_string_message.go",
"model_a_bit_of_everything_nested.go",
"model_examplepb_a_bit_of_everything.go",
"model_examplepb_a_bit_of_everything_repeated.go",
"model_examplepb_body.go",
"model_examplepb_numeric_enum.go",
"model_examplepb_update_v2_request.go",
"model_message_path_enum_nested_path_enum.go",
"model_nested_deep_enum.go",
"model_pathenum_path_enum.go",
"model_protobuf_field_mask.go",
"model_sub_string_message.go",
"response.go",
],
importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/abe",
deps = [
"//examples/proto/examplepb:go_default_library",
"//examples/proto/pathenum:go_default_library",
"//runtime:go_default_library",
"@com_github_go_resty_resty//:go_default_library",
"@com_github_antihax_optional//:go_default_library",
"@org_golang_x_oauth2//:go_default_library",
],
)

0 comments on commit c677e41

Please sign in to comment.