From f7eb2b8fd92250878eb853513fa7d18ca0f7ba8d Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Fri, 3 May 2019 18:41:07 +0200 Subject: [PATCH] [Golang][client] Make it possible to generate go.mod and go.sum files - fixes #2796 --- .../codegen/languages/GoClientCodegen.java | 3 ++- .../src/main/resources/go/go.mod.mustache | 6 ++++++ .../openapi-generator/src/main/resources/go/go.sum | 11 +++++++++++ samples/client/petstore/go/go-petstore/go.mod | 6 ++++++ samples/client/petstore/go/go-petstore/go.sum | 11 +++++++++++ .../openapi3/client/petstore/go/go-petstore/go.mod | 6 ++++++ .../openapi3/client/petstore/go/go-petstore/go.sum | 11 +++++++++++ 7 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 modules/openapi-generator/src/main/resources/go/go.mod.mustache create mode 100644 modules/openapi-generator/src/main/resources/go/go.sum create mode 100644 samples/client/petstore/go/go-petstore/go.mod create mode 100644 samples/client/petstore/go/go-petstore/go.sum create mode 100644 samples/openapi3/client/petstore/go/go-petstore/go.mod create mode 100644 samples/openapi3/client/petstore/go/go-petstore/go.sum diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java index d53368036270..af79157f93aa 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java @@ -60,7 +60,6 @@ public GoClientCodegen() { CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS_DESC) .defaultValue(Boolean.FALSE.toString())); - } @Override @@ -95,6 +94,8 @@ public void processOpts() { supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go")); supportingFiles.add(new SupportingFile("client.mustache", "", "client.go")); supportingFiles.add(new SupportingFile("response.mustache", "", "response.go")); + supportingFiles.add(new SupportingFile("go.mod.mustache", "", "go.mod")); + supportingFiles.add(new SupportingFile("go.sum", "", "go.sum")); supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml")); if (additionalProperties.containsKey(WITH_GO_CODEGEN_COMMENT)) { diff --git a/modules/openapi-generator/src/main/resources/go/go.mod.mustache b/modules/openapi-generator/src/main/resources/go/go.mod.mustache new file mode 100644 index 000000000000..bc919e42e0e5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/go/go.mod.mustache @@ -0,0 +1,6 @@ +module github.com/{{gitUserId}}/{{gitRepoId}} + +require ( + github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6 + golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a +) diff --git a/modules/openapi-generator/src/main/resources/go/go.sum b/modules/openapi-generator/src/main/resources/go/go.sum new file mode 100644 index 000000000000..e3c16fef3ac1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/go/go.sum @@ -0,0 +1,11 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/samples/client/petstore/go/go-petstore/go.mod b/samples/client/petstore/go/go-petstore/go.mod new file mode 100644 index 000000000000..199809ed7066 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/go.mod @@ -0,0 +1,6 @@ +module github.com/GIT_USER_ID/GIT_REPO_ID + +require ( + github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6 + golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a +) diff --git a/samples/client/petstore/go/go-petstore/go.sum b/samples/client/petstore/go/go-petstore/go.sum new file mode 100644 index 000000000000..e3c16fef3ac1 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/go.sum @@ -0,0 +1,11 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/samples/openapi3/client/petstore/go/go-petstore/go.mod b/samples/openapi3/client/petstore/go/go-petstore/go.mod new file mode 100644 index 000000000000..199809ed7066 --- /dev/null +++ b/samples/openapi3/client/petstore/go/go-petstore/go.mod @@ -0,0 +1,6 @@ +module github.com/GIT_USER_ID/GIT_REPO_ID + +require ( + github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6 + golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a +) diff --git a/samples/openapi3/client/petstore/go/go-petstore/go.sum b/samples/openapi3/client/petstore/go/go-petstore/go.sum new file mode 100644 index 000000000000..e3c16fef3ac1 --- /dev/null +++ b/samples/openapi3/client/petstore/go/go-petstore/go.sum @@ -0,0 +1,11 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=