From 82f10eb97ebe50d59ad889d28beabdf10c88312a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Tue, 3 Nov 2020 11:25:28 +0100
Subject: [PATCH 01/17] Fix a few issues with go examples generation

This fixes a bunch of issues seen when generating go examples, namely
 - Numbers aren't casted to the right type
 - The time import is missing
 - Enums are treated as regular models
---
 .../codegen/languages/GoClientCodegen.java    | 15 +++++++--
 .../src/main/resources/go/api_doc.mustache    |  3 +-
 .../petstore/go/go-petstore/docs/FakeApi.md   | 31 ++++++++++---------
 .../petstore/go/go-petstore/docs/PetApi.md    | 14 ++++-----
 .../petstore/go/go-petstore/docs/StoreApi.md  |  2 +-
 5 files changed, 38 insertions(+), 27 deletions(-)

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 ef49c8bc8f4..d316b2ee81c 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
@@ -452,8 +452,15 @@ public class GoClientCodegen extends AbstractGoCodegen {
 
         processedModelMaps.clear();
         for (CodegenOperation operation : operationList) {
+            boolean needTimeImport = false;
             for (CodegenParameter cp : operation.allParams) {
                 cp.vendorExtensions.put("x-go-example", constructExampleCode(cp, modelMaps, processedModelMaps));
+                if (cp.isDateTime || cp.isDate) { // datetime or date
+                        needTimeImport = true;
+                }
+            }
+            if (needTimeImport) {
+                operation.vendorExtensions.put("x-go-import", "    \"time\"");
             }
         }
 
@@ -486,7 +493,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
                 if (StringUtils.isEmpty(codegenParameter.example)) {
                     return codegenParameter.example;
                 } else {
-                    return "987";
+                    return codegenParameter.dataType + "(987)";
                 }
             }
         } else { // model
@@ -548,8 +555,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
     }
 
     private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
-        String example;
-
         // break infinite recursion. Return, in case a model is already processed in the current context.
         String model = codegenModel.name;
         if (processedModelMap.containsKey(model)) {
@@ -561,6 +566,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
             } else {
                 throw new RuntimeException("Invalid count when constructing example: " + count);
             }
+        } else if (codegenModel.isEnum) {
+                Map<String, Object> allowableValues = codegenModel.allowableValues;
+                List<Object> values = (List<Object>) allowableValues.get("values");
+                return "\"" + String.valueOf(values.get(0)) + "\"";
         } else {
             processedModelMap.put(model, 1);
         }
diff --git a/modules/openapi-generator/src/main/resources/go/api_doc.mustache b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
index 2049cc3ec37..4cd02b32da3 100644
--- a/modules/openapi-generator/src/main/resources/go/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
@@ -28,7 +28,8 @@ package main
 import (
     "context"
     "fmt"
-    "os"
+    "os"{{#vendorExtensions.x-go-import}}
+{{{vendorExtensions.x-go-import}}}{{/vendorExtensions.x-go-import}}
     {{goImportAlias}} "./openapi"
 )
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
index 2380fafb0dd..6eb8662e374 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -233,7 +233,7 @@ import (
 )
 
 func main() {
-    body := 987 // float32 | Input number as post body (optional)
+    body := float32(987) // float32 | Input number as post body (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -555,20 +555,21 @@ import (
     "context"
     "fmt"
     "os"
+    "time"
     openapiclient "./openapi"
 )
 
 func main() {
-    number := 987 // float32 | None
-    double := 987 // float64 | None
+    number := float32(987) // float32 | None
+    double := float64(987) // float64 | None
     patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None
-    byte_ := 987 // string | None
-    integer := 987 // int32 | None (optional)
-    int32_ := 987 // int32 | None (optional)
-    int64_ := 987 // int64 | None (optional)
-    float := 987 // float32 | None (optional)
+    byte_ := string(987) // string | None
+    integer := int32(987) // int32 | None (optional)
+    int32_ := int32(987) // int32 | None (optional)
+    int64_ := int64(987) // int64 | None (optional)
+    float := float32(987) // float32 | None (optional)
     string_ := "string__example" // string | None (optional)
-    binary := 987 // *os.File | None (optional)
+    binary := *os.File(987) // *os.File | None (optional)
     date := time.Now() // string | None (optional)
     dateTime := time.Now() // time.Time | None (optional)
     password := "password_example" // string | None (optional)
@@ -653,8 +654,8 @@ func main() {
     enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg")
     enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional)
     enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg")
-    enumQueryInteger := 987 // int32 | Query parameter enum test (double) (optional)
-    enumQueryDouble := 987 // float64 | Query parameter enum test (double) (optional)
+    enumQueryInteger := int32(987) // int32 | Query parameter enum test (double) (optional)
+    enumQueryDouble := float64(987) // float64 | Query parameter enum test (double) (optional)
     enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$")
     enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg")
 
@@ -727,12 +728,12 @@ import (
 )
 
 func main() {
-    requiredStringGroup := 987 // int32 | Required String in group parameters
+    requiredStringGroup := int32(987) // int32 | Required String in group parameters
     requiredBooleanGroup := true // bool | Required Boolean in group parameters
-    requiredInt64Group := 987 // int64 | Required Integer in group parameters
-    stringGroup := 987 // int32 | String in group parameters (optional)
+    requiredInt64Group := int64(987) // int64 | Required Integer in group parameters
+    stringGroup := int32(987) // int32 | String in group parameters (optional)
     booleanGroup := true // bool | Boolean in group parameters (optional)
-    int64Group := 987 // int64 | Integer in group parameters (optional)
+    int64Group := int64(987) // int64 | Integer in group parameters (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
index 7f9d4fb826e..7a6fba06f4c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
@@ -97,7 +97,7 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | Pet id to delete
+    petId := int64(987) // int64 | Pet id to delete
     apiKey := "apiKey_example" // string |  (optional)
 
     configuration := openapiclient.NewConfiguration()
@@ -299,7 +299,7 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet to return
+    petId := int64(987) // int64 | ID of pet to return
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -429,7 +429,7 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet that needs to be updated
+    petId := int64(987) // int64 | ID of pet that needs to be updated
     name := "name_example" // string | Updated name of the pet (optional)
     status := "status_example" // string | Updated status of the pet (optional)
 
@@ -499,9 +499,9 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet to update
+    petId := int64(987) // int64 | ID of pet to update
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
-    file := 987 // *os.File | file to upload (optional)
+    file := *os.File(987) // *os.File | file to upload (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -571,8 +571,8 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet to update
-    requiredFile := 987 // *os.File | file to upload
+    petId := int64(987) // int64 | ID of pet to update
+    requiredFile := *os.File(987) // *os.File | file to upload
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
 
     configuration := openapiclient.NewConfiguration()
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md
index 097fac90ec9..350014720fc 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md
@@ -161,7 +161,7 @@ import (
 )
 
 func main() {
-    orderId := 987 // int64 | ID of pet that needs to be fetched
+    orderId := int64(987) // int64 | ID of pet that needs to be fetched
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From 14156cb129192f8288949abb88072ddf9fb43c42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Wed, 4 Nov 2020 10:43:41 +0100
Subject: [PATCH 02/17] Rebuild more samples

---
 .../petstore/go/go-petstore/docs/FakeApi.md   | 31 ++++++++++---------
 .../petstore/go/go-petstore/docs/PetApi.md    | 14 ++++-----
 .../petstore/go/go-petstore/docs/StoreApi.md  |  2 +-
 3 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
index 0b26ad9d210..3077015a5fd 100644
--- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -238,7 +238,7 @@ import (
 )
 
 func main() {
-    body := 987 // float32 | Input number as post body (optional)
+    body := float32(987) // float32 | Input number as post body (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -560,20 +560,21 @@ import (
     "context"
     "fmt"
     "os"
+    "time"
     openapiclient "./openapi"
 )
 
 func main() {
-    number := 987 // float32 | None
-    double := 987 // float64 | None
+    number := float32(987) // float32 | None
+    double := float64(987) // float64 | None
     patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None
-    byte_ := 987 // string | None
-    integer := 987 // int32 | None (optional)
-    int32_ := 987 // int32 | None (optional)
-    int64_ := 987 // int64 | None (optional)
-    float := 987 // float32 | None (optional)
+    byte_ := string(987) // string | None
+    integer := int32(987) // int32 | None (optional)
+    int32_ := int32(987) // int32 | None (optional)
+    int64_ := int64(987) // int64 | None (optional)
+    float := float32(987) // float32 | None (optional)
     string_ := "string__example" // string | None (optional)
-    binary := 987 // *os.File | None (optional)
+    binary := *os.File(987) // *os.File | None (optional)
     date := time.Now() // string | None (optional)
     dateTime := time.Now() // time.Time | None (optional)
     password := "password_example" // string | None (optional)
@@ -658,8 +659,8 @@ func main() {
     enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg")
     enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional)
     enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg")
-    enumQueryInteger := 987 // int32 | Query parameter enum test (double) (optional)
-    enumQueryDouble := 987 // float64 | Query parameter enum test (double) (optional)
+    enumQueryInteger := int32(987) // int32 | Query parameter enum test (double) (optional)
+    enumQueryDouble := float64(987) // float64 | Query parameter enum test (double) (optional)
     enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$")
     enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg")
 
@@ -732,12 +733,12 @@ import (
 )
 
 func main() {
-    requiredStringGroup := 987 // int32 | Required String in group parameters
+    requiredStringGroup := int32(987) // int32 | Required String in group parameters
     requiredBooleanGroup := true // bool | Required Boolean in group parameters
-    requiredInt64Group := 987 // int64 | Required Integer in group parameters
-    stringGroup := 987 // int32 | String in group parameters (optional)
+    requiredInt64Group := int64(987) // int64 | Required Integer in group parameters
+    stringGroup := int32(987) // int32 | String in group parameters (optional)
     booleanGroup := true // bool | Boolean in group parameters (optional)
-    int64Group := 987 // int64 | Integer in group parameters (optional)
+    int64Group := int64(987) // int64 | Integer in group parameters (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md
index c04b65b69ee..b6eb0511d53 100644
--- a/samples/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md
@@ -97,7 +97,7 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | Pet id to delete
+    petId := int64(987) // int64 | Pet id to delete
     apiKey := "apiKey_example" // string |  (optional)
 
     configuration := openapiclient.NewConfiguration()
@@ -299,7 +299,7 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet to return
+    petId := int64(987) // int64 | ID of pet to return
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -429,7 +429,7 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet that needs to be updated
+    petId := int64(987) // int64 | ID of pet that needs to be updated
     name := "name_example" // string | Updated name of the pet (optional)
     status := "status_example" // string | Updated status of the pet (optional)
 
@@ -499,9 +499,9 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet to update
+    petId := int64(987) // int64 | ID of pet to update
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
-    file := 987 // *os.File | file to upload (optional)
+    file := *os.File(987) // *os.File | file to upload (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -571,8 +571,8 @@ import (
 )
 
 func main() {
-    petId := 987 // int64 | ID of pet to update
-    requiredFile := 987 // *os.File | file to upload
+    petId := int64(987) // int64 | ID of pet to update
+    requiredFile := *os.File(987) // *os.File | file to upload
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
 
     configuration := openapiclient.NewConfiguration()
diff --git a/samples/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/client/petstore/go/go-petstore/docs/StoreApi.md
index 0e9c4a8ec55..e529c5f6e85 100644
--- a/samples/client/petstore/go/go-petstore/docs/StoreApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/StoreApi.md
@@ -161,7 +161,7 @@ import (
 )
 
 func main() {
-    orderId := 987 // int64 | ID of pet that needs to be fetched
+    orderId := int64(987) // int64 | ID of pet that needs to be fetched
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From 67a316dd912d56fe19fd7b61756d7c62515c76a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Wed, 4 Nov 2020 12:02:50 +0100
Subject: [PATCH 03/17] Use examples properly

---
 .../codegen/languages/GoClientCodegen.java    | 16 ++++------
 .../petstore/go/go-petstore/docs/FakeApi.md   | 30 +++++++++----------
 .../petstore/go/go-petstore/docs/PetApi.md    | 18 +++++------
 .../petstore/go/go-petstore/docs/StoreApi.md  |  2 +-
 .../petstore/go/go-petstore/docs/FakeApi.md   | 30 +++++++++----------
 .../petstore/go/go-petstore/docs/PetApi.md    | 18 +++++------
 .../petstore/go/go-petstore/docs/StoreApi.md  |  2 +-
 7 files changed, 56 insertions(+), 60 deletions(-)

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 d316b2ee81c..ef7a1e44aa3 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
@@ -474,7 +474,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
             return codegenParameter.dataType + "{ \"key\": " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isPrimitiveType) { // primitive type
             if (codegenParameter.isString) {
-                if (StringUtils.isEmpty(codegenParameter.example)) {
+                if (!StringUtils.isEmpty(codegenParameter.example) && codegenParameter.example != "null") {
                     return "\"" + codegenParameter.example + "\"";
                 } else {
                     return "\"" + codegenParameter.paramName + "_example\"";
@@ -490,8 +490,8 @@ public class GoClientCodegen extends AbstractGoCodegen {
             } else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date
                 return "time.Now()";
             } else { // numeric
-                if (StringUtils.isEmpty(codegenParameter.example)) {
-                    return codegenParameter.example;
+                if (!StringUtils.isEmpty(codegenParameter.example) && codegenParameter.example != "null") {
+                    return codegenParameter.dataType + "(" + codegenParameter.example + ")";
                 } else {
                     return codegenParameter.dataType + "(987)";
                 }
@@ -514,7 +514,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
             return codegenProperty.dataType + "{ \"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isPrimitiveType) { // primitive type
             if (codegenProperty.isString) {
-                if (StringUtils.isEmpty(codegenProperty.example)) {
+                if (!StringUtils.isEmpty(codegenProperty.example) && codegenProperty.example != "null") {
                     return "\"" + codegenProperty.example + "\"";
                 } else {
                     return "\"" + codegenProperty.name + "_example\"";
@@ -531,17 +531,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
                 return "time.Now()";
             } else { // numeric
                 String example;
-                if (StringUtils.isEmpty(codegenProperty.example)) {
+                if (!StringUtils.isEmpty(codegenProperty.example) && codegenProperty.example != "null") {
                     example = codegenProperty.example;
                 } else {
                     example = "123";
                 }
 
-                if (codegenProperty.isLong) {
-                    return "int64(" + example + ")";
-                } else {
-                    return example;
-                }
+                return codegenProperty.dataType +  "(" + example + ")";
             }
         } else {
             // look up the model
diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
index 3077015a5fd..71783c67a92 100644
--- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -238,7 +238,7 @@ import (
 )
 
 func main() {
-    body := float32(987) // float32 | Input number as post body (optional)
+    body := float32(8.14) // float32 | Input number as post body (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -565,16 +565,16 @@ import (
 )
 
 func main() {
-    number := float32(987) // float32 | None
-    double := float64(987) // float64 | None
+    number := float32(8.14) // float32 | None
+    double := float64(1.2) // float64 | None
     patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None
-    byte_ := string(987) // string | None
-    integer := int32(987) // int32 | None (optional)
-    int32_ := int32(987) // int32 | None (optional)
-    int64_ := int64(987) // int64 | None (optional)
-    float := float32(987) // float32 | None (optional)
+    byte_ := string(BYTE_ARRAY_DATA_HERE) // string | None
+    integer := int32(56) // int32 | None (optional)
+    int32_ := int32(56) // int32 | None (optional)
+    int64_ := int64(789) // int64 | None (optional)
+    float := float32(3.4) // float32 | None (optional)
     string_ := "string__example" // string | None (optional)
-    binary := *os.File(987) // *os.File | None (optional)
+    binary := *os.File(BINARY_DATA_HERE) // *os.File | None (optional)
     date := time.Now() // string | None (optional)
     dateTime := time.Now() // time.Time | None (optional)
     password := "password_example" // string | None (optional)
@@ -659,8 +659,8 @@ func main() {
     enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg")
     enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional)
     enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg")
-    enumQueryInteger := int32(987) // int32 | Query parameter enum test (double) (optional)
-    enumQueryDouble := float64(987) // float64 | Query parameter enum test (double) (optional)
+    enumQueryInteger := int32(56) // int32 | Query parameter enum test (double) (optional)
+    enumQueryDouble := float64(1.2) // float64 | Query parameter enum test (double) (optional)
     enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$")
     enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg")
 
@@ -733,12 +733,12 @@ import (
 )
 
 func main() {
-    requiredStringGroup := int32(987) // int32 | Required String in group parameters
+    requiredStringGroup := int32(56) // int32 | Required String in group parameters
     requiredBooleanGroup := true // bool | Required Boolean in group parameters
-    requiredInt64Group := int64(987) // int64 | Required Integer in group parameters
-    stringGroup := int32(987) // int32 | String in group parameters (optional)
+    requiredInt64Group := int64(789) // int64 | Required Integer in group parameters
+    stringGroup := int32(56) // int32 | String in group parameters (optional)
     booleanGroup := true // bool | Boolean in group parameters (optional)
-    int64Group := int64(987) // int64 | Integer in group parameters (optional)
+    int64Group := int64(789) // int64 | Integer in group parameters (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md
index b6eb0511d53..bcba09678b4 100644
--- a/samples/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md
@@ -35,7 +35,7 @@ import (
 )
 
 func main() {
-    body := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -97,7 +97,7 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | Pet id to delete
+    petId := int64(789) // int64 | Pet id to delete
     apiKey := "apiKey_example" // string |  (optional)
 
     configuration := openapiclient.NewConfiguration()
@@ -299,7 +299,7 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet to return
+    petId := int64(789) // int64 | ID of pet to return
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -367,7 +367,7 @@ import (
 )
 
 func main() {
-    body := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -429,7 +429,7 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet that needs to be updated
+    petId := int64(789) // int64 | ID of pet that needs to be updated
     name := "name_example" // string | Updated name of the pet (optional)
     status := "status_example" // string | Updated status of the pet (optional)
 
@@ -499,9 +499,9 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet to update
+    petId := int64(789) // int64 | ID of pet to update
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
-    file := *os.File(987) // *os.File | file to upload (optional)
+    file := *os.File(BINARY_DATA_HERE) // *os.File | file to upload (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -571,8 +571,8 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet to update
-    requiredFile := *os.File(987) // *os.File | file to upload
+    petId := int64(789) // int64 | ID of pet to update
+    requiredFile := *os.File(BINARY_DATA_HERE) // *os.File | file to upload
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
 
     configuration := openapiclient.NewConfiguration()
diff --git a/samples/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/client/petstore/go/go-petstore/docs/StoreApi.md
index e529c5f6e85..1e5c0ae5ba8 100644
--- a/samples/client/petstore/go/go-petstore/docs/StoreApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/StoreApi.md
@@ -161,7 +161,7 @@ import (
 )
 
 func main() {
-    orderId := int64(987) // int64 | ID of pet that needs to be fetched
+    orderId := int64(789) // int64 | ID of pet that needs to be fetched
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
index 6eb8662e374..a47f1b5039d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -233,7 +233,7 @@ import (
 )
 
 func main() {
-    body := float32(987) // float32 | Input number as post body (optional)
+    body := float32(8.14) // float32 | Input number as post body (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -560,16 +560,16 @@ import (
 )
 
 func main() {
-    number := float32(987) // float32 | None
-    double := float64(987) // float64 | None
+    number := float32(8.14) // float32 | None
+    double := float64(1.2) // float64 | None
     patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None
-    byte_ := string(987) // string | None
-    integer := int32(987) // int32 | None (optional)
-    int32_ := int32(987) // int32 | None (optional)
-    int64_ := int64(987) // int64 | None (optional)
-    float := float32(987) // float32 | None (optional)
+    byte_ := string(BYTE_ARRAY_DATA_HERE) // string | None
+    integer := int32(56) // int32 | None (optional)
+    int32_ := int32(56) // int32 | None (optional)
+    int64_ := int64(789) // int64 | None (optional)
+    float := float32(3.4) // float32 | None (optional)
     string_ := "string__example" // string | None (optional)
-    binary := *os.File(987) // *os.File | None (optional)
+    binary := *os.File(BINARY_DATA_HERE) // *os.File | None (optional)
     date := time.Now() // string | None (optional)
     dateTime := time.Now() // time.Time | None (optional)
     password := "password_example" // string | None (optional)
@@ -654,8 +654,8 @@ func main() {
     enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg")
     enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional)
     enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg")
-    enumQueryInteger := int32(987) // int32 | Query parameter enum test (double) (optional)
-    enumQueryDouble := float64(987) // float64 | Query parameter enum test (double) (optional)
+    enumQueryInteger := int32(56) // int32 | Query parameter enum test (double) (optional)
+    enumQueryDouble := float64(1.2) // float64 | Query parameter enum test (double) (optional)
     enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$")
     enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg")
 
@@ -728,12 +728,12 @@ import (
 )
 
 func main() {
-    requiredStringGroup := int32(987) // int32 | Required String in group parameters
+    requiredStringGroup := int32(56) // int32 | Required String in group parameters
     requiredBooleanGroup := true // bool | Required Boolean in group parameters
-    requiredInt64Group := int64(987) // int64 | Required Integer in group parameters
-    stringGroup := int32(987) // int32 | String in group parameters (optional)
+    requiredInt64Group := int64(789) // int64 | Required Integer in group parameters
+    stringGroup := int32(56) // int32 | String in group parameters (optional)
     booleanGroup := true // bool | Boolean in group parameters (optional)
-    int64Group := int64(987) // int64 | Integer in group parameters (optional)
+    int64Group := int64(789) // int64 | Integer in group parameters (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
index 7a6fba06f4c..49d6f695455 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
@@ -35,7 +35,7 @@ import (
 )
 
 func main() {
-    pet := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -97,7 +97,7 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | Pet id to delete
+    petId := int64(789) // int64 | Pet id to delete
     apiKey := "apiKey_example" // string |  (optional)
 
     configuration := openapiclient.NewConfiguration()
@@ -299,7 +299,7 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet to return
+    petId := int64(789) // int64 | ID of pet to return
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -367,7 +367,7 @@ import (
 )
 
 func main() {
-    pet := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -429,7 +429,7 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet that needs to be updated
+    petId := int64(789) // int64 | ID of pet that needs to be updated
     name := "name_example" // string | Updated name of the pet (optional)
     status := "status_example" // string | Updated status of the pet (optional)
 
@@ -499,9 +499,9 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet to update
+    petId := int64(789) // int64 | ID of pet to update
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
-    file := *os.File(987) // *os.File | file to upload (optional)
+    file := *os.File(BINARY_DATA_HERE) // *os.File | file to upload (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -571,8 +571,8 @@ import (
 )
 
 func main() {
-    petId := int64(987) // int64 | ID of pet to update
-    requiredFile := *os.File(987) // *os.File | file to upload
+    petId := int64(789) // int64 | ID of pet to update
+    requiredFile := *os.File(BINARY_DATA_HERE) // *os.File | file to upload
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
 
     configuration := openapiclient.NewConfiguration()
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md
index 350014720fc..067ea382576 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/StoreApi.md
@@ -161,7 +161,7 @@ import (
 )
 
 func main() {
-    orderId := int64(987) // int64 | ID of pet that needs to be fetched
+    orderId := int64(789) // int64 | ID of pet that needs to be fetched
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From ad2949ce7144f3f68ae3b826e23961532cc20499 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 09:35:31 +0100
Subject: [PATCH 04/17] Handle multiple instances in the same doc

---
 .../org/openapitools/codegen/languages/GoClientCodegen.java   | 3 ++-
 .../openapi3/client/petstore/go/go-petstore/docs/UserApi.md   | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

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 ef7a1e44aa3..e30b7d3fff5 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
@@ -448,9 +448,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
             for (CodegenParameter p : op.allParams) {
                 p.vendorExtensions.put("x-go-example", constructExampleCode(p, modelMaps, processedModelMaps));
             }
+            processedModelMaps.clear();
         }
 
-        processedModelMaps.clear();
         for (CodegenOperation operation : operationList) {
             boolean needTimeImport = false;
             for (CodegenParameter cp : operation.allParams) {
@@ -462,6 +462,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
             if (needTimeImport) {
                 operation.vendorExtensions.put("x-go-import", "    \"time\"");
             }
+            processedModelMaps.clear();
         }
 
         return objs;
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md
index 4c89c0be927..9185cb0d478 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md
@@ -160,7 +160,7 @@ import (
 )
 
 func main() {
-    user := []User{} // []User | List of user object
+    user := []User{*openapiclient.NewUser()} // []User | List of user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -484,7 +484,7 @@ import (
 
 func main() {
     username := "username_example" // string | name that need to be deleted
-    user :=  // User | Updated user object
+    user := *openapiclient.NewUser() // User | Updated user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From e7e110a9f66247fb3cff3651796f83bddf02d0dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 09:49:07 +0100
Subject: [PATCH 05/17] Fix wrong array closure

---
 .../org/openapitools/codegen/languages/GoClientCodegen.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 e30b7d3fff5..f6aca4d3504 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
@@ -510,7 +510,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
 
     private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
         if (codegenProperty.isArray) { // array
-            return codegenProperty.dataType + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + ")";
+            return codegenProperty.dataType + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isMap) { // map
             return codegenProperty.dataType + "{ \"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isPrimitiveType) { // primitive type
-- 
GitLab


From 3d0a9d06881571dead4208b22190d6074e365dc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 10:50:42 +0100
Subject: [PATCH 06/17] Handle model arrays

---
 .../codegen/languages/GoClientCodegen.java       | 16 +++++++++++++---
 .../petstore/go/go-petstore/docs/PetApi.md       |  4 ++--
 .../petstore/go/go-petstore/docs/UserApi.md      |  4 ++--
 3 files changed, 17 insertions(+), 7 deletions(-)

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 f6aca4d3504..42aba203df5 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
@@ -470,7 +470,12 @@ public class GoClientCodegen extends AbstractGoCodegen {
 
     private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
         if (codegenParameter.isArray) { // array
-            return codegenParameter.dataType + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
+            String prefix = codegenParameter.dataType;
+            String dataType = codegenParameter.dataType.substring(2);
+            if (modelMaps.containsKey(dataType)) {
+                    prefix = "[]" + goImportAlias + "." + dataType;
+            }
+            return prefix + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isMap) {
             return codegenParameter.dataType + "{ \"key\": " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isPrimitiveType) { // primitive type
@@ -510,7 +515,12 @@ public class GoClientCodegen extends AbstractGoCodegen {
 
     private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
         if (codegenProperty.isArray) { // array
-            return codegenProperty.dataType + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
+            String prefix = codegenProperty.dataType;
+            String dataType = codegenProperty.dataType.substring(2);
+            if (modelMaps.containsKey(dataType)) {
+                    prefix = "[]" + goImportAlias + "." + dataType;
+            }
+            return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isMap) { // map
             return codegenProperty.dataType + "{ \"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isPrimitiveType) { // primitive type
@@ -575,6 +585,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
         for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
             propertyExamples.add(constructExampleCode(codegenProperty, modelMaps, processedModelMap));
         }
-        return "*" + goImportAlias + ".New" + codegenModel.name + "(" + StringUtils.join(propertyExamples, ", ") + ")";
+        return "*" + goImportAlias + ".New" + model + "(" + StringUtils.join(propertyExamples, ", ") + ")";
     }
 }
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
index 49d6f695455..858aed121c9 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
@@ -35,7 +35,7 @@ import (
 )
 
 func main() {
-    pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -367,7 +367,7 @@ import (
 )
 
 func main() {
-    pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md
index 9185cb0d478..dbbbe3fa792 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/UserApi.md
@@ -98,7 +98,7 @@ import (
 )
 
 func main() {
-    user := []User{*openapiclient.NewUser()} // []User | List of user object
+    user := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -160,7 +160,7 @@ import (
 )
 
 func main() {
-    user := []User{*openapiclient.NewUser()} // []User | List of user object
+    user := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From 9ea35ecf913136fe99d3ba9cdaf3d36313ef303f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 11:31:13 +0100
Subject: [PATCH 07/17] Fix file and enum namespace

---
 .../org/openapitools/codegen/languages/GoClientCodegen.java   | 4 +++-
 .../openapi3/client/petstore/go/go-petstore/docs/FakeApi.md   | 2 +-
 .../openapi3/client/petstore/go/go-petstore/docs/PetApi.md    | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

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 42aba203df5..db37c4a3e30 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
@@ -495,6 +495,8 @@ public class GoClientCodegen extends AbstractGoCodegen {
                 return "\"https://example.com\"";
             } else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date
                 return "time.Now()";
+            } else if (codegenParameter.isFile) {
+                return "os.NewFile(1234, \"some_file\")";
             } else { // numeric
                 if (!StringUtils.isEmpty(codegenParameter.example) && codegenParameter.example != "null") {
                     return codegenParameter.dataType + "(" + codegenParameter.example + ")";
@@ -576,7 +578,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
         } else if (codegenModel.isEnum) {
                 Map<String, Object> allowableValues = codegenModel.allowableValues;
                 List<Object> values = (List<Object>) allowableValues.get("values");
-                return "\"" + String.valueOf(values.get(0)) + "\"";
+                return goImportAlias + "." + model + "(\"" + String.valueOf(values.get(0)) + "\")";
         } else {
             processedModelMap.put(model, 1);
         }
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
index a47f1b5039d..a00754c47c1 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -569,7 +569,7 @@ func main() {
     int64_ := int64(789) // int64 | None (optional)
     float := float32(3.4) // float32 | None (optional)
     string_ := "string__example" // string | None (optional)
-    binary := *os.File(BINARY_DATA_HERE) // *os.File | None (optional)
+    binary := os.NewFile(1234, "some_file") // *os.File | None (optional)
     date := time.Now() // string | None (optional)
     dateTime := time.Now() // time.Time | None (optional)
     password := "password_example" // string | None (optional)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
index 858aed121c9..3a719f87da0 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
@@ -501,7 +501,7 @@ import (
 func main() {
     petId := int64(789) // int64 | ID of pet to update
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
-    file := *os.File(BINARY_DATA_HERE) // *os.File | file to upload (optional)
+    file := os.NewFile(1234, "some_file") // *os.File | file to upload (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -572,7 +572,7 @@ import (
 
 func main() {
     petId := int64(789) // int64 | ID of pet to update
-    requiredFile := *os.File(BINARY_DATA_HERE) // *os.File | file to upload
+    requiredFile := os.NewFile(1234, "some_file") // *os.File | file to upload
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
 
     configuration := openapiclient.NewConfiguration()
-- 
GitLab


From 63ea632a5b1b97c28a5648fa71600a3e514d73e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 14:30:28 +0100
Subject: [PATCH 08/17] Regenerate samples

---
 samples/client/petstore/go/go-petstore/docs/FakeApi.md | 2 +-
 samples/client/petstore/go/go-petstore/docs/PetApi.md  | 8 ++++----
 samples/client/petstore/go/go-petstore/docs/UserApi.md | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
index 71783c67a92..5e0c0661175 100644
--- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -574,7 +574,7 @@ func main() {
     int64_ := int64(789) // int64 | None (optional)
     float := float32(3.4) // float32 | None (optional)
     string_ := "string__example" // string | None (optional)
-    binary := *os.File(BINARY_DATA_HERE) // *os.File | None (optional)
+    binary := os.NewFile(1234, "some_file") // *os.File | None (optional)
     date := time.Now() // string | None (optional)
     dateTime := time.Now() // time.Time | None (optional)
     password := "password_example" // string | None (optional)
diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md
index bcba09678b4..ff4e36064fd 100644
--- a/samples/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md
@@ -35,7 +35,7 @@ import (
 )
 
 func main() {
-    body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -367,7 +367,7 @@ import (
 )
 
 func main() {
-    body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store
+    body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -501,7 +501,7 @@ import (
 func main() {
     petId := int64(789) // int64 | ID of pet to update
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
-    file := *os.File(BINARY_DATA_HERE) // *os.File | file to upload (optional)
+    file := os.NewFile(1234, "some_file") // *os.File | file to upload (optional)
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -572,7 +572,7 @@ import (
 
 func main() {
     petId := int64(789) // int64 | ID of pet to update
-    requiredFile := *os.File(BINARY_DATA_HERE) // *os.File | file to upload
+    requiredFile := os.NewFile(1234, "some_file") // *os.File | file to upload
     additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
 
     configuration := openapiclient.NewConfiguration()
diff --git a/samples/client/petstore/go/go-petstore/docs/UserApi.md b/samples/client/petstore/go/go-petstore/docs/UserApi.md
index 9eccb9144d0..e1623fabec4 100644
--- a/samples/client/petstore/go/go-petstore/docs/UserApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/UserApi.md
@@ -98,7 +98,7 @@ import (
 )
 
 func main() {
-    body := []User{*openapiclient.NewUser()} // []User | List of user object
+    body := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -160,7 +160,7 @@ import (
 )
 
 func main() {
-    body := []User{} // []User | List of user object
+    body := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
@@ -484,7 +484,7 @@ import (
 
 func main() {
     username := "username_example" // string | name that need to be deleted
-    body :=  // User | Updated user object
+    body := *openapiclient.NewUser() // User | Updated user object
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From 1a6712aa0d0e917accc2ca6f04148e12843365a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 14:40:26 +0100
Subject: [PATCH 09/17] Handle maps of complex types

---
 .../codegen/languages/GoClientCodegen.java    | 26 +++++++++++++------
 .../petstore/go/go-petstore/docs/FakeApi.md   |  2 +-
 .../petstore/go/go-petstore/docs/FakeApi.md   |  2 +-
 3 files changed, 20 insertions(+), 10 deletions(-)

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 db37c4a3e30..c3d03f9f9e8 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
@@ -456,7 +456,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
             for (CodegenParameter cp : operation.allParams) {
                 cp.vendorExtensions.put("x-go-example", constructExampleCode(cp, modelMaps, processedModelMaps));
                 if (cp.isDateTime || cp.isDate) { // datetime or date
-                        needTimeImport = true;
+                    needTimeImport = true;
                 }
             }
             if (needTimeImport) {
@@ -473,11 +473,16 @@ public class GoClientCodegen extends AbstractGoCodegen {
             String prefix = codegenParameter.dataType;
             String dataType = codegenParameter.dataType.substring(2);
             if (modelMaps.containsKey(dataType)) {
-                    prefix = "[]" + goImportAlias + "." + dataType;
+                prefix = "[]" + goImportAlias + "." + dataType;
             }
             return prefix + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isMap) {
-            return codegenParameter.dataType + "{ \"key\": " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
+            String prefix = codegenParameter.dataType;
+            String dataType = codegenParameter.dataType.substring(12); // map[string][]
+            if (modelMaps.containsKey(dataType)) {
+                prefix = "map[string][]" + goImportAlias + "." + dataType;
+            }
+            return prefix + "{\"key\": " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isPrimitiveType) { // primitive type
             if (codegenParameter.isString) {
                 if (!StringUtils.isEmpty(codegenParameter.example) && codegenParameter.example != "null") {
@@ -520,11 +525,16 @@ public class GoClientCodegen extends AbstractGoCodegen {
             String prefix = codegenProperty.dataType;
             String dataType = codegenProperty.dataType.substring(2);
             if (modelMaps.containsKey(dataType)) {
-                    prefix = "[]" + goImportAlias + "." + dataType;
+                prefix = "[]" + goImportAlias + "." + dataType;
             }
             return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isMap) { // map
-            return codegenProperty.dataType + "{ \"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
+            String prefix = codegenProperty.dataType;
+            String dataType = codegenProperty.dataType.substring(12); // map[string][]
+            if (modelMaps.containsKey(dataType)) {
+                prefix = "map[string][]" + goImportAlias + "." + dataType;
+            }
+            return prefix + "{\"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isPrimitiveType) { // primitive type
             if (codegenProperty.isString) {
                 if (!StringUtils.isEmpty(codegenProperty.example) && codegenProperty.example != "null") {
@@ -576,9 +586,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
                 throw new RuntimeException("Invalid count when constructing example: " + count);
             }
         } else if (codegenModel.isEnum) {
-                Map<String, Object> allowableValues = codegenModel.allowableValues;
-                List<Object> values = (List<Object>) allowableValues.get("values");
-                return goImportAlias + "." + model + "(\"" + String.valueOf(values.get(0)) + "\")";
+            Map<String, Object> allowableValues = codegenModel.allowableValues;
+            List<Object> values = (List<Object>) allowableValues.get("values");
+            return goImportAlias + "." + model + "(\"" + String.valueOf(values.get(0)) + "\")";
         } else {
             processedModelMap.put(model, 1);
         }
diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
index 5e0c0661175..fb24e089d32 100644
--- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -805,7 +805,7 @@ import (
 )
 
 func main() {
-    param := map[string]string{ "key": "Inner_example"} // map[string]string | request body
+    param := map[string]string{"key": "Inner_example"} // map[string]string | request body
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
index a00754c47c1..62dab103a1f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -800,7 +800,7 @@ import (
 )
 
 func main() {
-    requestBody := map[string]string{ "key": "Inner_example"} // map[string]string | request body
+    requestBody := map[string]string{"key": "Inner_example"} // map[string]string | request body
 
     configuration := openapiclient.NewConfiguration()
     api_client := openapiclient.NewAPIClient(configuration)
-- 
GitLab


From efa4f60054d55a7c2347ed9bfc14d0bb24c4dd08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 18:38:35 +0100
Subject: [PATCH 10/17] Handle oneOf

---
 .../org/openapitools/codegen/languages/GoClientCodegen.java   | 4 ++++
 1 file changed, 4 insertions(+)

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 c3d03f9f9e8..6075eb61d87 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
@@ -589,6 +589,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
             Map<String, Object> allowableValues = codegenModel.allowableValues;
             List<Object> values = (List<Object>) allowableValues.get("values");
             return goImportAlias + "." + model + "(\"" + String.valueOf(values.get(0)) + "\")";
+        } else if (codegenModel.oneOf != null && !codegenModel.oneOf.isEmpty()) {
+                String subModel = (String) codegenModel.oneOf.toArray()[0];
+                String oneOf = constructExampleCode(modelMaps.get(subModel), modelMaps, processedModelMap).substring(1);
+                return goImportAlias + "." + model + "{" + subModel + ": " + oneOf + "}";
         } else {
             processedModelMap.put(model, 1);
         }
-- 
GitLab


From ca56a1935a61b69e0ba3d80919bc2c8e70568ea8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Thu, 5 Nov 2020 18:42:41 +0100
Subject: [PATCH 11/17] Fix padding

---
 .../org/openapitools/codegen/languages/GoClientCodegen.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 6075eb61d87..78e445fb598 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
@@ -478,7 +478,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
             return prefix + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isMap) {
             String prefix = codegenParameter.dataType;
-            String dataType = codegenParameter.dataType.substring(12); // map[string][]
+            String dataType = codegenParameter.dataType.substring(13); // map[string][]
             if (modelMaps.containsKey(dataType)) {
                 prefix = "map[string][]" + goImportAlias + "." + dataType;
             }
@@ -530,7 +530,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
             return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isMap) { // map
             String prefix = codegenProperty.dataType;
-            String dataType = codegenProperty.dataType.substring(12); // map[string][]
+            String dataType = codegenProperty.dataType.substring(13); // map[string][]
             if (modelMaps.containsKey(dataType)) {
                 prefix = "map[string][]" + goImportAlias + "." + dataType;
             }
-- 
GitLab


From 48ceff6447bf354d655e8f253d193d92649bc100 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Mon, 9 Nov 2020 14:38:48 +0100
Subject: [PATCH 12/17] Fix enum doc

---
 .../src/main/resources/go/model_doc.mustache           |  9 ++++++++-
 .../client/petstore/go/go-petstore/docs/EnumClass.md   | 10 +++++++---
 .../client/petstore/go/go-petstore/docs/OuterEnum.md   | 10 +++++++---
 .../client/petstore/go/go-petstore/docs/EnumClass.md   | 10 +++++++---
 .../client/petstore/go/go-petstore/docs/OuterEnum.md   | 10 +++++++---
 .../go/go-petstore/docs/OuterEnumDefaultValue.md       | 10 +++++++---
 .../petstore/go/go-petstore/docs/OuterEnumInteger.md   | 10 +++++++---
 .../go-petstore/docs/OuterEnumIntegerDefaultValue.md   | 10 +++++++---
 8 files changed, 57 insertions(+), 22 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/model_doc.mustache b/modules/openapi-generator/src/main/resources/go/model_doc.mustache
index 9045d9fe088..d9e29359f57 100644
--- a/modules/openapi-generator/src/main/resources/go/model_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_doc.mustache
@@ -1,5 +1,6 @@
 {{#models}}{{#model}}# {{classname}}
 
+{{^isEnum}}
 ## Properties
 
 Name | Type | Description | Notes
@@ -12,7 +13,6 @@ Name | Type | Description | Notes
 {{/vars}}
 {{/vendorExtensions.x-is-one-of-interface}}
 
-{{^isEnum}}
 ## Methods
 
 {{^vendorExtensions.x-is-one-of-interface}}
@@ -84,6 +84,13 @@ Convenience method to wrap this instance of {{classname}} in {{{.}}}
 {{/vendorExtensions.x-implements}}
 {{/vendorExtensions.x-is-one-of-interface}}
 {{/isEnum}}
+{{#isEnum}}
+## Enum
+
+{{#allowableValues}}{{#enumVars}}
+* `{{name}}` (value: `{{{value}}}`)
+{{/enumVars}}{{/allowableValues}}
+{{/isEnum}}
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
 
diff --git a/samples/client/petstore/go/go-petstore/docs/EnumClass.md b/samples/client/petstore/go/go-petstore/docs/EnumClass.md
index e231f94bd73..98fc18f12ac 100644
--- a/samples/client/petstore/go/go-petstore/docs/EnumClass.md
+++ b/samples/client/petstore/go/go-petstore/docs/EnumClass.md
@@ -1,9 +1,13 @@
 # EnumClass
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `ABC` (value: `"_abc"`)
+
+* `EFG` (value: `"-efg"`)
+
+* `XYZ` (value: `"(xyz)"`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/client/petstore/go/go-petstore/docs/OuterEnum.md b/samples/client/petstore/go/go-petstore/docs/OuterEnum.md
index 13bed2d17fd..4b7e1971772 100644
--- a/samples/client/petstore/go/go-petstore/docs/OuterEnum.md
+++ b/samples/client/petstore/go/go-petstore/docs/OuterEnum.md
@@ -1,9 +1,13 @@
 # OuterEnum
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `PLACED` (value: `"placed"`)
+
+* `APPROVED` (value: `"approved"`)
+
+* `DELIVERED` (value: `"delivered"`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/EnumClass.md b/samples/openapi3/client/petstore/go/go-petstore/docs/EnumClass.md
index e231f94bd73..98fc18f12ac 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/EnumClass.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/EnumClass.md
@@ -1,9 +1,13 @@
 # EnumClass
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `ABC` (value: `"_abc"`)
+
+* `EFG` (value: `"-efg"`)
+
+* `XYZ` (value: `"(xyz)"`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnum.md b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnum.md
index 13bed2d17fd..4b7e1971772 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnum.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnum.md
@@ -1,9 +1,13 @@
 # OuterEnum
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `PLACED` (value: `"placed"`)
+
+* `APPROVED` (value: `"approved"`)
+
+* `DELIVERED` (value: `"delivered"`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumDefaultValue.md b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumDefaultValue.md
index 50f8ab0096c..af1747f3e09 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumDefaultValue.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumDefaultValue.md
@@ -1,9 +1,13 @@
 # OuterEnumDefaultValue
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `PLACED` (value: `"placed"`)
+
+* `APPROVED` (value: `"approved"`)
+
+* `DELIVERED` (value: `"delivered"`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumInteger.md b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumInteger.md
index eb033db7cc5..1bb73a90ee7 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumInteger.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumInteger.md
@@ -1,9 +1,13 @@
 # OuterEnumInteger
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `_0` (value: `0`)
+
+* `_1` (value: `1`)
+
+* `_2` (value: `2`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumIntegerDefaultValue.md b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumIntegerDefaultValue.md
index 7a163432954..495d8f91379 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumIntegerDefaultValue.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/OuterEnumIntegerDefaultValue.md
@@ -1,9 +1,13 @@
 # OuterEnumIntegerDefaultValue
 
-## Properties
+## Enum
 
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+
+* `_0` (value: `0`)
+
+* `_1` (value: `1`)
+
+* `_2` (value: `2`)
 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
-- 
GitLab


From 33de7b47b8f251f00109d9fe4e033f3298565c0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Mon, 9 Nov 2020 15:18:08 +0100
Subject: [PATCH 13/17] Removes links to basic types in arrays

---
 .../src/main/resources/go/api_doc.mustache       |  2 +-
 .../petstore/go/go-petstore/docs/FakeApi.md      | 16 ++++++++--------
 .../petstore/go/go-petstore/docs/PetApi.md       |  4 ++--
 .../petstore/go/go-petstore/docs/FakeApi.md      | 16 ++++++++--------
 .../petstore/go/go-petstore/docs/PetApi.md       |  4 ++--
 5 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api_doc.mustache b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
index 4cd02b32da3..b84dd6afca3 100644
--- a/modules/openapi-generator/src/main/resources/go/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
@@ -67,7 +67,7 @@ Other parameters are passed through a pointer to a api{{{nickname}}}Request stru
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
-{{^isPathParam}} **{{paramName}}** | {{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
+{{^isPathParam}} **{{paramName}}** | {{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{^isArray}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/isArray}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
 
 ### Return type
 
diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
index fb24e089d32..138a1a12d21 100644
--- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -685,13 +685,13 @@ Other parameters are passed through a pointer to a apiTestEnumParametersRequest
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **enumHeaderStringArray** | [**[]string**](string.md) | Header parameter enum test (string array) | 
+ **enumHeaderStringArray** | **[]string** | Header parameter enum test (string array) | 
  **enumHeaderString** | **string** | Header parameter enum test (string) | [default to &quot;-efg&quot;]
- **enumQueryStringArray** | [**[]string**](string.md) | Query parameter enum test (string array) | 
+ **enumQueryStringArray** | **[]string** | Query parameter enum test (string array) | 
  **enumQueryString** | **string** | Query parameter enum test (string) | [default to &quot;-efg&quot;]
  **enumQueryInteger** | **int32** | Query parameter enum test (double) | 
  **enumQueryDouble** | **float64** | Query parameter enum test (double) | 
- **enumFormStringArray** | [**[]string**](string.md) | Form parameter enum test (string array) | [default to &quot;$&quot;]
+ **enumFormStringArray** | **[]string** | Form parameter enum test (string array) | [default to &quot;$&quot;]
  **enumFormString** | **string** | Form parameter enum test (string) | [default to &quot;-efg&quot;]
 
 ### Return type
@@ -960,11 +960,11 @@ Other parameters are passed through a pointer to a apiTestQueryParameterCollecti
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **pipe** | [**[]string**](string.md) |  | 
- **ioutil** | [**[]string**](string.md) |  | 
- **http** | [**[]string**](string.md) |  | 
- **url** | [**[]string**](string.md) |  | 
- **context** | [**[]string**](string.md) |  | 
+ **pipe** | **[]string** |  | 
+ **ioutil** | **[]string** |  | 
+ **http** | **[]string** |  | 
+ **url** | **[]string** |  | 
+ **context** | **[]string** |  | 
 
 ### Return type
 
diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md
index ff4e36064fd..d93265c16ed 100644
--- a/samples/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md
@@ -192,7 +192,7 @@ Other parameters are passed through a pointer to a apiFindPetsByStatusRequest st
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **status** | [**[]string**](string.md) | Status values that need to be considered for filter | 
+ **status** | **[]string** | Status values that need to be considered for filter | 
 
 ### Return type
 
@@ -258,7 +258,7 @@ Other parameters are passed through a pointer to a apiFindPetsByTagsRequest stru
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **tags** | [**[]string**](string.md) | Tags to filter by | 
+ **tags** | **[]string** | Tags to filter by | 
 
 ### Return type
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
index 62dab103a1f..203bfaab641 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -680,13 +680,13 @@ Other parameters are passed through a pointer to a apiTestEnumParametersRequest
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **enumHeaderStringArray** | [**[]string**](string.md) | Header parameter enum test (string array) | 
+ **enumHeaderStringArray** | **[]string** | Header parameter enum test (string array) | 
  **enumHeaderString** | **string** | Header parameter enum test (string) | [default to &quot;-efg&quot;]
- **enumQueryStringArray** | [**[]string**](string.md) | Query parameter enum test (string array) | 
+ **enumQueryStringArray** | **[]string** | Query parameter enum test (string array) | 
  **enumQueryString** | **string** | Query parameter enum test (string) | [default to &quot;-efg&quot;]
  **enumQueryInteger** | **int32** | Query parameter enum test (double) | 
  **enumQueryDouble** | **float64** | Query parameter enum test (double) | 
- **enumFormStringArray** | [**[]string**](string.md) | Form parameter enum test (string array) | [default to &quot;$&quot;]
+ **enumFormStringArray** | **[]string** | Form parameter enum test (string array) | [default to &quot;$&quot;]
  **enumFormString** | **string** | Form parameter enum test (string) | [default to &quot;-efg&quot;]
 
 ### Return type
@@ -955,11 +955,11 @@ Other parameters are passed through a pointer to a apiTestQueryParameterCollecti
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **pipe** | [**[]string**](string.md) |  | 
- **ioutil** | [**[]string**](string.md) |  | 
- **http** | [**[]string**](string.md) |  | 
- **url** | [**[]string**](string.md) |  | 
- **context** | [**[]string**](string.md) |  | 
+ **pipe** | **[]string** |  | 
+ **ioutil** | **[]string** |  | 
+ **http** | **[]string** |  | 
+ **url** | **[]string** |  | 
+ **context** | **[]string** |  | 
 
 ### Return type
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
index 3a719f87da0..c99794e706d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/PetApi.md
@@ -192,7 +192,7 @@ Other parameters are passed through a pointer to a apiFindPetsByStatusRequest st
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **status** | [**[]string**](string.md) | Status values that need to be considered for filter | 
+ **status** | **[]string** | Status values that need to be considered for filter | 
 
 ### Return type
 
@@ -258,7 +258,7 @@ Other parameters are passed through a pointer to a apiFindPetsByTagsRequest stru
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **tags** | [**[]string**](string.md) | Tags to filter by | 
+ **tags** | **[]string** | Tags to filter by | 
 
 ### Return type
 
-- 
GitLab


From 6ef17db3d743b5111fd0dd8385c0f9a105edf74f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Mon, 9 Nov 2020 15:26:22 +0100
Subject: [PATCH 14/17] Remove links to basic types in maps

---
 .../openapi-generator/src/main/resources/go/api_doc.mustache    | 2 +-
 samples/client/petstore/go/go-petstore/docs/FakeApi.md          | 2 +-
 samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api_doc.mustache b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
index b84dd6afca3..386fb7c199a 100644
--- a/modules/openapi-generator/src/main/resources/go/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
@@ -67,7 +67,7 @@ Other parameters are passed through a pointer to a api{{{nickname}}}Request stru
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
-{{^isPathParam}} **{{paramName}}** | {{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{^isArray}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/isArray}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
+{{^isPathParam}} **{{paramName}}** | {{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
 
 ### Return type
 
diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
index 138a1a12d21..382058dc4db 100644
--- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -828,7 +828,7 @@ Other parameters are passed through a pointer to a apiTestInlineAdditionalProper
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **param** | [**map[string]string**](string.md) | request body | 
+ **param** | **map[string]string** | request body | 
 
 ### Return type
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
index 203bfaab641..9021892276c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -823,7 +823,7 @@ Other parameters are passed through a pointer to a apiTestInlineAdditionalProper
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------
- **requestBody** | [**map[string]string**](string.md) | request body | 
+ **requestBody** | **map[string]string** | request body | 
 
 ### Return type
 
-- 
GitLab


From 889dae7cdf78a35ad1584dbd1c3168979447d621 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Mon, 9 Nov 2020 18:53:13 +0100
Subject: [PATCH 15/17] Fix enum links

---
 .../openapi-generator/src/main/resources/go/api_doc.mustache    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api_doc.mustache b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
index 386fb7c199a..23f6e06bf93 100644
--- a/modules/openapi-generator/src/main/resources/go/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
@@ -67,7 +67,7 @@ Other parameters are passed through a pointer to a api{{{nickname}}}Request stru
 
 Name | Type | Description  | Notes
 ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
-{{^isPathParam}} **{{paramName}}** | {{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{#isEnum}}{{dataType}}{{/isEnum}}{{^isEnum}}{{baseType}}{{/isEnum}}.md){{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
+{{^isPathParam}} **{{paramName}}** | {{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
 
 ### Return type
 
-- 
GitLab


From 9bdb91ff37abac9790f2cd44054927174846440b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Mon, 9 Nov 2020 20:27:41 +0100
Subject: [PATCH 16/17] Minor indent fix

---
 Dockerfile                                                  | 2 +-
 .../org/openapitools/codegen/languages/GoClientCodegen.java | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index b1ca47344ed..7408ccda52b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,7 +20,7 @@ COPY ./modules/openapi-generator ${GEN_DIR}/modules/openapi-generator
 COPY ./pom.xml ${GEN_DIR}
 
 # Pre-compile openapi-generator-cli
-RUN mvn -am -pl "modules/openapi-generator-cli" package
+RUN mvn -DskipTests -am -pl "modules/openapi-generator-cli" package
 
 # This exists at the end of the file to benefit from cached layers when modifying docker-entrypoint.sh.
 COPY docker-entrypoint.sh /usr/local/bin/
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 78e445fb598..abd242d8c92 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
@@ -590,9 +590,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
             List<Object> values = (List<Object>) allowableValues.get("values");
             return goImportAlias + "." + model + "(\"" + String.valueOf(values.get(0)) + "\")";
         } else if (codegenModel.oneOf != null && !codegenModel.oneOf.isEmpty()) {
-                String subModel = (String) codegenModel.oneOf.toArray()[0];
-                String oneOf = constructExampleCode(modelMaps.get(subModel), modelMaps, processedModelMap).substring(1);
-                return goImportAlias + "." + model + "{" + subModel + ": " + oneOf + "}";
+            String subModel = (String) codegenModel.oneOf.toArray()[0];
+            String oneOf = constructExampleCode(modelMaps.get(subModel), modelMaps, processedModelMap).substring(1);
+            return goImportAlias + "." + model + "{" + subModel + ": " + oneOf + "}";
         } else {
             processedModelMap.put(model, 1);
         }
-- 
GitLab


From 8f35ab0e226c8e547feca668f029e0d815d2cf87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Herv=C3=A9?= <thomas.herve@datadoghq.com>
Date: Tue, 10 Nov 2020 11:29:33 +0100
Subject: [PATCH 17/17] Handle review comments

---
 Dockerfile                                                | 2 +-
 .../openapitools/codegen/languages/GoClientCodegen.java   | 8 ++++----
 .../src/main/resources/go/api_doc.mustache                | 6 ++++--
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 7408ccda52b..b1ca47344ed 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,7 +20,7 @@ COPY ./modules/openapi-generator ${GEN_DIR}/modules/openapi-generator
 COPY ./pom.xml ${GEN_DIR}
 
 # Pre-compile openapi-generator-cli
-RUN mvn -DskipTests -am -pl "modules/openapi-generator-cli" package
+RUN mvn -am -pl "modules/openapi-generator-cli" package
 
 # This exists at the end of the file to benefit from cached layers when modifying docker-entrypoint.sh.
 COPY docker-entrypoint.sh /usr/local/bin/
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 abd242d8c92..a062e7d6df1 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
@@ -471,14 +471,14 @@ public class GoClientCodegen extends AbstractGoCodegen {
     private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
         if (codegenParameter.isArray) { // array
             String prefix = codegenParameter.dataType;
-            String dataType = codegenParameter.dataType.substring(2);
+            String dataType = StringUtils.removeStart(codegenParameter.dataType, "[]");
             if (modelMaps.containsKey(dataType)) {
                 prefix = "[]" + goImportAlias + "." + dataType;
             }
             return prefix + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
         } else if (codegenParameter.isMap) {
             String prefix = codegenParameter.dataType;
-            String dataType = codegenParameter.dataType.substring(13); // map[string][]
+            String dataType = StringUtils.removeStart(codegenParameter.dataType, "map[string][]");
             if (modelMaps.containsKey(dataType)) {
                 prefix = "map[string][]" + goImportAlias + "." + dataType;
             }
@@ -523,14 +523,14 @@ public class GoClientCodegen extends AbstractGoCodegen {
     private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
         if (codegenProperty.isArray) { // array
             String prefix = codegenProperty.dataType;
-            String dataType = codegenProperty.dataType.substring(2);
+            String dataType = StringUtils.removeStart(codegenProperty.dataType, "[]");
             if (modelMaps.containsKey(dataType)) {
                 prefix = "[]" + goImportAlias + "." + dataType;
             }
             return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
         } else if (codegenProperty.isMap) { // map
             String prefix = codegenProperty.dataType;
-            String dataType = codegenProperty.dataType.substring(13); // map[string][]
+            String dataType = StringUtils.removeStart(codegenProperty.dataType, "map[string][]");
             if (modelMaps.containsKey(dataType)) {
                 prefix = "map[string][]" + goImportAlias + "." + dataType;
             }
diff --git a/modules/openapi-generator/src/main/resources/go/api_doc.mustache b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
index 23f6e06bf93..6bbf4439e6e 100644
--- a/modules/openapi-generator/src/main/resources/go/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api_doc.mustache
@@ -28,8 +28,10 @@ package main
 import (
     "context"
     "fmt"
-    "os"{{#vendorExtensions.x-go-import}}
-{{{vendorExtensions.x-go-import}}}{{/vendorExtensions.x-go-import}}
+    "os"
+{{#vendorExtensions.x-go-import}}
+{{{vendorExtensions.x-go-import}}}
+{{/vendorExtensions.x-go-import}}
     {{goImportAlias}} "./openapi"
 )
 
-- 
GitLab