From 0d9ff7131be58861ab0e36d7db82027fd252bef0 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 8 Oct 2022 11:35:58 +0200
Subject: [PATCH 01/15] issue #11401 - Go client generator doesn't support
 deepObject in query

---
 .../src/main/resources/go/api.mustache        | 10 +--
 .../src/main/resources/go/client.mustache     | 63 +++++++++++++++++--
 .../main/resources/go/model_simple.mustache   | 40 ++++++------
 .../src/main/resources/go/utils.mustache      |  5 +-
 4 files changed, 85 insertions(+), 33 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index 44fbbcf4f95..92a2d062efd 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -189,10 +189,10 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("{{baseName}}", parameterToString(s.Index(i), "{{collectionFormat}}"))
+				parameterToString(localVarQueryParams, "{{baseName}}", s.Index(i), "{{collectionFormat}}")
 			}
 		} else {
-			localVarQueryParams.Add("{{baseName}}", parameterToString(t, "{{collectionFormat}}"))
+                        parameterToString(localVarQueryParams, "{{baseName}}", t, "{{collectionFormat}}")
 		}
 	}
 	{{/isCollectionFormatMulti}}
@@ -207,14 +207,14 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("{{baseName}}", parameterToString(s.Index(i), "{{collectionFormat}}"))
+				parameterAddToQuery(localVarQueryParams, "{{baseName}}", s.Index(i), "{{collectionFormat}}")
 			}
 		} else {
-			localVarQueryParams.Add("{{baseName}}", parameterToString(t, "{{collectionFormat}}"))
+                        parameterAddToQuery(localVarQueryParams, "{{baseName}}", t, "{{collectionFormat}}")
 		}
 	{{/isCollectionFormatMulti}}
 	{{^isCollectionFormatMulti}}
-		localVarQueryParams.Add("{{baseName}}", parameterToString(*r.{{paramName}}, "{{collectionFormat}}"))
+                parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	{{/isCollectionFormatMulti}}
 	}
 	{{/required}}
diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index d5e45dfb03c..9bc1089ea46 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -132,8 +132,9 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
-func parameterToString(obj interface{}, collectionFormat string) string {
+// parameterAddToQuery adds the provided object to the url query supporting deep object specification
+// the del delimiter is used to the split the value as list
+func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -148,12 +149,64 @@ func parameterToString(obj interface{}, collectionFormat string) string {
 	}
 
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
+		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
+		if len(sliceValue) > 0 {
+			var ifaceValue = make([]interface{}, 0, len(sliceValue))
+			for v := range sliceValue {
+				ifaceValue = append(ifaceValue, v)
+			}
+			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
+		}
+		return
+
+	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+		var param,ok = obj.(MappedNullable)
+		if ok {
+			dataMap := param.ToMap()
+			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			return
+		}
+
 	} else if t, ok := obj.(time.Time); ok {
-		return t.Format(time.RFC3339)
+		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		return
+	}
+
+	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+}
+
+// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
+func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for key,value := range param {
+		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
 	}
+}
 
-	return fmt.Sprintf("%v", obj)
+// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
+func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for index,value := range param {
+		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
+	}
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
index 1f41f195532..bf10fd1f546 100644
--- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
@@ -1,3 +1,6 @@
+// checks if the {{classname}} type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &{{classname}}{}
+
 // {{classname}} {{{description}}}{{^description}}struct for {{{classname}}}{{/description}}
 type {{classname}} struct {
 {{#parent}}
@@ -122,13 +125,8 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
 // Deprecated
 {{/deprecated}}
 func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
-	if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
-{{^isFreeFormObject}}
-    return nil, false
-    {{/isFreeFormObject}}
-    {{#isFreeFormObject}}
-    return {{vendorExtensions.x-go-base-type}}{}, false
-    {{/isFreeFormObject}}
+	if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+		return nil, false
 	}
 {{#isNullable}}
 {{#vendorExtensions.x-golang-is-container}}
@@ -168,7 +166,7 @@ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
 // Deprecated
 {{/deprecated}}
 func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
-	if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+	if o == nil{{^isNullable}} || o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
 		var ret {{vendorExtensions.x-go-base-type}}
 		return ret
 	}
@@ -194,13 +192,8 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
 // Deprecated
 {{/deprecated}}
 func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
-	if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
-    {{^isFreeFormObject}}
-    return nil, false
-    {{/isFreeFormObject}}
-    {{#isFreeFormObject}}
-    return {{vendorExtensions.x-go-base-type}}{}, false
-    {{/isFreeFormObject}}
+	if o == nil{{^isNullable}} || o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+		return nil, false
 	}
 {{#isNullable}}
 {{#vendorExtensions.x-golang-is-container}}
@@ -217,7 +210,7 @@ func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/is
 
 // Has{{name}} returns a boolean if a field has been set.
 func (o *{{classname}}) Has{{name}}() bool {
-	if o != nil && {{^isNullable}}!isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+	if o != nil && {{^isNullable}}o.{{name}} != nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}o.{{name}} != nil{{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
 		return true
 	}
 
@@ -258,6 +251,11 @@ func (o *{{classname}}) Unset{{name}}() {
 {{/required}}
 {{/vars}}
 func (o {{classname}}) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o {{classname}}) ToMap() map[string]interface{} {
 	toSerialize := {{#isArray}}make([]interface{}, len(o.Items)){{/isArray}}{{^isArray}}map[string]interface{}{}{{/isArray}}
 	{{#parent}}
 	{{^isMap}}
@@ -284,19 +282,19 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
 	{{#vendorExtensions.x-golang-is-container}}
 	{{! support for container fields is not ideal at this point because of lack of Nullable* types}}
 	if o.{{name}} != nil {
-		toSerialize["{{baseName}}"] = o.{{name}}
+		toSerialize["{{baseName}}"] = *o.{{name}}
 	}
 	{{/vendorExtensions.x-golang-is-container}}
 	{{^vendorExtensions.x-golang-is-container}}
 	if {{#required}}true{{/required}}{{^required}}o.{{name}}.IsSet(){{/required}} {
-		toSerialize["{{baseName}}"] = o.{{name}}.Get()
+		toSerialize["{{baseName}}"] = *o.{{name}}.Get()
 	}
 	{{/vendorExtensions.x-golang-is-container}}
 	{{/isNullable}}
 	{{! if argument is not nullable, don't set it if it is nil}}
 	{{^isNullable}}
-	if {{#required}}true{{/required}}{{^required}}!isNil(o.{{name}}){{/required}} {
-		toSerialize["{{baseName}}"] = o.{{name}}
+	if {{#required}}true{{/required}}{{^required}}o.{{name}} != nil{{/required}} {
+		toSerialize["{{baseName}}"] = *o.{{name}}
 	}
 	{{/isNullable}}
 	{{/vars}}
@@ -307,7 +305,7 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
 	}
 
 	{{/isAdditionalPropertiesTrue}}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 {{#isAdditionalPropertiesTrue}}
diff --git a/modules/openapi-generator/src/main/resources/go/utils.mustache b/modules/openapi-generator/src/main/resources/go/utils.mustache
index cc42e879c85..b570eccc44f 100644
--- a/modules/openapi-generator/src/main/resources/go/utils.mustache
+++ b/modules/openapi-generator/src/main/resources/go/utils.mustache
@@ -3,7 +3,6 @@ package {{packageName}}
 
 import (
 	"encoding/json"
-    "reflect"
 	"time"
 )
 
@@ -331,4 +330,6 @@ func isNil(i interface{}) bool {
         return reflect.ValueOf(i).IsZero()
     }
     return false
-}
\ No newline at end of file
+}type MappedNullable interface {
+	ToMap() map[string]interface{}
+}
-- 
GitLab


From 60f39dcb0b4ef5779a00936d08749a314032355a Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Wed, 12 Oct 2022 00:16:28 -0400
Subject: [PATCH 02/15] samples generation

---
 .../petstore/go/go-petstore/api_fake.go       |  16 +-
 .../client/petstore/go/go-petstore/client.go  |  63 ++-
 .../go/go-petstore/model_200_response.go      |  14 +-
 .../model_additional_properties_any_type.go   |  12 +-
 .../model_additional_properties_array.go      |  22 +-
 .../model_additional_properties_boolean.go    |  22 +-
 .../model_additional_properties_class.go      | 142 +++----
 .../model_additional_properties_integer.go    |  22 +-
 .../model_additional_properties_number.go     |  22 +-
 .../model_additional_properties_object.go     |  22 +-
 .../model_additional_properties_string.go     |  22 +-
 .../petstore/go/go-petstore/model_animal.go   |  26 +-
 .../go/go-petstore/model_api_response.go      |  46 ++-
 .../model_array_of_array_of_number_only.go    |  22 +-
 .../go-petstore/model_array_of_number_only.go |  22 +-
 .../go/go-petstore/model_array_test_.go       |  46 ++-
 .../petstore/go/go-petstore/model_big_cat.go  |  22 +-
 .../go/go-petstore/model_big_cat_all_of.go    |  22 +-
 .../go/go-petstore/model_capitalization.go    |  82 ++--
 .../petstore/go/go-petstore/model_cat.go      |  22 +-
 .../go/go-petstore/model_cat_all_of.go        |  22 +-
 .../petstore/go/go-petstore/model_category.go |  26 +-
 .../go/go-petstore/model_class_model.go       |  22 +-
 .../petstore/go/go-petstore/model_client.go   |  12 +-
 .../petstore/go/go-petstore/model_dog.go      |  22 +-
 .../go/go-petstore/model_dog_all_of.go        |  22 +-
 .../go/go-petstore/model_enum_arrays.go       |  34 +-
 .../go/go-petstore/model_enum_test_.go        |  62 +--
 .../petstore/go/go-petstore/model_file.go     |  22 +-
 .../model_file_schema_test_class.go           |  34 +-
 .../go/go-petstore/model_format_test_.go      | 146 +++----
 .../go-petstore/model_has_only_read_only.go   |  34 +-
 .../petstore/go/go-petstore/model_list.go     |  22 +-
 .../go/go-petstore/model_map_test_.go         |  58 +--
 ...perties_and_additional_properties_class.go |  46 ++-
 .../petstore/go/go-petstore/model_name.go     |  50 ++-
 .../go/go-petstore/model_number_only.go       |  22 +-
 .../petstore/go/go-petstore/model_order.go    |  82 ++--
 .../go/go-petstore/model_outer_composite.go   |  46 ++-
 .../petstore/go/go-petstore/model_pet.go      |  66 ++--
 .../go/go-petstore/model_read_only_first.go   |  34 +-
 .../petstore/go/go-petstore/model_return.go   |  22 +-
 .../go-petstore/model_special_model_name.go   |  22 +-
 .../petstore/go/go-petstore/model_tag.go      |  34 +-
 .../go-petstore/model_type_holder_default.go  |  20 +-
 .../go-petstore/model_type_holder_example.go  |  22 +-
 .../petstore/go/go-petstore/model_user.go     | 106 +++---
 .../petstore/go/go-petstore/model_xml_item.go | 358 +++++++++---------
 .../client/petstore/go/go-petstore/utils.go   |   5 +-
 .../x-auth-id-alias/go-experimental/client.go |  63 ++-
 .../x-auth-id-alias/go-experimental/utils.go  |   5 +-
 .../petstore/go/go-petstore/api_fake.go       |  26 +-
 .../client/petstore/go/go-petstore/client.go  |  63 ++-
 .../go/go-petstore/model_200_response.go      |  34 +-
 .../model__foo_get_default_response.go        |  22 +-
 .../go-petstore/model__special_model_name_.go |  22 +-
 .../model_additional_properties_class.go      |  34 +-
 .../petstore/go/go-petstore/model_animal.go   |  26 +-
 .../go/go-petstore/model_api_response.go      |  46 ++-
 .../petstore/go/go-petstore/model_apple.go    |  22 +-
 .../go/go-petstore/model_apple_req.go         |  26 +-
 .../model_array_of_array_of_number_only.go    |  22 +-
 .../go-petstore/model_array_of_number_only.go |  22 +-
 .../go/go-petstore/model_array_test_.go       |  46 ++-
 .../petstore/go/go-petstore/model_banana.go   |  22 +-
 .../go/go-petstore/model_banana_req.go        |  26 +-
 .../go/go-petstore/model_capitalization.go    |  82 ++--
 .../petstore/go/go-petstore/model_cat.go      |  22 +-
 .../go/go-petstore/model_cat_all_of.go        |  22 +-
 .../petstore/go/go-petstore/model_category.go |  26 +-
 .../go/go-petstore/model_class_model.go       |  22 +-
 .../petstore/go/go-petstore/model_client.go   |  22 +-
 .../petstore/go/go-petstore/model_dog.go      |  22 +-
 .../go/go-petstore/model_dog_all_of.go        |  22 +-
 .../model_duplicated_prop_child.go            |  22 +-
 .../model_duplicated_prop_child_all_of.go     |  22 +-
 .../model_duplicated_prop_parent.go           |  12 +-
 .../go/go-petstore/model_enum_arrays.go       |  34 +-
 .../go/go-petstore/model_enum_test_.go        |  92 +++--
 .../petstore/go/go-petstore/model_file.go     |  22 +-
 .../model_file_schema_test_class.go           |  34 +-
 .../petstore/go/go-petstore/model_foo.go      |  22 +-
 .../go/go-petstore/model_format_test_.go      | 158 ++++----
 .../go-petstore/model_has_only_read_only.go   |  34 +-
 .../go-petstore/model_health_check_result.go  |  12 +-
 .../petstore/go/go-petstore/model_list.go     |  22 +-
 .../go/go-petstore/model_map_of_file_test_.go |  22 +-
 .../go/go-petstore/model_map_test_.go         |  58 +--
 ...perties_and_additional_properties_class.go |  46 ++-
 .../petstore/go/go-petstore/model_name.go     |  50 ++-
 .../go/go-petstore/model_nullable_all_of.go   |  12 +-
 .../model_nullable_all_of_child.go            |  22 +-
 .../go/go-petstore/model_nullable_class.go    | 102 ++---
 .../go/go-petstore/model_number_only.go       |  22 +-
 .../model_one_of_primitive_type_child.go      |  22 +-
 .../petstore/go/go-petstore/model_order.go    |  82 ++--
 .../go/go-petstore/model_outer_composite.go   |  46 ++-
 .../petstore/go/go-petstore/model_pet.go      |  66 ++--
 .../go/go-petstore/model_read_only_first.go   |  34 +-
 .../model_read_only_with_default.go           |  94 ++---
 .../petstore/go/go-petstore/model_return.go   |  22 +-
 .../petstore/go/go-petstore/model_tag.go      |  34 +-
 .../petstore/go/go-petstore/model_user.go     | 142 +++----
 .../petstore/go/go-petstore/model_whale.go    |  38 +-
 .../petstore/go/go-petstore/model_zebra.go    |  26 +-
 .../client/petstore/go/go-petstore/utils.go   |   5 +-
 106 files changed, 2656 insertions(+), 1704 deletions(-)

diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go
index 5d576ab4d4e..b7dd6b55ddb 100644
--- a/samples/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/client/petstore/go/go-petstore/api_fake.go
@@ -1422,16 +1422,16 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 	localVarFormParams := url.Values{}
 
 	if r.enumQueryStringArray != nil {
-		localVarQueryParams.Add("enum_query_string_array", parameterToString(*r.enumQueryStringArray, "csv"))
+                parameterAddToQuery(localVarQueryParams, "enum_query_string_array", r.enumQueryStringArray, "csv")
 	}
 	if r.enumQueryString != nil {
-		localVarQueryParams.Add("enum_query_string", parameterToString(*r.enumQueryString, ""))
+                parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
 	}
 	if r.enumQueryInteger != nil {
-		localVarQueryParams.Add("enum_query_integer", parameterToString(*r.enumQueryInteger, ""))
+                parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
 	}
 	if r.enumQueryDouble != nil {
-		localVarQueryParams.Add("enum_query_double", parameterToString(*r.enumQueryDouble, ""))
+                parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/x-www-form-urlencoded"}
@@ -1587,10 +1587,10 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	localVarQueryParams.Add("required_string_group", parameterToString(*r.requiredStringGroup, ""))
 	localVarQueryParams.Add("required_int64_group", parameterToString(*r.requiredInt64Group, ""))
 	if r.stringGroup != nil {
-		localVarQueryParams.Add("string_group", parameterToString(*r.stringGroup, ""))
+                parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
 	}
 	if r.int64Group != nil {
-		localVarQueryParams.Add("int64_group", parameterToString(*r.int64Group, ""))
+                parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
@@ -1944,10 +1944,10 @@ func (a *FakeApiService) TestQueryParameterCollectionFormatExecute(r ApiTestQuer
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("context", parameterToString(s.Index(i), "multi"))
+				parameterToString(localVarQueryParams, "context", s.Index(i), "multi")
 			}
 		} else {
-			localVarQueryParams.Add("context", parameterToString(t, "multi"))
+                        parameterToString(localVarQueryParams, "context", t, "multi")
 		}
 	}
 	// to determine the Content-Type header
diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go
index b48d903b06a..61121d7ba86 100644
--- a/samples/client/petstore/go/go-petstore/client.go
+++ b/samples/client/petstore/go/go-petstore/client.go
@@ -140,8 +140,9 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
-func parameterToString(obj interface{}, collectionFormat string) string {
+// parameterAddToQuery adds the provided object to the url query supporting deep object specification
+// the del delimiter is used to the split the value as list
+func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -156,12 +157,64 @@ func parameterToString(obj interface{}, collectionFormat string) string {
 	}
 
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
+		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
+		if len(sliceValue) > 0 {
+			var ifaceValue = make([]interface{}, 0, len(sliceValue))
+			for v := range sliceValue {
+				ifaceValue = append(ifaceValue, v)
+			}
+			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
+		}
+		return
+
+	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+		var param,ok = obj.(MappedNullable)
+		if ok {
+			dataMap := param.ToMap()
+			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			return
+		}
+
 	} else if t, ok := obj.(time.Time); ok {
-		return t.Format(time.RFC3339)
+		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		return
+	}
+
+	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+}
+
+// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
+func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for key,value := range param {
+		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
 	}
+}
 
-	return fmt.Sprintf("%v", obj)
+// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
+func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for index,value := range param {
+		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
+	}
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/samples/client/petstore/go/go-petstore/model_200_response.go b/samples/client/petstore/go/go-petstore/model_200_response.go
index 53a803b1303..11e8dc46eb4 100644
--- a/samples/client/petstore/go/go-petstore/model_200_response.go
+++ b/samples/client/petstore/go/go-petstore/model_200_response.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Model200Response type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Model200Response{}
+
 // Model200Response Model for testing model name starting with number
 type Model200Response struct {
 	Name *int32 `json:"name,omitempty"`
@@ -102,14 +105,19 @@ func (o *Model200Response) SetClass(v string) {
 }
 
 func (o Model200Response) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Model200Response) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
 	if !isNil(o.Class) {
-		toSerialize["class"] = o.Class
+		toSerialize["class"] = *o.Class
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableModel200Response struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
index ccbfd32b867..fb464b6c172 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesAnyType type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesAnyType{}
+
 // AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType
 type AdditionalPropertiesAnyType struct {
 	Name *string `json:"name,omitempty"`
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesAnyType) SetName(v string) {
 }
 
 func (o AdditionalPropertiesAnyType) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesAnyType) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesAnyType struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
index 24f75bcd6bb..a1e5f97858a 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesArray type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesArray{}
+
 // AdditionalPropertiesArray struct for AdditionalPropertiesArray
 type AdditionalPropertiesArray struct {
 	Name *string `json:"name,omitempty"`
@@ -38,7 +41,7 @@ func NewAdditionalPropertiesArrayWithDefaults() *AdditionalPropertiesArray {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesArray) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *AdditionalPropertiesArray) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesArray) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesArray) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesArray) SetName(v string) {
 }
 
 func (o AdditionalPropertiesArray) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesArray) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesArray struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
index f354bfd38cb..af99e19671b 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesBoolean type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesBoolean{}
+
 // AdditionalPropertiesBoolean struct for AdditionalPropertiesBoolean
 type AdditionalPropertiesBoolean struct {
 	Name *string `json:"name,omitempty"`
@@ -38,7 +41,7 @@ func NewAdditionalPropertiesBooleanWithDefaults() *AdditionalPropertiesBoolean {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesBoolean) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *AdditionalPropertiesBoolean) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesBoolean) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesBoolean) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesBoolean) SetName(v string) {
 }
 
 func (o AdditionalPropertiesBoolean) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesBoolean) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesBoolean struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
index 21f240005fa..54fa3c635ea 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesClass{}
+
 // AdditionalPropertiesClass struct for AdditionalPropertiesClass
 type AdditionalPropertiesClass struct {
 	MapString *map[string]string `json:"map_string,omitempty"`
@@ -48,7 +51,7 @@ func NewAdditionalPropertiesClassWithDefaults() *AdditionalPropertiesClass {
 
 // GetMapString returns the MapString field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapString() map[string]string {
-	if o == nil || isNil(o.MapString) {
+	if o == nil || o.MapString == nil {
 		var ret map[string]string
 		return ret
 	}
@@ -58,15 +61,15 @@ func (o *AdditionalPropertiesClass) GetMapString() map[string]string {
 // GetMapStringOk returns a tuple with the MapString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapStringOk() (*map[string]string, bool) {
-	if o == nil || isNil(o.MapString) {
-    return nil, false
+	if o == nil || o.MapString == nil {
+		return nil, false
 	}
 	return o.MapString, true
 }
 
 // HasMapString returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapString() bool {
-	if o != nil && !isNil(o.MapString) {
+	if o != nil && o.MapString != nil {
 		return true
 	}
 
@@ -80,7 +83,7 @@ func (o *AdditionalPropertiesClass) SetMapString(v map[string]string) {
 
 // GetMapNumber returns the MapNumber field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapNumber() map[string]float32 {
-	if o == nil || isNil(o.MapNumber) {
+	if o == nil || o.MapNumber == nil {
 		var ret map[string]float32
 		return ret
 	}
@@ -90,15 +93,15 @@ func (o *AdditionalPropertiesClass) GetMapNumber() map[string]float32 {
 // GetMapNumberOk returns a tuple with the MapNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapNumberOk() (*map[string]float32, bool) {
-	if o == nil || isNil(o.MapNumber) {
-    return nil, false
+	if o == nil || o.MapNumber == nil {
+		return nil, false
 	}
 	return o.MapNumber, true
 }
 
 // HasMapNumber returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapNumber() bool {
-	if o != nil && !isNil(o.MapNumber) {
+	if o != nil && o.MapNumber != nil {
 		return true
 	}
 
@@ -112,7 +115,7 @@ func (o *AdditionalPropertiesClass) SetMapNumber(v map[string]float32) {
 
 // GetMapInteger returns the MapInteger field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapInteger() map[string]int32 {
-	if o == nil || isNil(o.MapInteger) {
+	if o == nil || o.MapInteger == nil {
 		var ret map[string]int32
 		return ret
 	}
@@ -122,15 +125,15 @@ func (o *AdditionalPropertiesClass) GetMapInteger() map[string]int32 {
 // GetMapIntegerOk returns a tuple with the MapInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapIntegerOk() (*map[string]int32, bool) {
-	if o == nil || isNil(o.MapInteger) {
-    return nil, false
+	if o == nil || o.MapInteger == nil {
+		return nil, false
 	}
 	return o.MapInteger, true
 }
 
 // HasMapInteger returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapInteger() bool {
-	if o != nil && !isNil(o.MapInteger) {
+	if o != nil && o.MapInteger != nil {
 		return true
 	}
 
@@ -144,7 +147,7 @@ func (o *AdditionalPropertiesClass) SetMapInteger(v map[string]int32) {
 
 // GetMapBoolean returns the MapBoolean field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapBoolean() map[string]bool {
-	if o == nil || isNil(o.MapBoolean) {
+	if o == nil || o.MapBoolean == nil {
 		var ret map[string]bool
 		return ret
 	}
@@ -154,15 +157,15 @@ func (o *AdditionalPropertiesClass) GetMapBoolean() map[string]bool {
 // GetMapBooleanOk returns a tuple with the MapBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapBooleanOk() (*map[string]bool, bool) {
-	if o == nil || isNil(o.MapBoolean) {
-    return nil, false
+	if o == nil || o.MapBoolean == nil {
+		return nil, false
 	}
 	return o.MapBoolean, true
 }
 
 // HasMapBoolean returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapBoolean() bool {
-	if o != nil && !isNil(o.MapBoolean) {
+	if o != nil && o.MapBoolean != nil {
 		return true
 	}
 
@@ -176,7 +179,7 @@ func (o *AdditionalPropertiesClass) SetMapBoolean(v map[string]bool) {
 
 // GetMapArrayInteger returns the MapArrayInteger field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapArrayInteger() map[string][]int32 {
-	if o == nil || isNil(o.MapArrayInteger) {
+	if o == nil || o.MapArrayInteger == nil {
 		var ret map[string][]int32
 		return ret
 	}
@@ -186,15 +189,15 @@ func (o *AdditionalPropertiesClass) GetMapArrayInteger() map[string][]int32 {
 // GetMapArrayIntegerOk returns a tuple with the MapArrayInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapArrayIntegerOk() (*map[string][]int32, bool) {
-	if o == nil || isNil(o.MapArrayInteger) {
-    return nil, false
+	if o == nil || o.MapArrayInteger == nil {
+		return nil, false
 	}
 	return o.MapArrayInteger, true
 }
 
 // HasMapArrayInteger returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapArrayInteger() bool {
-	if o != nil && !isNil(o.MapArrayInteger) {
+	if o != nil && o.MapArrayInteger != nil {
 		return true
 	}
 
@@ -208,7 +211,7 @@ func (o *AdditionalPropertiesClass) SetMapArrayInteger(v map[string][]int32) {
 
 // GetMapArrayAnytype returns the MapArrayAnytype field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapArrayAnytype() map[string][]map[string]interface{} {
-	if o == nil || isNil(o.MapArrayAnytype) {
+	if o == nil || o.MapArrayAnytype == nil {
 		var ret map[string][]map[string]interface{}
 		return ret
 	}
@@ -218,15 +221,15 @@ func (o *AdditionalPropertiesClass) GetMapArrayAnytype() map[string][]map[string
 // GetMapArrayAnytypeOk returns a tuple with the MapArrayAnytype field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapArrayAnytypeOk() (*map[string][]map[string]interface{}, bool) {
-	if o == nil || isNil(o.MapArrayAnytype) {
-    return nil, false
+	if o == nil || o.MapArrayAnytype == nil {
+		return nil, false
 	}
 	return o.MapArrayAnytype, true
 }
 
 // HasMapArrayAnytype returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapArrayAnytype() bool {
-	if o != nil && !isNil(o.MapArrayAnytype) {
+	if o != nil && o.MapArrayAnytype != nil {
 		return true
 	}
 
@@ -240,7 +243,7 @@ func (o *AdditionalPropertiesClass) SetMapArrayAnytype(v map[string][]map[string
 
 // GetMapMapString returns the MapMapString field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapMapString() map[string]map[string]string {
-	if o == nil || isNil(o.MapMapString) {
+	if o == nil || o.MapMapString == nil {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -250,15 +253,15 @@ func (o *AdditionalPropertiesClass) GetMapMapString() map[string]map[string]stri
 // GetMapMapStringOk returns a tuple with the MapMapString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapMapStringOk() (*map[string]map[string]string, bool) {
-	if o == nil || isNil(o.MapMapString) {
-    return nil, false
+	if o == nil || o.MapMapString == nil {
+		return nil, false
 	}
 	return o.MapMapString, true
 }
 
 // HasMapMapString returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapMapString() bool {
-	if o != nil && !isNil(o.MapMapString) {
+	if o != nil && o.MapMapString != nil {
 		return true
 	}
 
@@ -272,7 +275,7 @@ func (o *AdditionalPropertiesClass) SetMapMapString(v map[string]map[string]stri
 
 // GetMapMapAnytype returns the MapMapAnytype field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapMapAnytype() map[string]map[string]map[string]interface{} {
-	if o == nil || isNil(o.MapMapAnytype) {
+	if o == nil || o.MapMapAnytype == nil {
 		var ret map[string]map[string]map[string]interface{}
 		return ret
 	}
@@ -282,15 +285,15 @@ func (o *AdditionalPropertiesClass) GetMapMapAnytype() map[string]map[string]map
 // GetMapMapAnytypeOk returns a tuple with the MapMapAnytype field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapMapAnytypeOk() (*map[string]map[string]map[string]interface{}, bool) {
-	if o == nil || isNil(o.MapMapAnytype) {
-    return nil, false
+	if o == nil || o.MapMapAnytype == nil {
+		return nil, false
 	}
 	return o.MapMapAnytype, true
 }
 
 // HasMapMapAnytype returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapMapAnytype() bool {
-	if o != nil && !isNil(o.MapMapAnytype) {
+	if o != nil && o.MapMapAnytype != nil {
 		return true
 	}
 
@@ -304,7 +307,7 @@ func (o *AdditionalPropertiesClass) SetMapMapAnytype(v map[string]map[string]map
 
 // GetAnytype1 returns the Anytype1 field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetAnytype1() map[string]interface{} {
-	if o == nil || isNil(o.Anytype1) {
+	if o == nil || o.Anytype1 == nil {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -314,15 +317,15 @@ func (o *AdditionalPropertiesClass) GetAnytype1() map[string]interface{} {
 // GetAnytype1Ok returns a tuple with the Anytype1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetAnytype1Ok() (map[string]interface{}, bool) {
-	if o == nil || isNil(o.Anytype1) {
-    return map[string]interface{}{}, false
+	if o == nil || o.Anytype1 == nil {
+		return nil, false
 	}
 	return o.Anytype1, true
 }
 
 // HasAnytype1 returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasAnytype1() bool {
-	if o != nil && !isNil(o.Anytype1) {
+	if o != nil && o.Anytype1 != nil {
 		return true
 	}
 
@@ -336,7 +339,7 @@ func (o *AdditionalPropertiesClass) SetAnytype1(v map[string]interface{}) {
 
 // GetAnytype2 returns the Anytype2 field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetAnytype2() map[string]interface{} {
-	if o == nil || isNil(o.Anytype2) {
+	if o == nil || o.Anytype2 == nil {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -346,15 +349,15 @@ func (o *AdditionalPropertiesClass) GetAnytype2() map[string]interface{} {
 // GetAnytype2Ok returns a tuple with the Anytype2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetAnytype2Ok() (map[string]interface{}, bool) {
-	if o == nil || isNil(o.Anytype2) {
-    return map[string]interface{}{}, false
+	if o == nil || o.Anytype2 == nil {
+		return nil, false
 	}
 	return o.Anytype2, true
 }
 
 // HasAnytype2 returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasAnytype2() bool {
-	if o != nil && !isNil(o.Anytype2) {
+	if o != nil && o.Anytype2 != nil {
 		return true
 	}
 
@@ -368,7 +371,7 @@ func (o *AdditionalPropertiesClass) SetAnytype2(v map[string]interface{}) {
 
 // GetAnytype3 returns the Anytype3 field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetAnytype3() map[string]interface{} {
-	if o == nil || isNil(o.Anytype3) {
+	if o == nil || o.Anytype3 == nil {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -378,15 +381,15 @@ func (o *AdditionalPropertiesClass) GetAnytype3() map[string]interface{} {
 // GetAnytype3Ok returns a tuple with the Anytype3 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetAnytype3Ok() (map[string]interface{}, bool) {
-	if o == nil || isNil(o.Anytype3) {
-    return map[string]interface{}{}, false
+	if o == nil || o.Anytype3 == nil {
+		return nil, false
 	}
 	return o.Anytype3, true
 }
 
 // HasAnytype3 returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasAnytype3() bool {
-	if o != nil && !isNil(o.Anytype3) {
+	if o != nil && o.Anytype3 != nil {
 		return true
 	}
 
@@ -399,41 +402,46 @@ func (o *AdditionalPropertiesClass) SetAnytype3(v map[string]interface{}) {
 }
 
 func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.MapString) {
-		toSerialize["map_string"] = o.MapString
+	if o.MapString != nil {
+		toSerialize["map_string"] = *o.MapString
 	}
-	if !isNil(o.MapNumber) {
-		toSerialize["map_number"] = o.MapNumber
+	if o.MapNumber != nil {
+		toSerialize["map_number"] = *o.MapNumber
 	}
-	if !isNil(o.MapInteger) {
-		toSerialize["map_integer"] = o.MapInteger
+	if o.MapInteger != nil {
+		toSerialize["map_integer"] = *o.MapInteger
 	}
-	if !isNil(o.MapBoolean) {
-		toSerialize["map_boolean"] = o.MapBoolean
+	if o.MapBoolean != nil {
+		toSerialize["map_boolean"] = *o.MapBoolean
 	}
-	if !isNil(o.MapArrayInteger) {
-		toSerialize["map_array_integer"] = o.MapArrayInteger
+	if o.MapArrayInteger != nil {
+		toSerialize["map_array_integer"] = *o.MapArrayInteger
 	}
-	if !isNil(o.MapArrayAnytype) {
-		toSerialize["map_array_anytype"] = o.MapArrayAnytype
+	if o.MapArrayAnytype != nil {
+		toSerialize["map_array_anytype"] = *o.MapArrayAnytype
 	}
-	if !isNil(o.MapMapString) {
-		toSerialize["map_map_string"] = o.MapMapString
+	if o.MapMapString != nil {
+		toSerialize["map_map_string"] = *o.MapMapString
 	}
-	if !isNil(o.MapMapAnytype) {
-		toSerialize["map_map_anytype"] = o.MapMapAnytype
+	if o.MapMapAnytype != nil {
+		toSerialize["map_map_anytype"] = *o.MapMapAnytype
 	}
-	if !isNil(o.Anytype1) {
-		toSerialize["anytype_1"] = o.Anytype1
+	if o.Anytype1 != nil {
+		toSerialize["anytype_1"] = *o.Anytype1
 	}
-	if !isNil(o.Anytype2) {
-		toSerialize["anytype_2"] = o.Anytype2
+	if o.Anytype2 != nil {
+		toSerialize["anytype_2"] = *o.Anytype2
 	}
-	if !isNil(o.Anytype3) {
-		toSerialize["anytype_3"] = o.Anytype3
+	if o.Anytype3 != nil {
+		toSerialize["anytype_3"] = *o.Anytype3
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesClass struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
index f4f6d506e51..ddf23105e93 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesInteger type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesInteger{}
+
 // AdditionalPropertiesInteger struct for AdditionalPropertiesInteger
 type AdditionalPropertiesInteger struct {
 	Name *string `json:"name,omitempty"`
@@ -38,7 +41,7 @@ func NewAdditionalPropertiesIntegerWithDefaults() *AdditionalPropertiesInteger {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesInteger) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *AdditionalPropertiesInteger) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesInteger) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesInteger) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesInteger) SetName(v string) {
 }
 
 func (o AdditionalPropertiesInteger) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesInteger) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesInteger struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
index 04c192d4330..667b492c5ec 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesNumber type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesNumber{}
+
 // AdditionalPropertiesNumber struct for AdditionalPropertiesNumber
 type AdditionalPropertiesNumber struct {
 	Name *string `json:"name,omitempty"`
@@ -38,7 +41,7 @@ func NewAdditionalPropertiesNumberWithDefaults() *AdditionalPropertiesNumber {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesNumber) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *AdditionalPropertiesNumber) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesNumber) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesNumber) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesNumber) SetName(v string) {
 }
 
 func (o AdditionalPropertiesNumber) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesNumber) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesNumber struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
index b2c2df5625b..8b305e63c82 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesObject type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesObject{}
+
 // AdditionalPropertiesObject struct for AdditionalPropertiesObject
 type AdditionalPropertiesObject struct {
 	Name *string `json:"name,omitempty"`
@@ -38,7 +41,7 @@ func NewAdditionalPropertiesObjectWithDefaults() *AdditionalPropertiesObject {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesObject) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *AdditionalPropertiesObject) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesObject) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesObject) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesObject) SetName(v string) {
 }
 
 func (o AdditionalPropertiesObject) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesObject) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesObject struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
index 06e571f77e5..4e010565792 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesString type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesString{}
+
 // AdditionalPropertiesString struct for AdditionalPropertiesString
 type AdditionalPropertiesString struct {
 	Name *string `json:"name,omitempty"`
@@ -38,7 +41,7 @@ func NewAdditionalPropertiesStringWithDefaults() *AdditionalPropertiesString {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesString) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *AdditionalPropertiesString) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesString) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesString) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *AdditionalPropertiesString) SetName(v string) {
 }
 
 func (o AdditionalPropertiesString) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesString) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAdditionalPropertiesString struct {
diff --git a/samples/client/petstore/go/go-petstore/model_animal.go b/samples/client/petstore/go/go-petstore/model_animal.go
index 72a80684bdb..38736d0c620 100644
--- a/samples/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/client/petstore/go/go-petstore/model_animal.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Animal type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Animal{}
+
 // Animal struct for Animal
 type Animal struct {
 	ClassName string `json:"className"`
@@ -56,7 +59,7 @@ func (o *Animal) GetClassName() string {
 // and a boolean to check if the value has been set.
 func (o *Animal) GetClassNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.ClassName, true
 }
@@ -68,7 +71,7 @@ func (o *Animal) SetClassName(v string) {
 
 // GetColor returns the Color field value if set, zero value otherwise.
 func (o *Animal) GetColor() string {
-	if o == nil || isNil(o.Color) {
+	if o == nil || o.Color == nil {
 		var ret string
 		return ret
 	}
@@ -78,15 +81,15 @@ func (o *Animal) GetColor() string {
 // GetColorOk returns a tuple with the Color field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Animal) GetColorOk() (*string, bool) {
-	if o == nil || isNil(o.Color) {
-    return nil, false
+	if o == nil || o.Color == nil {
+		return nil, false
 	}
 	return o.Color, true
 }
 
 // HasColor returns a boolean if a field has been set.
 func (o *Animal) HasColor() bool {
-	if o != nil && !isNil(o.Color) {
+	if o != nil && o.Color != nil {
 		return true
 	}
 
@@ -99,14 +102,19 @@ func (o *Animal) SetColor(v string) {
 }
 
 func (o Animal) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Animal) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["className"] = o.ClassName
+		toSerialize["className"] = *o.ClassName
 	}
-	if !isNil(o.Color) {
-		toSerialize["color"] = o.Color
+	if o.Color != nil {
+		toSerialize["color"] = *o.Color
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableAnimal struct {
diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go
index 8f585392558..ac2bef0ac2b 100644
--- a/samples/client/petstore/go/go-petstore/model_api_response.go
+++ b/samples/client/petstore/go/go-petstore/model_api_response.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ApiResponse type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ApiResponse{}
+
 // ApiResponse struct for ApiResponse
 type ApiResponse struct {
 	Code *int32 `json:"code,omitempty"`
@@ -40,7 +43,7 @@ func NewApiResponseWithDefaults() *ApiResponse {
 
 // GetCode returns the Code field value if set, zero value otherwise.
 func (o *ApiResponse) GetCode() int32 {
-	if o == nil || isNil(o.Code) {
+	if o == nil || o.Code == nil {
 		var ret int32
 		return ret
 	}
@@ -50,15 +53,15 @@ func (o *ApiResponse) GetCode() int32 {
 // GetCodeOk returns a tuple with the Code field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetCodeOk() (*int32, bool) {
-	if o == nil || isNil(o.Code) {
-    return nil, false
+	if o == nil || o.Code == nil {
+		return nil, false
 	}
 	return o.Code, true
 }
 
 // HasCode returns a boolean if a field has been set.
 func (o *ApiResponse) HasCode() bool {
-	if o != nil && !isNil(o.Code) {
+	if o != nil && o.Code != nil {
 		return true
 	}
 
@@ -72,7 +75,7 @@ func (o *ApiResponse) SetCode(v int32) {
 
 // GetType returns the Type field value if set, zero value otherwise.
 func (o *ApiResponse) GetType() string {
-	if o == nil || isNil(o.Type) {
+	if o == nil || o.Type == nil {
 		var ret string
 		return ret
 	}
@@ -82,15 +85,15 @@ func (o *ApiResponse) GetType() string {
 // GetTypeOk returns a tuple with the Type field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetTypeOk() (*string, bool) {
-	if o == nil || isNil(o.Type) {
-    return nil, false
+	if o == nil || o.Type == nil {
+		return nil, false
 	}
 	return o.Type, true
 }
 
 // HasType returns a boolean if a field has been set.
 func (o *ApiResponse) HasType() bool {
-	if o != nil && !isNil(o.Type) {
+	if o != nil && o.Type != nil {
 		return true
 	}
 
@@ -104,7 +107,7 @@ func (o *ApiResponse) SetType(v string) {
 
 // GetMessage returns the Message field value if set, zero value otherwise.
 func (o *ApiResponse) GetMessage() string {
-	if o == nil || isNil(o.Message) {
+	if o == nil || o.Message == nil {
 		var ret string
 		return ret
 	}
@@ -114,15 +117,15 @@ func (o *ApiResponse) GetMessage() string {
 // GetMessageOk returns a tuple with the Message field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetMessageOk() (*string, bool) {
-	if o == nil || isNil(o.Message) {
-    return nil, false
+	if o == nil || o.Message == nil {
+		return nil, false
 	}
 	return o.Message, true
 }
 
 // HasMessage returns a boolean if a field has been set.
 func (o *ApiResponse) HasMessage() bool {
-	if o != nil && !isNil(o.Message) {
+	if o != nil && o.Message != nil {
 		return true
 	}
 
@@ -135,17 +138,22 @@ func (o *ApiResponse) SetMessage(v string) {
 }
 
 func (o ApiResponse) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ApiResponse) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Code) {
-		toSerialize["code"] = o.Code
+	if o.Code != nil {
+		toSerialize["code"] = *o.Code
 	}
-	if !isNil(o.Type) {
-		toSerialize["type"] = o.Type
+	if o.Type != nil {
+		toSerialize["type"] = *o.Type
 	}
-	if !isNil(o.Message) {
-		toSerialize["message"] = o.Message
+	if o.Message != nil {
+		toSerialize["message"] = *o.Message
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableApiResponse struct {
diff --git a/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
index 1f0657d501f..7f241e946e3 100644
--- a/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ArrayOfArrayOfNumberOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ArrayOfArrayOfNumberOnly{}
+
 // ArrayOfArrayOfNumberOnly struct for ArrayOfArrayOfNumberOnly
 type ArrayOfArrayOfNumberOnly struct {
 	ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty"`
@@ -38,7 +41,7 @@ func NewArrayOfArrayOfNumberOnlyWithDefaults() *ArrayOfArrayOfNumberOnly {
 
 // GetArrayArrayNumber returns the ArrayArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
-	if o == nil || isNil(o.ArrayArrayNumber) {
+	if o == nil || o.ArrayArrayNumber == nil {
 		var ret [][]float32
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
 // GetArrayArrayNumberOk returns a tuple with the ArrayArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumberOk() ([][]float32, bool) {
-	if o == nil || isNil(o.ArrayArrayNumber) {
-    return nil, false
+	if o == nil || o.ArrayArrayNumber == nil {
+		return nil, false
 	}
 	return o.ArrayArrayNumber, true
 }
 
 // HasArrayArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfArrayOfNumberOnly) HasArrayArrayNumber() bool {
-	if o != nil && !isNil(o.ArrayArrayNumber) {
+	if o != nil && o.ArrayArrayNumber != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *ArrayOfArrayOfNumberOnly) SetArrayArrayNumber(v [][]float32) {
 }
 
 func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ArrayOfArrayOfNumberOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.ArrayArrayNumber) {
-		toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber
+	if o.ArrayArrayNumber != nil {
+		toSerialize["ArrayArrayNumber"] = *o.ArrayArrayNumber
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableArrayOfArrayOfNumberOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
index 91796160fbf..8ef33ca44d4 100644
--- a/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ArrayOfNumberOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ArrayOfNumberOnly{}
+
 // ArrayOfNumberOnly struct for ArrayOfNumberOnly
 type ArrayOfNumberOnly struct {
 	ArrayNumber []float32 `json:"ArrayNumber,omitempty"`
@@ -38,7 +41,7 @@ func NewArrayOfNumberOnlyWithDefaults() *ArrayOfNumberOnly {
 
 // GetArrayNumber returns the ArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
-	if o == nil || isNil(o.ArrayNumber) {
+	if o == nil || o.ArrayNumber == nil {
 		var ret []float32
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
 // GetArrayNumberOk returns a tuple with the ArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfNumberOnly) GetArrayNumberOk() ([]float32, bool) {
-	if o == nil || isNil(o.ArrayNumber) {
-    return nil, false
+	if o == nil || o.ArrayNumber == nil {
+		return nil, false
 	}
 	return o.ArrayNumber, true
 }
 
 // HasArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfNumberOnly) HasArrayNumber() bool {
-	if o != nil && !isNil(o.ArrayNumber) {
+	if o != nil && o.ArrayNumber != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *ArrayOfNumberOnly) SetArrayNumber(v []float32) {
 }
 
 func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ArrayOfNumberOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.ArrayNumber) {
-		toSerialize["ArrayNumber"] = o.ArrayNumber
+	if o.ArrayNumber != nil {
+		toSerialize["ArrayNumber"] = *o.ArrayNumber
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableArrayOfNumberOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_array_test_.go b/samples/client/petstore/go/go-petstore/model_array_test_.go
index 48bb0124c2d..dac8e9eeaaa 100644
--- a/samples/client/petstore/go/go-petstore/model_array_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_array_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ArrayTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ArrayTest{}
+
 // ArrayTest struct for ArrayTest
 type ArrayTest struct {
 	ArrayOfString []string `json:"array_of_string,omitempty"`
@@ -40,7 +43,7 @@ func NewArrayTestWithDefaults() *ArrayTest {
 
 // GetArrayOfString returns the ArrayOfString field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayOfString() []string {
-	if o == nil || isNil(o.ArrayOfString) {
+	if o == nil || o.ArrayOfString == nil {
 		var ret []string
 		return ret
 	}
@@ -50,15 +53,15 @@ func (o *ArrayTest) GetArrayOfString() []string {
 // GetArrayOfStringOk returns a tuple with the ArrayOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayOfStringOk() ([]string, bool) {
-	if o == nil || isNil(o.ArrayOfString) {
-    return nil, false
+	if o == nil || o.ArrayOfString == nil {
+		return nil, false
 	}
 	return o.ArrayOfString, true
 }
 
 // HasArrayOfString returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayOfString() bool {
-	if o != nil && !isNil(o.ArrayOfString) {
+	if o != nil && o.ArrayOfString != nil {
 		return true
 	}
 
@@ -72,7 +75,7 @@ func (o *ArrayTest) SetArrayOfString(v []string) {
 
 // GetArrayArrayOfInteger returns the ArrayArrayOfInteger field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
-	if o == nil || isNil(o.ArrayArrayOfInteger) {
+	if o == nil || o.ArrayArrayOfInteger == nil {
 		var ret [][]int64
 		return ret
 	}
@@ -82,15 +85,15 @@ func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
 // GetArrayArrayOfIntegerOk returns a tuple with the ArrayArrayOfInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfIntegerOk() ([][]int64, bool) {
-	if o == nil || isNil(o.ArrayArrayOfInteger) {
-    return nil, false
+	if o == nil || o.ArrayArrayOfInteger == nil {
+		return nil, false
 	}
 	return o.ArrayArrayOfInteger, true
 }
 
 // HasArrayArrayOfInteger returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfInteger() bool {
-	if o != nil && !isNil(o.ArrayArrayOfInteger) {
+	if o != nil && o.ArrayArrayOfInteger != nil {
 		return true
 	}
 
@@ -104,7 +107,7 @@ func (o *ArrayTest) SetArrayArrayOfInteger(v [][]int64) {
 
 // GetArrayArrayOfModel returns the ArrayArrayOfModel field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
-	if o == nil || isNil(o.ArrayArrayOfModel) {
+	if o == nil || o.ArrayArrayOfModel == nil {
 		var ret [][]ReadOnlyFirst
 		return ret
 	}
@@ -114,15 +117,15 @@ func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
 // GetArrayArrayOfModelOk returns a tuple with the ArrayArrayOfModel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfModelOk() ([][]ReadOnlyFirst, bool) {
-	if o == nil || isNil(o.ArrayArrayOfModel) {
-    return nil, false
+	if o == nil || o.ArrayArrayOfModel == nil {
+		return nil, false
 	}
 	return o.ArrayArrayOfModel, true
 }
 
 // HasArrayArrayOfModel returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfModel() bool {
-	if o != nil && !isNil(o.ArrayArrayOfModel) {
+	if o != nil && o.ArrayArrayOfModel != nil {
 		return true
 	}
 
@@ -135,17 +138,22 @@ func (o *ArrayTest) SetArrayArrayOfModel(v [][]ReadOnlyFirst) {
 }
 
 func (o ArrayTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ArrayTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.ArrayOfString) {
-		toSerialize["array_of_string"] = o.ArrayOfString
+	if o.ArrayOfString != nil {
+		toSerialize["array_of_string"] = *o.ArrayOfString
 	}
-	if !isNil(o.ArrayArrayOfInteger) {
-		toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger
+	if o.ArrayArrayOfInteger != nil {
+		toSerialize["array_array_of_integer"] = *o.ArrayArrayOfInteger
 	}
-	if !isNil(o.ArrayArrayOfModel) {
-		toSerialize["array_array_of_model"] = o.ArrayArrayOfModel
+	if o.ArrayArrayOfModel != nil {
+		toSerialize["array_array_of_model"] = *o.ArrayArrayOfModel
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableArrayTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_big_cat.go b/samples/client/petstore/go/go-petstore/model_big_cat.go
index e1ab343cbed..04df2c94a0c 100644
--- a/samples/client/petstore/go/go-petstore/model_big_cat.go
+++ b/samples/client/petstore/go/go-petstore/model_big_cat.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the BigCat type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &BigCat{}
+
 // BigCat struct for BigCat
 type BigCat struct {
 	Cat
@@ -42,7 +45,7 @@ func NewBigCatWithDefaults() *BigCat {
 
 // GetKind returns the Kind field value if set, zero value otherwise.
 func (o *BigCat) GetKind() string {
-	if o == nil || isNil(o.Kind) {
+	if o == nil || o.Kind == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *BigCat) GetKind() string {
 // GetKindOk returns a tuple with the Kind field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *BigCat) GetKindOk() (*string, bool) {
-	if o == nil || isNil(o.Kind) {
-    return nil, false
+	if o == nil || o.Kind == nil {
+		return nil, false
 	}
 	return o.Kind, true
 }
 
 // HasKind returns a boolean if a field has been set.
 func (o *BigCat) HasKind() bool {
-	if o != nil && !isNil(o.Kind) {
+	if o != nil && o.Kind != nil {
 		return true
 	}
 
@@ -73,6 +76,11 @@ func (o *BigCat) SetKind(v string) {
 }
 
 func (o BigCat) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o BigCat) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	serializedCat, errCat := json.Marshal(o.Cat)
 	if errCat != nil {
@@ -82,10 +90,10 @@ func (o BigCat) MarshalJSON() ([]byte, error) {
 	if errCat != nil {
 		return []byte{}, errCat
 	}
-	if !isNil(o.Kind) {
-		toSerialize["kind"] = o.Kind
+	if o.Kind != nil {
+		toSerialize["kind"] = *o.Kind
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableBigCat struct {
diff --git a/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go b/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
index ab21f0ce905..bff2ad62e00 100644
--- a/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the BigCatAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &BigCatAllOf{}
+
 // BigCatAllOf struct for BigCatAllOf
 type BigCatAllOf struct {
 	Kind *string `json:"kind,omitempty"`
@@ -38,7 +41,7 @@ func NewBigCatAllOfWithDefaults() *BigCatAllOf {
 
 // GetKind returns the Kind field value if set, zero value otherwise.
 func (o *BigCatAllOf) GetKind() string {
-	if o == nil || isNil(o.Kind) {
+	if o == nil || o.Kind == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *BigCatAllOf) GetKind() string {
 // GetKindOk returns a tuple with the Kind field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *BigCatAllOf) GetKindOk() (*string, bool) {
-	if o == nil || isNil(o.Kind) {
-    return nil, false
+	if o == nil || o.Kind == nil {
+		return nil, false
 	}
 	return o.Kind, true
 }
 
 // HasKind returns a boolean if a field has been set.
 func (o *BigCatAllOf) HasKind() bool {
-	if o != nil && !isNil(o.Kind) {
+	if o != nil && o.Kind != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *BigCatAllOf) SetKind(v string) {
 }
 
 func (o BigCatAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o BigCatAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Kind) {
-		toSerialize["kind"] = o.Kind
+	if o.Kind != nil {
+		toSerialize["kind"] = *o.Kind
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableBigCatAllOf struct {
diff --git a/samples/client/petstore/go/go-petstore/model_capitalization.go b/samples/client/petstore/go/go-petstore/model_capitalization.go
index f04c7c8ffb2..89019319977 100644
--- a/samples/client/petstore/go/go-petstore/model_capitalization.go
+++ b/samples/client/petstore/go/go-petstore/model_capitalization.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Capitalization type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Capitalization{}
+
 // Capitalization struct for Capitalization
 type Capitalization struct {
 	SmallCamel *string `json:"smallCamel,omitempty"`
@@ -44,7 +47,7 @@ func NewCapitalizationWithDefaults() *Capitalization {
 
 // GetSmallCamel returns the SmallCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallCamel() string {
-	if o == nil || isNil(o.SmallCamel) {
+	if o == nil || o.SmallCamel == nil {
 		var ret string
 		return ret
 	}
@@ -54,15 +57,15 @@ func (o *Capitalization) GetSmallCamel() string {
 // GetSmallCamelOk returns a tuple with the SmallCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallCamelOk() (*string, bool) {
-	if o == nil || isNil(o.SmallCamel) {
-    return nil, false
+	if o == nil || o.SmallCamel == nil {
+		return nil, false
 	}
 	return o.SmallCamel, true
 }
 
 // HasSmallCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallCamel() bool {
-	if o != nil && !isNil(o.SmallCamel) {
+	if o != nil && o.SmallCamel != nil {
 		return true
 	}
 
@@ -76,7 +79,7 @@ func (o *Capitalization) SetSmallCamel(v string) {
 
 // GetCapitalCamel returns the CapitalCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalCamel() string {
-	if o == nil || isNil(o.CapitalCamel) {
+	if o == nil || o.CapitalCamel == nil {
 		var ret string
 		return ret
 	}
@@ -86,15 +89,15 @@ func (o *Capitalization) GetCapitalCamel() string {
 // GetCapitalCamelOk returns a tuple with the CapitalCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalCamelOk() (*string, bool) {
-	if o == nil || isNil(o.CapitalCamel) {
-    return nil, false
+	if o == nil || o.CapitalCamel == nil {
+		return nil, false
 	}
 	return o.CapitalCamel, true
 }
 
 // HasCapitalCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalCamel() bool {
-	if o != nil && !isNil(o.CapitalCamel) {
+	if o != nil && o.CapitalCamel != nil {
 		return true
 	}
 
@@ -108,7 +111,7 @@ func (o *Capitalization) SetCapitalCamel(v string) {
 
 // GetSmallSnake returns the SmallSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallSnake() string {
-	if o == nil || isNil(o.SmallSnake) {
+	if o == nil || o.SmallSnake == nil {
 		var ret string
 		return ret
 	}
@@ -118,15 +121,15 @@ func (o *Capitalization) GetSmallSnake() string {
 // GetSmallSnakeOk returns a tuple with the SmallSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallSnakeOk() (*string, bool) {
-	if o == nil || isNil(o.SmallSnake) {
-    return nil, false
+	if o == nil || o.SmallSnake == nil {
+		return nil, false
 	}
 	return o.SmallSnake, true
 }
 
 // HasSmallSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallSnake() bool {
-	if o != nil && !isNil(o.SmallSnake) {
+	if o != nil && o.SmallSnake != nil {
 		return true
 	}
 
@@ -140,7 +143,7 @@ func (o *Capitalization) SetSmallSnake(v string) {
 
 // GetCapitalSnake returns the CapitalSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalSnake() string {
-	if o == nil || isNil(o.CapitalSnake) {
+	if o == nil || o.CapitalSnake == nil {
 		var ret string
 		return ret
 	}
@@ -150,15 +153,15 @@ func (o *Capitalization) GetCapitalSnake() string {
 // GetCapitalSnakeOk returns a tuple with the CapitalSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalSnakeOk() (*string, bool) {
-	if o == nil || isNil(o.CapitalSnake) {
-    return nil, false
+	if o == nil || o.CapitalSnake == nil {
+		return nil, false
 	}
 	return o.CapitalSnake, true
 }
 
 // HasCapitalSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalSnake() bool {
-	if o != nil && !isNil(o.CapitalSnake) {
+	if o != nil && o.CapitalSnake != nil {
 		return true
 	}
 
@@ -172,7 +175,7 @@ func (o *Capitalization) SetCapitalSnake(v string) {
 
 // GetSCAETHFlowPoints returns the SCAETHFlowPoints field value if set, zero value otherwise.
 func (o *Capitalization) GetSCAETHFlowPoints() string {
-	if o == nil || isNil(o.SCAETHFlowPoints) {
+	if o == nil || o.SCAETHFlowPoints == nil {
 		var ret string
 		return ret
 	}
@@ -182,15 +185,15 @@ func (o *Capitalization) GetSCAETHFlowPoints() string {
 // GetSCAETHFlowPointsOk returns a tuple with the SCAETHFlowPoints field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSCAETHFlowPointsOk() (*string, bool) {
-	if o == nil || isNil(o.SCAETHFlowPoints) {
-    return nil, false
+	if o == nil || o.SCAETHFlowPoints == nil {
+		return nil, false
 	}
 	return o.SCAETHFlowPoints, true
 }
 
 // HasSCAETHFlowPoints returns a boolean if a field has been set.
 func (o *Capitalization) HasSCAETHFlowPoints() bool {
-	if o != nil && !isNil(o.SCAETHFlowPoints) {
+	if o != nil && o.SCAETHFlowPoints != nil {
 		return true
 	}
 
@@ -204,7 +207,7 @@ func (o *Capitalization) SetSCAETHFlowPoints(v string) {
 
 // GetATT_NAME returns the ATT_NAME field value if set, zero value otherwise.
 func (o *Capitalization) GetATT_NAME() string {
-	if o == nil || isNil(o.ATT_NAME) {
+	if o == nil || o.ATT_NAME == nil {
 		var ret string
 		return ret
 	}
@@ -214,15 +217,15 @@ func (o *Capitalization) GetATT_NAME() string {
 // GetATT_NAMEOk returns a tuple with the ATT_NAME field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetATT_NAMEOk() (*string, bool) {
-	if o == nil || isNil(o.ATT_NAME) {
-    return nil, false
+	if o == nil || o.ATT_NAME == nil {
+		return nil, false
 	}
 	return o.ATT_NAME, true
 }
 
 // HasATT_NAME returns a boolean if a field has been set.
 func (o *Capitalization) HasATT_NAME() bool {
-	if o != nil && !isNil(o.ATT_NAME) {
+	if o != nil && o.ATT_NAME != nil {
 		return true
 	}
 
@@ -235,26 +238,31 @@ func (o *Capitalization) SetATT_NAME(v string) {
 }
 
 func (o Capitalization) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Capitalization) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.SmallCamel) {
-		toSerialize["smallCamel"] = o.SmallCamel
+	if o.SmallCamel != nil {
+		toSerialize["smallCamel"] = *o.SmallCamel
 	}
-	if !isNil(o.CapitalCamel) {
-		toSerialize["CapitalCamel"] = o.CapitalCamel
+	if o.CapitalCamel != nil {
+		toSerialize["CapitalCamel"] = *o.CapitalCamel
 	}
-	if !isNil(o.SmallSnake) {
-		toSerialize["small_Snake"] = o.SmallSnake
+	if o.SmallSnake != nil {
+		toSerialize["small_Snake"] = *o.SmallSnake
 	}
-	if !isNil(o.CapitalSnake) {
-		toSerialize["Capital_Snake"] = o.CapitalSnake
+	if o.CapitalSnake != nil {
+		toSerialize["Capital_Snake"] = *o.CapitalSnake
 	}
-	if !isNil(o.SCAETHFlowPoints) {
-		toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints
+	if o.SCAETHFlowPoints != nil {
+		toSerialize["SCA_ETH_Flow_Points"] = *o.SCAETHFlowPoints
 	}
-	if !isNil(o.ATT_NAME) {
-		toSerialize["ATT_NAME"] = o.ATT_NAME
+	if o.ATT_NAME != nil {
+		toSerialize["ATT_NAME"] = *o.ATT_NAME
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableCapitalization struct {
diff --git a/samples/client/petstore/go/go-petstore/model_cat.go b/samples/client/petstore/go/go-petstore/model_cat.go
index ed956db4ef6..1c9a9ad3fef 100644
--- a/samples/client/petstore/go/go-petstore/model_cat.go
+++ b/samples/client/petstore/go/go-petstore/model_cat.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Cat type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Cat{}
+
 // Cat struct for Cat
 type Cat struct {
 	Animal
@@ -42,7 +45,7 @@ func NewCatWithDefaults() *Cat {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *Cat) GetDeclawed() bool {
-	if o == nil || isNil(o.Declawed) {
+	if o == nil || o.Declawed == nil {
 		var ret bool
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *Cat) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Cat) GetDeclawedOk() (*bool, bool) {
-	if o == nil || isNil(o.Declawed) {
-    return nil, false
+	if o == nil || o.Declawed == nil {
+		return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *Cat) HasDeclawed() bool {
-	if o != nil && !isNil(o.Declawed) {
+	if o != nil && o.Declawed != nil {
 		return true
 	}
 
@@ -73,6 +76,11 @@ func (o *Cat) SetDeclawed(v bool) {
 }
 
 func (o Cat) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Cat) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
@@ -82,10 +90,10 @@ func (o Cat) MarshalJSON() ([]byte, error) {
 	if errAnimal != nil {
 		return []byte{}, errAnimal
 	}
-	if !isNil(o.Declawed) {
-		toSerialize["declawed"] = o.Declawed
+	if o.Declawed != nil {
+		toSerialize["declawed"] = *o.Declawed
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableCat struct {
diff --git a/samples/client/petstore/go/go-petstore/model_cat_all_of.go b/samples/client/petstore/go/go-petstore/model_cat_all_of.go
index 2ed2d917d6f..a0135f62932 100644
--- a/samples/client/petstore/go/go-petstore/model_cat_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_cat_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the CatAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &CatAllOf{}
+
 // CatAllOf struct for CatAllOf
 type CatAllOf struct {
 	Declawed *bool `json:"declawed,omitempty"`
@@ -38,7 +41,7 @@ func NewCatAllOfWithDefaults() *CatAllOf {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *CatAllOf) GetDeclawed() bool {
-	if o == nil || isNil(o.Declawed) {
+	if o == nil || o.Declawed == nil {
 		var ret bool
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *CatAllOf) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *CatAllOf) GetDeclawedOk() (*bool, bool) {
-	if o == nil || isNil(o.Declawed) {
-    return nil, false
+	if o == nil || o.Declawed == nil {
+		return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *CatAllOf) HasDeclawed() bool {
-	if o != nil && !isNil(o.Declawed) {
+	if o != nil && o.Declawed != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *CatAllOf) SetDeclawed(v bool) {
 }
 
 func (o CatAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o CatAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Declawed) {
-		toSerialize["declawed"] = o.Declawed
+	if o.Declawed != nil {
+		toSerialize["declawed"] = *o.Declawed
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableCatAllOf struct {
diff --git a/samples/client/petstore/go/go-petstore/model_category.go b/samples/client/petstore/go/go-petstore/model_category.go
index 5604617d913..65bf1213e51 100644
--- a/samples/client/petstore/go/go-petstore/model_category.go
+++ b/samples/client/petstore/go/go-petstore/model_category.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Category type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Category{}
+
 // Category struct for Category
 type Category struct {
 	Id *int64 `json:"id,omitempty"`
@@ -42,7 +45,7 @@ func NewCategoryWithDefaults() *Category {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Category) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *Category) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Category) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Category) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -86,7 +89,7 @@ func (o *Category) GetName() string {
 // and a boolean to check if the value has been set.
 func (o *Category) GetNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Name, true
 }
@@ -97,14 +100,19 @@ func (o *Category) SetName(v string) {
 }
 
 func (o Category) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Category) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
 	if true {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableCategory struct {
diff --git a/samples/client/petstore/go/go-petstore/model_class_model.go b/samples/client/petstore/go/go-petstore/model_class_model.go
index 2a0321a8b86..0c2743ef8a0 100644
--- a/samples/client/petstore/go/go-petstore/model_class_model.go
+++ b/samples/client/petstore/go/go-petstore/model_class_model.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ClassModel type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ClassModel{}
+
 // ClassModel Model for testing model with \"_class\" property
 type ClassModel struct {
 	Class *string `json:"_class,omitempty"`
@@ -38,7 +41,7 @@ func NewClassModelWithDefaults() *ClassModel {
 
 // GetClass returns the Class field value if set, zero value otherwise.
 func (o *ClassModel) GetClass() string {
-	if o == nil || isNil(o.Class) {
+	if o == nil || o.Class == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *ClassModel) GetClass() string {
 // GetClassOk returns a tuple with the Class field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ClassModel) GetClassOk() (*string, bool) {
-	if o == nil || isNil(o.Class) {
-    return nil, false
+	if o == nil || o.Class == nil {
+		return nil, false
 	}
 	return o.Class, true
 }
 
 // HasClass returns a boolean if a field has been set.
 func (o *ClassModel) HasClass() bool {
-	if o != nil && !isNil(o.Class) {
+	if o != nil && o.Class != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *ClassModel) SetClass(v string) {
 }
 
 func (o ClassModel) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ClassModel) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Class) {
-		toSerialize["_class"] = o.Class
+	if o.Class != nil {
+		toSerialize["_class"] = *o.Class
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableClassModel struct {
diff --git a/samples/client/petstore/go/go-petstore/model_client.go b/samples/client/petstore/go/go-petstore/model_client.go
index d975f74a5f3..f0dc6b41738 100644
--- a/samples/client/petstore/go/go-petstore/model_client.go
+++ b/samples/client/petstore/go/go-petstore/model_client.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Client type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Client{}
+
 // Client struct for Client
 type Client struct {
 	Client *string `json:"client,omitempty"`
@@ -69,11 +72,16 @@ func (o *Client) SetClient(v string) {
 }
 
 func (o Client) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Client) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Client) {
-		toSerialize["client"] = o.Client
+		toSerialize["client"] = *o.Client
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableClient struct {
diff --git a/samples/client/petstore/go/go-petstore/model_dog.go b/samples/client/petstore/go/go-petstore/model_dog.go
index d3d615a3b67..1180fb9efde 100644
--- a/samples/client/petstore/go/go-petstore/model_dog.go
+++ b/samples/client/petstore/go/go-petstore/model_dog.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Dog type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Dog{}
+
 // Dog struct for Dog
 type Dog struct {
 	Animal
@@ -42,7 +45,7 @@ func NewDogWithDefaults() *Dog {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *Dog) GetBreed() string {
-	if o == nil || isNil(o.Breed) {
+	if o == nil || o.Breed == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *Dog) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Dog) GetBreedOk() (*string, bool) {
-	if o == nil || isNil(o.Breed) {
-    return nil, false
+	if o == nil || o.Breed == nil {
+		return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *Dog) HasBreed() bool {
-	if o != nil && !isNil(o.Breed) {
+	if o != nil && o.Breed != nil {
 		return true
 	}
 
@@ -73,6 +76,11 @@ func (o *Dog) SetBreed(v string) {
 }
 
 func (o Dog) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Dog) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
@@ -82,10 +90,10 @@ func (o Dog) MarshalJSON() ([]byte, error) {
 	if errAnimal != nil {
 		return []byte{}, errAnimal
 	}
-	if !isNil(o.Breed) {
-		toSerialize["breed"] = o.Breed
+	if o.Breed != nil {
+		toSerialize["breed"] = *o.Breed
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableDog struct {
diff --git a/samples/client/petstore/go/go-petstore/model_dog_all_of.go b/samples/client/petstore/go/go-petstore/model_dog_all_of.go
index 5e6ee65d837..c31616fc129 100644
--- a/samples/client/petstore/go/go-petstore/model_dog_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_dog_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the DogAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &DogAllOf{}
+
 // DogAllOf struct for DogAllOf
 type DogAllOf struct {
 	Breed *string `json:"breed,omitempty"`
@@ -38,7 +41,7 @@ func NewDogAllOfWithDefaults() *DogAllOf {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *DogAllOf) GetBreed() string {
-	if o == nil || isNil(o.Breed) {
+	if o == nil || o.Breed == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *DogAllOf) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DogAllOf) GetBreedOk() (*string, bool) {
-	if o == nil || isNil(o.Breed) {
-    return nil, false
+	if o == nil || o.Breed == nil {
+		return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *DogAllOf) HasBreed() bool {
-	if o != nil && !isNil(o.Breed) {
+	if o != nil && o.Breed != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *DogAllOf) SetBreed(v string) {
 }
 
 func (o DogAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o DogAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Breed) {
-		toSerialize["breed"] = o.Breed
+	if o.Breed != nil {
+		toSerialize["breed"] = *o.Breed
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableDogAllOf struct {
diff --git a/samples/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/client/petstore/go/go-petstore/model_enum_arrays.go
index fb8f5c0c48f..c2727b8daf7 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_arrays.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_arrays.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the EnumArrays type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &EnumArrays{}
+
 // EnumArrays struct for EnumArrays
 type EnumArrays struct {
 	JustSymbol *string `json:"just_symbol,omitempty"`
@@ -39,7 +42,7 @@ func NewEnumArraysWithDefaults() *EnumArrays {
 
 // GetJustSymbol returns the JustSymbol field value if set, zero value otherwise.
 func (o *EnumArrays) GetJustSymbol() string {
-	if o == nil || isNil(o.JustSymbol) {
+	if o == nil || o.JustSymbol == nil {
 		var ret string
 		return ret
 	}
@@ -49,15 +52,15 @@ func (o *EnumArrays) GetJustSymbol() string {
 // GetJustSymbolOk returns a tuple with the JustSymbol field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetJustSymbolOk() (*string, bool) {
-	if o == nil || isNil(o.JustSymbol) {
-    return nil, false
+	if o == nil || o.JustSymbol == nil {
+		return nil, false
 	}
 	return o.JustSymbol, true
 }
 
 // HasJustSymbol returns a boolean if a field has been set.
 func (o *EnumArrays) HasJustSymbol() bool {
-	if o != nil && !isNil(o.JustSymbol) {
+	if o != nil && o.JustSymbol != nil {
 		return true
 	}
 
@@ -71,7 +74,7 @@ func (o *EnumArrays) SetJustSymbol(v string) {
 
 // GetArrayEnum returns the ArrayEnum field value if set, zero value otherwise.
 func (o *EnumArrays) GetArrayEnum() []string {
-	if o == nil || isNil(o.ArrayEnum) {
+	if o == nil || o.ArrayEnum == nil {
 		var ret []string
 		return ret
 	}
@@ -81,15 +84,15 @@ func (o *EnumArrays) GetArrayEnum() []string {
 // GetArrayEnumOk returns a tuple with the ArrayEnum field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetArrayEnumOk() ([]string, bool) {
-	if o == nil || isNil(o.ArrayEnum) {
-    return nil, false
+	if o == nil || o.ArrayEnum == nil {
+		return nil, false
 	}
 	return o.ArrayEnum, true
 }
 
 // HasArrayEnum returns a boolean if a field has been set.
 func (o *EnumArrays) HasArrayEnum() bool {
-	if o != nil && !isNil(o.ArrayEnum) {
+	if o != nil && o.ArrayEnum != nil {
 		return true
 	}
 
@@ -102,14 +105,19 @@ func (o *EnumArrays) SetArrayEnum(v []string) {
 }
 
 func (o EnumArrays) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o EnumArrays) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.JustSymbol) {
-		toSerialize["just_symbol"] = o.JustSymbol
+	if o.JustSymbol != nil {
+		toSerialize["just_symbol"] = *o.JustSymbol
 	}
-	if !isNil(o.ArrayEnum) {
-		toSerialize["array_enum"] = o.ArrayEnum
+	if o.ArrayEnum != nil {
+		toSerialize["array_enum"] = *o.ArrayEnum
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableEnumArrays struct {
diff --git a/samples/client/petstore/go/go-petstore/model_enum_test_.go b/samples/client/petstore/go/go-petstore/model_enum_test_.go
index 3daa3c62be9..f07dd6ca950 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the EnumTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &EnumTest{}
+
 // EnumTest struct for EnumTest
 type EnumTest struct {
 	EnumString *string `json:"enum_string,omitempty"`
@@ -43,7 +46,7 @@ func NewEnumTestWithDefaults() *EnumTest {
 
 // GetEnumString returns the EnumString field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumString() string {
-	if o == nil || isNil(o.EnumString) {
+	if o == nil || o.EnumString == nil {
 		var ret string
 		return ret
 	}
@@ -53,15 +56,15 @@ func (o *EnumTest) GetEnumString() string {
 // GetEnumStringOk returns a tuple with the EnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringOk() (*string, bool) {
-	if o == nil || isNil(o.EnumString) {
-    return nil, false
+	if o == nil || o.EnumString == nil {
+		return nil, false
 	}
 	return o.EnumString, true
 }
 
 // HasEnumString returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumString() bool {
-	if o != nil && !isNil(o.EnumString) {
+	if o != nil && o.EnumString != nil {
 		return true
 	}
 
@@ -87,7 +90,7 @@ func (o *EnumTest) GetEnumStringRequired() string {
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringRequiredOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.EnumStringRequired, true
 }
@@ -99,7 +102,7 @@ func (o *EnumTest) SetEnumStringRequired(v string) {
 
 // GetEnumInteger returns the EnumInteger field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumInteger() int32 {
-	if o == nil || isNil(o.EnumInteger) {
+	if o == nil || o.EnumInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -109,15 +112,15 @@ func (o *EnumTest) GetEnumInteger() int32 {
 // GetEnumIntegerOk returns a tuple with the EnumInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.EnumInteger) {
-    return nil, false
+	if o == nil || o.EnumInteger == nil {
+		return nil, false
 	}
 	return o.EnumInteger, true
 }
 
 // HasEnumInteger returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumInteger() bool {
-	if o != nil && !isNil(o.EnumInteger) {
+	if o != nil && o.EnumInteger != nil {
 		return true
 	}
 
@@ -131,7 +134,7 @@ func (o *EnumTest) SetEnumInteger(v int32) {
 
 // GetEnumNumber returns the EnumNumber field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumNumber() float64 {
-	if o == nil || isNil(o.EnumNumber) {
+	if o == nil || o.EnumNumber == nil {
 		var ret float64
 		return ret
 	}
@@ -141,15 +144,15 @@ func (o *EnumTest) GetEnumNumber() float64 {
 // GetEnumNumberOk returns a tuple with the EnumNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumNumberOk() (*float64, bool) {
-	if o == nil || isNil(o.EnumNumber) {
-    return nil, false
+	if o == nil || o.EnumNumber == nil {
+		return nil, false
 	}
 	return o.EnumNumber, true
 }
 
 // HasEnumNumber returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumNumber() bool {
-	if o != nil && !isNil(o.EnumNumber) {
+	if o != nil && o.EnumNumber != nil {
 		return true
 	}
 
@@ -163,7 +166,7 @@ func (o *EnumTest) SetEnumNumber(v float64) {
 
 // GetOuterEnum returns the OuterEnum field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnum() OuterEnum {
-	if o == nil || isNil(o.OuterEnum) {
+	if o == nil || o.OuterEnum == nil {
 		var ret OuterEnum
 		return ret
 	}
@@ -173,15 +176,15 @@ func (o *EnumTest) GetOuterEnum() OuterEnum {
 // GetOuterEnumOk returns a tuple with the OuterEnum field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumOk() (*OuterEnum, bool) {
-	if o == nil || isNil(o.OuterEnum) {
-    return nil, false
+	if o == nil || o.OuterEnum == nil {
+		return nil, false
 	}
 	return o.OuterEnum, true
 }
 
 // HasOuterEnum returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnum() bool {
-	if o != nil && !isNil(o.OuterEnum) {
+	if o != nil && o.OuterEnum != nil {
 		return true
 	}
 
@@ -194,23 +197,28 @@ func (o *EnumTest) SetOuterEnum(v OuterEnum) {
 }
 
 func (o EnumTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o EnumTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.EnumString) {
-		toSerialize["enum_string"] = o.EnumString
+	if o.EnumString != nil {
+		toSerialize["enum_string"] = *o.EnumString
 	}
 	if true {
-		toSerialize["enum_string_required"] = o.EnumStringRequired
+		toSerialize["enum_string_required"] = *o.EnumStringRequired
 	}
-	if !isNil(o.EnumInteger) {
-		toSerialize["enum_integer"] = o.EnumInteger
+	if o.EnumInteger != nil {
+		toSerialize["enum_integer"] = *o.EnumInteger
 	}
-	if !isNil(o.EnumNumber) {
-		toSerialize["enum_number"] = o.EnumNumber
+	if o.EnumNumber != nil {
+		toSerialize["enum_number"] = *o.EnumNumber
 	}
-	if !isNil(o.OuterEnum) {
-		toSerialize["outerEnum"] = o.OuterEnum
+	if o.OuterEnum != nil {
+		toSerialize["outerEnum"] = *o.OuterEnum
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableEnumTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_file.go b/samples/client/petstore/go/go-petstore/model_file.go
index 900282eb6f0..ee59c77788a 100644
--- a/samples/client/petstore/go/go-petstore/model_file.go
+++ b/samples/client/petstore/go/go-petstore/model_file.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the File type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &File{}
+
 // File Must be named `File` for test.
 type File struct {
 	// Test capitalization
@@ -39,7 +42,7 @@ func NewFileWithDefaults() *File {
 
 // GetSourceURI returns the SourceURI field value if set, zero value otherwise.
 func (o *File) GetSourceURI() string {
-	if o == nil || isNil(o.SourceURI) {
+	if o == nil || o.SourceURI == nil {
 		var ret string
 		return ret
 	}
@@ -49,15 +52,15 @@ func (o *File) GetSourceURI() string {
 // GetSourceURIOk returns a tuple with the SourceURI field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *File) GetSourceURIOk() (*string, bool) {
-	if o == nil || isNil(o.SourceURI) {
-    return nil, false
+	if o == nil || o.SourceURI == nil {
+		return nil, false
 	}
 	return o.SourceURI, true
 }
 
 // HasSourceURI returns a boolean if a field has been set.
 func (o *File) HasSourceURI() bool {
-	if o != nil && !isNil(o.SourceURI) {
+	if o != nil && o.SourceURI != nil {
 		return true
 	}
 
@@ -70,11 +73,16 @@ func (o *File) SetSourceURI(v string) {
 }
 
 func (o File) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o File) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.SourceURI) {
-		toSerialize["sourceURI"] = o.SourceURI
+	if o.SourceURI != nil {
+		toSerialize["sourceURI"] = *o.SourceURI
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableFile struct {
diff --git a/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
index bdca1597b4d..c047aac8348 100644
--- a/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
+++ b/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the FileSchemaTestClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FileSchemaTestClass{}
+
 // FileSchemaTestClass struct for FileSchemaTestClass
 type FileSchemaTestClass struct {
 	File *File `json:"file,omitempty"`
@@ -39,7 +42,7 @@ func NewFileSchemaTestClassWithDefaults() *FileSchemaTestClass {
 
 // GetFile returns the File field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFile() File {
-	if o == nil || isNil(o.File) {
+	if o == nil || o.File == nil {
 		var ret File
 		return ret
 	}
@@ -49,15 +52,15 @@ func (o *FileSchemaTestClass) GetFile() File {
 // GetFileOk returns a tuple with the File field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFileOk() (*File, bool) {
-	if o == nil || isNil(o.File) {
-    return nil, false
+	if o == nil || o.File == nil {
+		return nil, false
 	}
 	return o.File, true
 }
 
 // HasFile returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFile() bool {
-	if o != nil && !isNil(o.File) {
+	if o != nil && o.File != nil {
 		return true
 	}
 
@@ -71,7 +74,7 @@ func (o *FileSchemaTestClass) SetFile(v File) {
 
 // GetFiles returns the Files field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFiles() []File {
-	if o == nil || isNil(o.Files) {
+	if o == nil || o.Files == nil {
 		var ret []File
 		return ret
 	}
@@ -81,15 +84,15 @@ func (o *FileSchemaTestClass) GetFiles() []File {
 // GetFilesOk returns a tuple with the Files field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFilesOk() ([]File, bool) {
-	if o == nil || isNil(o.Files) {
-    return nil, false
+	if o == nil || o.Files == nil {
+		return nil, false
 	}
 	return o.Files, true
 }
 
 // HasFiles returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFiles() bool {
-	if o != nil && !isNil(o.Files) {
+	if o != nil && o.Files != nil {
 		return true
 	}
 
@@ -102,14 +105,19 @@ func (o *FileSchemaTestClass) SetFiles(v []File) {
 }
 
 func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o FileSchemaTestClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.File) {
-		toSerialize["file"] = o.File
+	if o.File != nil {
+		toSerialize["file"] = *o.File
 	}
-	if !isNil(o.Files) {
-		toSerialize["files"] = o.Files
+	if o.Files != nil {
+		toSerialize["files"] = *o.Files
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableFileSchemaTestClass struct {
diff --git a/samples/client/petstore/go/go-petstore/model_format_test_.go b/samples/client/petstore/go/go-petstore/model_format_test_.go
index a8484f5ac34..77a69bc0b10 100644
--- a/samples/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_format_test_.go
@@ -16,6 +16,9 @@ import (
 	"time"
 )
 
+// checks if the FormatTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FormatTest{}
+
 // FormatTest struct for FormatTest
 type FormatTest struct {
 	Integer *int32 `json:"integer,omitempty"`
@@ -57,7 +60,7 @@ func NewFormatTestWithDefaults() *FormatTest {
 
 // GetInteger returns the Integer field value if set, zero value otherwise.
 func (o *FormatTest) GetInteger() int32 {
-	if o == nil || isNil(o.Integer) {
+	if o == nil || o.Integer == nil {
 		var ret int32
 		return ret
 	}
@@ -67,15 +70,15 @@ func (o *FormatTest) GetInteger() int32 {
 // GetIntegerOk returns a tuple with the Integer field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.Integer) {
-    return nil, false
+	if o == nil || o.Integer == nil {
+		return nil, false
 	}
 	return o.Integer, true
 }
 
 // HasInteger returns a boolean if a field has been set.
 func (o *FormatTest) HasInteger() bool {
-	if o != nil && !isNil(o.Integer) {
+	if o != nil && o.Integer != nil {
 		return true
 	}
 
@@ -89,7 +92,7 @@ func (o *FormatTest) SetInteger(v int32) {
 
 // GetInt32 returns the Int32 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt32() int32 {
-	if o == nil || isNil(o.Int32) {
+	if o == nil || o.Int32 == nil {
 		var ret int32
 		return ret
 	}
@@ -99,15 +102,15 @@ func (o *FormatTest) GetInt32() int32 {
 // GetInt32Ok returns a tuple with the Int32 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt32Ok() (*int32, bool) {
-	if o == nil || isNil(o.Int32) {
-    return nil, false
+	if o == nil || o.Int32 == nil {
+		return nil, false
 	}
 	return o.Int32, true
 }
 
 // HasInt32 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt32() bool {
-	if o != nil && !isNil(o.Int32) {
+	if o != nil && o.Int32 != nil {
 		return true
 	}
 
@@ -121,7 +124,7 @@ func (o *FormatTest) SetInt32(v int32) {
 
 // GetInt64 returns the Int64 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt64() int64 {
-	if o == nil || isNil(o.Int64) {
+	if o == nil || o.Int64 == nil {
 		var ret int64
 		return ret
 	}
@@ -131,15 +134,15 @@ func (o *FormatTest) GetInt64() int64 {
 // GetInt64Ok returns a tuple with the Int64 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt64Ok() (*int64, bool) {
-	if o == nil || isNil(o.Int64) {
-    return nil, false
+	if o == nil || o.Int64 == nil {
+		return nil, false
 	}
 	return o.Int64, true
 }
 
 // HasInt64 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt64() bool {
-	if o != nil && !isNil(o.Int64) {
+	if o != nil && o.Int64 != nil {
 		return true
 	}
 
@@ -165,7 +168,7 @@ func (o *FormatTest) GetNumber() float32 {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetNumberOk() (*float32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Number, true
 }
@@ -177,7 +180,7 @@ func (o *FormatTest) SetNumber(v float32) {
 
 // GetFloat returns the Float field value if set, zero value otherwise.
 func (o *FormatTest) GetFloat() float32 {
-	if o == nil || isNil(o.Float) {
+	if o == nil || o.Float == nil {
 		var ret float32
 		return ret
 	}
@@ -187,15 +190,15 @@ func (o *FormatTest) GetFloat() float32 {
 // GetFloatOk returns a tuple with the Float field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetFloatOk() (*float32, bool) {
-	if o == nil || isNil(o.Float) {
-    return nil, false
+	if o == nil || o.Float == nil {
+		return nil, false
 	}
 	return o.Float, true
 }
 
 // HasFloat returns a boolean if a field has been set.
 func (o *FormatTest) HasFloat() bool {
-	if o != nil && !isNil(o.Float) {
+	if o != nil && o.Float != nil {
 		return true
 	}
 
@@ -209,7 +212,7 @@ func (o *FormatTest) SetFloat(v float32) {
 
 // GetDouble returns the Double field value if set, zero value otherwise.
 func (o *FormatTest) GetDouble() float64 {
-	if o == nil || isNil(o.Double) {
+	if o == nil || o.Double == nil {
 		var ret float64
 		return ret
 	}
@@ -219,15 +222,15 @@ func (o *FormatTest) GetDouble() float64 {
 // GetDoubleOk returns a tuple with the Double field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDoubleOk() (*float64, bool) {
-	if o == nil || isNil(o.Double) {
-    return nil, false
+	if o == nil || o.Double == nil {
+		return nil, false
 	}
 	return o.Double, true
 }
 
 // HasDouble returns a boolean if a field has been set.
 func (o *FormatTest) HasDouble() bool {
-	if o != nil && !isNil(o.Double) {
+	if o != nil && o.Double != nil {
 		return true
 	}
 
@@ -241,7 +244,7 @@ func (o *FormatTest) SetDouble(v float64) {
 
 // GetString returns the String field value if set, zero value otherwise.
 func (o *FormatTest) GetString() string {
-	if o == nil || isNil(o.String) {
+	if o == nil || o.String == nil {
 		var ret string
 		return ret
 	}
@@ -251,15 +254,15 @@ func (o *FormatTest) GetString() string {
 // GetStringOk returns a tuple with the String field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetStringOk() (*string, bool) {
-	if o == nil || isNil(o.String) {
-    return nil, false
+	if o == nil || o.String == nil {
+		return nil, false
 	}
 	return o.String, true
 }
 
 // HasString returns a boolean if a field has been set.
 func (o *FormatTest) HasString() bool {
-	if o != nil && !isNil(o.String) {
+	if o != nil && o.String != nil {
 		return true
 	}
 
@@ -285,7 +288,7 @@ func (o *FormatTest) GetByte() string {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetByteOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Byte, true
 }
@@ -297,7 +300,7 @@ func (o *FormatTest) SetByte(v string) {
 
 // GetBinary returns the Binary field value if set, zero value otherwise.
 func (o *FormatTest) GetBinary() *os.File {
-	if o == nil || isNil(o.Binary) {
+	if o == nil || o.Binary == nil {
 		var ret *os.File
 		return ret
 	}
@@ -307,15 +310,15 @@ func (o *FormatTest) GetBinary() *os.File {
 // GetBinaryOk returns a tuple with the Binary field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetBinaryOk() (**os.File, bool) {
-	if o == nil || isNil(o.Binary) {
-    return nil, false
+	if o == nil || o.Binary == nil {
+		return nil, false
 	}
 	return o.Binary, true
 }
 
 // HasBinary returns a boolean if a field has been set.
 func (o *FormatTest) HasBinary() bool {
-	if o != nil && !isNil(o.Binary) {
+	if o != nil && o.Binary != nil {
 		return true
 	}
 
@@ -341,7 +344,7 @@ func (o *FormatTest) GetDate() string {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Date, true
 }
@@ -353,7 +356,7 @@ func (o *FormatTest) SetDate(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *FormatTest) GetDateTime() time.Time {
-	if o == nil || isNil(o.DateTime) {
+	if o == nil || o.DateTime == nil {
 		var ret time.Time
 		return ret
 	}
@@ -363,15 +366,15 @@ func (o *FormatTest) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || isNil(o.DateTime) {
-    return nil, false
+	if o == nil || o.DateTime == nil {
+		return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *FormatTest) HasDateTime() bool {
-	if o != nil && !isNil(o.DateTime) {
+	if o != nil && o.DateTime != nil {
 		return true
 	}
 
@@ -385,7 +388,7 @@ func (o *FormatTest) SetDateTime(v time.Time) {
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *FormatTest) GetUuid() string {
-	if o == nil || isNil(o.Uuid) {
+	if o == nil || o.Uuid == nil {
 		var ret string
 		return ret
 	}
@@ -395,15 +398,15 @@ func (o *FormatTest) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetUuidOk() (*string, bool) {
-	if o == nil || isNil(o.Uuid) {
-    return nil, false
+	if o == nil || o.Uuid == nil {
+		return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *FormatTest) HasUuid() bool {
-	if o != nil && !isNil(o.Uuid) {
+	if o != nil && o.Uuid != nil {
 		return true
 	}
 
@@ -429,7 +432,7 @@ func (o *FormatTest) GetPassword() string {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPasswordOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Password, true
 }
@@ -441,7 +444,7 @@ func (o *FormatTest) SetPassword(v string) {
 
 // GetBigDecimal returns the BigDecimal field value if set, zero value otherwise.
 func (o *FormatTest) GetBigDecimal() float64 {
-	if o == nil || isNil(o.BigDecimal) {
+	if o == nil || o.BigDecimal == nil {
 		var ret float64
 		return ret
 	}
@@ -451,15 +454,15 @@ func (o *FormatTest) GetBigDecimal() float64 {
 // GetBigDecimalOk returns a tuple with the BigDecimal field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetBigDecimalOk() (*float64, bool) {
-	if o == nil || isNil(o.BigDecimal) {
-    return nil, false
+	if o == nil || o.BigDecimal == nil {
+		return nil, false
 	}
 	return o.BigDecimal, true
 }
 
 // HasBigDecimal returns a boolean if a field has been set.
 func (o *FormatTest) HasBigDecimal() bool {
-	if o != nil && !isNil(o.BigDecimal) {
+	if o != nil && o.BigDecimal != nil {
 		return true
 	}
 
@@ -472,50 +475,55 @@ func (o *FormatTest) SetBigDecimal(v float64) {
 }
 
 func (o FormatTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o FormatTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Integer) {
-		toSerialize["integer"] = o.Integer
+	if o.Integer != nil {
+		toSerialize["integer"] = *o.Integer
 	}
-	if !isNil(o.Int32) {
-		toSerialize["int32"] = o.Int32
+	if o.Int32 != nil {
+		toSerialize["int32"] = *o.Int32
 	}
-	if !isNil(o.Int64) {
-		toSerialize["int64"] = o.Int64
+	if o.Int64 != nil {
+		toSerialize["int64"] = *o.Int64
 	}
 	if true {
-		toSerialize["number"] = o.Number
+		toSerialize["number"] = *o.Number
 	}
-	if !isNil(o.Float) {
-		toSerialize["float"] = o.Float
+	if o.Float != nil {
+		toSerialize["float"] = *o.Float
 	}
-	if !isNil(o.Double) {
-		toSerialize["double"] = o.Double
+	if o.Double != nil {
+		toSerialize["double"] = *o.Double
 	}
-	if !isNil(o.String) {
-		toSerialize["string"] = o.String
+	if o.String != nil {
+		toSerialize["string"] = *o.String
 	}
 	if true {
-		toSerialize["byte"] = o.Byte
+		toSerialize["byte"] = *o.Byte
 	}
-	if !isNil(o.Binary) {
-		toSerialize["binary"] = o.Binary
+	if o.Binary != nil {
+		toSerialize["binary"] = *o.Binary
 	}
 	if true {
-		toSerialize["date"] = o.Date
+		toSerialize["date"] = *o.Date
 	}
-	if !isNil(o.DateTime) {
-		toSerialize["dateTime"] = o.DateTime
+	if o.DateTime != nil {
+		toSerialize["dateTime"] = *o.DateTime
 	}
-	if !isNil(o.Uuid) {
-		toSerialize["uuid"] = o.Uuid
+	if o.Uuid != nil {
+		toSerialize["uuid"] = *o.Uuid
 	}
 	if true {
-		toSerialize["password"] = o.Password
+		toSerialize["password"] = *o.Password
 	}
-	if !isNil(o.BigDecimal) {
-		toSerialize["BigDecimal"] = o.BigDecimal
+	if o.BigDecimal != nil {
+		toSerialize["BigDecimal"] = *o.BigDecimal
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableFormatTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
index b197ab04e30..b051916c891 100644
--- a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
+++ b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the HasOnlyReadOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &HasOnlyReadOnly{}
+
 // HasOnlyReadOnly struct for HasOnlyReadOnly
 type HasOnlyReadOnly struct {
 	Bar *string `json:"bar,omitempty"`
@@ -39,7 +42,7 @@ func NewHasOnlyReadOnlyWithDefaults() *HasOnlyReadOnly {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetBar() string {
-	if o == nil || isNil(o.Bar) {
+	if o == nil || o.Bar == nil {
 		var ret string
 		return ret
 	}
@@ -49,15 +52,15 @@ func (o *HasOnlyReadOnly) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetBarOk() (*string, bool) {
-	if o == nil || isNil(o.Bar) {
-    return nil, false
+	if o == nil || o.Bar == nil {
+		return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasBar() bool {
-	if o != nil && !isNil(o.Bar) {
+	if o != nil && o.Bar != nil {
 		return true
 	}
 
@@ -71,7 +74,7 @@ func (o *HasOnlyReadOnly) SetBar(v string) {
 
 // GetFoo returns the Foo field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetFoo() string {
-	if o == nil || isNil(o.Foo) {
+	if o == nil || o.Foo == nil {
 		var ret string
 		return ret
 	}
@@ -81,15 +84,15 @@ func (o *HasOnlyReadOnly) GetFoo() string {
 // GetFooOk returns a tuple with the Foo field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetFooOk() (*string, bool) {
-	if o == nil || isNil(o.Foo) {
-    return nil, false
+	if o == nil || o.Foo == nil {
+		return nil, false
 	}
 	return o.Foo, true
 }
 
 // HasFoo returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasFoo() bool {
-	if o != nil && !isNil(o.Foo) {
+	if o != nil && o.Foo != nil {
 		return true
 	}
 
@@ -102,14 +105,19 @@ func (o *HasOnlyReadOnly) SetFoo(v string) {
 }
 
 func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o HasOnlyReadOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Bar) {
-		toSerialize["bar"] = o.Bar
+	if o.Bar != nil {
+		toSerialize["bar"] = *o.Bar
 	}
-	if !isNil(o.Foo) {
-		toSerialize["foo"] = o.Foo
+	if o.Foo != nil {
+		toSerialize["foo"] = *o.Foo
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableHasOnlyReadOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_list.go b/samples/client/petstore/go/go-petstore/model_list.go
index ee55ad221f7..db9fbabf794 100644
--- a/samples/client/petstore/go/go-petstore/model_list.go
+++ b/samples/client/petstore/go/go-petstore/model_list.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the List type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &List{}
+
 // List struct for List
 type List struct {
 	Var123List *string `json:"123-list,omitempty"`
@@ -38,7 +41,7 @@ func NewListWithDefaults() *List {
 
 // GetVar123List returns the Var123List field value if set, zero value otherwise.
 func (o *List) GetVar123List() string {
-	if o == nil || isNil(o.Var123List) {
+	if o == nil || o.Var123List == nil {
 		var ret string
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *List) GetVar123List() string {
 // GetVar123ListOk returns a tuple with the Var123List field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *List) GetVar123ListOk() (*string, bool) {
-	if o == nil || isNil(o.Var123List) {
-    return nil, false
+	if o == nil || o.Var123List == nil {
+		return nil, false
 	}
 	return o.Var123List, true
 }
 
 // HasVar123List returns a boolean if a field has been set.
 func (o *List) HasVar123List() bool {
-	if o != nil && !isNil(o.Var123List) {
+	if o != nil && o.Var123List != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *List) SetVar123List(v string) {
 }
 
 func (o List) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o List) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Var123List) {
-		toSerialize["123-list"] = o.Var123List
+	if o.Var123List != nil {
+		toSerialize["123-list"] = *o.Var123List
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableList struct {
diff --git a/samples/client/petstore/go/go-petstore/model_map_test_.go b/samples/client/petstore/go/go-petstore/model_map_test_.go
index 5fa142fe20c..cb4b8f86278 100644
--- a/samples/client/petstore/go/go-petstore/model_map_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_map_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the MapTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &MapTest{}
+
 // MapTest struct for MapTest
 type MapTest struct {
 	MapMapOfString *map[string]map[string]string `json:"map_map_of_string,omitempty"`
@@ -41,7 +44,7 @@ func NewMapTestWithDefaults() *MapTest {
 
 // GetMapMapOfString returns the MapMapOfString field value if set, zero value otherwise.
 func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
-	if o == nil || isNil(o.MapMapOfString) {
+	if o == nil || o.MapMapOfString == nil {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
 // GetMapMapOfStringOk returns a tuple with the MapMapOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapMapOfStringOk() (*map[string]map[string]string, bool) {
-	if o == nil || isNil(o.MapMapOfString) {
-    return nil, false
+	if o == nil || o.MapMapOfString == nil {
+		return nil, false
 	}
 	return o.MapMapOfString, true
 }
 
 // HasMapMapOfString returns a boolean if a field has been set.
 func (o *MapTest) HasMapMapOfString() bool {
-	if o != nil && !isNil(o.MapMapOfString) {
+	if o != nil && o.MapMapOfString != nil {
 		return true
 	}
 
@@ -73,7 +76,7 @@ func (o *MapTest) SetMapMapOfString(v map[string]map[string]string) {
 
 // GetMapOfEnumString returns the MapOfEnumString field value if set, zero value otherwise.
 func (o *MapTest) GetMapOfEnumString() map[string]string {
-	if o == nil || isNil(o.MapOfEnumString) {
+	if o == nil || o.MapOfEnumString == nil {
 		var ret map[string]string
 		return ret
 	}
@@ -83,15 +86,15 @@ func (o *MapTest) GetMapOfEnumString() map[string]string {
 // GetMapOfEnumStringOk returns a tuple with the MapOfEnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapOfEnumStringOk() (*map[string]string, bool) {
-	if o == nil || isNil(o.MapOfEnumString) {
-    return nil, false
+	if o == nil || o.MapOfEnumString == nil {
+		return nil, false
 	}
 	return o.MapOfEnumString, true
 }
 
 // HasMapOfEnumString returns a boolean if a field has been set.
 func (o *MapTest) HasMapOfEnumString() bool {
-	if o != nil && !isNil(o.MapOfEnumString) {
+	if o != nil && o.MapOfEnumString != nil {
 		return true
 	}
 
@@ -105,7 +108,7 @@ func (o *MapTest) SetMapOfEnumString(v map[string]string) {
 
 // GetDirectMap returns the DirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetDirectMap() map[string]bool {
-	if o == nil || isNil(o.DirectMap) {
+	if o == nil || o.DirectMap == nil {
 		var ret map[string]bool
 		return ret
 	}
@@ -115,15 +118,15 @@ func (o *MapTest) GetDirectMap() map[string]bool {
 // GetDirectMapOk returns a tuple with the DirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetDirectMapOk() (*map[string]bool, bool) {
-	if o == nil || isNil(o.DirectMap) {
-    return nil, false
+	if o == nil || o.DirectMap == nil {
+		return nil, false
 	}
 	return o.DirectMap, true
 }
 
 // HasDirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasDirectMap() bool {
-	if o != nil && !isNil(o.DirectMap) {
+	if o != nil && o.DirectMap != nil {
 		return true
 	}
 
@@ -137,7 +140,7 @@ func (o *MapTest) SetDirectMap(v map[string]bool) {
 
 // GetIndirectMap returns the IndirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetIndirectMap() map[string]bool {
-	if o == nil || isNil(o.IndirectMap) {
+	if o == nil || o.IndirectMap == nil {
 		var ret map[string]bool
 		return ret
 	}
@@ -147,15 +150,15 @@ func (o *MapTest) GetIndirectMap() map[string]bool {
 // GetIndirectMapOk returns a tuple with the IndirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetIndirectMapOk() (*map[string]bool, bool) {
-	if o == nil || isNil(o.IndirectMap) {
-    return nil, false
+	if o == nil || o.IndirectMap == nil {
+		return nil, false
 	}
 	return o.IndirectMap, true
 }
 
 // HasIndirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasIndirectMap() bool {
-	if o != nil && !isNil(o.IndirectMap) {
+	if o != nil && o.IndirectMap != nil {
 		return true
 	}
 
@@ -168,20 +171,25 @@ func (o *MapTest) SetIndirectMap(v map[string]bool) {
 }
 
 func (o MapTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o MapTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.MapMapOfString) {
-		toSerialize["map_map_of_string"] = o.MapMapOfString
+	if o.MapMapOfString != nil {
+		toSerialize["map_map_of_string"] = *o.MapMapOfString
 	}
-	if !isNil(o.MapOfEnumString) {
-		toSerialize["map_of_enum_string"] = o.MapOfEnumString
+	if o.MapOfEnumString != nil {
+		toSerialize["map_of_enum_string"] = *o.MapOfEnumString
 	}
-	if !isNil(o.DirectMap) {
-		toSerialize["direct_map"] = o.DirectMap
+	if o.DirectMap != nil {
+		toSerialize["direct_map"] = *o.DirectMap
 	}
-	if !isNil(o.IndirectMap) {
-		toSerialize["indirect_map"] = o.IndirectMap
+	if o.IndirectMap != nil {
+		toSerialize["indirect_map"] = *o.IndirectMap
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableMapTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
index b56557d28a0..426b09d2c55 100644
--- a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
+++ b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
@@ -15,6 +15,9 @@ import (
 	"time"
 )
 
+// checks if the MixedPropertiesAndAdditionalPropertiesClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &MixedPropertiesAndAdditionalPropertiesClass{}
+
 // MixedPropertiesAndAdditionalPropertiesClass struct for MixedPropertiesAndAdditionalPropertiesClass
 type MixedPropertiesAndAdditionalPropertiesClass struct {
 	Uuid *string `json:"uuid,omitempty"`
@@ -41,7 +44,7 @@ func NewMixedPropertiesAndAdditionalPropertiesClassWithDefaults() *MixedProperti
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
-	if o == nil || isNil(o.Uuid) {
+	if o == nil || o.Uuid == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuidOk() (*string, bool) {
-	if o == nil || isNil(o.Uuid) {
-    return nil, false
+	if o == nil || o.Uuid == nil {
+		return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasUuid() bool {
-	if o != nil && !isNil(o.Uuid) {
+	if o != nil && o.Uuid != nil {
 		return true
 	}
 
@@ -73,7 +76,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetUuid(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
-	if o == nil || isNil(o.DateTime) {
+	if o == nil || o.DateTime == nil {
 		var ret time.Time
 		return ret
 	}
@@ -83,15 +86,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || isNil(o.DateTime) {
-    return nil, false
+	if o == nil || o.DateTime == nil {
+		return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasDateTime() bool {
-	if o != nil && !isNil(o.DateTime) {
+	if o != nil && o.DateTime != nil {
 		return true
 	}
 
@@ -105,7 +108,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetDateTime(v time.Time) {
 
 // GetMap returns the Map field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal {
-	if o == nil || isNil(o.Map) {
+	if o == nil || o.Map == nil {
 		var ret map[string]Animal
 		return ret
 	}
@@ -115,15 +118,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal
 // GetMapOk returns a tuple with the Map field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMapOk() (*map[string]Animal, bool) {
-	if o == nil || isNil(o.Map) {
-    return nil, false
+	if o == nil || o.Map == nil {
+		return nil, false
 	}
 	return o.Map, true
 }
 
 // HasMap returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasMap() bool {
-	if o != nil && !isNil(o.Map) {
+	if o != nil && o.Map != nil {
 		return true
 	}
 
@@ -136,17 +139,22 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetMap(v map[string]Animal
 }
 
 func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Uuid) {
-		toSerialize["uuid"] = o.Uuid
+	if o.Uuid != nil {
+		toSerialize["uuid"] = *o.Uuid
 	}
-	if !isNil(o.DateTime) {
-		toSerialize["dateTime"] = o.DateTime
+	if o.DateTime != nil {
+		toSerialize["dateTime"] = *o.DateTime
 	}
-	if !isNil(o.Map) {
-		toSerialize["map"] = o.Map
+	if o.Map != nil {
+		toSerialize["map"] = *o.Map
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableMixedPropertiesAndAdditionalPropertiesClass struct {
diff --git a/samples/client/petstore/go/go-petstore/model_name.go b/samples/client/petstore/go/go-petstore/model_name.go
index 98d098343b1..7c5140c31b1 100644
--- a/samples/client/petstore/go/go-petstore/model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_name.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Name type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Name{}
+
 // Name Model for testing model name same as property name
 type Name struct {
 	Name int32 `json:"name"`
@@ -54,7 +57,7 @@ func (o *Name) GetName() int32 {
 // and a boolean to check if the value has been set.
 func (o *Name) GetNameOk() (*int32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Name, true
 }
@@ -66,7 +69,7 @@ func (o *Name) SetName(v int32) {
 
 // GetSnakeCase returns the SnakeCase field value if set, zero value otherwise.
 func (o *Name) GetSnakeCase() int32 {
-	if o == nil || isNil(o.SnakeCase) {
+	if o == nil || o.SnakeCase == nil {
 		var ret int32
 		return ret
 	}
@@ -76,15 +79,15 @@ func (o *Name) GetSnakeCase() int32 {
 // GetSnakeCaseOk returns a tuple with the SnakeCase field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetSnakeCaseOk() (*int32, bool) {
-	if o == nil || isNil(o.SnakeCase) {
-    return nil, false
+	if o == nil || o.SnakeCase == nil {
+		return nil, false
 	}
 	return o.SnakeCase, true
 }
 
 // HasSnakeCase returns a boolean if a field has been set.
 func (o *Name) HasSnakeCase() bool {
-	if o != nil && !isNil(o.SnakeCase) {
+	if o != nil && o.SnakeCase != nil {
 		return true
 	}
 
@@ -98,7 +101,7 @@ func (o *Name) SetSnakeCase(v int32) {
 
 // GetProperty returns the Property field value if set, zero value otherwise.
 func (o *Name) GetProperty() string {
-	if o == nil || isNil(o.Property) {
+	if o == nil || o.Property == nil {
 		var ret string
 		return ret
 	}
@@ -108,15 +111,15 @@ func (o *Name) GetProperty() string {
 // GetPropertyOk returns a tuple with the Property field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetPropertyOk() (*string, bool) {
-	if o == nil || isNil(o.Property) {
-    return nil, false
+	if o == nil || o.Property == nil {
+		return nil, false
 	}
 	return o.Property, true
 }
 
 // HasProperty returns a boolean if a field has been set.
 func (o *Name) HasProperty() bool {
-	if o != nil && !isNil(o.Property) {
+	if o != nil && o.Property != nil {
 		return true
 	}
 
@@ -130,7 +133,7 @@ func (o *Name) SetProperty(v string) {
 
 // GetVar123Number returns the Var123Number field value if set, zero value otherwise.
 func (o *Name) GetVar123Number() int32 {
-	if o == nil || isNil(o.Var123Number) {
+	if o == nil || o.Var123Number == nil {
 		var ret int32
 		return ret
 	}
@@ -140,15 +143,15 @@ func (o *Name) GetVar123Number() int32 {
 // GetVar123NumberOk returns a tuple with the Var123Number field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetVar123NumberOk() (*int32, bool) {
-	if o == nil || isNil(o.Var123Number) {
-    return nil, false
+	if o == nil || o.Var123Number == nil {
+		return nil, false
 	}
 	return o.Var123Number, true
 }
 
 // HasVar123Number returns a boolean if a field has been set.
 func (o *Name) HasVar123Number() bool {
-	if o != nil && !isNil(o.Var123Number) {
+	if o != nil && o.Var123Number != nil {
 		return true
 	}
 
@@ -161,20 +164,25 @@ func (o *Name) SetVar123Number(v int32) {
 }
 
 func (o Name) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Name) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
-	if !isNil(o.SnakeCase) {
-		toSerialize["snake_case"] = o.SnakeCase
+	if o.SnakeCase != nil {
+		toSerialize["snake_case"] = *o.SnakeCase
 	}
-	if !isNil(o.Property) {
-		toSerialize["property"] = o.Property
+	if o.Property != nil {
+		toSerialize["property"] = *o.Property
 	}
-	if !isNil(o.Var123Number) {
-		toSerialize["123Number"] = o.Var123Number
+	if o.Var123Number != nil {
+		toSerialize["123Number"] = *o.Var123Number
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableName struct {
diff --git a/samples/client/petstore/go/go-petstore/model_number_only.go b/samples/client/petstore/go/go-petstore/model_number_only.go
index d935a91b3bf..a9e6c5622d6 100644
--- a/samples/client/petstore/go/go-petstore/model_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_number_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the NumberOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &NumberOnly{}
+
 // NumberOnly struct for NumberOnly
 type NumberOnly struct {
 	JustNumber *float32 `json:"JustNumber,omitempty"`
@@ -38,7 +41,7 @@ func NewNumberOnlyWithDefaults() *NumberOnly {
 
 // GetJustNumber returns the JustNumber field value if set, zero value otherwise.
 func (o *NumberOnly) GetJustNumber() float32 {
-	if o == nil || isNil(o.JustNumber) {
+	if o == nil || o.JustNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *NumberOnly) GetJustNumber() float32 {
 // GetJustNumberOk returns a tuple with the JustNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NumberOnly) GetJustNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.JustNumber) {
-    return nil, false
+	if o == nil || o.JustNumber == nil {
+		return nil, false
 	}
 	return o.JustNumber, true
 }
 
 // HasJustNumber returns a boolean if a field has been set.
 func (o *NumberOnly) HasJustNumber() bool {
-	if o != nil && !isNil(o.JustNumber) {
+	if o != nil && o.JustNumber != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *NumberOnly) SetJustNumber(v float32) {
 }
 
 func (o NumberOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o NumberOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.JustNumber) {
-		toSerialize["JustNumber"] = o.JustNumber
+	if o.JustNumber != nil {
+		toSerialize["JustNumber"] = *o.JustNumber
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableNumberOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_order.go b/samples/client/petstore/go/go-petstore/model_order.go
index a9afd6693d3..3b8b21eec5b 100644
--- a/samples/client/petstore/go/go-petstore/model_order.go
+++ b/samples/client/petstore/go/go-petstore/model_order.go
@@ -15,6 +15,9 @@ import (
 	"time"
 )
 
+// checks if the Order type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Order{}
+
 // Order struct for Order
 type Order struct {
 	Id *int64 `json:"id,omitempty"`
@@ -49,7 +52,7 @@ func NewOrderWithDefaults() *Order {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Order) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -59,15 +62,15 @@ func (o *Order) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Order) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -81,7 +84,7 @@ func (o *Order) SetId(v int64) {
 
 // GetPetId returns the PetId field value if set, zero value otherwise.
 func (o *Order) GetPetId() int64 {
-	if o == nil || isNil(o.PetId) {
+	if o == nil || o.PetId == nil {
 		var ret int64
 		return ret
 	}
@@ -91,15 +94,15 @@ func (o *Order) GetPetId() int64 {
 // GetPetIdOk returns a tuple with the PetId field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetPetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.PetId) {
-    return nil, false
+	if o == nil || o.PetId == nil {
+		return nil, false
 	}
 	return o.PetId, true
 }
 
 // HasPetId returns a boolean if a field has been set.
 func (o *Order) HasPetId() bool {
-	if o != nil && !isNil(o.PetId) {
+	if o != nil && o.PetId != nil {
 		return true
 	}
 
@@ -113,7 +116,7 @@ func (o *Order) SetPetId(v int64) {
 
 // GetQuantity returns the Quantity field value if set, zero value otherwise.
 func (o *Order) GetQuantity() int32 {
-	if o == nil || isNil(o.Quantity) {
+	if o == nil || o.Quantity == nil {
 		var ret int32
 		return ret
 	}
@@ -123,15 +126,15 @@ func (o *Order) GetQuantity() int32 {
 // GetQuantityOk returns a tuple with the Quantity field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetQuantityOk() (*int32, bool) {
-	if o == nil || isNil(o.Quantity) {
-    return nil, false
+	if o == nil || o.Quantity == nil {
+		return nil, false
 	}
 	return o.Quantity, true
 }
 
 // HasQuantity returns a boolean if a field has been set.
 func (o *Order) HasQuantity() bool {
-	if o != nil && !isNil(o.Quantity) {
+	if o != nil && o.Quantity != nil {
 		return true
 	}
 
@@ -145,7 +148,7 @@ func (o *Order) SetQuantity(v int32) {
 
 // GetShipDate returns the ShipDate field value if set, zero value otherwise.
 func (o *Order) GetShipDate() time.Time {
-	if o == nil || isNil(o.ShipDate) {
+	if o == nil || o.ShipDate == nil {
 		var ret time.Time
 		return ret
 	}
@@ -155,15 +158,15 @@ func (o *Order) GetShipDate() time.Time {
 // GetShipDateOk returns a tuple with the ShipDate field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetShipDateOk() (*time.Time, bool) {
-	if o == nil || isNil(o.ShipDate) {
-    return nil, false
+	if o == nil || o.ShipDate == nil {
+		return nil, false
 	}
 	return o.ShipDate, true
 }
 
 // HasShipDate returns a boolean if a field has been set.
 func (o *Order) HasShipDate() bool {
-	if o != nil && !isNil(o.ShipDate) {
+	if o != nil && o.ShipDate != nil {
 		return true
 	}
 
@@ -177,7 +180,7 @@ func (o *Order) SetShipDate(v time.Time) {
 
 // GetStatus returns the Status field value if set, zero value otherwise.
 func (o *Order) GetStatus() string {
-	if o == nil || isNil(o.Status) {
+	if o == nil || o.Status == nil {
 		var ret string
 		return ret
 	}
@@ -187,15 +190,15 @@ func (o *Order) GetStatus() string {
 // GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetStatusOk() (*string, bool) {
-	if o == nil || isNil(o.Status) {
-    return nil, false
+	if o == nil || o.Status == nil {
+		return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Order) HasStatus() bool {
-	if o != nil && !isNil(o.Status) {
+	if o != nil && o.Status != nil {
 		return true
 	}
 
@@ -209,7 +212,7 @@ func (o *Order) SetStatus(v string) {
 
 // GetComplete returns the Complete field value if set, zero value otherwise.
 func (o *Order) GetComplete() bool {
-	if o == nil || isNil(o.Complete) {
+	if o == nil || o.Complete == nil {
 		var ret bool
 		return ret
 	}
@@ -219,15 +222,15 @@ func (o *Order) GetComplete() bool {
 // GetCompleteOk returns a tuple with the Complete field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetCompleteOk() (*bool, bool) {
-	if o == nil || isNil(o.Complete) {
-    return nil, false
+	if o == nil || o.Complete == nil {
+		return nil, false
 	}
 	return o.Complete, true
 }
 
 // HasComplete returns a boolean if a field has been set.
 func (o *Order) HasComplete() bool {
-	if o != nil && !isNil(o.Complete) {
+	if o != nil && o.Complete != nil {
 		return true
 	}
 
@@ -240,26 +243,31 @@ func (o *Order) SetComplete(v bool) {
 }
 
 func (o Order) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Order) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.PetId) {
-		toSerialize["petId"] = o.PetId
+	if o.PetId != nil {
+		toSerialize["petId"] = *o.PetId
 	}
-	if !isNil(o.Quantity) {
-		toSerialize["quantity"] = o.Quantity
+	if o.Quantity != nil {
+		toSerialize["quantity"] = *o.Quantity
 	}
-	if !isNil(o.ShipDate) {
-		toSerialize["shipDate"] = o.ShipDate
+	if o.ShipDate != nil {
+		toSerialize["shipDate"] = *o.ShipDate
 	}
-	if !isNil(o.Status) {
-		toSerialize["status"] = o.Status
+	if o.Status != nil {
+		toSerialize["status"] = *o.Status
 	}
-	if !isNil(o.Complete) {
-		toSerialize["complete"] = o.Complete
+	if o.Complete != nil {
+		toSerialize["complete"] = *o.Complete
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableOrder struct {
diff --git a/samples/client/petstore/go/go-petstore/model_outer_composite.go b/samples/client/petstore/go/go-petstore/model_outer_composite.go
index 8d5bb096b30..94127a2815d 100644
--- a/samples/client/petstore/go/go-petstore/model_outer_composite.go
+++ b/samples/client/petstore/go/go-petstore/model_outer_composite.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the OuterComposite type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &OuterComposite{}
+
 // OuterComposite struct for OuterComposite
 type OuterComposite struct {
 	MyNumber *float32 `json:"my_number,omitempty"`
@@ -40,7 +43,7 @@ func NewOuterCompositeWithDefaults() *OuterComposite {
 
 // GetMyNumber returns the MyNumber field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyNumber() float32 {
-	if o == nil || isNil(o.MyNumber) {
+	if o == nil || o.MyNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -50,15 +53,15 @@ func (o *OuterComposite) GetMyNumber() float32 {
 // GetMyNumberOk returns a tuple with the MyNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.MyNumber) {
-    return nil, false
+	if o == nil || o.MyNumber == nil {
+		return nil, false
 	}
 	return o.MyNumber, true
 }
 
 // HasMyNumber returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyNumber() bool {
-	if o != nil && !isNil(o.MyNumber) {
+	if o != nil && o.MyNumber != nil {
 		return true
 	}
 
@@ -72,7 +75,7 @@ func (o *OuterComposite) SetMyNumber(v float32) {
 
 // GetMyString returns the MyString field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyString() string {
-	if o == nil || isNil(o.MyString) {
+	if o == nil || o.MyString == nil {
 		var ret string
 		return ret
 	}
@@ -82,15 +85,15 @@ func (o *OuterComposite) GetMyString() string {
 // GetMyStringOk returns a tuple with the MyString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyStringOk() (*string, bool) {
-	if o == nil || isNil(o.MyString) {
-    return nil, false
+	if o == nil || o.MyString == nil {
+		return nil, false
 	}
 	return o.MyString, true
 }
 
 // HasMyString returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyString() bool {
-	if o != nil && !isNil(o.MyString) {
+	if o != nil && o.MyString != nil {
 		return true
 	}
 
@@ -104,7 +107,7 @@ func (o *OuterComposite) SetMyString(v string) {
 
 // GetMyBoolean returns the MyBoolean field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyBoolean() bool {
-	if o == nil || isNil(o.MyBoolean) {
+	if o == nil || o.MyBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -114,15 +117,15 @@ func (o *OuterComposite) GetMyBoolean() bool {
 // GetMyBooleanOk returns a tuple with the MyBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.MyBoolean) {
-    return nil, false
+	if o == nil || o.MyBoolean == nil {
+		return nil, false
 	}
 	return o.MyBoolean, true
 }
 
 // HasMyBoolean returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyBoolean() bool {
-	if o != nil && !isNil(o.MyBoolean) {
+	if o != nil && o.MyBoolean != nil {
 		return true
 	}
 
@@ -135,17 +138,22 @@ func (o *OuterComposite) SetMyBoolean(v bool) {
 }
 
 func (o OuterComposite) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o OuterComposite) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.MyNumber) {
-		toSerialize["my_number"] = o.MyNumber
+	if o.MyNumber != nil {
+		toSerialize["my_number"] = *o.MyNumber
 	}
-	if !isNil(o.MyString) {
-		toSerialize["my_string"] = o.MyString
+	if o.MyString != nil {
+		toSerialize["my_string"] = *o.MyString
 	}
-	if !isNil(o.MyBoolean) {
-		toSerialize["my_boolean"] = o.MyBoolean
+	if o.MyBoolean != nil {
+		toSerialize["my_boolean"] = *o.MyBoolean
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableOuterComposite struct {
diff --git a/samples/client/petstore/go/go-petstore/model_pet.go b/samples/client/petstore/go/go-petstore/model_pet.go
index f53374c5236..c5617bd9405 100644
--- a/samples/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/client/petstore/go/go-petstore/model_pet.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Pet type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Pet{}
+
 // Pet struct for Pet
 type Pet struct {
 	Id *int64 `json:"id,omitempty"`
@@ -46,7 +49,7 @@ func NewPetWithDefaults() *Pet {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Pet) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -56,15 +59,15 @@ func (o *Pet) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Pet) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -78,7 +81,7 @@ func (o *Pet) SetId(v int64) {
 
 // GetCategory returns the Category field value if set, zero value otherwise.
 func (o *Pet) GetCategory() Category {
-	if o == nil || isNil(o.Category) {
+	if o == nil || o.Category == nil {
 		var ret Category
 		return ret
 	}
@@ -88,15 +91,15 @@ func (o *Pet) GetCategory() Category {
 // GetCategoryOk returns a tuple with the Category field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetCategoryOk() (*Category, bool) {
-	if o == nil || isNil(o.Category) {
-    return nil, false
+	if o == nil || o.Category == nil {
+		return nil, false
 	}
 	return o.Category, true
 }
 
 // HasCategory returns a boolean if a field has been set.
 func (o *Pet) HasCategory() bool {
-	if o != nil && !isNil(o.Category) {
+	if o != nil && o.Category != nil {
 		return true
 	}
 
@@ -122,7 +125,7 @@ func (o *Pet) GetName() string {
 // and a boolean to check if the value has been set.
 func (o *Pet) GetNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Name, true
 }
@@ -146,7 +149,7 @@ func (o *Pet) GetPhotoUrls() []string {
 // and a boolean to check if the value has been set.
 func (o *Pet) GetPhotoUrlsOk() ([]string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.PhotoUrls, true
 }
@@ -158,7 +161,7 @@ func (o *Pet) SetPhotoUrls(v []string) {
 
 // GetTags returns the Tags field value if set, zero value otherwise.
 func (o *Pet) GetTags() []Tag {
-	if o == nil || isNil(o.Tags) {
+	if o == nil || o.Tags == nil {
 		var ret []Tag
 		return ret
 	}
@@ -168,15 +171,15 @@ func (o *Pet) GetTags() []Tag {
 // GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetTagsOk() ([]Tag, bool) {
-	if o == nil || isNil(o.Tags) {
-    return nil, false
+	if o == nil || o.Tags == nil {
+		return nil, false
 	}
 	return o.Tags, true
 }
 
 // HasTags returns a boolean if a field has been set.
 func (o *Pet) HasTags() bool {
-	if o != nil && !isNil(o.Tags) {
+	if o != nil && o.Tags != nil {
 		return true
 	}
 
@@ -190,7 +193,7 @@ func (o *Pet) SetTags(v []Tag) {
 
 // GetStatus returns the Status field value if set, zero value otherwise.
 func (o *Pet) GetStatus() string {
-	if o == nil || isNil(o.Status) {
+	if o == nil || o.Status == nil {
 		var ret string
 		return ret
 	}
@@ -200,15 +203,15 @@ func (o *Pet) GetStatus() string {
 // GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetStatusOk() (*string, bool) {
-	if o == nil || isNil(o.Status) {
-    return nil, false
+	if o == nil || o.Status == nil {
+		return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Pet) HasStatus() bool {
-	if o != nil && !isNil(o.Status) {
+	if o != nil && o.Status != nil {
 		return true
 	}
 
@@ -221,26 +224,31 @@ func (o *Pet) SetStatus(v string) {
 }
 
 func (o Pet) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Pet) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.Category) {
-		toSerialize["category"] = o.Category
+	if o.Category != nil {
+		toSerialize["category"] = *o.Category
 	}
 	if true {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
 	if true {
-		toSerialize["photoUrls"] = o.PhotoUrls
+		toSerialize["photoUrls"] = *o.PhotoUrls
 	}
-	if !isNil(o.Tags) {
-		toSerialize["tags"] = o.Tags
+	if o.Tags != nil {
+		toSerialize["tags"] = *o.Tags
 	}
-	if !isNil(o.Status) {
-		toSerialize["status"] = o.Status
+	if o.Status != nil {
+		toSerialize["status"] = *o.Status
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullablePet struct {
diff --git a/samples/client/petstore/go/go-petstore/model_read_only_first.go b/samples/client/petstore/go/go-petstore/model_read_only_first.go
index 5d051234960..028d81d0115 100644
--- a/samples/client/petstore/go/go-petstore/model_read_only_first.go
+++ b/samples/client/petstore/go/go-petstore/model_read_only_first.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ReadOnlyFirst type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ReadOnlyFirst{}
+
 // ReadOnlyFirst struct for ReadOnlyFirst
 type ReadOnlyFirst struct {
 	Bar *string `json:"bar,omitempty"`
@@ -39,7 +42,7 @@ func NewReadOnlyFirstWithDefaults() *ReadOnlyFirst {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBar() string {
-	if o == nil || isNil(o.Bar) {
+	if o == nil || o.Bar == nil {
 		var ret string
 		return ret
 	}
@@ -49,15 +52,15 @@ func (o *ReadOnlyFirst) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBarOk() (*string, bool) {
-	if o == nil || isNil(o.Bar) {
-    return nil, false
+	if o == nil || o.Bar == nil {
+		return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBar() bool {
-	if o != nil && !isNil(o.Bar) {
+	if o != nil && o.Bar != nil {
 		return true
 	}
 
@@ -71,7 +74,7 @@ func (o *ReadOnlyFirst) SetBar(v string) {
 
 // GetBaz returns the Baz field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBaz() string {
-	if o == nil || isNil(o.Baz) {
+	if o == nil || o.Baz == nil {
 		var ret string
 		return ret
 	}
@@ -81,15 +84,15 @@ func (o *ReadOnlyFirst) GetBaz() string {
 // GetBazOk returns a tuple with the Baz field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBazOk() (*string, bool) {
-	if o == nil || isNil(o.Baz) {
-    return nil, false
+	if o == nil || o.Baz == nil {
+		return nil, false
 	}
 	return o.Baz, true
 }
 
 // HasBaz returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBaz() bool {
-	if o != nil && !isNil(o.Baz) {
+	if o != nil && o.Baz != nil {
 		return true
 	}
 
@@ -102,14 +105,19 @@ func (o *ReadOnlyFirst) SetBaz(v string) {
 }
 
 func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ReadOnlyFirst) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Bar) {
-		toSerialize["bar"] = o.Bar
+	if o.Bar != nil {
+		toSerialize["bar"] = *o.Bar
 	}
-	if !isNil(o.Baz) {
-		toSerialize["baz"] = o.Baz
+	if o.Baz != nil {
+		toSerialize["baz"] = *o.Baz
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableReadOnlyFirst struct {
diff --git a/samples/client/petstore/go/go-petstore/model_return.go b/samples/client/petstore/go/go-petstore/model_return.go
index 62fcb20af41..0f1b3691bf7 100644
--- a/samples/client/petstore/go/go-petstore/model_return.go
+++ b/samples/client/petstore/go/go-petstore/model_return.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Return type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Return{}
+
 // Return Model for testing reserved words
 type Return struct {
 	Return *int32 `json:"return,omitempty"`
@@ -38,7 +41,7 @@ func NewReturnWithDefaults() *Return {
 
 // GetReturn returns the Return field value if set, zero value otherwise.
 func (o *Return) GetReturn() int32 {
-	if o == nil || isNil(o.Return) {
+	if o == nil || o.Return == nil {
 		var ret int32
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *Return) GetReturn() int32 {
 // GetReturnOk returns a tuple with the Return field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Return) GetReturnOk() (*int32, bool) {
-	if o == nil || isNil(o.Return) {
-    return nil, false
+	if o == nil || o.Return == nil {
+		return nil, false
 	}
 	return o.Return, true
 }
 
 // HasReturn returns a boolean if a field has been set.
 func (o *Return) HasReturn() bool {
-	if o != nil && !isNil(o.Return) {
+	if o != nil && o.Return != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *Return) SetReturn(v int32) {
 }
 
 func (o Return) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Return) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Return) {
-		toSerialize["return"] = o.Return
+	if o.Return != nil {
+		toSerialize["return"] = *o.Return
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableReturn struct {
diff --git a/samples/client/petstore/go/go-petstore/model_special_model_name.go b/samples/client/petstore/go/go-petstore/model_special_model_name.go
index ba232f8d8f3..2c921b69838 100644
--- a/samples/client/petstore/go/go-petstore/model_special_model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_special_model_name.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the SpecialModelName type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &SpecialModelName{}
+
 // SpecialModelName struct for SpecialModelName
 type SpecialModelName struct {
 	SpecialPropertyName *int64 `json:"$special[property.name],omitempty"`
@@ -38,7 +41,7 @@ func NewSpecialModelNameWithDefaults() *SpecialModelName {
 
 // GetSpecialPropertyName returns the SpecialPropertyName field value if set, zero value otherwise.
 func (o *SpecialModelName) GetSpecialPropertyName() int64 {
-	if o == nil || isNil(o.SpecialPropertyName) {
+	if o == nil || o.SpecialPropertyName == nil {
 		var ret int64
 		return ret
 	}
@@ -48,15 +51,15 @@ func (o *SpecialModelName) GetSpecialPropertyName() int64 {
 // GetSpecialPropertyNameOk returns a tuple with the SpecialPropertyName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *SpecialModelName) GetSpecialPropertyNameOk() (*int64, bool) {
-	if o == nil || isNil(o.SpecialPropertyName) {
-    return nil, false
+	if o == nil || o.SpecialPropertyName == nil {
+		return nil, false
 	}
 	return o.SpecialPropertyName, true
 }
 
 // HasSpecialPropertyName returns a boolean if a field has been set.
 func (o *SpecialModelName) HasSpecialPropertyName() bool {
-	if o != nil && !isNil(o.SpecialPropertyName) {
+	if o != nil && o.SpecialPropertyName != nil {
 		return true
 	}
 
@@ -69,11 +72,16 @@ func (o *SpecialModelName) SetSpecialPropertyName(v int64) {
 }
 
 func (o SpecialModelName) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o SpecialModelName) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.SpecialPropertyName) {
-		toSerialize["$special[property.name]"] = o.SpecialPropertyName
+	if o.SpecialPropertyName != nil {
+		toSerialize["$special[property.name]"] = *o.SpecialPropertyName
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableSpecialModelName struct {
diff --git a/samples/client/petstore/go/go-petstore/model_tag.go b/samples/client/petstore/go/go-petstore/model_tag.go
index aa5518326ae..7b2a52904be 100644
--- a/samples/client/petstore/go/go-petstore/model_tag.go
+++ b/samples/client/petstore/go/go-petstore/model_tag.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Tag type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Tag{}
+
 // Tag struct for Tag
 type Tag struct {
 	Id *int64 `json:"id,omitempty"`
@@ -39,7 +42,7 @@ func NewTagWithDefaults() *Tag {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Tag) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -49,15 +52,15 @@ func (o *Tag) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Tag) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -71,7 +74,7 @@ func (o *Tag) SetId(v int64) {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *Tag) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -81,15 +84,15 @@ func (o *Tag) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *Tag) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -102,14 +105,19 @@ func (o *Tag) SetName(v string) {
 }
 
 func (o Tag) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Tag) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableTag struct {
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_default.go b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
index 4d5b3f612b6..998451518a1 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_default.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the TypeHolderDefault type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &TypeHolderDefault{}
+
 // TypeHolderDefault struct for TypeHolderDefault
 type TypeHolderDefault struct {
 	StringItem string `json:"string_item"`
@@ -170,23 +173,28 @@ func (o *TypeHolderDefault) SetArrayItem(v []int32) {
 }
 
 func (o TypeHolderDefault) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o TypeHolderDefault) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["string_item"] = o.StringItem
+		toSerialize["string_item"] = *o.StringItem
 	}
 	if true {
-		toSerialize["number_item"] = o.NumberItem
+		toSerialize["number_item"] = *o.NumberItem
 	}
 	if true {
-		toSerialize["integer_item"] = o.IntegerItem
+		toSerialize["integer_item"] = *o.IntegerItem
 	}
 	if true {
-		toSerialize["bool_item"] = o.BoolItem
+		toSerialize["bool_item"] = *o.BoolItem
 	}
 	if true {
-		toSerialize["array_item"] = o.ArrayItem
+		toSerialize["array_item"] = *o.ArrayItem
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableTypeHolderDefault struct {
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_example.go b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
index c166ea0cffd..d531f5f50f0 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_example.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the TypeHolderExample type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &TypeHolderExample{}
+
 // TypeHolderExample struct for TypeHolderExample
 type TypeHolderExample struct {
 	StringItem string `json:"string_item"`
@@ -192,26 +195,31 @@ func (o *TypeHolderExample) SetArrayItem(v []int32) {
 }
 
 func (o TypeHolderExample) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o TypeHolderExample) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["string_item"] = o.StringItem
+		toSerialize["string_item"] = *o.StringItem
 	}
 	if true {
-		toSerialize["number_item"] = o.NumberItem
+		toSerialize["number_item"] = *o.NumberItem
 	}
 	if true {
-		toSerialize["float_item"] = o.FloatItem
+		toSerialize["float_item"] = *o.FloatItem
 	}
 	if true {
-		toSerialize["integer_item"] = o.IntegerItem
+		toSerialize["integer_item"] = *o.IntegerItem
 	}
 	if true {
-		toSerialize["bool_item"] = o.BoolItem
+		toSerialize["bool_item"] = *o.BoolItem
 	}
 	if true {
-		toSerialize["array_item"] = o.ArrayItem
+		toSerialize["array_item"] = *o.ArrayItem
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableTypeHolderExample struct {
diff --git a/samples/client/petstore/go/go-petstore/model_user.go b/samples/client/petstore/go/go-petstore/model_user.go
index 900951571dc..3b48b7e9ada 100644
--- a/samples/client/petstore/go/go-petstore/model_user.go
+++ b/samples/client/petstore/go/go-petstore/model_user.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the User type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &User{}
+
 // User struct for User
 type User struct {
 	Id *int64 `json:"id,omitempty"`
@@ -46,7 +49,7 @@ func NewUserWithDefaults() *User {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *User) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -56,15 +59,15 @@ func (o *User) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *User) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -78,7 +81,7 @@ func (o *User) SetId(v int64) {
 
 // GetUsername returns the Username field value if set, zero value otherwise.
 func (o *User) GetUsername() string {
-	if o == nil || isNil(o.Username) {
+	if o == nil || o.Username == nil {
 		var ret string
 		return ret
 	}
@@ -88,15 +91,15 @@ func (o *User) GetUsername() string {
 // GetUsernameOk returns a tuple with the Username field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUsernameOk() (*string, bool) {
-	if o == nil || isNil(o.Username) {
-    return nil, false
+	if o == nil || o.Username == nil {
+		return nil, false
 	}
 	return o.Username, true
 }
 
 // HasUsername returns a boolean if a field has been set.
 func (o *User) HasUsername() bool {
-	if o != nil && !isNil(o.Username) {
+	if o != nil && o.Username != nil {
 		return true
 	}
 
@@ -110,7 +113,7 @@ func (o *User) SetUsername(v string) {
 
 // GetFirstName returns the FirstName field value if set, zero value otherwise.
 func (o *User) GetFirstName() string {
-	if o == nil || isNil(o.FirstName) {
+	if o == nil || o.FirstName == nil {
 		var ret string
 		return ret
 	}
@@ -120,15 +123,15 @@ func (o *User) GetFirstName() string {
 // GetFirstNameOk returns a tuple with the FirstName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetFirstNameOk() (*string, bool) {
-	if o == nil || isNil(o.FirstName) {
-    return nil, false
+	if o == nil || o.FirstName == nil {
+		return nil, false
 	}
 	return o.FirstName, true
 }
 
 // HasFirstName returns a boolean if a field has been set.
 func (o *User) HasFirstName() bool {
-	if o != nil && !isNil(o.FirstName) {
+	if o != nil && o.FirstName != nil {
 		return true
 	}
 
@@ -142,7 +145,7 @@ func (o *User) SetFirstName(v string) {
 
 // GetLastName returns the LastName field value if set, zero value otherwise.
 func (o *User) GetLastName() string {
-	if o == nil || isNil(o.LastName) {
+	if o == nil || o.LastName == nil {
 		var ret string
 		return ret
 	}
@@ -152,15 +155,15 @@ func (o *User) GetLastName() string {
 // GetLastNameOk returns a tuple with the LastName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetLastNameOk() (*string, bool) {
-	if o == nil || isNil(o.LastName) {
-    return nil, false
+	if o == nil || o.LastName == nil {
+		return nil, false
 	}
 	return o.LastName, true
 }
 
 // HasLastName returns a boolean if a field has been set.
 func (o *User) HasLastName() bool {
-	if o != nil && !isNil(o.LastName) {
+	if o != nil && o.LastName != nil {
 		return true
 	}
 
@@ -174,7 +177,7 @@ func (o *User) SetLastName(v string) {
 
 // GetEmail returns the Email field value if set, zero value otherwise.
 func (o *User) GetEmail() string {
-	if o == nil || isNil(o.Email) {
+	if o == nil || o.Email == nil {
 		var ret string
 		return ret
 	}
@@ -184,15 +187,15 @@ func (o *User) GetEmail() string {
 // GetEmailOk returns a tuple with the Email field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetEmailOk() (*string, bool) {
-	if o == nil || isNil(o.Email) {
-    return nil, false
+	if o == nil || o.Email == nil {
+		return nil, false
 	}
 	return o.Email, true
 }
 
 // HasEmail returns a boolean if a field has been set.
 func (o *User) HasEmail() bool {
-	if o != nil && !isNil(o.Email) {
+	if o != nil && o.Email != nil {
 		return true
 	}
 
@@ -206,7 +209,7 @@ func (o *User) SetEmail(v string) {
 
 // GetPassword returns the Password field value if set, zero value otherwise.
 func (o *User) GetPassword() string {
-	if o == nil || isNil(o.Password) {
+	if o == nil || o.Password == nil {
 		var ret string
 		return ret
 	}
@@ -216,15 +219,15 @@ func (o *User) GetPassword() string {
 // GetPasswordOk returns a tuple with the Password field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPasswordOk() (*string, bool) {
-	if o == nil || isNil(o.Password) {
-    return nil, false
+	if o == nil || o.Password == nil {
+		return nil, false
 	}
 	return o.Password, true
 }
 
 // HasPassword returns a boolean if a field has been set.
 func (o *User) HasPassword() bool {
-	if o != nil && !isNil(o.Password) {
+	if o != nil && o.Password != nil {
 		return true
 	}
 
@@ -238,7 +241,7 @@ func (o *User) SetPassword(v string) {
 
 // GetPhone returns the Phone field value if set, zero value otherwise.
 func (o *User) GetPhone() string {
-	if o == nil || isNil(o.Phone) {
+	if o == nil || o.Phone == nil {
 		var ret string
 		return ret
 	}
@@ -248,15 +251,15 @@ func (o *User) GetPhone() string {
 // GetPhoneOk returns a tuple with the Phone field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPhoneOk() (*string, bool) {
-	if o == nil || isNil(o.Phone) {
-    return nil, false
+	if o == nil || o.Phone == nil {
+		return nil, false
 	}
 	return o.Phone, true
 }
 
 // HasPhone returns a boolean if a field has been set.
 func (o *User) HasPhone() bool {
-	if o != nil && !isNil(o.Phone) {
+	if o != nil && o.Phone != nil {
 		return true
 	}
 
@@ -270,7 +273,7 @@ func (o *User) SetPhone(v string) {
 
 // GetUserStatus returns the UserStatus field value if set, zero value otherwise.
 func (o *User) GetUserStatus() int32 {
-	if o == nil || isNil(o.UserStatus) {
+	if o == nil || o.UserStatus == nil {
 		var ret int32
 		return ret
 	}
@@ -280,15 +283,15 @@ func (o *User) GetUserStatus() int32 {
 // GetUserStatusOk returns a tuple with the UserStatus field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUserStatusOk() (*int32, bool) {
-	if o == nil || isNil(o.UserStatus) {
-    return nil, false
+	if o == nil || o.UserStatus == nil {
+		return nil, false
 	}
 	return o.UserStatus, true
 }
 
 // HasUserStatus returns a boolean if a field has been set.
 func (o *User) HasUserStatus() bool {
-	if o != nil && !isNil(o.UserStatus) {
+	if o != nil && o.UserStatus != nil {
 		return true
 	}
 
@@ -301,32 +304,37 @@ func (o *User) SetUserStatus(v int32) {
 }
 
 func (o User) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o User) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.Username) {
-		toSerialize["username"] = o.Username
+	if o.Username != nil {
+		toSerialize["username"] = *o.Username
 	}
-	if !isNil(o.FirstName) {
-		toSerialize["firstName"] = o.FirstName
+	if o.FirstName != nil {
+		toSerialize["firstName"] = *o.FirstName
 	}
-	if !isNil(o.LastName) {
-		toSerialize["lastName"] = o.LastName
+	if o.LastName != nil {
+		toSerialize["lastName"] = *o.LastName
 	}
-	if !isNil(o.Email) {
-		toSerialize["email"] = o.Email
+	if o.Email != nil {
+		toSerialize["email"] = *o.Email
 	}
-	if !isNil(o.Password) {
-		toSerialize["password"] = o.Password
+	if o.Password != nil {
+		toSerialize["password"] = *o.Password
 	}
-	if !isNil(o.Phone) {
-		toSerialize["phone"] = o.Phone
+	if o.Phone != nil {
+		toSerialize["phone"] = *o.Phone
 	}
-	if !isNil(o.UserStatus) {
-		toSerialize["userStatus"] = o.UserStatus
+	if o.UserStatus != nil {
+		toSerialize["userStatus"] = *o.UserStatus
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableUser struct {
diff --git a/samples/client/petstore/go/go-petstore/model_xml_item.go b/samples/client/petstore/go/go-petstore/model_xml_item.go
index c22bb15a399..5378ce76a6e 100644
--- a/samples/client/petstore/go/go-petstore/model_xml_item.go
+++ b/samples/client/petstore/go/go-petstore/model_xml_item.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the XmlItem type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &XmlItem{}
+
 // XmlItem struct for XmlItem
 type XmlItem struct {
 	AttributeString *string `json:"attribute_string,omitempty"`
@@ -66,7 +69,7 @@ func NewXmlItemWithDefaults() *XmlItem {
 
 // GetAttributeString returns the AttributeString field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeString() string {
-	if o == nil || isNil(o.AttributeString) {
+	if o == nil || o.AttributeString == nil {
 		var ret string
 		return ret
 	}
@@ -76,15 +79,15 @@ func (o *XmlItem) GetAttributeString() string {
 // GetAttributeStringOk returns a tuple with the AttributeString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeStringOk() (*string, bool) {
-	if o == nil || isNil(o.AttributeString) {
-    return nil, false
+	if o == nil || o.AttributeString == nil {
+		return nil, false
 	}
 	return o.AttributeString, true
 }
 
 // HasAttributeString returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeString() bool {
-	if o != nil && !isNil(o.AttributeString) {
+	if o != nil && o.AttributeString != nil {
 		return true
 	}
 
@@ -98,7 +101,7 @@ func (o *XmlItem) SetAttributeString(v string) {
 
 // GetAttributeNumber returns the AttributeNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeNumber() float32 {
-	if o == nil || isNil(o.AttributeNumber) {
+	if o == nil || o.AttributeNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -108,15 +111,15 @@ func (o *XmlItem) GetAttributeNumber() float32 {
 // GetAttributeNumberOk returns a tuple with the AttributeNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.AttributeNumber) {
-    return nil, false
+	if o == nil || o.AttributeNumber == nil {
+		return nil, false
 	}
 	return o.AttributeNumber, true
 }
 
 // HasAttributeNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeNumber() bool {
-	if o != nil && !isNil(o.AttributeNumber) {
+	if o != nil && o.AttributeNumber != nil {
 		return true
 	}
 
@@ -130,7 +133,7 @@ func (o *XmlItem) SetAttributeNumber(v float32) {
 
 // GetAttributeInteger returns the AttributeInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeInteger() int32 {
-	if o == nil || isNil(o.AttributeInteger) {
+	if o == nil || o.AttributeInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -140,15 +143,15 @@ func (o *XmlItem) GetAttributeInteger() int32 {
 // GetAttributeIntegerOk returns a tuple with the AttributeInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.AttributeInteger) {
-    return nil, false
+	if o == nil || o.AttributeInteger == nil {
+		return nil, false
 	}
 	return o.AttributeInteger, true
 }
 
 // HasAttributeInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeInteger() bool {
-	if o != nil && !isNil(o.AttributeInteger) {
+	if o != nil && o.AttributeInteger != nil {
 		return true
 	}
 
@@ -162,7 +165,7 @@ func (o *XmlItem) SetAttributeInteger(v int32) {
 
 // GetAttributeBoolean returns the AttributeBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeBoolean() bool {
-	if o == nil || isNil(o.AttributeBoolean) {
+	if o == nil || o.AttributeBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -172,15 +175,15 @@ func (o *XmlItem) GetAttributeBoolean() bool {
 // GetAttributeBooleanOk returns a tuple with the AttributeBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.AttributeBoolean) {
-    return nil, false
+	if o == nil || o.AttributeBoolean == nil {
+		return nil, false
 	}
 	return o.AttributeBoolean, true
 }
 
 // HasAttributeBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeBoolean() bool {
-	if o != nil && !isNil(o.AttributeBoolean) {
+	if o != nil && o.AttributeBoolean != nil {
 		return true
 	}
 
@@ -194,7 +197,7 @@ func (o *XmlItem) SetAttributeBoolean(v bool) {
 
 // GetWrappedArray returns the WrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetWrappedArray() []int32 {
-	if o == nil || isNil(o.WrappedArray) {
+	if o == nil || o.WrappedArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -204,15 +207,15 @@ func (o *XmlItem) GetWrappedArray() []int32 {
 // GetWrappedArrayOk returns a tuple with the WrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetWrappedArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.WrappedArray) {
-    return nil, false
+	if o == nil || o.WrappedArray == nil {
+		return nil, false
 	}
 	return o.WrappedArray, true
 }
 
 // HasWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasWrappedArray() bool {
-	if o != nil && !isNil(o.WrappedArray) {
+	if o != nil && o.WrappedArray != nil {
 		return true
 	}
 
@@ -226,7 +229,7 @@ func (o *XmlItem) SetWrappedArray(v []int32) {
 
 // GetNameString returns the NameString field value if set, zero value otherwise.
 func (o *XmlItem) GetNameString() string {
-	if o == nil || isNil(o.NameString) {
+	if o == nil || o.NameString == nil {
 		var ret string
 		return ret
 	}
@@ -236,15 +239,15 @@ func (o *XmlItem) GetNameString() string {
 // GetNameStringOk returns a tuple with the NameString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameStringOk() (*string, bool) {
-	if o == nil || isNil(o.NameString) {
-    return nil, false
+	if o == nil || o.NameString == nil {
+		return nil, false
 	}
 	return o.NameString, true
 }
 
 // HasNameString returns a boolean if a field has been set.
 func (o *XmlItem) HasNameString() bool {
-	if o != nil && !isNil(o.NameString) {
+	if o != nil && o.NameString != nil {
 		return true
 	}
 
@@ -258,7 +261,7 @@ func (o *XmlItem) SetNameString(v string) {
 
 // GetNameNumber returns the NameNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetNameNumber() float32 {
-	if o == nil || isNil(o.NameNumber) {
+	if o == nil || o.NameNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -268,15 +271,15 @@ func (o *XmlItem) GetNameNumber() float32 {
 // GetNameNumberOk returns a tuple with the NameNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.NameNumber) {
-    return nil, false
+	if o == nil || o.NameNumber == nil {
+		return nil, false
 	}
 	return o.NameNumber, true
 }
 
 // HasNameNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasNameNumber() bool {
-	if o != nil && !isNil(o.NameNumber) {
+	if o != nil && o.NameNumber != nil {
 		return true
 	}
 
@@ -290,7 +293,7 @@ func (o *XmlItem) SetNameNumber(v float32) {
 
 // GetNameInteger returns the NameInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetNameInteger() int32 {
-	if o == nil || isNil(o.NameInteger) {
+	if o == nil || o.NameInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -300,15 +303,15 @@ func (o *XmlItem) GetNameInteger() int32 {
 // GetNameIntegerOk returns a tuple with the NameInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.NameInteger) {
-    return nil, false
+	if o == nil || o.NameInteger == nil {
+		return nil, false
 	}
 	return o.NameInteger, true
 }
 
 // HasNameInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasNameInteger() bool {
-	if o != nil && !isNil(o.NameInteger) {
+	if o != nil && o.NameInteger != nil {
 		return true
 	}
 
@@ -322,7 +325,7 @@ func (o *XmlItem) SetNameInteger(v int32) {
 
 // GetNameBoolean returns the NameBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetNameBoolean() bool {
-	if o == nil || isNil(o.NameBoolean) {
+	if o == nil || o.NameBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -332,15 +335,15 @@ func (o *XmlItem) GetNameBoolean() bool {
 // GetNameBooleanOk returns a tuple with the NameBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.NameBoolean) {
-    return nil, false
+	if o == nil || o.NameBoolean == nil {
+		return nil, false
 	}
 	return o.NameBoolean, true
 }
 
 // HasNameBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasNameBoolean() bool {
-	if o != nil && !isNil(o.NameBoolean) {
+	if o != nil && o.NameBoolean != nil {
 		return true
 	}
 
@@ -354,7 +357,7 @@ func (o *XmlItem) SetNameBoolean(v bool) {
 
 // GetNameArray returns the NameArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNameArray() []int32 {
-	if o == nil || isNil(o.NameArray) {
+	if o == nil || o.NameArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -364,15 +367,15 @@ func (o *XmlItem) GetNameArray() []int32 {
 // GetNameArrayOk returns a tuple with the NameArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.NameArray) {
-    return nil, false
+	if o == nil || o.NameArray == nil {
+		return nil, false
 	}
 	return o.NameArray, true
 }
 
 // HasNameArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNameArray() bool {
-	if o != nil && !isNil(o.NameArray) {
+	if o != nil && o.NameArray != nil {
 		return true
 	}
 
@@ -386,7 +389,7 @@ func (o *XmlItem) SetNameArray(v []int32) {
 
 // GetNameWrappedArray returns the NameWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNameWrappedArray() []int32 {
-	if o == nil || isNil(o.NameWrappedArray) {
+	if o == nil || o.NameWrappedArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -396,15 +399,15 @@ func (o *XmlItem) GetNameWrappedArray() []int32 {
 // GetNameWrappedArrayOk returns a tuple with the NameWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameWrappedArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.NameWrappedArray) {
-    return nil, false
+	if o == nil || o.NameWrappedArray == nil {
+		return nil, false
 	}
 	return o.NameWrappedArray, true
 }
 
 // HasNameWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNameWrappedArray() bool {
-	if o != nil && !isNil(o.NameWrappedArray) {
+	if o != nil && o.NameWrappedArray != nil {
 		return true
 	}
 
@@ -418,7 +421,7 @@ func (o *XmlItem) SetNameWrappedArray(v []int32) {
 
 // GetPrefixString returns the PrefixString field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixString() string {
-	if o == nil || isNil(o.PrefixString) {
+	if o == nil || o.PrefixString == nil {
 		var ret string
 		return ret
 	}
@@ -428,15 +431,15 @@ func (o *XmlItem) GetPrefixString() string {
 // GetPrefixStringOk returns a tuple with the PrefixString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixStringOk() (*string, bool) {
-	if o == nil || isNil(o.PrefixString) {
-    return nil, false
+	if o == nil || o.PrefixString == nil {
+		return nil, false
 	}
 	return o.PrefixString, true
 }
 
 // HasPrefixString returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixString() bool {
-	if o != nil && !isNil(o.PrefixString) {
+	if o != nil && o.PrefixString != nil {
 		return true
 	}
 
@@ -450,7 +453,7 @@ func (o *XmlItem) SetPrefixString(v string) {
 
 // GetPrefixNumber returns the PrefixNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNumber() float32 {
-	if o == nil || isNil(o.PrefixNumber) {
+	if o == nil || o.PrefixNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -460,15 +463,15 @@ func (o *XmlItem) GetPrefixNumber() float32 {
 // GetPrefixNumberOk returns a tuple with the PrefixNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.PrefixNumber) {
-    return nil, false
+	if o == nil || o.PrefixNumber == nil {
+		return nil, false
 	}
 	return o.PrefixNumber, true
 }
 
 // HasPrefixNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNumber() bool {
-	if o != nil && !isNil(o.PrefixNumber) {
+	if o != nil && o.PrefixNumber != nil {
 		return true
 	}
 
@@ -482,7 +485,7 @@ func (o *XmlItem) SetPrefixNumber(v float32) {
 
 // GetPrefixInteger returns the PrefixInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixInteger() int32 {
-	if o == nil || isNil(o.PrefixInteger) {
+	if o == nil || o.PrefixInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -492,15 +495,15 @@ func (o *XmlItem) GetPrefixInteger() int32 {
 // GetPrefixIntegerOk returns a tuple with the PrefixInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.PrefixInteger) {
-    return nil, false
+	if o == nil || o.PrefixInteger == nil {
+		return nil, false
 	}
 	return o.PrefixInteger, true
 }
 
 // HasPrefixInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixInteger() bool {
-	if o != nil && !isNil(o.PrefixInteger) {
+	if o != nil && o.PrefixInteger != nil {
 		return true
 	}
 
@@ -514,7 +517,7 @@ func (o *XmlItem) SetPrefixInteger(v int32) {
 
 // GetPrefixBoolean returns the PrefixBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixBoolean() bool {
-	if o == nil || isNil(o.PrefixBoolean) {
+	if o == nil || o.PrefixBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -524,15 +527,15 @@ func (o *XmlItem) GetPrefixBoolean() bool {
 // GetPrefixBooleanOk returns a tuple with the PrefixBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.PrefixBoolean) {
-    return nil, false
+	if o == nil || o.PrefixBoolean == nil {
+		return nil, false
 	}
 	return o.PrefixBoolean, true
 }
 
 // HasPrefixBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixBoolean() bool {
-	if o != nil && !isNil(o.PrefixBoolean) {
+	if o != nil && o.PrefixBoolean != nil {
 		return true
 	}
 
@@ -546,7 +549,7 @@ func (o *XmlItem) SetPrefixBoolean(v bool) {
 
 // GetPrefixArray returns the PrefixArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixArray() []int32 {
-	if o == nil || isNil(o.PrefixArray) {
+	if o == nil || o.PrefixArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -556,15 +559,15 @@ func (o *XmlItem) GetPrefixArray() []int32 {
 // GetPrefixArrayOk returns a tuple with the PrefixArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.PrefixArray) {
-    return nil, false
+	if o == nil || o.PrefixArray == nil {
+		return nil, false
 	}
 	return o.PrefixArray, true
 }
 
 // HasPrefixArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixArray() bool {
-	if o != nil && !isNil(o.PrefixArray) {
+	if o != nil && o.PrefixArray != nil {
 		return true
 	}
 
@@ -578,7 +581,7 @@ func (o *XmlItem) SetPrefixArray(v []int32) {
 
 // GetPrefixWrappedArray returns the PrefixWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixWrappedArray() []int32 {
-	if o == nil || isNil(o.PrefixWrappedArray) {
+	if o == nil || o.PrefixWrappedArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -588,15 +591,15 @@ func (o *XmlItem) GetPrefixWrappedArray() []int32 {
 // GetPrefixWrappedArrayOk returns a tuple with the PrefixWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixWrappedArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.PrefixWrappedArray) {
-    return nil, false
+	if o == nil || o.PrefixWrappedArray == nil {
+		return nil, false
 	}
 	return o.PrefixWrappedArray, true
 }
 
 // HasPrefixWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixWrappedArray() bool {
-	if o != nil && !isNil(o.PrefixWrappedArray) {
+	if o != nil && o.PrefixWrappedArray != nil {
 		return true
 	}
 
@@ -610,7 +613,7 @@ func (o *XmlItem) SetPrefixWrappedArray(v []int32) {
 
 // GetNamespaceString returns the NamespaceString field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceString() string {
-	if o == nil || isNil(o.NamespaceString) {
+	if o == nil || o.NamespaceString == nil {
 		var ret string
 		return ret
 	}
@@ -620,15 +623,15 @@ func (o *XmlItem) GetNamespaceString() string {
 // GetNamespaceStringOk returns a tuple with the NamespaceString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceStringOk() (*string, bool) {
-	if o == nil || isNil(o.NamespaceString) {
-    return nil, false
+	if o == nil || o.NamespaceString == nil {
+		return nil, false
 	}
 	return o.NamespaceString, true
 }
 
 // HasNamespaceString returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceString() bool {
-	if o != nil && !isNil(o.NamespaceString) {
+	if o != nil && o.NamespaceString != nil {
 		return true
 	}
 
@@ -642,7 +645,7 @@ func (o *XmlItem) SetNamespaceString(v string) {
 
 // GetNamespaceNumber returns the NamespaceNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceNumber() float32 {
-	if o == nil || isNil(o.NamespaceNumber) {
+	if o == nil || o.NamespaceNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -652,15 +655,15 @@ func (o *XmlItem) GetNamespaceNumber() float32 {
 // GetNamespaceNumberOk returns a tuple with the NamespaceNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.NamespaceNumber) {
-    return nil, false
+	if o == nil || o.NamespaceNumber == nil {
+		return nil, false
 	}
 	return o.NamespaceNumber, true
 }
 
 // HasNamespaceNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceNumber() bool {
-	if o != nil && !isNil(o.NamespaceNumber) {
+	if o != nil && o.NamespaceNumber != nil {
 		return true
 	}
 
@@ -674,7 +677,7 @@ func (o *XmlItem) SetNamespaceNumber(v float32) {
 
 // GetNamespaceInteger returns the NamespaceInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceInteger() int32 {
-	if o == nil || isNil(o.NamespaceInteger) {
+	if o == nil || o.NamespaceInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -684,15 +687,15 @@ func (o *XmlItem) GetNamespaceInteger() int32 {
 // GetNamespaceIntegerOk returns a tuple with the NamespaceInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.NamespaceInteger) {
-    return nil, false
+	if o == nil || o.NamespaceInteger == nil {
+		return nil, false
 	}
 	return o.NamespaceInteger, true
 }
 
 // HasNamespaceInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceInteger() bool {
-	if o != nil && !isNil(o.NamespaceInteger) {
+	if o != nil && o.NamespaceInteger != nil {
 		return true
 	}
 
@@ -706,7 +709,7 @@ func (o *XmlItem) SetNamespaceInteger(v int32) {
 
 // GetNamespaceBoolean returns the NamespaceBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceBoolean() bool {
-	if o == nil || isNil(o.NamespaceBoolean) {
+	if o == nil || o.NamespaceBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -716,15 +719,15 @@ func (o *XmlItem) GetNamespaceBoolean() bool {
 // GetNamespaceBooleanOk returns a tuple with the NamespaceBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.NamespaceBoolean) {
-    return nil, false
+	if o == nil || o.NamespaceBoolean == nil {
+		return nil, false
 	}
 	return o.NamespaceBoolean, true
 }
 
 // HasNamespaceBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceBoolean() bool {
-	if o != nil && !isNil(o.NamespaceBoolean) {
+	if o != nil && o.NamespaceBoolean != nil {
 		return true
 	}
 
@@ -738,7 +741,7 @@ func (o *XmlItem) SetNamespaceBoolean(v bool) {
 
 // GetNamespaceArray returns the NamespaceArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceArray() []int32 {
-	if o == nil || isNil(o.NamespaceArray) {
+	if o == nil || o.NamespaceArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -748,15 +751,15 @@ func (o *XmlItem) GetNamespaceArray() []int32 {
 // GetNamespaceArrayOk returns a tuple with the NamespaceArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.NamespaceArray) {
-    return nil, false
+	if o == nil || o.NamespaceArray == nil {
+		return nil, false
 	}
 	return o.NamespaceArray, true
 }
 
 // HasNamespaceArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceArray() bool {
-	if o != nil && !isNil(o.NamespaceArray) {
+	if o != nil && o.NamespaceArray != nil {
 		return true
 	}
 
@@ -770,7 +773,7 @@ func (o *XmlItem) SetNamespaceArray(v []int32) {
 
 // GetNamespaceWrappedArray returns the NamespaceWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceWrappedArray() []int32 {
-	if o == nil || isNil(o.NamespaceWrappedArray) {
+	if o == nil || o.NamespaceWrappedArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -780,15 +783,15 @@ func (o *XmlItem) GetNamespaceWrappedArray() []int32 {
 // GetNamespaceWrappedArrayOk returns a tuple with the NamespaceWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceWrappedArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.NamespaceWrappedArray) {
-    return nil, false
+	if o == nil || o.NamespaceWrappedArray == nil {
+		return nil, false
 	}
 	return o.NamespaceWrappedArray, true
 }
 
 // HasNamespaceWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceWrappedArray() bool {
-	if o != nil && !isNil(o.NamespaceWrappedArray) {
+	if o != nil && o.NamespaceWrappedArray != nil {
 		return true
 	}
 
@@ -802,7 +805,7 @@ func (o *XmlItem) SetNamespaceWrappedArray(v []int32) {
 
 // GetPrefixNsString returns the PrefixNsString field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsString() string {
-	if o == nil || isNil(o.PrefixNsString) {
+	if o == nil || o.PrefixNsString == nil {
 		var ret string
 		return ret
 	}
@@ -812,15 +815,15 @@ func (o *XmlItem) GetPrefixNsString() string {
 // GetPrefixNsStringOk returns a tuple with the PrefixNsString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsStringOk() (*string, bool) {
-	if o == nil || isNil(o.PrefixNsString) {
-    return nil, false
+	if o == nil || o.PrefixNsString == nil {
+		return nil, false
 	}
 	return o.PrefixNsString, true
 }
 
 // HasPrefixNsString returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsString() bool {
-	if o != nil && !isNil(o.PrefixNsString) {
+	if o != nil && o.PrefixNsString != nil {
 		return true
 	}
 
@@ -834,7 +837,7 @@ func (o *XmlItem) SetPrefixNsString(v string) {
 
 // GetPrefixNsNumber returns the PrefixNsNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsNumber() float32 {
-	if o == nil || isNil(o.PrefixNsNumber) {
+	if o == nil || o.PrefixNsNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -844,15 +847,15 @@ func (o *XmlItem) GetPrefixNsNumber() float32 {
 // GetPrefixNsNumberOk returns a tuple with the PrefixNsNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.PrefixNsNumber) {
-    return nil, false
+	if o == nil || o.PrefixNsNumber == nil {
+		return nil, false
 	}
 	return o.PrefixNsNumber, true
 }
 
 // HasPrefixNsNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsNumber() bool {
-	if o != nil && !isNil(o.PrefixNsNumber) {
+	if o != nil && o.PrefixNsNumber != nil {
 		return true
 	}
 
@@ -866,7 +869,7 @@ func (o *XmlItem) SetPrefixNsNumber(v float32) {
 
 // GetPrefixNsInteger returns the PrefixNsInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsInteger() int32 {
-	if o == nil || isNil(o.PrefixNsInteger) {
+	if o == nil || o.PrefixNsInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -876,15 +879,15 @@ func (o *XmlItem) GetPrefixNsInteger() int32 {
 // GetPrefixNsIntegerOk returns a tuple with the PrefixNsInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.PrefixNsInteger) {
-    return nil, false
+	if o == nil || o.PrefixNsInteger == nil {
+		return nil, false
 	}
 	return o.PrefixNsInteger, true
 }
 
 // HasPrefixNsInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsInteger() bool {
-	if o != nil && !isNil(o.PrefixNsInteger) {
+	if o != nil && o.PrefixNsInteger != nil {
 		return true
 	}
 
@@ -898,7 +901,7 @@ func (o *XmlItem) SetPrefixNsInteger(v int32) {
 
 // GetPrefixNsBoolean returns the PrefixNsBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsBoolean() bool {
-	if o == nil || isNil(o.PrefixNsBoolean) {
+	if o == nil || o.PrefixNsBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -908,15 +911,15 @@ func (o *XmlItem) GetPrefixNsBoolean() bool {
 // GetPrefixNsBooleanOk returns a tuple with the PrefixNsBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.PrefixNsBoolean) {
-    return nil, false
+	if o == nil || o.PrefixNsBoolean == nil {
+		return nil, false
 	}
 	return o.PrefixNsBoolean, true
 }
 
 // HasPrefixNsBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsBoolean() bool {
-	if o != nil && !isNil(o.PrefixNsBoolean) {
+	if o != nil && o.PrefixNsBoolean != nil {
 		return true
 	}
 
@@ -930,7 +933,7 @@ func (o *XmlItem) SetPrefixNsBoolean(v bool) {
 
 // GetPrefixNsArray returns the PrefixNsArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsArray() []int32 {
-	if o == nil || isNil(o.PrefixNsArray) {
+	if o == nil || o.PrefixNsArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -940,15 +943,15 @@ func (o *XmlItem) GetPrefixNsArray() []int32 {
 // GetPrefixNsArrayOk returns a tuple with the PrefixNsArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.PrefixNsArray) {
-    return nil, false
+	if o == nil || o.PrefixNsArray == nil {
+		return nil, false
 	}
 	return o.PrefixNsArray, true
 }
 
 // HasPrefixNsArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsArray() bool {
-	if o != nil && !isNil(o.PrefixNsArray) {
+	if o != nil && o.PrefixNsArray != nil {
 		return true
 	}
 
@@ -962,7 +965,7 @@ func (o *XmlItem) SetPrefixNsArray(v []int32) {
 
 // GetPrefixNsWrappedArray returns the PrefixNsWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsWrappedArray() []int32 {
-	if o == nil || isNil(o.PrefixNsWrappedArray) {
+	if o == nil || o.PrefixNsWrappedArray == nil {
 		var ret []int32
 		return ret
 	}
@@ -972,15 +975,15 @@ func (o *XmlItem) GetPrefixNsWrappedArray() []int32 {
 // GetPrefixNsWrappedArrayOk returns a tuple with the PrefixNsWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsWrappedArrayOk() ([]int32, bool) {
-	if o == nil || isNil(o.PrefixNsWrappedArray) {
-    return nil, false
+	if o == nil || o.PrefixNsWrappedArray == nil {
+		return nil, false
 	}
 	return o.PrefixNsWrappedArray, true
 }
 
 // HasPrefixNsWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsWrappedArray() bool {
-	if o != nil && !isNil(o.PrefixNsWrappedArray) {
+	if o != nil && o.PrefixNsWrappedArray != nil {
 		return true
 	}
 
@@ -993,95 +996,100 @@ func (o *XmlItem) SetPrefixNsWrappedArray(v []int32) {
 }
 
 func (o XmlItem) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o XmlItem) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.AttributeString) {
-		toSerialize["attribute_string"] = o.AttributeString
+	if o.AttributeString != nil {
+		toSerialize["attribute_string"] = *o.AttributeString
 	}
-	if !isNil(o.AttributeNumber) {
-		toSerialize["attribute_number"] = o.AttributeNumber
+	if o.AttributeNumber != nil {
+		toSerialize["attribute_number"] = *o.AttributeNumber
 	}
-	if !isNil(o.AttributeInteger) {
-		toSerialize["attribute_integer"] = o.AttributeInteger
+	if o.AttributeInteger != nil {
+		toSerialize["attribute_integer"] = *o.AttributeInteger
 	}
-	if !isNil(o.AttributeBoolean) {
-		toSerialize["attribute_boolean"] = o.AttributeBoolean
+	if o.AttributeBoolean != nil {
+		toSerialize["attribute_boolean"] = *o.AttributeBoolean
 	}
-	if !isNil(o.WrappedArray) {
-		toSerialize["wrapped_array"] = o.WrappedArray
+	if o.WrappedArray != nil {
+		toSerialize["wrapped_array"] = *o.WrappedArray
 	}
-	if !isNil(o.NameString) {
-		toSerialize["name_string"] = o.NameString
+	if o.NameString != nil {
+		toSerialize["name_string"] = *o.NameString
 	}
-	if !isNil(o.NameNumber) {
-		toSerialize["name_number"] = o.NameNumber
+	if o.NameNumber != nil {
+		toSerialize["name_number"] = *o.NameNumber
 	}
-	if !isNil(o.NameInteger) {
-		toSerialize["name_integer"] = o.NameInteger
+	if o.NameInteger != nil {
+		toSerialize["name_integer"] = *o.NameInteger
 	}
-	if !isNil(o.NameBoolean) {
-		toSerialize["name_boolean"] = o.NameBoolean
+	if o.NameBoolean != nil {
+		toSerialize["name_boolean"] = *o.NameBoolean
 	}
-	if !isNil(o.NameArray) {
-		toSerialize["name_array"] = o.NameArray
+	if o.NameArray != nil {
+		toSerialize["name_array"] = *o.NameArray
 	}
-	if !isNil(o.NameWrappedArray) {
-		toSerialize["name_wrapped_array"] = o.NameWrappedArray
+	if o.NameWrappedArray != nil {
+		toSerialize["name_wrapped_array"] = *o.NameWrappedArray
 	}
-	if !isNil(o.PrefixString) {
-		toSerialize["prefix_string"] = o.PrefixString
+	if o.PrefixString != nil {
+		toSerialize["prefix_string"] = *o.PrefixString
 	}
-	if !isNil(o.PrefixNumber) {
-		toSerialize["prefix_number"] = o.PrefixNumber
+	if o.PrefixNumber != nil {
+		toSerialize["prefix_number"] = *o.PrefixNumber
 	}
-	if !isNil(o.PrefixInteger) {
-		toSerialize["prefix_integer"] = o.PrefixInteger
+	if o.PrefixInteger != nil {
+		toSerialize["prefix_integer"] = *o.PrefixInteger
 	}
-	if !isNil(o.PrefixBoolean) {
-		toSerialize["prefix_boolean"] = o.PrefixBoolean
+	if o.PrefixBoolean != nil {
+		toSerialize["prefix_boolean"] = *o.PrefixBoolean
 	}
-	if !isNil(o.PrefixArray) {
-		toSerialize["prefix_array"] = o.PrefixArray
+	if o.PrefixArray != nil {
+		toSerialize["prefix_array"] = *o.PrefixArray
 	}
-	if !isNil(o.PrefixWrappedArray) {
-		toSerialize["prefix_wrapped_array"] = o.PrefixWrappedArray
+	if o.PrefixWrappedArray != nil {
+		toSerialize["prefix_wrapped_array"] = *o.PrefixWrappedArray
 	}
-	if !isNil(o.NamespaceString) {
-		toSerialize["namespace_string"] = o.NamespaceString
+	if o.NamespaceString != nil {
+		toSerialize["namespace_string"] = *o.NamespaceString
 	}
-	if !isNil(o.NamespaceNumber) {
-		toSerialize["namespace_number"] = o.NamespaceNumber
+	if o.NamespaceNumber != nil {
+		toSerialize["namespace_number"] = *o.NamespaceNumber
 	}
-	if !isNil(o.NamespaceInteger) {
-		toSerialize["namespace_integer"] = o.NamespaceInteger
+	if o.NamespaceInteger != nil {
+		toSerialize["namespace_integer"] = *o.NamespaceInteger
 	}
-	if !isNil(o.NamespaceBoolean) {
-		toSerialize["namespace_boolean"] = o.NamespaceBoolean
+	if o.NamespaceBoolean != nil {
+		toSerialize["namespace_boolean"] = *o.NamespaceBoolean
 	}
-	if !isNil(o.NamespaceArray) {
-		toSerialize["namespace_array"] = o.NamespaceArray
+	if o.NamespaceArray != nil {
+		toSerialize["namespace_array"] = *o.NamespaceArray
 	}
-	if !isNil(o.NamespaceWrappedArray) {
-		toSerialize["namespace_wrapped_array"] = o.NamespaceWrappedArray
+	if o.NamespaceWrappedArray != nil {
+		toSerialize["namespace_wrapped_array"] = *o.NamespaceWrappedArray
 	}
-	if !isNil(o.PrefixNsString) {
-		toSerialize["prefix_ns_string"] = o.PrefixNsString
+	if o.PrefixNsString != nil {
+		toSerialize["prefix_ns_string"] = *o.PrefixNsString
 	}
-	if !isNil(o.PrefixNsNumber) {
-		toSerialize["prefix_ns_number"] = o.PrefixNsNumber
+	if o.PrefixNsNumber != nil {
+		toSerialize["prefix_ns_number"] = *o.PrefixNsNumber
 	}
-	if !isNil(o.PrefixNsInteger) {
-		toSerialize["prefix_ns_integer"] = o.PrefixNsInteger
+	if o.PrefixNsInteger != nil {
+		toSerialize["prefix_ns_integer"] = *o.PrefixNsInteger
 	}
-	if !isNil(o.PrefixNsBoolean) {
-		toSerialize["prefix_ns_boolean"] = o.PrefixNsBoolean
+	if o.PrefixNsBoolean != nil {
+		toSerialize["prefix_ns_boolean"] = *o.PrefixNsBoolean
 	}
-	if !isNil(o.PrefixNsArray) {
-		toSerialize["prefix_ns_array"] = o.PrefixNsArray
+	if o.PrefixNsArray != nil {
+		toSerialize["prefix_ns_array"] = *o.PrefixNsArray
 	}
-	if !isNil(o.PrefixNsWrappedArray) {
-		toSerialize["prefix_ns_wrapped_array"] = o.PrefixNsWrappedArray
+	if o.PrefixNsWrappedArray != nil {
+		toSerialize["prefix_ns_wrapped_array"] = *o.PrefixNsWrappedArray
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableXmlItem struct {
diff --git a/samples/client/petstore/go/go-petstore/utils.go b/samples/client/petstore/go/go-petstore/utils.go
index 866bbf7f1eb..ba83c9efcf3 100644
--- a/samples/client/petstore/go/go-petstore/utils.go
+++ b/samples/client/petstore/go/go-petstore/utils.go
@@ -340,4 +340,7 @@ func isNil(i interface{}) bool {
         return reflect.ValueOf(i).IsZero()
     }
     return false
-}
\ No newline at end of file
+}
+type MappedNullable interface {
+	ToMap() map[string]interface{}
+}
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
index 7501f465647..ff967dc2057 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
@@ -125,8 +125,9 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
-func parameterToString(obj interface{}, collectionFormat string) string {
+// parameterAddToQuery adds the provided object to the url query supporting deep object specification
+// the del delimiter is used to the split the value as list
+func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -141,12 +142,64 @@ func parameterToString(obj interface{}, collectionFormat string) string {
 	}
 
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
+		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
+		if len(sliceValue) > 0 {
+			var ifaceValue = make([]interface{}, 0, len(sliceValue))
+			for v := range sliceValue {
+				ifaceValue = append(ifaceValue, v)
+			}
+			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
+		}
+		return
+
+	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+		var param,ok = obj.(MappedNullable)
+		if ok {
+			dataMap := param.ToMap()
+			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			return
+		}
+
 	} else if t, ok := obj.(time.Time); ok {
-		return t.Format(time.RFC3339)
+		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		return
+	}
+
+	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+}
+
+// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
+func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for key,value := range param {
+		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
 	}
+}
 
-	return fmt.Sprintf("%v", obj)
+// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
+func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for index,value := range param {
+		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
+	}
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
index 4cff93795c1..c0c6b2cb309 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
@@ -340,4 +340,7 @@ func isNil(i interface{}) bool {
         return reflect.ValueOf(i).IsZero()
     }
     return false
-}
\ No newline at end of file
+}
+type MappedNullable interface {
+	ToMap() map[string]interface{}
+}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
index 4594645964c..68343374529 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
@@ -1442,20 +1442,20 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("enum_query_string_array", parameterToString(s.Index(i), "multi"))
+				parameterAddToQuery(localVarQueryParams, "enum_query_string_array", s.Index(i), "multi")
 			}
 		} else {
-			localVarQueryParams.Add("enum_query_string_array", parameterToString(t, "multi"))
+                        parameterAddToQuery(localVarQueryParams, "enum_query_string_array", t, "multi")
 		}
 	}
 	if r.enumQueryString != nil {
-		localVarQueryParams.Add("enum_query_string", parameterToString(*r.enumQueryString, ""))
+                parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
 	}
 	if r.enumQueryInteger != nil {
-		localVarQueryParams.Add("enum_query_integer", parameterToString(*r.enumQueryInteger, ""))
+                parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
 	}
 	if r.enumQueryDouble != nil {
-		localVarQueryParams.Add("enum_query_double", parameterToString(*r.enumQueryDouble, ""))
+                parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/x-www-form-urlencoded"}
@@ -1611,10 +1611,10 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	localVarQueryParams.Add("required_string_group", parameterToString(*r.requiredStringGroup, ""))
 	localVarQueryParams.Add("required_int64_group", parameterToString(*r.requiredInt64Group, ""))
 	if r.stringGroup != nil {
-		localVarQueryParams.Add("string_group", parameterToString(*r.stringGroup, ""))
+                parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
 	}
 	if r.int64Group != nil {
-		localVarQueryParams.Add("int64_group", parameterToString(*r.int64Group, ""))
+                parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
@@ -1978,10 +1978,10 @@ func (a *FakeApiService) TestQueryParameterCollectionFormatExecute(r ApiTestQuer
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("pipe", parameterToString(s.Index(i), "multi"))
+				parameterToString(localVarQueryParams, "pipe", s.Index(i), "multi")
 			}
 		} else {
-			localVarQueryParams.Add("pipe", parameterToString(t, "multi"))
+                        parameterToString(localVarQueryParams, "pipe", t, "multi")
 		}
 	}
 	localVarQueryParams.Add("ioutil", parameterToString(*r.ioutil, "csv"))
@@ -1992,10 +1992,10 @@ func (a *FakeApiService) TestQueryParameterCollectionFormatExecute(r ApiTestQuer
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("context", parameterToString(s.Index(i), "multi"))
+				parameterToString(localVarQueryParams, "context", s.Index(i), "multi")
 			}
 		} else {
-			localVarQueryParams.Add("context", parameterToString(t, "multi"))
+                        parameterToString(localVarQueryParams, "context", t, "multi")
 		}
 	}
 	// to determine the Content-Type header
@@ -2111,10 +2111,10 @@ func (a *FakeApiService) TestUniqueItemsHeaderAndQueryParameterCollectionFormatE
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				localVarQueryParams.Add("queryUnique", parameterToString(s.Index(i), "multi"))
+				parameterToString(localVarQueryParams, "queryUnique", s.Index(i), "multi")
 			}
 		} else {
-			localVarQueryParams.Add("queryUnique", parameterToString(t, "multi"))
+                        parameterToString(localVarQueryParams, "queryUnique", t, "multi")
 		}
 	}
 	// to determine the Content-Type header
diff --git a/samples/openapi3/client/petstore/go/go-petstore/client.go b/samples/openapi3/client/petstore/go/go-petstore/client.go
index a573bd4fa89..eaab27a18e1 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/client.go
@@ -143,8 +143,9 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
-func parameterToString(obj interface{}, collectionFormat string) string {
+// parameterAddToQuery adds the provided object to the url query supporting deep object specification
+// the del delimiter is used to the split the value as list
+func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -159,12 +160,64 @@ func parameterToString(obj interface{}, collectionFormat string) string {
 	}
 
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
+		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
+		if len(sliceValue) > 0 {
+			var ifaceValue = make([]interface{}, 0, len(sliceValue))
+			for v := range sliceValue {
+				ifaceValue = append(ifaceValue, v)
+			}
+			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
+		}
+		return
+
+	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+		var param,ok = obj.(MappedNullable)
+		if ok {
+			dataMap := param.ToMap()
+			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			return
+		}
+
 	} else if t, ok := obj.(time.Time); ok {
-		return t.Format(time.RFC3339)
+		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		return
+	}
+
+	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+}
+
+// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
+func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for key,value := range param {
+		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
 	}
+}
 
-	return fmt.Sprintf("%v", obj)
+// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
+func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
+	if len(param) == 0 {
+		return
+	}
+	for index,value := range param {
+		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
+		if reflect.TypeOf(value).Kind() == reflect.Slice {
+			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
+		} else if reflect.TypeOf(value).Kind() == reflect.Map {
+			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
+		} else {
+			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+		}
+	}
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
index d71fe66e143..dcc0c38ddf1 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Model200Response type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Model200Response{}
+
 // Model200Response Model for testing model name starting with number
 type Model200Response struct {
 	Name *int32 `json:"name,omitempty"`
@@ -42,7 +45,7 @@ func NewModel200ResponseWithDefaults() *Model200Response {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *Model200Response) GetName() int32 {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret int32
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *Model200Response) GetName() int32 {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Model200Response) GetNameOk() (*int32, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *Model200Response) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *Model200Response) SetName(v int32) {
 
 // GetClass returns the Class field value if set, zero value otherwise.
 func (o *Model200Response) GetClass() string {
-	if o == nil || isNil(o.Class) {
+	if o == nil || o.Class == nil {
 		var ret string
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *Model200Response) GetClass() string {
 // GetClassOk returns a tuple with the Class field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Model200Response) GetClassOk() (*string, bool) {
-	if o == nil || isNil(o.Class) {
-    return nil, false
+	if o == nil || o.Class == nil {
+		return nil, false
 	}
 	return o.Class, true
 }
 
 // HasClass returns a boolean if a field has been set.
 func (o *Model200Response) HasClass() bool {
-	if o != nil && !isNil(o.Class) {
+	if o != nil && o.Class != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *Model200Response) SetClass(v string) {
 }
 
 func (o Model200Response) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Model200Response) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
-	if !isNil(o.Class) {
-		toSerialize["class"] = o.Class
+	if o.Class != nil {
+		toSerialize["class"] = *o.Class
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Model200Response) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
index af0a9889e8a..16bb6d2f7a6 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the FooGetDefaultResponse type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FooGetDefaultResponse{}
+
 // FooGetDefaultResponse struct for FooGetDefaultResponse
 type FooGetDefaultResponse struct {
 	String *Foo `json:"string,omitempty"`
@@ -41,7 +44,7 @@ func NewFooGetDefaultResponseWithDefaults() *FooGetDefaultResponse {
 
 // GetString returns the String field value if set, zero value otherwise.
 func (o *FooGetDefaultResponse) GetString() Foo {
-	if o == nil || isNil(o.String) {
+	if o == nil || o.String == nil {
 		var ret Foo
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *FooGetDefaultResponse) GetString() Foo {
 // GetStringOk returns a tuple with the String field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FooGetDefaultResponse) GetStringOk() (*Foo, bool) {
-	if o == nil || isNil(o.String) {
-    return nil, false
+	if o == nil || o.String == nil {
+		return nil, false
 	}
 	return o.String, true
 }
 
 // HasString returns a boolean if a field has been set.
 func (o *FooGetDefaultResponse) HasString() bool {
-	if o != nil && !isNil(o.String) {
+	if o != nil && o.String != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *FooGetDefaultResponse) SetString(v Foo) {
 }
 
 func (o FooGetDefaultResponse) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o FooGetDefaultResponse) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.String) {
-		toSerialize["string"] = o.String
+	if o.String != nil {
+		toSerialize["string"] = *o.String
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *FooGetDefaultResponse) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
index 081d5b1970a..6fd4106a838 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the SpecialModelName type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &SpecialModelName{}
+
 // SpecialModelName struct for SpecialModelName
 type SpecialModelName struct {
 	SpecialPropertyName *int64 `json:"$special[property.name],omitempty"`
@@ -41,7 +44,7 @@ func NewSpecialModelNameWithDefaults() *SpecialModelName {
 
 // GetSpecialPropertyName returns the SpecialPropertyName field value if set, zero value otherwise.
 func (o *SpecialModelName) GetSpecialPropertyName() int64 {
-	if o == nil || isNil(o.SpecialPropertyName) {
+	if o == nil || o.SpecialPropertyName == nil {
 		var ret int64
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *SpecialModelName) GetSpecialPropertyName() int64 {
 // GetSpecialPropertyNameOk returns a tuple with the SpecialPropertyName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *SpecialModelName) GetSpecialPropertyNameOk() (*int64, bool) {
-	if o == nil || isNil(o.SpecialPropertyName) {
-    return nil, false
+	if o == nil || o.SpecialPropertyName == nil {
+		return nil, false
 	}
 	return o.SpecialPropertyName, true
 }
 
 // HasSpecialPropertyName returns a boolean if a field has been set.
 func (o *SpecialModelName) HasSpecialPropertyName() bool {
-	if o != nil && !isNil(o.SpecialPropertyName) {
+	if o != nil && o.SpecialPropertyName != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *SpecialModelName) SetSpecialPropertyName(v int64) {
 }
 
 func (o SpecialModelName) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o SpecialModelName) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.SpecialPropertyName) {
-		toSerialize["$special[property.name]"] = o.SpecialPropertyName
+	if o.SpecialPropertyName != nil {
+		toSerialize["$special[property.name]"] = *o.SpecialPropertyName
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *SpecialModelName) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
index c0a955ec13a..279f2cfeaac 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AdditionalPropertiesClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AdditionalPropertiesClass{}
+
 // AdditionalPropertiesClass struct for AdditionalPropertiesClass
 type AdditionalPropertiesClass struct {
 	MapProperty *map[string]string `json:"map_property,omitempty"`
@@ -42,7 +45,7 @@ func NewAdditionalPropertiesClassWithDefaults() *AdditionalPropertiesClass {
 
 // GetMapProperty returns the MapProperty field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapProperty() map[string]string {
-	if o == nil || isNil(o.MapProperty) {
+	if o == nil || o.MapProperty == nil {
 		var ret map[string]string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *AdditionalPropertiesClass) GetMapProperty() map[string]string {
 // GetMapPropertyOk returns a tuple with the MapProperty field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapPropertyOk() (*map[string]string, bool) {
-	if o == nil || isNil(o.MapProperty) {
-    return nil, false
+	if o == nil || o.MapProperty == nil {
+		return nil, false
 	}
 	return o.MapProperty, true
 }
 
 // HasMapProperty returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapProperty() bool {
-	if o != nil && !isNil(o.MapProperty) {
+	if o != nil && o.MapProperty != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *AdditionalPropertiesClass) SetMapProperty(v map[string]string) {
 
 // GetMapOfMapProperty returns the MapOfMapProperty field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapOfMapProperty() map[string]map[string]string {
-	if o == nil || isNil(o.MapOfMapProperty) {
+	if o == nil || o.MapOfMapProperty == nil {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *AdditionalPropertiesClass) GetMapOfMapProperty() map[string]map[string]
 // GetMapOfMapPropertyOk returns a tuple with the MapOfMapProperty field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapOfMapPropertyOk() (*map[string]map[string]string, bool) {
-	if o == nil || isNil(o.MapOfMapProperty) {
-    return nil, false
+	if o == nil || o.MapOfMapProperty == nil {
+		return nil, false
 	}
 	return o.MapOfMapProperty, true
 }
 
 // HasMapOfMapProperty returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapOfMapProperty() bool {
-	if o != nil && !isNil(o.MapOfMapProperty) {
+	if o != nil && o.MapOfMapProperty != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *AdditionalPropertiesClass) SetMapOfMapProperty(v map[string]map[string]
 }
 
 func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AdditionalPropertiesClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.MapProperty) {
-		toSerialize["map_property"] = o.MapProperty
+	if o.MapProperty != nil {
+		toSerialize["map_property"] = *o.MapProperty
 	}
-	if !isNil(o.MapOfMapProperty) {
-		toSerialize["map_of_map_property"] = o.MapOfMapProperty
+	if o.MapOfMapProperty != nil {
+		toSerialize["map_of_map_property"] = *o.MapOfMapProperty
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *AdditionalPropertiesClass) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
index cc666634936..2d4dfcf0c39 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Animal type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Animal{}
+
 // Animal struct for Animal
 type Animal struct {
 	ClassName string `json:"className"`
@@ -59,7 +62,7 @@ func (o *Animal) GetClassName() string {
 // and a boolean to check if the value has been set.
 func (o *Animal) GetClassNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.ClassName, true
 }
@@ -71,7 +74,7 @@ func (o *Animal) SetClassName(v string) {
 
 // GetColor returns the Color field value if set, zero value otherwise.
 func (o *Animal) GetColor() string {
-	if o == nil || isNil(o.Color) {
+	if o == nil || o.Color == nil {
 		var ret string
 		return ret
 	}
@@ -81,15 +84,15 @@ func (o *Animal) GetColor() string {
 // GetColorOk returns a tuple with the Color field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Animal) GetColorOk() (*string, bool) {
-	if o == nil || isNil(o.Color) {
-    return nil, false
+	if o == nil || o.Color == nil {
+		return nil, false
 	}
 	return o.Color, true
 }
 
 // HasColor returns a boolean if a field has been set.
 func (o *Animal) HasColor() bool {
-	if o != nil && !isNil(o.Color) {
+	if o != nil && o.Color != nil {
 		return true
 	}
 
@@ -102,19 +105,24 @@ func (o *Animal) SetColor(v string) {
 }
 
 func (o Animal) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Animal) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["className"] = o.ClassName
+		toSerialize["className"] = *o.ClassName
 	}
-	if !isNil(o.Color) {
-		toSerialize["color"] = o.Color
+	if o.Color != nil {
+		toSerialize["color"] = *o.Color
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Animal) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
index cbc0cfc691f..53e28c4db6e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ApiResponse type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ApiResponse{}
+
 // ApiResponse struct for ApiResponse
 type ApiResponse struct {
 	Code *int32 `json:"code,omitempty"`
@@ -43,7 +46,7 @@ func NewApiResponseWithDefaults() *ApiResponse {
 
 // GetCode returns the Code field value if set, zero value otherwise.
 func (o *ApiResponse) GetCode() int32 {
-	if o == nil || isNil(o.Code) {
+	if o == nil || o.Code == nil {
 		var ret int32
 		return ret
 	}
@@ -53,15 +56,15 @@ func (o *ApiResponse) GetCode() int32 {
 // GetCodeOk returns a tuple with the Code field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetCodeOk() (*int32, bool) {
-	if o == nil || isNil(o.Code) {
-    return nil, false
+	if o == nil || o.Code == nil {
+		return nil, false
 	}
 	return o.Code, true
 }
 
 // HasCode returns a boolean if a field has been set.
 func (o *ApiResponse) HasCode() bool {
-	if o != nil && !isNil(o.Code) {
+	if o != nil && o.Code != nil {
 		return true
 	}
 
@@ -75,7 +78,7 @@ func (o *ApiResponse) SetCode(v int32) {
 
 // GetType returns the Type field value if set, zero value otherwise.
 func (o *ApiResponse) GetType() string {
-	if o == nil || isNil(o.Type) {
+	if o == nil || o.Type == nil {
 		var ret string
 		return ret
 	}
@@ -85,15 +88,15 @@ func (o *ApiResponse) GetType() string {
 // GetTypeOk returns a tuple with the Type field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetTypeOk() (*string, bool) {
-	if o == nil || isNil(o.Type) {
-    return nil, false
+	if o == nil || o.Type == nil {
+		return nil, false
 	}
 	return o.Type, true
 }
 
 // HasType returns a boolean if a field has been set.
 func (o *ApiResponse) HasType() bool {
-	if o != nil && !isNil(o.Type) {
+	if o != nil && o.Type != nil {
 		return true
 	}
 
@@ -107,7 +110,7 @@ func (o *ApiResponse) SetType(v string) {
 
 // GetMessage returns the Message field value if set, zero value otherwise.
 func (o *ApiResponse) GetMessage() string {
-	if o == nil || isNil(o.Message) {
+	if o == nil || o.Message == nil {
 		var ret string
 		return ret
 	}
@@ -117,15 +120,15 @@ func (o *ApiResponse) GetMessage() string {
 // GetMessageOk returns a tuple with the Message field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetMessageOk() (*string, bool) {
-	if o == nil || isNil(o.Message) {
-    return nil, false
+	if o == nil || o.Message == nil {
+		return nil, false
 	}
 	return o.Message, true
 }
 
 // HasMessage returns a boolean if a field has been set.
 func (o *ApiResponse) HasMessage() bool {
-	if o != nil && !isNil(o.Message) {
+	if o != nil && o.Message != nil {
 		return true
 	}
 
@@ -138,22 +141,27 @@ func (o *ApiResponse) SetMessage(v string) {
 }
 
 func (o ApiResponse) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ApiResponse) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Code) {
-		toSerialize["code"] = o.Code
+	if o.Code != nil {
+		toSerialize["code"] = *o.Code
 	}
-	if !isNil(o.Type) {
-		toSerialize["type"] = o.Type
+	if o.Type != nil {
+		toSerialize["type"] = *o.Type
 	}
-	if !isNil(o.Message) {
-		toSerialize["message"] = o.Message
+	if o.Message != nil {
+		toSerialize["message"] = *o.Message
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ApiResponse) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
index ef09d3d96bb..a7d90769792 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Apple type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Apple{}
+
 // Apple struct for Apple
 type Apple struct {
 	Cultivar *string `json:"cultivar,omitempty"`
@@ -41,7 +44,7 @@ func NewAppleWithDefaults() *Apple {
 
 // GetCultivar returns the Cultivar field value if set, zero value otherwise.
 func (o *Apple) GetCultivar() string {
-	if o == nil || isNil(o.Cultivar) {
+	if o == nil || o.Cultivar == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *Apple) GetCultivar() string {
 // GetCultivarOk returns a tuple with the Cultivar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Apple) GetCultivarOk() (*string, bool) {
-	if o == nil || isNil(o.Cultivar) {
-    return nil, false
+	if o == nil || o.Cultivar == nil {
+		return nil, false
 	}
 	return o.Cultivar, true
 }
 
 // HasCultivar returns a boolean if a field has been set.
 func (o *Apple) HasCultivar() bool {
-	if o != nil && !isNil(o.Cultivar) {
+	if o != nil && o.Cultivar != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *Apple) SetCultivar(v string) {
 }
 
 func (o Apple) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Apple) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Cultivar) {
-		toSerialize["cultivar"] = o.Cultivar
+	if o.Cultivar != nil {
+		toSerialize["cultivar"] = *o.Cultivar
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Apple) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
index 9dc1e2cca6a..738553d3d22 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AppleReq type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AppleReq{}
+
 // AppleReq struct for AppleReq
 type AppleReq struct {
 	Cultivar string `json:"cultivar"`
@@ -55,7 +58,7 @@ func (o *AppleReq) GetCultivar() string {
 // and a boolean to check if the value has been set.
 func (o *AppleReq) GetCultivarOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Cultivar, true
 }
@@ -67,7 +70,7 @@ func (o *AppleReq) SetCultivar(v string) {
 
 // GetMealy returns the Mealy field value if set, zero value otherwise.
 func (o *AppleReq) GetMealy() bool {
-	if o == nil || isNil(o.Mealy) {
+	if o == nil || o.Mealy == nil {
 		var ret bool
 		return ret
 	}
@@ -77,15 +80,15 @@ func (o *AppleReq) GetMealy() bool {
 // GetMealyOk returns a tuple with the Mealy field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AppleReq) GetMealyOk() (*bool, bool) {
-	if o == nil || isNil(o.Mealy) {
-    return nil, false
+	if o == nil || o.Mealy == nil {
+		return nil, false
 	}
 	return o.Mealy, true
 }
 
 // HasMealy returns a boolean if a field has been set.
 func (o *AppleReq) HasMealy() bool {
-	if o != nil && !isNil(o.Mealy) {
+	if o != nil && o.Mealy != nil {
 		return true
 	}
 
@@ -98,19 +101,24 @@ func (o *AppleReq) SetMealy(v bool) {
 }
 
 func (o AppleReq) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o AppleReq) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["cultivar"] = o.Cultivar
+		toSerialize["cultivar"] = *o.Cultivar
 	}
-	if !isNil(o.Mealy) {
-		toSerialize["mealy"] = o.Mealy
+	if o.Mealy != nil {
+		toSerialize["mealy"] = *o.Mealy
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *AppleReq) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
index 2e56b7dba7e..7748a7e9872 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ArrayOfArrayOfNumberOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ArrayOfArrayOfNumberOnly{}
+
 // ArrayOfArrayOfNumberOnly struct for ArrayOfArrayOfNumberOnly
 type ArrayOfArrayOfNumberOnly struct {
 	ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty"`
@@ -41,7 +44,7 @@ func NewArrayOfArrayOfNumberOnlyWithDefaults() *ArrayOfArrayOfNumberOnly {
 
 // GetArrayArrayNumber returns the ArrayArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
-	if o == nil || isNil(o.ArrayArrayNumber) {
+	if o == nil || o.ArrayArrayNumber == nil {
 		var ret [][]float32
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
 // GetArrayArrayNumberOk returns a tuple with the ArrayArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumberOk() ([][]float32, bool) {
-	if o == nil || isNil(o.ArrayArrayNumber) {
-    return nil, false
+	if o == nil || o.ArrayArrayNumber == nil {
+		return nil, false
 	}
 	return o.ArrayArrayNumber, true
 }
 
 // HasArrayArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfArrayOfNumberOnly) HasArrayArrayNumber() bool {
-	if o != nil && !isNil(o.ArrayArrayNumber) {
+	if o != nil && o.ArrayArrayNumber != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *ArrayOfArrayOfNumberOnly) SetArrayArrayNumber(v [][]float32) {
 }
 
 func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ArrayOfArrayOfNumberOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.ArrayArrayNumber) {
-		toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber
+	if o.ArrayArrayNumber != nil {
+		toSerialize["ArrayArrayNumber"] = *o.ArrayArrayNumber
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ArrayOfArrayOfNumberOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
index e447774dca1..5ef3eddb80e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ArrayOfNumberOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ArrayOfNumberOnly{}
+
 // ArrayOfNumberOnly struct for ArrayOfNumberOnly
 type ArrayOfNumberOnly struct {
 	ArrayNumber []float32 `json:"ArrayNumber,omitempty"`
@@ -41,7 +44,7 @@ func NewArrayOfNumberOnlyWithDefaults() *ArrayOfNumberOnly {
 
 // GetArrayNumber returns the ArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
-	if o == nil || isNil(o.ArrayNumber) {
+	if o == nil || o.ArrayNumber == nil {
 		var ret []float32
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
 // GetArrayNumberOk returns a tuple with the ArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfNumberOnly) GetArrayNumberOk() ([]float32, bool) {
-	if o == nil || isNil(o.ArrayNumber) {
-    return nil, false
+	if o == nil || o.ArrayNumber == nil {
+		return nil, false
 	}
 	return o.ArrayNumber, true
 }
 
 // HasArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfNumberOnly) HasArrayNumber() bool {
-	if o != nil && !isNil(o.ArrayNumber) {
+	if o != nil && o.ArrayNumber != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *ArrayOfNumberOnly) SetArrayNumber(v []float32) {
 }
 
 func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ArrayOfNumberOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.ArrayNumber) {
-		toSerialize["ArrayNumber"] = o.ArrayNumber
+	if o.ArrayNumber != nil {
+		toSerialize["ArrayNumber"] = *o.ArrayNumber
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ArrayOfNumberOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
index ebd6bb0846e..5a5aa0e0450 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ArrayTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ArrayTest{}
+
 // ArrayTest struct for ArrayTest
 type ArrayTest struct {
 	ArrayOfString []string `json:"array_of_string,omitempty"`
@@ -43,7 +46,7 @@ func NewArrayTestWithDefaults() *ArrayTest {
 
 // GetArrayOfString returns the ArrayOfString field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayOfString() []string {
-	if o == nil || isNil(o.ArrayOfString) {
+	if o == nil || o.ArrayOfString == nil {
 		var ret []string
 		return ret
 	}
@@ -53,15 +56,15 @@ func (o *ArrayTest) GetArrayOfString() []string {
 // GetArrayOfStringOk returns a tuple with the ArrayOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayOfStringOk() ([]string, bool) {
-	if o == nil || isNil(o.ArrayOfString) {
-    return nil, false
+	if o == nil || o.ArrayOfString == nil {
+		return nil, false
 	}
 	return o.ArrayOfString, true
 }
 
 // HasArrayOfString returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayOfString() bool {
-	if o != nil && !isNil(o.ArrayOfString) {
+	if o != nil && o.ArrayOfString != nil {
 		return true
 	}
 
@@ -75,7 +78,7 @@ func (o *ArrayTest) SetArrayOfString(v []string) {
 
 // GetArrayArrayOfInteger returns the ArrayArrayOfInteger field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
-	if o == nil || isNil(o.ArrayArrayOfInteger) {
+	if o == nil || o.ArrayArrayOfInteger == nil {
 		var ret [][]int64
 		return ret
 	}
@@ -85,15 +88,15 @@ func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
 // GetArrayArrayOfIntegerOk returns a tuple with the ArrayArrayOfInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfIntegerOk() ([][]int64, bool) {
-	if o == nil || isNil(o.ArrayArrayOfInteger) {
-    return nil, false
+	if o == nil || o.ArrayArrayOfInteger == nil {
+		return nil, false
 	}
 	return o.ArrayArrayOfInteger, true
 }
 
 // HasArrayArrayOfInteger returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfInteger() bool {
-	if o != nil && !isNil(o.ArrayArrayOfInteger) {
+	if o != nil && o.ArrayArrayOfInteger != nil {
 		return true
 	}
 
@@ -107,7 +110,7 @@ func (o *ArrayTest) SetArrayArrayOfInteger(v [][]int64) {
 
 // GetArrayArrayOfModel returns the ArrayArrayOfModel field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
-	if o == nil || isNil(o.ArrayArrayOfModel) {
+	if o == nil || o.ArrayArrayOfModel == nil {
 		var ret [][]ReadOnlyFirst
 		return ret
 	}
@@ -117,15 +120,15 @@ func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
 // GetArrayArrayOfModelOk returns a tuple with the ArrayArrayOfModel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfModelOk() ([][]ReadOnlyFirst, bool) {
-	if o == nil || isNil(o.ArrayArrayOfModel) {
-    return nil, false
+	if o == nil || o.ArrayArrayOfModel == nil {
+		return nil, false
 	}
 	return o.ArrayArrayOfModel, true
 }
 
 // HasArrayArrayOfModel returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfModel() bool {
-	if o != nil && !isNil(o.ArrayArrayOfModel) {
+	if o != nil && o.ArrayArrayOfModel != nil {
 		return true
 	}
 
@@ -138,22 +141,27 @@ func (o *ArrayTest) SetArrayArrayOfModel(v [][]ReadOnlyFirst) {
 }
 
 func (o ArrayTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ArrayTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.ArrayOfString) {
-		toSerialize["array_of_string"] = o.ArrayOfString
+	if o.ArrayOfString != nil {
+		toSerialize["array_of_string"] = *o.ArrayOfString
 	}
-	if !isNil(o.ArrayArrayOfInteger) {
-		toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger
+	if o.ArrayArrayOfInteger != nil {
+		toSerialize["array_array_of_integer"] = *o.ArrayArrayOfInteger
 	}
-	if !isNil(o.ArrayArrayOfModel) {
-		toSerialize["array_array_of_model"] = o.ArrayArrayOfModel
+	if o.ArrayArrayOfModel != nil {
+		toSerialize["array_array_of_model"] = *o.ArrayArrayOfModel
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ArrayTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
index cbfc560ba85..90571fb50d9 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Banana type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Banana{}
+
 // Banana struct for Banana
 type Banana struct {
 	LengthCm *float32 `json:"lengthCm,omitempty"`
@@ -41,7 +44,7 @@ func NewBananaWithDefaults() *Banana {
 
 // GetLengthCm returns the LengthCm field value if set, zero value otherwise.
 func (o *Banana) GetLengthCm() float32 {
-	if o == nil || isNil(o.LengthCm) {
+	if o == nil || o.LengthCm == nil {
 		var ret float32
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *Banana) GetLengthCm() float32 {
 // GetLengthCmOk returns a tuple with the LengthCm field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Banana) GetLengthCmOk() (*float32, bool) {
-	if o == nil || isNil(o.LengthCm) {
-    return nil, false
+	if o == nil || o.LengthCm == nil {
+		return nil, false
 	}
 	return o.LengthCm, true
 }
 
 // HasLengthCm returns a boolean if a field has been set.
 func (o *Banana) HasLengthCm() bool {
-	if o != nil && !isNil(o.LengthCm) {
+	if o != nil && o.LengthCm != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *Banana) SetLengthCm(v float32) {
 }
 
 func (o Banana) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Banana) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.LengthCm) {
-		toSerialize["lengthCm"] = o.LengthCm
+	if o.LengthCm != nil {
+		toSerialize["lengthCm"] = *o.LengthCm
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Banana) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
index aad3ba228f3..7153d24eb7d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the BananaReq type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &BananaReq{}
+
 // BananaReq struct for BananaReq
 type BananaReq struct {
 	LengthCm float32 `json:"lengthCm"`
@@ -55,7 +58,7 @@ func (o *BananaReq) GetLengthCm() float32 {
 // and a boolean to check if the value has been set.
 func (o *BananaReq) GetLengthCmOk() (*float32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.LengthCm, true
 }
@@ -67,7 +70,7 @@ func (o *BananaReq) SetLengthCm(v float32) {
 
 // GetSweet returns the Sweet field value if set, zero value otherwise.
 func (o *BananaReq) GetSweet() bool {
-	if o == nil || isNil(o.Sweet) {
+	if o == nil || o.Sweet == nil {
 		var ret bool
 		return ret
 	}
@@ -77,15 +80,15 @@ func (o *BananaReq) GetSweet() bool {
 // GetSweetOk returns a tuple with the Sweet field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *BananaReq) GetSweetOk() (*bool, bool) {
-	if o == nil || isNil(o.Sweet) {
-    return nil, false
+	if o == nil || o.Sweet == nil {
+		return nil, false
 	}
 	return o.Sweet, true
 }
 
 // HasSweet returns a boolean if a field has been set.
 func (o *BananaReq) HasSweet() bool {
-	if o != nil && !isNil(o.Sweet) {
+	if o != nil && o.Sweet != nil {
 		return true
 	}
 
@@ -98,19 +101,24 @@ func (o *BananaReq) SetSweet(v bool) {
 }
 
 func (o BananaReq) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o BananaReq) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["lengthCm"] = o.LengthCm
+		toSerialize["lengthCm"] = *o.LengthCm
 	}
-	if !isNil(o.Sweet) {
-		toSerialize["sweet"] = o.Sweet
+	if o.Sweet != nil {
+		toSerialize["sweet"] = *o.Sweet
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *BananaReq) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
index caaf7d1f604..a14484cba92 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Capitalization type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Capitalization{}
+
 // Capitalization struct for Capitalization
 type Capitalization struct {
 	SmallCamel *string `json:"smallCamel,omitempty"`
@@ -47,7 +50,7 @@ func NewCapitalizationWithDefaults() *Capitalization {
 
 // GetSmallCamel returns the SmallCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallCamel() string {
-	if o == nil || isNil(o.SmallCamel) {
+	if o == nil || o.SmallCamel == nil {
 		var ret string
 		return ret
 	}
@@ -57,15 +60,15 @@ func (o *Capitalization) GetSmallCamel() string {
 // GetSmallCamelOk returns a tuple with the SmallCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallCamelOk() (*string, bool) {
-	if o == nil || isNil(o.SmallCamel) {
-    return nil, false
+	if o == nil || o.SmallCamel == nil {
+		return nil, false
 	}
 	return o.SmallCamel, true
 }
 
 // HasSmallCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallCamel() bool {
-	if o != nil && !isNil(o.SmallCamel) {
+	if o != nil && o.SmallCamel != nil {
 		return true
 	}
 
@@ -79,7 +82,7 @@ func (o *Capitalization) SetSmallCamel(v string) {
 
 // GetCapitalCamel returns the CapitalCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalCamel() string {
-	if o == nil || isNil(o.CapitalCamel) {
+	if o == nil || o.CapitalCamel == nil {
 		var ret string
 		return ret
 	}
@@ -89,15 +92,15 @@ func (o *Capitalization) GetCapitalCamel() string {
 // GetCapitalCamelOk returns a tuple with the CapitalCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalCamelOk() (*string, bool) {
-	if o == nil || isNil(o.CapitalCamel) {
-    return nil, false
+	if o == nil || o.CapitalCamel == nil {
+		return nil, false
 	}
 	return o.CapitalCamel, true
 }
 
 // HasCapitalCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalCamel() bool {
-	if o != nil && !isNil(o.CapitalCamel) {
+	if o != nil && o.CapitalCamel != nil {
 		return true
 	}
 
@@ -111,7 +114,7 @@ func (o *Capitalization) SetCapitalCamel(v string) {
 
 // GetSmallSnake returns the SmallSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallSnake() string {
-	if o == nil || isNil(o.SmallSnake) {
+	if o == nil || o.SmallSnake == nil {
 		var ret string
 		return ret
 	}
@@ -121,15 +124,15 @@ func (o *Capitalization) GetSmallSnake() string {
 // GetSmallSnakeOk returns a tuple with the SmallSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallSnakeOk() (*string, bool) {
-	if o == nil || isNil(o.SmallSnake) {
-    return nil, false
+	if o == nil || o.SmallSnake == nil {
+		return nil, false
 	}
 	return o.SmallSnake, true
 }
 
 // HasSmallSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallSnake() bool {
-	if o != nil && !isNil(o.SmallSnake) {
+	if o != nil && o.SmallSnake != nil {
 		return true
 	}
 
@@ -143,7 +146,7 @@ func (o *Capitalization) SetSmallSnake(v string) {
 
 // GetCapitalSnake returns the CapitalSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalSnake() string {
-	if o == nil || isNil(o.CapitalSnake) {
+	if o == nil || o.CapitalSnake == nil {
 		var ret string
 		return ret
 	}
@@ -153,15 +156,15 @@ func (o *Capitalization) GetCapitalSnake() string {
 // GetCapitalSnakeOk returns a tuple with the CapitalSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalSnakeOk() (*string, bool) {
-	if o == nil || isNil(o.CapitalSnake) {
-    return nil, false
+	if o == nil || o.CapitalSnake == nil {
+		return nil, false
 	}
 	return o.CapitalSnake, true
 }
 
 // HasCapitalSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalSnake() bool {
-	if o != nil && !isNil(o.CapitalSnake) {
+	if o != nil && o.CapitalSnake != nil {
 		return true
 	}
 
@@ -175,7 +178,7 @@ func (o *Capitalization) SetCapitalSnake(v string) {
 
 // GetSCAETHFlowPoints returns the SCAETHFlowPoints field value if set, zero value otherwise.
 func (o *Capitalization) GetSCAETHFlowPoints() string {
-	if o == nil || isNil(o.SCAETHFlowPoints) {
+	if o == nil || o.SCAETHFlowPoints == nil {
 		var ret string
 		return ret
 	}
@@ -185,15 +188,15 @@ func (o *Capitalization) GetSCAETHFlowPoints() string {
 // GetSCAETHFlowPointsOk returns a tuple with the SCAETHFlowPoints field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSCAETHFlowPointsOk() (*string, bool) {
-	if o == nil || isNil(o.SCAETHFlowPoints) {
-    return nil, false
+	if o == nil || o.SCAETHFlowPoints == nil {
+		return nil, false
 	}
 	return o.SCAETHFlowPoints, true
 }
 
 // HasSCAETHFlowPoints returns a boolean if a field has been set.
 func (o *Capitalization) HasSCAETHFlowPoints() bool {
-	if o != nil && !isNil(o.SCAETHFlowPoints) {
+	if o != nil && o.SCAETHFlowPoints != nil {
 		return true
 	}
 
@@ -207,7 +210,7 @@ func (o *Capitalization) SetSCAETHFlowPoints(v string) {
 
 // GetATT_NAME returns the ATT_NAME field value if set, zero value otherwise.
 func (o *Capitalization) GetATT_NAME() string {
-	if o == nil || isNil(o.ATT_NAME) {
+	if o == nil || o.ATT_NAME == nil {
 		var ret string
 		return ret
 	}
@@ -217,15 +220,15 @@ func (o *Capitalization) GetATT_NAME() string {
 // GetATT_NAMEOk returns a tuple with the ATT_NAME field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetATT_NAMEOk() (*string, bool) {
-	if o == nil || isNil(o.ATT_NAME) {
-    return nil, false
+	if o == nil || o.ATT_NAME == nil {
+		return nil, false
 	}
 	return o.ATT_NAME, true
 }
 
 // HasATT_NAME returns a boolean if a field has been set.
 func (o *Capitalization) HasATT_NAME() bool {
-	if o != nil && !isNil(o.ATT_NAME) {
+	if o != nil && o.ATT_NAME != nil {
 		return true
 	}
 
@@ -238,31 +241,36 @@ func (o *Capitalization) SetATT_NAME(v string) {
 }
 
 func (o Capitalization) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Capitalization) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.SmallCamel) {
-		toSerialize["smallCamel"] = o.SmallCamel
+	if o.SmallCamel != nil {
+		toSerialize["smallCamel"] = *o.SmallCamel
 	}
-	if !isNil(o.CapitalCamel) {
-		toSerialize["CapitalCamel"] = o.CapitalCamel
+	if o.CapitalCamel != nil {
+		toSerialize["CapitalCamel"] = *o.CapitalCamel
 	}
-	if !isNil(o.SmallSnake) {
-		toSerialize["small_Snake"] = o.SmallSnake
+	if o.SmallSnake != nil {
+		toSerialize["small_Snake"] = *o.SmallSnake
 	}
-	if !isNil(o.CapitalSnake) {
-		toSerialize["Capital_Snake"] = o.CapitalSnake
+	if o.CapitalSnake != nil {
+		toSerialize["Capital_Snake"] = *o.CapitalSnake
 	}
-	if !isNil(o.SCAETHFlowPoints) {
-		toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints
+	if o.SCAETHFlowPoints != nil {
+		toSerialize["SCA_ETH_Flow_Points"] = *o.SCAETHFlowPoints
 	}
-	if !isNil(o.ATT_NAME) {
-		toSerialize["ATT_NAME"] = o.ATT_NAME
+	if o.ATT_NAME != nil {
+		toSerialize["ATT_NAME"] = *o.ATT_NAME
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Capitalization) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_cat.go b/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
index 7618e4be07a..d60cfc739cf 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
@@ -16,6 +16,9 @@ import (
 	"strings"
 )
 
+// checks if the Cat type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Cat{}
+
 // Cat struct for Cat
 type Cat struct {
 	Animal
@@ -47,7 +50,7 @@ func NewCatWithDefaults() *Cat {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *Cat) GetDeclawed() bool {
-	if o == nil || isNil(o.Declawed) {
+	if o == nil || o.Declawed == nil {
 		var ret bool
 		return ret
 	}
@@ -57,15 +60,15 @@ func (o *Cat) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Cat) GetDeclawedOk() (*bool, bool) {
-	if o == nil || isNil(o.Declawed) {
-    return nil, false
+	if o == nil || o.Declawed == nil {
+		return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *Cat) HasDeclawed() bool {
-	if o != nil && !isNil(o.Declawed) {
+	if o != nil && o.Declawed != nil {
 		return true
 	}
 
@@ -78,6 +81,11 @@ func (o *Cat) SetDeclawed(v bool) {
 }
 
 func (o Cat) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Cat) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
@@ -87,15 +95,15 @@ func (o Cat) MarshalJSON() ([]byte, error) {
 	if errAnimal != nil {
 		return []byte{}, errAnimal
 	}
-	if !isNil(o.Declawed) {
-		toSerialize["declawed"] = o.Declawed
+	if o.Declawed != nil {
+		toSerialize["declawed"] = *o.Declawed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Cat) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
index c138a3698bf..f70eb03a0d1 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the CatAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &CatAllOf{}
+
 // CatAllOf struct for CatAllOf
 type CatAllOf struct {
 	Declawed *bool `json:"declawed,omitempty"`
@@ -41,7 +44,7 @@ func NewCatAllOfWithDefaults() *CatAllOf {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *CatAllOf) GetDeclawed() bool {
-	if o == nil || isNil(o.Declawed) {
+	if o == nil || o.Declawed == nil {
 		var ret bool
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *CatAllOf) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *CatAllOf) GetDeclawedOk() (*bool, bool) {
-	if o == nil || isNil(o.Declawed) {
-    return nil, false
+	if o == nil || o.Declawed == nil {
+		return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *CatAllOf) HasDeclawed() bool {
-	if o != nil && !isNil(o.Declawed) {
+	if o != nil && o.Declawed != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *CatAllOf) SetDeclawed(v bool) {
 }
 
 func (o CatAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o CatAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Declawed) {
-		toSerialize["declawed"] = o.Declawed
+	if o.Declawed != nil {
+		toSerialize["declawed"] = *o.Declawed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *CatAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_category.go b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
index 14f69aba5e7..22774f69107 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_category.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Category type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Category{}
+
 // Category struct for Category
 type Category struct {
 	Id *int64 `json:"id,omitempty"`
@@ -45,7 +48,7 @@ func NewCategoryWithDefaults() *Category {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Category) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -55,15 +58,15 @@ func (o *Category) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Category) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Category) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -89,7 +92,7 @@ func (o *Category) GetName() string {
 // and a boolean to check if the value has been set.
 func (o *Category) GetNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Name, true
 }
@@ -100,19 +103,24 @@ func (o *Category) SetName(v string) {
 }
 
 func (o Category) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Category) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
 	if true {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Category) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
index 0e655645ed1..3c243878587 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ClassModel type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ClassModel{}
+
 // ClassModel Model for testing model with \"_class\" property
 type ClassModel struct {
 	Class *string `json:"_class,omitempty"`
@@ -41,7 +44,7 @@ func NewClassModelWithDefaults() *ClassModel {
 
 // GetClass returns the Class field value if set, zero value otherwise.
 func (o *ClassModel) GetClass() string {
-	if o == nil || isNil(o.Class) {
+	if o == nil || o.Class == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *ClassModel) GetClass() string {
 // GetClassOk returns a tuple with the Class field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ClassModel) GetClassOk() (*string, bool) {
-	if o == nil || isNil(o.Class) {
-    return nil, false
+	if o == nil || o.Class == nil {
+		return nil, false
 	}
 	return o.Class, true
 }
 
 // HasClass returns a boolean if a field has been set.
 func (o *ClassModel) HasClass() bool {
-	if o != nil && !isNil(o.Class) {
+	if o != nil && o.Class != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *ClassModel) SetClass(v string) {
 }
 
 func (o ClassModel) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ClassModel) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Class) {
-		toSerialize["_class"] = o.Class
+	if o.Class != nil {
+		toSerialize["_class"] = *o.Class
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ClassModel) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_client.go b/samples/openapi3/client/petstore/go/go-petstore/model_client.go
index 523123bd38f..3c37f3808f4 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_client.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Client type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Client{}
+
 // Client struct for Client
 type Client struct {
 	Client *string `json:"client,omitempty"`
@@ -41,7 +44,7 @@ func NewClientWithDefaults() *Client {
 
 // GetClient returns the Client field value if set, zero value otherwise.
 func (o *Client) GetClient() string {
-	if o == nil || isNil(o.Client) {
+	if o == nil || o.Client == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *Client) GetClient() string {
 // GetClientOk returns a tuple with the Client field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Client) GetClientOk() (*string, bool) {
-	if o == nil || isNil(o.Client) {
-    return nil, false
+	if o == nil || o.Client == nil {
+		return nil, false
 	}
 	return o.Client, true
 }
 
 // HasClient returns a boolean if a field has been set.
 func (o *Client) HasClient() bool {
-	if o != nil && !isNil(o.Client) {
+	if o != nil && o.Client != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *Client) SetClient(v string) {
 }
 
 func (o Client) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Client) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Client) {
-		toSerialize["client"] = o.Client
+	if o.Client != nil {
+		toSerialize["client"] = *o.Client
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Client) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_dog.go b/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
index 8414fb18f8d..b810967e090 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
@@ -16,6 +16,9 @@ import (
 	"strings"
 )
 
+// checks if the Dog type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Dog{}
+
 // Dog struct for Dog
 type Dog struct {
 	Animal
@@ -47,7 +50,7 @@ func NewDogWithDefaults() *Dog {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *Dog) GetBreed() string {
-	if o == nil || isNil(o.Breed) {
+	if o == nil || o.Breed == nil {
 		var ret string
 		return ret
 	}
@@ -57,15 +60,15 @@ func (o *Dog) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Dog) GetBreedOk() (*string, bool) {
-	if o == nil || isNil(o.Breed) {
-    return nil, false
+	if o == nil || o.Breed == nil {
+		return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *Dog) HasBreed() bool {
-	if o != nil && !isNil(o.Breed) {
+	if o != nil && o.Breed != nil {
 		return true
 	}
 
@@ -78,6 +81,11 @@ func (o *Dog) SetBreed(v string) {
 }
 
 func (o Dog) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Dog) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
@@ -87,15 +95,15 @@ func (o Dog) MarshalJSON() ([]byte, error) {
 	if errAnimal != nil {
 		return []byte{}, errAnimal
 	}
-	if !isNil(o.Breed) {
-		toSerialize["breed"] = o.Breed
+	if o.Breed != nil {
+		toSerialize["breed"] = *o.Breed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Dog) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
index 162bddcfea3..6a127ea5052 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the DogAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &DogAllOf{}
+
 // DogAllOf struct for DogAllOf
 type DogAllOf struct {
 	Breed *string `json:"breed,omitempty"`
@@ -41,7 +44,7 @@ func NewDogAllOfWithDefaults() *DogAllOf {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *DogAllOf) GetBreed() string {
-	if o == nil || isNil(o.Breed) {
+	if o == nil || o.Breed == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *DogAllOf) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DogAllOf) GetBreedOk() (*string, bool) {
-	if o == nil || isNil(o.Breed) {
-    return nil, false
+	if o == nil || o.Breed == nil {
+		return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *DogAllOf) HasBreed() bool {
-	if o != nil && !isNil(o.Breed) {
+	if o != nil && o.Breed != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *DogAllOf) SetBreed(v string) {
 }
 
 func (o DogAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o DogAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Breed) {
-		toSerialize["breed"] = o.Breed
+	if o.Breed != nil {
+		toSerialize["breed"] = *o.Breed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *DogAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
index 4c0bec52ab9..7b3ba5e04a8 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
@@ -16,6 +16,9 @@ import (
 	"strings"
 )
 
+// checks if the DuplicatedPropChild type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &DuplicatedPropChild{}
+
 // DuplicatedPropChild struct for DuplicatedPropChild
 type DuplicatedPropChild struct {
 	DuplicatedPropParent
@@ -45,7 +48,7 @@ func NewDuplicatedPropChildWithDefaults() *DuplicatedPropChild {
 
 // GetDupProp returns the DupProp field value if set, zero value otherwise.
 func (o *DuplicatedPropChild) GetDupProp() string {
-	if o == nil || isNil(o.DupProp) {
+	if o == nil || o.DupProp == nil {
 		var ret string
 		return ret
 	}
@@ -55,15 +58,15 @@ func (o *DuplicatedPropChild) GetDupProp() string {
 // GetDupPropOk returns a tuple with the DupProp field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DuplicatedPropChild) GetDupPropOk() (*string, bool) {
-	if o == nil || isNil(o.DupProp) {
-    return nil, false
+	if o == nil || o.DupProp == nil {
+		return nil, false
 	}
 	return o.DupProp, true
 }
 
 // HasDupProp returns a boolean if a field has been set.
 func (o *DuplicatedPropChild) HasDupProp() bool {
-	if o != nil && !isNil(o.DupProp) {
+	if o != nil && o.DupProp != nil {
 		return true
 	}
 
@@ -76,6 +79,11 @@ func (o *DuplicatedPropChild) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropChild) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o DuplicatedPropChild) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	serializedDuplicatedPropParent, errDuplicatedPropParent := json.Marshal(o.DuplicatedPropParent)
 	if errDuplicatedPropParent != nil {
@@ -85,15 +93,15 @@ func (o DuplicatedPropChild) MarshalJSON() ([]byte, error) {
 	if errDuplicatedPropParent != nil {
 		return []byte{}, errDuplicatedPropParent
 	}
-	if !isNil(o.DupProp) {
-		toSerialize["dup-prop"] = o.DupProp
+	if o.DupProp != nil {
+		toSerialize["dup-prop"] = *o.DupProp
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *DuplicatedPropChild) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
index 9e456999a1c..2e9a1163783 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the DuplicatedPropChildAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &DuplicatedPropChildAllOf{}
+
 // DuplicatedPropChildAllOf struct for DuplicatedPropChildAllOf
 type DuplicatedPropChildAllOf struct {
 	// A discriminator value
@@ -42,7 +45,7 @@ func NewDuplicatedPropChildAllOfWithDefaults() *DuplicatedPropChildAllOf {
 
 // GetDupProp returns the DupProp field value if set, zero value otherwise.
 func (o *DuplicatedPropChildAllOf) GetDupProp() string {
-	if o == nil || isNil(o.DupProp) {
+	if o == nil || o.DupProp == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *DuplicatedPropChildAllOf) GetDupProp() string {
 // GetDupPropOk returns a tuple with the DupProp field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DuplicatedPropChildAllOf) GetDupPropOk() (*string, bool) {
-	if o == nil || isNil(o.DupProp) {
-    return nil, false
+	if o == nil || o.DupProp == nil {
+		return nil, false
 	}
 	return o.DupProp, true
 }
 
 // HasDupProp returns a boolean if a field has been set.
 func (o *DuplicatedPropChildAllOf) HasDupProp() bool {
-	if o != nil && !isNil(o.DupProp) {
+	if o != nil && o.DupProp != nil {
 		return true
 	}
 
@@ -73,16 +76,21 @@ func (o *DuplicatedPropChildAllOf) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropChildAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o DuplicatedPropChildAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.DupProp) {
-		toSerialize["dup-prop"] = o.DupProp
+	if o.DupProp != nil {
+		toSerialize["dup-prop"] = *o.DupProp
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *DuplicatedPropChildAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
index fa95a4edf5f..5e8d630e222 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the DuplicatedPropParent type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &DuplicatedPropParent{}
+
 // DuplicatedPropParent parent model with duplicated property
 type DuplicatedPropParent struct {
 	// A discriminator value
@@ -66,16 +69,21 @@ func (o *DuplicatedPropParent) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropParent) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o DuplicatedPropParent) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["dup-prop"] = o.DupProp
+		toSerialize["dup-prop"] = *o.DupProp
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *DuplicatedPropParent) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
index 622768e8ae3..e410778f23e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the EnumArrays type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &EnumArrays{}
+
 // EnumArrays struct for EnumArrays
 type EnumArrays struct {
 	JustSymbol *string `json:"just_symbol,omitempty"`
@@ -42,7 +45,7 @@ func NewEnumArraysWithDefaults() *EnumArrays {
 
 // GetJustSymbol returns the JustSymbol field value if set, zero value otherwise.
 func (o *EnumArrays) GetJustSymbol() string {
-	if o == nil || isNil(o.JustSymbol) {
+	if o == nil || o.JustSymbol == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *EnumArrays) GetJustSymbol() string {
 // GetJustSymbolOk returns a tuple with the JustSymbol field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetJustSymbolOk() (*string, bool) {
-	if o == nil || isNil(o.JustSymbol) {
-    return nil, false
+	if o == nil || o.JustSymbol == nil {
+		return nil, false
 	}
 	return o.JustSymbol, true
 }
 
 // HasJustSymbol returns a boolean if a field has been set.
 func (o *EnumArrays) HasJustSymbol() bool {
-	if o != nil && !isNil(o.JustSymbol) {
+	if o != nil && o.JustSymbol != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *EnumArrays) SetJustSymbol(v string) {
 
 // GetArrayEnum returns the ArrayEnum field value if set, zero value otherwise.
 func (o *EnumArrays) GetArrayEnum() []string {
-	if o == nil || isNil(o.ArrayEnum) {
+	if o == nil || o.ArrayEnum == nil {
 		var ret []string
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *EnumArrays) GetArrayEnum() []string {
 // GetArrayEnumOk returns a tuple with the ArrayEnum field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetArrayEnumOk() ([]string, bool) {
-	if o == nil || isNil(o.ArrayEnum) {
-    return nil, false
+	if o == nil || o.ArrayEnum == nil {
+		return nil, false
 	}
 	return o.ArrayEnum, true
 }
 
 // HasArrayEnum returns a boolean if a field has been set.
 func (o *EnumArrays) HasArrayEnum() bool {
-	if o != nil && !isNil(o.ArrayEnum) {
+	if o != nil && o.ArrayEnum != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *EnumArrays) SetArrayEnum(v []string) {
 }
 
 func (o EnumArrays) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o EnumArrays) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.JustSymbol) {
-		toSerialize["just_symbol"] = o.JustSymbol
+	if o.JustSymbol != nil {
+		toSerialize["just_symbol"] = *o.JustSymbol
 	}
-	if !isNil(o.ArrayEnum) {
-		toSerialize["array_enum"] = o.ArrayEnum
+	if o.ArrayEnum != nil {
+		toSerialize["array_enum"] = *o.ArrayEnum
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *EnumArrays) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
index aec53b6795c..63655c9561f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the EnumTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &EnumTest{}
+
 // EnumTest struct for EnumTest
 type EnumTest struct {
 	EnumString *string `json:"enum_string,omitempty"`
@@ -57,7 +60,7 @@ func NewEnumTestWithDefaults() *EnumTest {
 
 // GetEnumString returns the EnumString field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumString() string {
-	if o == nil || isNil(o.EnumString) {
+	if o == nil || o.EnumString == nil {
 		var ret string
 		return ret
 	}
@@ -67,15 +70,15 @@ func (o *EnumTest) GetEnumString() string {
 // GetEnumStringOk returns a tuple with the EnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringOk() (*string, bool) {
-	if o == nil || isNil(o.EnumString) {
-    return nil, false
+	if o == nil || o.EnumString == nil {
+		return nil, false
 	}
 	return o.EnumString, true
 }
 
 // HasEnumString returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumString() bool {
-	if o != nil && !isNil(o.EnumString) {
+	if o != nil && o.EnumString != nil {
 		return true
 	}
 
@@ -101,7 +104,7 @@ func (o *EnumTest) GetEnumStringRequired() string {
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringRequiredOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.EnumStringRequired, true
 }
@@ -113,7 +116,7 @@ func (o *EnumTest) SetEnumStringRequired(v string) {
 
 // GetEnumInteger returns the EnumInteger field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumInteger() int32 {
-	if o == nil || isNil(o.EnumInteger) {
+	if o == nil || o.EnumInteger == nil {
 		var ret int32
 		return ret
 	}
@@ -123,15 +126,15 @@ func (o *EnumTest) GetEnumInteger() int32 {
 // GetEnumIntegerOk returns a tuple with the EnumInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.EnumInteger) {
-    return nil, false
+	if o == nil || o.EnumInteger == nil {
+		return nil, false
 	}
 	return o.EnumInteger, true
 }
 
 // HasEnumInteger returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumInteger() bool {
-	if o != nil && !isNil(o.EnumInteger) {
+	if o != nil && o.EnumInteger != nil {
 		return true
 	}
 
@@ -145,7 +148,7 @@ func (o *EnumTest) SetEnumInteger(v int32) {
 
 // GetEnumNumber returns the EnumNumber field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumNumber() float64 {
-	if o == nil || isNil(o.EnumNumber) {
+	if o == nil || o.EnumNumber == nil {
 		var ret float64
 		return ret
 	}
@@ -155,15 +158,15 @@ func (o *EnumTest) GetEnumNumber() float64 {
 // GetEnumNumberOk returns a tuple with the EnumNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumNumberOk() (*float64, bool) {
-	if o == nil || isNil(o.EnumNumber) {
-    return nil, false
+	if o == nil || o.EnumNumber == nil {
+		return nil, false
 	}
 	return o.EnumNumber, true
 }
 
 // HasEnumNumber returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumNumber() bool {
-	if o != nil && !isNil(o.EnumNumber) {
+	if o != nil && o.EnumNumber != nil {
 		return true
 	}
 
@@ -177,7 +180,7 @@ func (o *EnumTest) SetEnumNumber(v float64) {
 
 // GetOuterEnum returns the OuterEnum field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *EnumTest) GetOuterEnum() OuterEnum {
-	if o == nil || isNil(o.OuterEnum.Get()) {
+	if o == nil || o.OuterEnum.Get() == nil {
 		var ret OuterEnum
 		return ret
 	}
@@ -189,7 +192,7 @@ func (o *EnumTest) GetOuterEnum() OuterEnum {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *EnumTest) GetOuterEnumOk() (*OuterEnum, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.OuterEnum.Get(), o.OuterEnum.IsSet()
 }
@@ -219,7 +222,7 @@ func (o *EnumTest) UnsetOuterEnum() {
 
 // GetOuterEnumInteger returns the OuterEnumInteger field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnumInteger() OuterEnumInteger {
-	if o == nil || isNil(o.OuterEnumInteger) {
+	if o == nil || o.OuterEnumInteger == nil {
 		var ret OuterEnumInteger
 		return ret
 	}
@@ -229,15 +232,15 @@ func (o *EnumTest) GetOuterEnumInteger() OuterEnumInteger {
 // GetOuterEnumIntegerOk returns a tuple with the OuterEnumInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumIntegerOk() (*OuterEnumInteger, bool) {
-	if o == nil || isNil(o.OuterEnumInteger) {
-    return nil, false
+	if o == nil || o.OuterEnumInteger == nil {
+		return nil, false
 	}
 	return o.OuterEnumInteger, true
 }
 
 // HasOuterEnumInteger returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnumInteger() bool {
-	if o != nil && !isNil(o.OuterEnumInteger) {
+	if o != nil && o.OuterEnumInteger != nil {
 		return true
 	}
 
@@ -251,7 +254,7 @@ func (o *EnumTest) SetOuterEnumInteger(v OuterEnumInteger) {
 
 // GetOuterEnumDefaultValue returns the OuterEnumDefaultValue field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnumDefaultValue() OuterEnumDefaultValue {
-	if o == nil || isNil(o.OuterEnumDefaultValue) {
+	if o == nil || o.OuterEnumDefaultValue == nil {
 		var ret OuterEnumDefaultValue
 		return ret
 	}
@@ -261,15 +264,15 @@ func (o *EnumTest) GetOuterEnumDefaultValue() OuterEnumDefaultValue {
 // GetOuterEnumDefaultValueOk returns a tuple with the OuterEnumDefaultValue field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumDefaultValueOk() (*OuterEnumDefaultValue, bool) {
-	if o == nil || isNil(o.OuterEnumDefaultValue) {
-    return nil, false
+	if o == nil || o.OuterEnumDefaultValue == nil {
+		return nil, false
 	}
 	return o.OuterEnumDefaultValue, true
 }
 
 // HasOuterEnumDefaultValue returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnumDefaultValue() bool {
-	if o != nil && !isNil(o.OuterEnumDefaultValue) {
+	if o != nil && o.OuterEnumDefaultValue != nil {
 		return true
 	}
 
@@ -283,7 +286,7 @@ func (o *EnumTest) SetOuterEnumDefaultValue(v OuterEnumDefaultValue) {
 
 // GetOuterEnumIntegerDefaultValue returns the OuterEnumIntegerDefaultValue field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnumIntegerDefaultValue() OuterEnumIntegerDefaultValue {
-	if o == nil || isNil(o.OuterEnumIntegerDefaultValue) {
+	if o == nil || o.OuterEnumIntegerDefaultValue == nil {
 		var ret OuterEnumIntegerDefaultValue
 		return ret
 	}
@@ -293,15 +296,15 @@ func (o *EnumTest) GetOuterEnumIntegerDefaultValue() OuterEnumIntegerDefaultValu
 // GetOuterEnumIntegerDefaultValueOk returns a tuple with the OuterEnumIntegerDefaultValue field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumIntegerDefaultValueOk() (*OuterEnumIntegerDefaultValue, bool) {
-	if o == nil || isNil(o.OuterEnumIntegerDefaultValue) {
-    return nil, false
+	if o == nil || o.OuterEnumIntegerDefaultValue == nil {
+		return nil, false
 	}
 	return o.OuterEnumIntegerDefaultValue, true
 }
 
 // HasOuterEnumIntegerDefaultValue returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnumIntegerDefaultValue() bool {
-	if o != nil && !isNil(o.OuterEnumIntegerDefaultValue) {
+	if o != nil && o.OuterEnumIntegerDefaultValue != nil {
 		return true
 	}
 
@@ -314,37 +317,42 @@ func (o *EnumTest) SetOuterEnumIntegerDefaultValue(v OuterEnumIntegerDefaultValu
 }
 
 func (o EnumTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o EnumTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.EnumString) {
-		toSerialize["enum_string"] = o.EnumString
+	if o.EnumString != nil {
+		toSerialize["enum_string"] = *o.EnumString
 	}
 	if true {
-		toSerialize["enum_string_required"] = o.EnumStringRequired
+		toSerialize["enum_string_required"] = *o.EnumStringRequired
 	}
-	if !isNil(o.EnumInteger) {
-		toSerialize["enum_integer"] = o.EnumInteger
+	if o.EnumInteger != nil {
+		toSerialize["enum_integer"] = *o.EnumInteger
 	}
-	if !isNil(o.EnumNumber) {
-		toSerialize["enum_number"] = o.EnumNumber
+	if o.EnumNumber != nil {
+		toSerialize["enum_number"] = *o.EnumNumber
 	}
 	if o.OuterEnum.IsSet() {
-		toSerialize["outerEnum"] = o.OuterEnum.Get()
+		toSerialize["outerEnum"] = *o.OuterEnum.Get()
 	}
-	if !isNil(o.OuterEnumInteger) {
-		toSerialize["outerEnumInteger"] = o.OuterEnumInteger
+	if o.OuterEnumInteger != nil {
+		toSerialize["outerEnumInteger"] = *o.OuterEnumInteger
 	}
-	if !isNil(o.OuterEnumDefaultValue) {
-		toSerialize["outerEnumDefaultValue"] = o.OuterEnumDefaultValue
+	if o.OuterEnumDefaultValue != nil {
+		toSerialize["outerEnumDefaultValue"] = *o.OuterEnumDefaultValue
 	}
-	if !isNil(o.OuterEnumIntegerDefaultValue) {
-		toSerialize["outerEnumIntegerDefaultValue"] = o.OuterEnumIntegerDefaultValue
+	if o.OuterEnumIntegerDefaultValue != nil {
+		toSerialize["outerEnumIntegerDefaultValue"] = *o.OuterEnumIntegerDefaultValue
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *EnumTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file.go b/samples/openapi3/client/petstore/go/go-petstore/model_file.go
index c850c827ffe..7a46b0ca5e0 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_file.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_file.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the File type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &File{}
+
 // File Must be named `File` for test.
 type File struct {
 	// Test capitalization
@@ -42,7 +45,7 @@ func NewFileWithDefaults() *File {
 
 // GetSourceURI returns the SourceURI field value if set, zero value otherwise.
 func (o *File) GetSourceURI() string {
-	if o == nil || isNil(o.SourceURI) {
+	if o == nil || o.SourceURI == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *File) GetSourceURI() string {
 // GetSourceURIOk returns a tuple with the SourceURI field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *File) GetSourceURIOk() (*string, bool) {
-	if o == nil || isNil(o.SourceURI) {
-    return nil, false
+	if o == nil || o.SourceURI == nil {
+		return nil, false
 	}
 	return o.SourceURI, true
 }
 
 // HasSourceURI returns a boolean if a field has been set.
 func (o *File) HasSourceURI() bool {
-	if o != nil && !isNil(o.SourceURI) {
+	if o != nil && o.SourceURI != nil {
 		return true
 	}
 
@@ -73,16 +76,21 @@ func (o *File) SetSourceURI(v string) {
 }
 
 func (o File) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o File) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.SourceURI) {
-		toSerialize["sourceURI"] = o.SourceURI
+	if o.SourceURI != nil {
+		toSerialize["sourceURI"] = *o.SourceURI
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *File) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
index c6627b01a14..c6105432577 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the FileSchemaTestClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FileSchemaTestClass{}
+
 // FileSchemaTestClass struct for FileSchemaTestClass
 type FileSchemaTestClass struct {
 	File *File `json:"file,omitempty"`
@@ -42,7 +45,7 @@ func NewFileSchemaTestClassWithDefaults() *FileSchemaTestClass {
 
 // GetFile returns the File field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFile() File {
-	if o == nil || isNil(o.File) {
+	if o == nil || o.File == nil {
 		var ret File
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *FileSchemaTestClass) GetFile() File {
 // GetFileOk returns a tuple with the File field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFileOk() (*File, bool) {
-	if o == nil || isNil(o.File) {
-    return nil, false
+	if o == nil || o.File == nil {
+		return nil, false
 	}
 	return o.File, true
 }
 
 // HasFile returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFile() bool {
-	if o != nil && !isNil(o.File) {
+	if o != nil && o.File != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *FileSchemaTestClass) SetFile(v File) {
 
 // GetFiles returns the Files field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFiles() []File {
-	if o == nil || isNil(o.Files) {
+	if o == nil || o.Files == nil {
 		var ret []File
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *FileSchemaTestClass) GetFiles() []File {
 // GetFilesOk returns a tuple with the Files field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFilesOk() ([]File, bool) {
-	if o == nil || isNil(o.Files) {
-    return nil, false
+	if o == nil || o.Files == nil {
+		return nil, false
 	}
 	return o.Files, true
 }
 
 // HasFiles returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFiles() bool {
-	if o != nil && !isNil(o.Files) {
+	if o != nil && o.Files != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *FileSchemaTestClass) SetFiles(v []File) {
 }
 
 func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o FileSchemaTestClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.File) {
-		toSerialize["file"] = o.File
+	if o.File != nil {
+		toSerialize["file"] = *o.File
 	}
-	if !isNil(o.Files) {
-		toSerialize["files"] = o.Files
+	if o.Files != nil {
+		toSerialize["files"] = *o.Files
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *FileSchemaTestClass) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
index 145def4ff16..6d968e73579 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Foo type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Foo{}
+
 // Foo struct for Foo
 type Foo struct {
 	Bar *string `json:"bar,omitempty"`
@@ -45,7 +48,7 @@ func NewFooWithDefaults() *Foo {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *Foo) GetBar() string {
-	if o == nil || isNil(o.Bar) {
+	if o == nil || o.Bar == nil {
 		var ret string
 		return ret
 	}
@@ -55,15 +58,15 @@ func (o *Foo) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Foo) GetBarOk() (*string, bool) {
-	if o == nil || isNil(o.Bar) {
-    return nil, false
+	if o == nil || o.Bar == nil {
+		return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *Foo) HasBar() bool {
-	if o != nil && !isNil(o.Bar) {
+	if o != nil && o.Bar != nil {
 		return true
 	}
 
@@ -76,16 +79,21 @@ func (o *Foo) SetBar(v string) {
 }
 
 func (o Foo) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Foo) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Bar) {
-		toSerialize["bar"] = o.Bar
+	if o.Bar != nil {
+		toSerialize["bar"] = *o.Bar
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Foo) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
index bc69d8dabb7..3c6826f2989 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
@@ -16,6 +16,9 @@ import (
 	"time"
 )
 
+// checks if the FormatTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FormatTest{}
+
 // FormatTest struct for FormatTest
 type FormatTest struct {
 	Integer *int32 `json:"integer,omitempty"`
@@ -63,7 +66,7 @@ func NewFormatTestWithDefaults() *FormatTest {
 
 // GetInteger returns the Integer field value if set, zero value otherwise.
 func (o *FormatTest) GetInteger() int32 {
-	if o == nil || isNil(o.Integer) {
+	if o == nil || o.Integer == nil {
 		var ret int32
 		return ret
 	}
@@ -73,15 +76,15 @@ func (o *FormatTest) GetInteger() int32 {
 // GetIntegerOk returns a tuple with the Integer field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetIntegerOk() (*int32, bool) {
-	if o == nil || isNil(o.Integer) {
-    return nil, false
+	if o == nil || o.Integer == nil {
+		return nil, false
 	}
 	return o.Integer, true
 }
 
 // HasInteger returns a boolean if a field has been set.
 func (o *FormatTest) HasInteger() bool {
-	if o != nil && !isNil(o.Integer) {
+	if o != nil && o.Integer != nil {
 		return true
 	}
 
@@ -95,7 +98,7 @@ func (o *FormatTest) SetInteger(v int32) {
 
 // GetInt32 returns the Int32 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt32() int32 {
-	if o == nil || isNil(o.Int32) {
+	if o == nil || o.Int32 == nil {
 		var ret int32
 		return ret
 	}
@@ -105,15 +108,15 @@ func (o *FormatTest) GetInt32() int32 {
 // GetInt32Ok returns a tuple with the Int32 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt32Ok() (*int32, bool) {
-	if o == nil || isNil(o.Int32) {
-    return nil, false
+	if o == nil || o.Int32 == nil {
+		return nil, false
 	}
 	return o.Int32, true
 }
 
 // HasInt32 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt32() bool {
-	if o != nil && !isNil(o.Int32) {
+	if o != nil && o.Int32 != nil {
 		return true
 	}
 
@@ -127,7 +130,7 @@ func (o *FormatTest) SetInt32(v int32) {
 
 // GetInt64 returns the Int64 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt64() int64 {
-	if o == nil || isNil(o.Int64) {
+	if o == nil || o.Int64 == nil {
 		var ret int64
 		return ret
 	}
@@ -137,15 +140,15 @@ func (o *FormatTest) GetInt64() int64 {
 // GetInt64Ok returns a tuple with the Int64 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt64Ok() (*int64, bool) {
-	if o == nil || isNil(o.Int64) {
-    return nil, false
+	if o == nil || o.Int64 == nil {
+		return nil, false
 	}
 	return o.Int64, true
 }
 
 // HasInt64 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt64() bool {
-	if o != nil && !isNil(o.Int64) {
+	if o != nil && o.Int64 != nil {
 		return true
 	}
 
@@ -171,7 +174,7 @@ func (o *FormatTest) GetNumber() float32 {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetNumberOk() (*float32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Number, true
 }
@@ -183,7 +186,7 @@ func (o *FormatTest) SetNumber(v float32) {
 
 // GetFloat returns the Float field value if set, zero value otherwise.
 func (o *FormatTest) GetFloat() float32 {
-	if o == nil || isNil(o.Float) {
+	if o == nil || o.Float == nil {
 		var ret float32
 		return ret
 	}
@@ -193,15 +196,15 @@ func (o *FormatTest) GetFloat() float32 {
 // GetFloatOk returns a tuple with the Float field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetFloatOk() (*float32, bool) {
-	if o == nil || isNil(o.Float) {
-    return nil, false
+	if o == nil || o.Float == nil {
+		return nil, false
 	}
 	return o.Float, true
 }
 
 // HasFloat returns a boolean if a field has been set.
 func (o *FormatTest) HasFloat() bool {
-	if o != nil && !isNil(o.Float) {
+	if o != nil && o.Float != nil {
 		return true
 	}
 
@@ -215,7 +218,7 @@ func (o *FormatTest) SetFloat(v float32) {
 
 // GetDouble returns the Double field value if set, zero value otherwise.
 func (o *FormatTest) GetDouble() float64 {
-	if o == nil || isNil(o.Double) {
+	if o == nil || o.Double == nil {
 		var ret float64
 		return ret
 	}
@@ -225,15 +228,15 @@ func (o *FormatTest) GetDouble() float64 {
 // GetDoubleOk returns a tuple with the Double field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDoubleOk() (*float64, bool) {
-	if o == nil || isNil(o.Double) {
-    return nil, false
+	if o == nil || o.Double == nil {
+		return nil, false
 	}
 	return o.Double, true
 }
 
 // HasDouble returns a boolean if a field has been set.
 func (o *FormatTest) HasDouble() bool {
-	if o != nil && !isNil(o.Double) {
+	if o != nil && o.Double != nil {
 		return true
 	}
 
@@ -247,7 +250,7 @@ func (o *FormatTest) SetDouble(v float64) {
 
 // GetString returns the String field value if set, zero value otherwise.
 func (o *FormatTest) GetString() string {
-	if o == nil || isNil(o.String) {
+	if o == nil || o.String == nil {
 		var ret string
 		return ret
 	}
@@ -257,15 +260,15 @@ func (o *FormatTest) GetString() string {
 // GetStringOk returns a tuple with the String field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetStringOk() (*string, bool) {
-	if o == nil || isNil(o.String) {
-    return nil, false
+	if o == nil || o.String == nil {
+		return nil, false
 	}
 	return o.String, true
 }
 
 // HasString returns a boolean if a field has been set.
 func (o *FormatTest) HasString() bool {
-	if o != nil && !isNil(o.String) {
+	if o != nil && o.String != nil {
 		return true
 	}
 
@@ -291,7 +294,7 @@ func (o *FormatTest) GetByte() string {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetByteOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Byte, true
 }
@@ -303,7 +306,7 @@ func (o *FormatTest) SetByte(v string) {
 
 // GetBinary returns the Binary field value if set, zero value otherwise.
 func (o *FormatTest) GetBinary() *os.File {
-	if o == nil || isNil(o.Binary) {
+	if o == nil || o.Binary == nil {
 		var ret *os.File
 		return ret
 	}
@@ -313,15 +316,15 @@ func (o *FormatTest) GetBinary() *os.File {
 // GetBinaryOk returns a tuple with the Binary field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetBinaryOk() (**os.File, bool) {
-	if o == nil || isNil(o.Binary) {
-    return nil, false
+	if o == nil || o.Binary == nil {
+		return nil, false
 	}
 	return o.Binary, true
 }
 
 // HasBinary returns a boolean if a field has been set.
 func (o *FormatTest) HasBinary() bool {
-	if o != nil && !isNil(o.Binary) {
+	if o != nil && o.Binary != nil {
 		return true
 	}
 
@@ -347,7 +350,7 @@ func (o *FormatTest) GetDate() string {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Date, true
 }
@@ -359,7 +362,7 @@ func (o *FormatTest) SetDate(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *FormatTest) GetDateTime() time.Time {
-	if o == nil || isNil(o.DateTime) {
+	if o == nil || o.DateTime == nil {
 		var ret time.Time
 		return ret
 	}
@@ -369,15 +372,15 @@ func (o *FormatTest) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || isNil(o.DateTime) {
-    return nil, false
+	if o == nil || o.DateTime == nil {
+		return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *FormatTest) HasDateTime() bool {
-	if o != nil && !isNil(o.DateTime) {
+	if o != nil && o.DateTime != nil {
 		return true
 	}
 
@@ -391,7 +394,7 @@ func (o *FormatTest) SetDateTime(v time.Time) {
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *FormatTest) GetUuid() string {
-	if o == nil || isNil(o.Uuid) {
+	if o == nil || o.Uuid == nil {
 		var ret string
 		return ret
 	}
@@ -401,15 +404,15 @@ func (o *FormatTest) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetUuidOk() (*string, bool) {
-	if o == nil || isNil(o.Uuid) {
-    return nil, false
+	if o == nil || o.Uuid == nil {
+		return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *FormatTest) HasUuid() bool {
-	if o != nil && !isNil(o.Uuid) {
+	if o != nil && o.Uuid != nil {
 		return true
 	}
 
@@ -435,7 +438,7 @@ func (o *FormatTest) GetPassword() string {
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPasswordOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Password, true
 }
@@ -447,7 +450,7 @@ func (o *FormatTest) SetPassword(v string) {
 
 // GetPatternWithDigits returns the PatternWithDigits field value if set, zero value otherwise.
 func (o *FormatTest) GetPatternWithDigits() string {
-	if o == nil || isNil(o.PatternWithDigits) {
+	if o == nil || o.PatternWithDigits == nil {
 		var ret string
 		return ret
 	}
@@ -457,15 +460,15 @@ func (o *FormatTest) GetPatternWithDigits() string {
 // GetPatternWithDigitsOk returns a tuple with the PatternWithDigits field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPatternWithDigitsOk() (*string, bool) {
-	if o == nil || isNil(o.PatternWithDigits) {
-    return nil, false
+	if o == nil || o.PatternWithDigits == nil {
+		return nil, false
 	}
 	return o.PatternWithDigits, true
 }
 
 // HasPatternWithDigits returns a boolean if a field has been set.
 func (o *FormatTest) HasPatternWithDigits() bool {
-	if o != nil && !isNil(o.PatternWithDigits) {
+	if o != nil && o.PatternWithDigits != nil {
 		return true
 	}
 
@@ -479,7 +482,7 @@ func (o *FormatTest) SetPatternWithDigits(v string) {
 
 // GetPatternWithDigitsAndDelimiter returns the PatternWithDigitsAndDelimiter field value if set, zero value otherwise.
 func (o *FormatTest) GetPatternWithDigitsAndDelimiter() string {
-	if o == nil || isNil(o.PatternWithDigitsAndDelimiter) {
+	if o == nil || o.PatternWithDigitsAndDelimiter == nil {
 		var ret string
 		return ret
 	}
@@ -489,15 +492,15 @@ func (o *FormatTest) GetPatternWithDigitsAndDelimiter() string {
 // GetPatternWithDigitsAndDelimiterOk returns a tuple with the PatternWithDigitsAndDelimiter field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPatternWithDigitsAndDelimiterOk() (*string, bool) {
-	if o == nil || isNil(o.PatternWithDigitsAndDelimiter) {
-    return nil, false
+	if o == nil || o.PatternWithDigitsAndDelimiter == nil {
+		return nil, false
 	}
 	return o.PatternWithDigitsAndDelimiter, true
 }
 
 // HasPatternWithDigitsAndDelimiter returns a boolean if a field has been set.
 func (o *FormatTest) HasPatternWithDigitsAndDelimiter() bool {
-	if o != nil && !isNil(o.PatternWithDigitsAndDelimiter) {
+	if o != nil && o.PatternWithDigitsAndDelimiter != nil {
 		return true
 	}
 
@@ -510,58 +513,63 @@ func (o *FormatTest) SetPatternWithDigitsAndDelimiter(v string) {
 }
 
 func (o FormatTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o FormatTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Integer) {
-		toSerialize["integer"] = o.Integer
+	if o.Integer != nil {
+		toSerialize["integer"] = *o.Integer
 	}
-	if !isNil(o.Int32) {
-		toSerialize["int32"] = o.Int32
+	if o.Int32 != nil {
+		toSerialize["int32"] = *o.Int32
 	}
-	if !isNil(o.Int64) {
-		toSerialize["int64"] = o.Int64
+	if o.Int64 != nil {
+		toSerialize["int64"] = *o.Int64
 	}
 	if true {
-		toSerialize["number"] = o.Number
+		toSerialize["number"] = *o.Number
 	}
-	if !isNil(o.Float) {
-		toSerialize["float"] = o.Float
+	if o.Float != nil {
+		toSerialize["float"] = *o.Float
 	}
-	if !isNil(o.Double) {
-		toSerialize["double"] = o.Double
+	if o.Double != nil {
+		toSerialize["double"] = *o.Double
 	}
-	if !isNil(o.String) {
-		toSerialize["string"] = o.String
+	if o.String != nil {
+		toSerialize["string"] = *o.String
 	}
 	if true {
-		toSerialize["byte"] = o.Byte
+		toSerialize["byte"] = *o.Byte
 	}
-	if !isNil(o.Binary) {
-		toSerialize["binary"] = o.Binary
+	if o.Binary != nil {
+		toSerialize["binary"] = *o.Binary
 	}
 	if true {
-		toSerialize["date"] = o.Date
+		toSerialize["date"] = *o.Date
 	}
-	if !isNil(o.DateTime) {
-		toSerialize["dateTime"] = o.DateTime
+	if o.DateTime != nil {
+		toSerialize["dateTime"] = *o.DateTime
 	}
-	if !isNil(o.Uuid) {
-		toSerialize["uuid"] = o.Uuid
+	if o.Uuid != nil {
+		toSerialize["uuid"] = *o.Uuid
 	}
 	if true {
-		toSerialize["password"] = o.Password
+		toSerialize["password"] = *o.Password
 	}
-	if !isNil(o.PatternWithDigits) {
-		toSerialize["pattern_with_digits"] = o.PatternWithDigits
+	if o.PatternWithDigits != nil {
+		toSerialize["pattern_with_digits"] = *o.PatternWithDigits
 	}
-	if !isNil(o.PatternWithDigitsAndDelimiter) {
-		toSerialize["pattern_with_digits_and_delimiter"] = o.PatternWithDigitsAndDelimiter
+	if o.PatternWithDigitsAndDelimiter != nil {
+		toSerialize["pattern_with_digits_and_delimiter"] = *o.PatternWithDigitsAndDelimiter
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *FormatTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
index 64ffc72e40d..d705c205845 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the HasOnlyReadOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &HasOnlyReadOnly{}
+
 // HasOnlyReadOnly struct for HasOnlyReadOnly
 type HasOnlyReadOnly struct {
 	Bar *string `json:"bar,omitempty"`
@@ -42,7 +45,7 @@ func NewHasOnlyReadOnlyWithDefaults() *HasOnlyReadOnly {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetBar() string {
-	if o == nil || isNil(o.Bar) {
+	if o == nil || o.Bar == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *HasOnlyReadOnly) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetBarOk() (*string, bool) {
-	if o == nil || isNil(o.Bar) {
-    return nil, false
+	if o == nil || o.Bar == nil {
+		return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasBar() bool {
-	if o != nil && !isNil(o.Bar) {
+	if o != nil && o.Bar != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *HasOnlyReadOnly) SetBar(v string) {
 
 // GetFoo returns the Foo field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetFoo() string {
-	if o == nil || isNil(o.Foo) {
+	if o == nil || o.Foo == nil {
 		var ret string
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *HasOnlyReadOnly) GetFoo() string {
 // GetFooOk returns a tuple with the Foo field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetFooOk() (*string, bool) {
-	if o == nil || isNil(o.Foo) {
-    return nil, false
+	if o == nil || o.Foo == nil {
+		return nil, false
 	}
 	return o.Foo, true
 }
 
 // HasFoo returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasFoo() bool {
-	if o != nil && !isNil(o.Foo) {
+	if o != nil && o.Foo != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *HasOnlyReadOnly) SetFoo(v string) {
 }
 
 func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o HasOnlyReadOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Bar) {
-		toSerialize["bar"] = o.Bar
+	if o.Bar != nil {
+		toSerialize["bar"] = *o.Bar
 	}
-	if !isNil(o.Foo) {
-		toSerialize["foo"] = o.Foo
+	if o.Foo != nil {
+		toSerialize["foo"] = *o.Foo
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *HasOnlyReadOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go b/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go
index dd7aa8d8b16..bc519af8d08 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the HealthCheckResult type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &HealthCheckResult{}
+
 // HealthCheckResult Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
 type HealthCheckResult struct {
 	NullableMessage NullableString `json:"NullableMessage,omitempty"`
@@ -82,16 +85,21 @@ func (o *HealthCheckResult) UnsetNullableMessage() {
 }
 
 func (o HealthCheckResult) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o HealthCheckResult) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if o.NullableMessage.IsSet() {
-		toSerialize["NullableMessage"] = o.NullableMessage.Get()
+		toSerialize["NullableMessage"] = *o.NullableMessage.Get()
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *HealthCheckResult) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_list.go b/samples/openapi3/client/petstore/go/go-petstore/model_list.go
index ee1faa38b75..d670f1c19ed 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_list.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_list.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the List type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &List{}
+
 // List struct for List
 type List struct {
 	Var123List *string `json:"123-list,omitempty"`
@@ -41,7 +44,7 @@ func NewListWithDefaults() *List {
 
 // GetVar123List returns the Var123List field value if set, zero value otherwise.
 func (o *List) GetVar123List() string {
-	if o == nil || isNil(o.Var123List) {
+	if o == nil || o.Var123List == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *List) GetVar123List() string {
 // GetVar123ListOk returns a tuple with the Var123List field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *List) GetVar123ListOk() (*string, bool) {
-	if o == nil || isNil(o.Var123List) {
-    return nil, false
+	if o == nil || o.Var123List == nil {
+		return nil, false
 	}
 	return o.Var123List, true
 }
 
 // HasVar123List returns a boolean if a field has been set.
 func (o *List) HasVar123List() bool {
-	if o != nil && !isNil(o.Var123List) {
+	if o != nil && o.Var123List != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *List) SetVar123List(v string) {
 }
 
 func (o List) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o List) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Var123List) {
-		toSerialize["123-list"] = o.Var123List
+	if o.Var123List != nil {
+		toSerialize["123-list"] = *o.Var123List
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *List) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
index f64dfb0488a..e76d76b74c0 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
@@ -15,6 +15,9 @@ import (
 	"os"
 )
 
+// checks if the MapOfFileTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &MapOfFileTest{}
+
 // MapOfFileTest test map of file in a property
 type MapOfFileTest struct {
 	// a property to test map of file
@@ -43,7 +46,7 @@ func NewMapOfFileTestWithDefaults() *MapOfFileTest {
 
 // GetPropTest returns the PropTest field value if set, zero value otherwise.
 func (o *MapOfFileTest) GetPropTest() map[string]*os.File {
-	if o == nil || isNil(o.PropTest) {
+	if o == nil || o.PropTest == nil {
 		var ret map[string]*os.File
 		return ret
 	}
@@ -53,15 +56,15 @@ func (o *MapOfFileTest) GetPropTest() map[string]*os.File {
 // GetPropTestOk returns a tuple with the PropTest field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapOfFileTest) GetPropTestOk() (*map[string]*os.File, bool) {
-	if o == nil || isNil(o.PropTest) {
-    return nil, false
+	if o == nil || o.PropTest == nil {
+		return nil, false
 	}
 	return o.PropTest, true
 }
 
 // HasPropTest returns a boolean if a field has been set.
 func (o *MapOfFileTest) HasPropTest() bool {
-	if o != nil && !isNil(o.PropTest) {
+	if o != nil && o.PropTest != nil {
 		return true
 	}
 
@@ -74,16 +77,21 @@ func (o *MapOfFileTest) SetPropTest(v map[string]*os.File) {
 }
 
 func (o MapOfFileTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o MapOfFileTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.PropTest) {
-		toSerialize["prop_test"] = o.PropTest
+	if o.PropTest != nil {
+		toSerialize["prop_test"] = *o.PropTest
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *MapOfFileTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
index 86e9ad60551..e48f4fce9ba 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the MapTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &MapTest{}
+
 // MapTest struct for MapTest
 type MapTest struct {
 	MapMapOfString *map[string]map[string]string `json:"map_map_of_string,omitempty"`
@@ -44,7 +47,7 @@ func NewMapTestWithDefaults() *MapTest {
 
 // GetMapMapOfString returns the MapMapOfString field value if set, zero value otherwise.
 func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
-	if o == nil || isNil(o.MapMapOfString) {
+	if o == nil || o.MapMapOfString == nil {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -54,15 +57,15 @@ func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
 // GetMapMapOfStringOk returns a tuple with the MapMapOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapMapOfStringOk() (*map[string]map[string]string, bool) {
-	if o == nil || isNil(o.MapMapOfString) {
-    return nil, false
+	if o == nil || o.MapMapOfString == nil {
+		return nil, false
 	}
 	return o.MapMapOfString, true
 }
 
 // HasMapMapOfString returns a boolean if a field has been set.
 func (o *MapTest) HasMapMapOfString() bool {
-	if o != nil && !isNil(o.MapMapOfString) {
+	if o != nil && o.MapMapOfString != nil {
 		return true
 	}
 
@@ -76,7 +79,7 @@ func (o *MapTest) SetMapMapOfString(v map[string]map[string]string) {
 
 // GetMapOfEnumString returns the MapOfEnumString field value if set, zero value otherwise.
 func (o *MapTest) GetMapOfEnumString() map[string]string {
-	if o == nil || isNil(o.MapOfEnumString) {
+	if o == nil || o.MapOfEnumString == nil {
 		var ret map[string]string
 		return ret
 	}
@@ -86,15 +89,15 @@ func (o *MapTest) GetMapOfEnumString() map[string]string {
 // GetMapOfEnumStringOk returns a tuple with the MapOfEnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapOfEnumStringOk() (*map[string]string, bool) {
-	if o == nil || isNil(o.MapOfEnumString) {
-    return nil, false
+	if o == nil || o.MapOfEnumString == nil {
+		return nil, false
 	}
 	return o.MapOfEnumString, true
 }
 
 // HasMapOfEnumString returns a boolean if a field has been set.
 func (o *MapTest) HasMapOfEnumString() bool {
-	if o != nil && !isNil(o.MapOfEnumString) {
+	if o != nil && o.MapOfEnumString != nil {
 		return true
 	}
 
@@ -108,7 +111,7 @@ func (o *MapTest) SetMapOfEnumString(v map[string]string) {
 
 // GetDirectMap returns the DirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetDirectMap() map[string]bool {
-	if o == nil || isNil(o.DirectMap) {
+	if o == nil || o.DirectMap == nil {
 		var ret map[string]bool
 		return ret
 	}
@@ -118,15 +121,15 @@ func (o *MapTest) GetDirectMap() map[string]bool {
 // GetDirectMapOk returns a tuple with the DirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetDirectMapOk() (*map[string]bool, bool) {
-	if o == nil || isNil(o.DirectMap) {
-    return nil, false
+	if o == nil || o.DirectMap == nil {
+		return nil, false
 	}
 	return o.DirectMap, true
 }
 
 // HasDirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasDirectMap() bool {
-	if o != nil && !isNil(o.DirectMap) {
+	if o != nil && o.DirectMap != nil {
 		return true
 	}
 
@@ -140,7 +143,7 @@ func (o *MapTest) SetDirectMap(v map[string]bool) {
 
 // GetIndirectMap returns the IndirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetIndirectMap() map[string]bool {
-	if o == nil || isNil(o.IndirectMap) {
+	if o == nil || o.IndirectMap == nil {
 		var ret map[string]bool
 		return ret
 	}
@@ -150,15 +153,15 @@ func (o *MapTest) GetIndirectMap() map[string]bool {
 // GetIndirectMapOk returns a tuple with the IndirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetIndirectMapOk() (*map[string]bool, bool) {
-	if o == nil || isNil(o.IndirectMap) {
-    return nil, false
+	if o == nil || o.IndirectMap == nil {
+		return nil, false
 	}
 	return o.IndirectMap, true
 }
 
 // HasIndirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasIndirectMap() bool {
-	if o != nil && !isNil(o.IndirectMap) {
+	if o != nil && o.IndirectMap != nil {
 		return true
 	}
 
@@ -171,25 +174,30 @@ func (o *MapTest) SetIndirectMap(v map[string]bool) {
 }
 
 func (o MapTest) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o MapTest) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.MapMapOfString) {
-		toSerialize["map_map_of_string"] = o.MapMapOfString
+	if o.MapMapOfString != nil {
+		toSerialize["map_map_of_string"] = *o.MapMapOfString
 	}
-	if !isNil(o.MapOfEnumString) {
-		toSerialize["map_of_enum_string"] = o.MapOfEnumString
+	if o.MapOfEnumString != nil {
+		toSerialize["map_of_enum_string"] = *o.MapOfEnumString
 	}
-	if !isNil(o.DirectMap) {
-		toSerialize["direct_map"] = o.DirectMap
+	if o.DirectMap != nil {
+		toSerialize["direct_map"] = *o.DirectMap
 	}
-	if !isNil(o.IndirectMap) {
-		toSerialize["indirect_map"] = o.IndirectMap
+	if o.IndirectMap != nil {
+		toSerialize["indirect_map"] = *o.IndirectMap
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *MapTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
index 290ad5082ed..76f19c0a850 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
@@ -15,6 +15,9 @@ import (
 	"time"
 )
 
+// checks if the MixedPropertiesAndAdditionalPropertiesClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &MixedPropertiesAndAdditionalPropertiesClass{}
+
 // MixedPropertiesAndAdditionalPropertiesClass struct for MixedPropertiesAndAdditionalPropertiesClass
 type MixedPropertiesAndAdditionalPropertiesClass struct {
 	Uuid *string `json:"uuid,omitempty"`
@@ -44,7 +47,7 @@ func NewMixedPropertiesAndAdditionalPropertiesClassWithDefaults() *MixedProperti
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
-	if o == nil || isNil(o.Uuid) {
+	if o == nil || o.Uuid == nil {
 		var ret string
 		return ret
 	}
@@ -54,15 +57,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuidOk() (*string, bool) {
-	if o == nil || isNil(o.Uuid) {
-    return nil, false
+	if o == nil || o.Uuid == nil {
+		return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasUuid() bool {
-	if o != nil && !isNil(o.Uuid) {
+	if o != nil && o.Uuid != nil {
 		return true
 	}
 
@@ -76,7 +79,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetUuid(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
-	if o == nil || isNil(o.DateTime) {
+	if o == nil || o.DateTime == nil {
 		var ret time.Time
 		return ret
 	}
@@ -86,15 +89,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || isNil(o.DateTime) {
-    return nil, false
+	if o == nil || o.DateTime == nil {
+		return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasDateTime() bool {
-	if o != nil && !isNil(o.DateTime) {
+	if o != nil && o.DateTime != nil {
 		return true
 	}
 
@@ -108,7 +111,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetDateTime(v time.Time) {
 
 // GetMap returns the Map field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal {
-	if o == nil || isNil(o.Map) {
+	if o == nil || o.Map == nil {
 		var ret map[string]Animal
 		return ret
 	}
@@ -118,15 +121,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal
 // GetMapOk returns a tuple with the Map field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMapOk() (*map[string]Animal, bool) {
-	if o == nil || isNil(o.Map) {
-    return nil, false
+	if o == nil || o.Map == nil {
+		return nil, false
 	}
 	return o.Map, true
 }
 
 // HasMap returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasMap() bool {
-	if o != nil && !isNil(o.Map) {
+	if o != nil && o.Map != nil {
 		return true
 	}
 
@@ -139,22 +142,27 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetMap(v map[string]Animal
 }
 
 func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Uuid) {
-		toSerialize["uuid"] = o.Uuid
+	if o.Uuid != nil {
+		toSerialize["uuid"] = *o.Uuid
 	}
-	if !isNil(o.DateTime) {
-		toSerialize["dateTime"] = o.DateTime
+	if o.DateTime != nil {
+		toSerialize["dateTime"] = *o.DateTime
 	}
-	if !isNil(o.Map) {
-		toSerialize["map"] = o.Map
+	if o.Map != nil {
+		toSerialize["map"] = *o.Map
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *MixedPropertiesAndAdditionalPropertiesClass) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_name.go b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
index e94a43b0c0f..3f7e5178ba9 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_name.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Name type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Name{}
+
 // Name Model for testing model name same as property name
 type Name struct {
 	Name int32 `json:"name"`
@@ -57,7 +60,7 @@ func (o *Name) GetName() int32 {
 // and a boolean to check if the value has been set.
 func (o *Name) GetNameOk() (*int32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Name, true
 }
@@ -69,7 +72,7 @@ func (o *Name) SetName(v int32) {
 
 // GetSnakeCase returns the SnakeCase field value if set, zero value otherwise.
 func (o *Name) GetSnakeCase() int32 {
-	if o == nil || isNil(o.SnakeCase) {
+	if o == nil || o.SnakeCase == nil {
 		var ret int32
 		return ret
 	}
@@ -79,15 +82,15 @@ func (o *Name) GetSnakeCase() int32 {
 // GetSnakeCaseOk returns a tuple with the SnakeCase field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetSnakeCaseOk() (*int32, bool) {
-	if o == nil || isNil(o.SnakeCase) {
-    return nil, false
+	if o == nil || o.SnakeCase == nil {
+		return nil, false
 	}
 	return o.SnakeCase, true
 }
 
 // HasSnakeCase returns a boolean if a field has been set.
 func (o *Name) HasSnakeCase() bool {
-	if o != nil && !isNil(o.SnakeCase) {
+	if o != nil && o.SnakeCase != nil {
 		return true
 	}
 
@@ -101,7 +104,7 @@ func (o *Name) SetSnakeCase(v int32) {
 
 // GetProperty returns the Property field value if set, zero value otherwise.
 func (o *Name) GetProperty() string {
-	if o == nil || isNil(o.Property) {
+	if o == nil || o.Property == nil {
 		var ret string
 		return ret
 	}
@@ -111,15 +114,15 @@ func (o *Name) GetProperty() string {
 // GetPropertyOk returns a tuple with the Property field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetPropertyOk() (*string, bool) {
-	if o == nil || isNil(o.Property) {
-    return nil, false
+	if o == nil || o.Property == nil {
+		return nil, false
 	}
 	return o.Property, true
 }
 
 // HasProperty returns a boolean if a field has been set.
 func (o *Name) HasProperty() bool {
-	if o != nil && !isNil(o.Property) {
+	if o != nil && o.Property != nil {
 		return true
 	}
 
@@ -133,7 +136,7 @@ func (o *Name) SetProperty(v string) {
 
 // GetVar123Number returns the Var123Number field value if set, zero value otherwise.
 func (o *Name) GetVar123Number() int32 {
-	if o == nil || isNil(o.Var123Number) {
+	if o == nil || o.Var123Number == nil {
 		var ret int32
 		return ret
 	}
@@ -143,15 +146,15 @@ func (o *Name) GetVar123Number() int32 {
 // GetVar123NumberOk returns a tuple with the Var123Number field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetVar123NumberOk() (*int32, bool) {
-	if o == nil || isNil(o.Var123Number) {
-    return nil, false
+	if o == nil || o.Var123Number == nil {
+		return nil, false
 	}
 	return o.Var123Number, true
 }
 
 // HasVar123Number returns a boolean if a field has been set.
 func (o *Name) HasVar123Number() bool {
-	if o != nil && !isNil(o.Var123Number) {
+	if o != nil && o.Var123Number != nil {
 		return true
 	}
 
@@ -164,25 +167,30 @@ func (o *Name) SetVar123Number(v int32) {
 }
 
 func (o Name) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Name) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if true {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
-	if !isNil(o.SnakeCase) {
-		toSerialize["snake_case"] = o.SnakeCase
+	if o.SnakeCase != nil {
+		toSerialize["snake_case"] = *o.SnakeCase
 	}
-	if !isNil(o.Property) {
-		toSerialize["property"] = o.Property
+	if o.Property != nil {
+		toSerialize["property"] = *o.Property
 	}
-	if !isNil(o.Var123Number) {
-		toSerialize["123Number"] = o.Var123Number
+	if o.Var123Number != nil {
+		toSerialize["123Number"] = *o.Var123Number
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Name) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go
index 4e2ca7760b6..64845e67426 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the NullableAllOf type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &NullableAllOf{}
+
 // NullableAllOf struct for NullableAllOf
 type NullableAllOf struct {
 	Child NullableNullableAllOfChild `json:"child,omitempty"`
@@ -82,16 +85,21 @@ func (o *NullableAllOf) UnsetChild() {
 }
 
 func (o NullableAllOf) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o NullableAllOf) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if o.Child.IsSet() {
-		toSerialize["child"] = o.Child.Get()
+		toSerialize["child"] = *o.Child.Get()
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *NullableAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
index e445ed4d57f..7ec6b4fb09d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the NullableAllOfChild type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &NullableAllOfChild{}
+
 // NullableAllOfChild struct for NullableAllOfChild
 type NullableAllOfChild struct {
 	Name *string `json:"name,omitempty"`
@@ -41,7 +44,7 @@ func NewNullableAllOfChildWithDefaults() *NullableAllOfChild {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *NullableAllOfChild) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *NullableAllOfChild) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NullableAllOfChild) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *NullableAllOfChild) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *NullableAllOfChild) SetName(v string) {
 }
 
 func (o NullableAllOfChild) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o NullableAllOfChild) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *NullableAllOfChild) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
index 49d57949b0a..7d5ecbf96e5 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
@@ -15,6 +15,9 @@ import (
 	"time"
 )
 
+// checks if the NullableClass type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &NullableClass{}
+
 // NullableClass struct for NullableClass
 type NullableClass struct {
 	IntegerProp NullableInt32 `json:"integer_prop,omitempty"`
@@ -54,7 +57,7 @@ func NewNullableClassWithDefaults() *NullableClass {
 
 // GetIntegerProp returns the IntegerProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetIntegerProp() int32 {
-	if o == nil || isNil(o.IntegerProp.Get()) {
+	if o == nil || o.IntegerProp.Get() == nil {
 		var ret int32
 		return ret
 	}
@@ -66,7 +69,7 @@ func (o *NullableClass) GetIntegerProp() int32 {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetIntegerPropOk() (*int32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.IntegerProp.Get(), o.IntegerProp.IsSet()
 }
@@ -96,7 +99,7 @@ func (o *NullableClass) UnsetIntegerProp() {
 
 // GetNumberProp returns the NumberProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetNumberProp() float32 {
-	if o == nil || isNil(o.NumberProp.Get()) {
+	if o == nil || o.NumberProp.Get() == nil {
 		var ret float32
 		return ret
 	}
@@ -108,7 +111,7 @@ func (o *NullableClass) GetNumberProp() float32 {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetNumberPropOk() (*float32, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.NumberProp.Get(), o.NumberProp.IsSet()
 }
@@ -138,7 +141,7 @@ func (o *NullableClass) UnsetNumberProp() {
 
 // GetBooleanProp returns the BooleanProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetBooleanProp() bool {
-	if o == nil || isNil(o.BooleanProp.Get()) {
+	if o == nil || o.BooleanProp.Get() == nil {
 		var ret bool
 		return ret
 	}
@@ -150,7 +153,7 @@ func (o *NullableClass) GetBooleanProp() bool {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetBooleanPropOk() (*bool, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.BooleanProp.Get(), o.BooleanProp.IsSet()
 }
@@ -180,7 +183,7 @@ func (o *NullableClass) UnsetBooleanProp() {
 
 // GetStringProp returns the StringProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetStringProp() string {
-	if o == nil || isNil(o.StringProp.Get()) {
+	if o == nil || o.StringProp.Get() == nil {
 		var ret string
 		return ret
 	}
@@ -192,7 +195,7 @@ func (o *NullableClass) GetStringProp() string {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetStringPropOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.StringProp.Get(), o.StringProp.IsSet()
 }
@@ -222,7 +225,7 @@ func (o *NullableClass) UnsetStringProp() {
 
 // GetDateProp returns the DateProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetDateProp() string {
-	if o == nil || isNil(o.DateProp.Get()) {
+	if o == nil || o.DateProp.Get() == nil {
 		var ret string
 		return ret
 	}
@@ -234,7 +237,7 @@ func (o *NullableClass) GetDateProp() string {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetDatePropOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.DateProp.Get(), o.DateProp.IsSet()
 }
@@ -264,7 +267,7 @@ func (o *NullableClass) UnsetDateProp() {
 
 // GetDatetimeProp returns the DatetimeProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetDatetimeProp() time.Time {
-	if o == nil || isNil(o.DatetimeProp.Get()) {
+	if o == nil || o.DatetimeProp.Get() == nil {
 		var ret time.Time
 		return ret
 	}
@@ -276,7 +279,7 @@ func (o *NullableClass) GetDatetimeProp() time.Time {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetDatetimePropOk() (*time.Time, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.DatetimeProp.Get(), o.DatetimeProp.IsSet()
 }
@@ -317,15 +320,15 @@ func (o *NullableClass) GetArrayNullableProp() []map[string]interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool) {
-	if o == nil || isNil(o.ArrayNullableProp) {
-    return nil, false
+	if o == nil || o.ArrayNullableProp == nil {
+		return nil, false
 	}
 	return o.ArrayNullableProp, true
 }
 
 // HasArrayNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasArrayNullableProp() bool {
-	if o != nil && isNil(o.ArrayNullableProp) {
+	if o != nil && o.ArrayNullableProp != nil {
 		return true
 	}
 
@@ -350,15 +353,15 @@ func (o *NullableClass) GetArrayAndItemsNullableProp() []*map[string]interface{}
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]*map[string]interface{}, bool) {
-	if o == nil || isNil(o.ArrayAndItemsNullableProp) {
-    return nil, false
+	if o == nil || o.ArrayAndItemsNullableProp == nil {
+		return nil, false
 	}
 	return o.ArrayAndItemsNullableProp, true
 }
 
 // HasArrayAndItemsNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasArrayAndItemsNullableProp() bool {
-	if o != nil && isNil(o.ArrayAndItemsNullableProp) {
+	if o != nil && o.ArrayAndItemsNullableProp != nil {
 		return true
 	}
 
@@ -372,7 +375,7 @@ func (o *NullableClass) SetArrayAndItemsNullableProp(v []*map[string]interface{}
 
 // GetArrayItemsNullable returns the ArrayItemsNullable field value if set, zero value otherwise.
 func (o *NullableClass) GetArrayItemsNullable() []*map[string]interface{} {
-	if o == nil || isNil(o.ArrayItemsNullable) {
+	if o == nil || o.ArrayItemsNullable == nil {
 		var ret []*map[string]interface{}
 		return ret
 	}
@@ -382,15 +385,15 @@ func (o *NullableClass) GetArrayItemsNullable() []*map[string]interface{} {
 // GetArrayItemsNullableOk returns a tuple with the ArrayItemsNullable field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NullableClass) GetArrayItemsNullableOk() ([]*map[string]interface{}, bool) {
-	if o == nil || isNil(o.ArrayItemsNullable) {
-    return nil, false
+	if o == nil || o.ArrayItemsNullable == nil {
+		return nil, false
 	}
 	return o.ArrayItemsNullable, true
 }
 
 // HasArrayItemsNullable returns a boolean if a field has been set.
 func (o *NullableClass) HasArrayItemsNullable() bool {
-	if o != nil && !isNil(o.ArrayItemsNullable) {
+	if o != nil && o.ArrayItemsNullable != nil {
 		return true
 	}
 
@@ -415,15 +418,15 @@ func (o *NullableClass) GetObjectNullableProp() map[string]map[string]interface{
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interface{}, bool) {
-	if o == nil || isNil(o.ObjectNullableProp) {
-    return map[string]map[string]interface{}{}, false
+	if o == nil || o.ObjectNullableProp == nil {
+		return nil, false
 	}
 	return o.ObjectNullableProp, true
 }
 
 // HasObjectNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasObjectNullableProp() bool {
-	if o != nil && isNil(o.ObjectNullableProp) {
+	if o != nil && o.ObjectNullableProp != nil {
 		return true
 	}
 
@@ -448,15 +451,15 @@ func (o *NullableClass) GetObjectAndItemsNullableProp() map[string]map[string]in
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string]interface{}, bool) {
-	if o == nil || isNil(o.ObjectAndItemsNullableProp) {
-    return map[string]map[string]interface{}{}, false
+	if o == nil || o.ObjectAndItemsNullableProp == nil {
+		return nil, false
 	}
 	return o.ObjectAndItemsNullableProp, true
 }
 
 // HasObjectAndItemsNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasObjectAndItemsNullableProp() bool {
-	if o != nil && isNil(o.ObjectAndItemsNullableProp) {
+	if o != nil && o.ObjectAndItemsNullableProp != nil {
 		return true
 	}
 
@@ -470,7 +473,7 @@ func (o *NullableClass) SetObjectAndItemsNullableProp(v map[string]map[string]in
 
 // GetObjectItemsNullable returns the ObjectItemsNullable field value if set, zero value otherwise.
 func (o *NullableClass) GetObjectItemsNullable() map[string]map[string]interface{} {
-	if o == nil || isNil(o.ObjectItemsNullable) {
+	if o == nil || o.ObjectItemsNullable == nil {
 		var ret map[string]map[string]interface{}
 		return ret
 	}
@@ -480,15 +483,15 @@ func (o *NullableClass) GetObjectItemsNullable() map[string]map[string]interface
 // GetObjectItemsNullableOk returns a tuple with the ObjectItemsNullable field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NullableClass) GetObjectItemsNullableOk() (map[string]map[string]interface{}, bool) {
-	if o == nil || isNil(o.ObjectItemsNullable) {
-    return map[string]map[string]interface{}{}, false
+	if o == nil || o.ObjectItemsNullable == nil {
+		return nil, false
 	}
 	return o.ObjectItemsNullable, true
 }
 
 // HasObjectItemsNullable returns a boolean if a field has been set.
 func (o *NullableClass) HasObjectItemsNullable() bool {
-	if o != nil && !isNil(o.ObjectItemsNullable) {
+	if o != nil && o.ObjectItemsNullable != nil {
 		return true
 	}
 
@@ -501,44 +504,49 @@ func (o *NullableClass) SetObjectItemsNullable(v map[string]map[string]interface
 }
 
 func (o NullableClass) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o NullableClass) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
 	if o.IntegerProp.IsSet() {
-		toSerialize["integer_prop"] = o.IntegerProp.Get()
+		toSerialize["integer_prop"] = *o.IntegerProp.Get()
 	}
 	if o.NumberProp.IsSet() {
-		toSerialize["number_prop"] = o.NumberProp.Get()
+		toSerialize["number_prop"] = *o.NumberProp.Get()
 	}
 	if o.BooleanProp.IsSet() {
-		toSerialize["boolean_prop"] = o.BooleanProp.Get()
+		toSerialize["boolean_prop"] = *o.BooleanProp.Get()
 	}
 	if o.StringProp.IsSet() {
-		toSerialize["string_prop"] = o.StringProp.Get()
+		toSerialize["string_prop"] = *o.StringProp.Get()
 	}
 	if o.DateProp.IsSet() {
-		toSerialize["date_prop"] = o.DateProp.Get()
+		toSerialize["date_prop"] = *o.DateProp.Get()
 	}
 	if o.DatetimeProp.IsSet() {
-		toSerialize["datetime_prop"] = o.DatetimeProp.Get()
+		toSerialize["datetime_prop"] = *o.DatetimeProp.Get()
 	}
 	if o.ArrayNullableProp != nil {
-		toSerialize["array_nullable_prop"] = o.ArrayNullableProp
+		toSerialize["array_nullable_prop"] = *o.ArrayNullableProp
 	}
 	if o.ArrayAndItemsNullableProp != nil {
-		toSerialize["array_and_items_nullable_prop"] = o.ArrayAndItemsNullableProp
+		toSerialize["array_and_items_nullable_prop"] = *o.ArrayAndItemsNullableProp
 	}
-	if !isNil(o.ArrayItemsNullable) {
-		toSerialize["array_items_nullable"] = o.ArrayItemsNullable
+	if o.ArrayItemsNullable != nil {
+		toSerialize["array_items_nullable"] = *o.ArrayItemsNullable
 	}
 	if o.ObjectNullableProp != nil {
-		toSerialize["object_nullable_prop"] = o.ObjectNullableProp
+		toSerialize["object_nullable_prop"] = *o.ObjectNullableProp
 	}
 	if o.ObjectAndItemsNullableProp != nil {
-		toSerialize["object_and_items_nullable_prop"] = o.ObjectAndItemsNullableProp
+		toSerialize["object_and_items_nullable_prop"] = *o.ObjectAndItemsNullableProp
 	}
-	if !isNil(o.ObjectItemsNullable) {
-		toSerialize["object_items_nullable"] = o.ObjectItemsNullable
+	if o.ObjectItemsNullable != nil {
+		toSerialize["object_items_nullable"] = *o.ObjectItemsNullable
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 type NullableNullableClass struct {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
index 12a0b61b7f2..9eb2e9eb2d6 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the NumberOnly type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &NumberOnly{}
+
 // NumberOnly struct for NumberOnly
 type NumberOnly struct {
 	JustNumber *float32 `json:"JustNumber,omitempty"`
@@ -41,7 +44,7 @@ func NewNumberOnlyWithDefaults() *NumberOnly {
 
 // GetJustNumber returns the JustNumber field value if set, zero value otherwise.
 func (o *NumberOnly) GetJustNumber() float32 {
-	if o == nil || isNil(o.JustNumber) {
+	if o == nil || o.JustNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *NumberOnly) GetJustNumber() float32 {
 // GetJustNumberOk returns a tuple with the JustNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NumberOnly) GetJustNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.JustNumber) {
-    return nil, false
+	if o == nil || o.JustNumber == nil {
+		return nil, false
 	}
 	return o.JustNumber, true
 }
 
 // HasJustNumber returns a boolean if a field has been set.
 func (o *NumberOnly) HasJustNumber() bool {
-	if o != nil && !isNil(o.JustNumber) {
+	if o != nil && o.JustNumber != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *NumberOnly) SetJustNumber(v float32) {
 }
 
 func (o NumberOnly) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o NumberOnly) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.JustNumber) {
-		toSerialize["JustNumber"] = o.JustNumber
+	if o.JustNumber != nil {
+		toSerialize["JustNumber"] = *o.JustNumber
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *NumberOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
index 49ee36631cd..7d653b92fd9 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the OneOfPrimitiveTypeChild type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &OneOfPrimitiveTypeChild{}
+
 // OneOfPrimitiveTypeChild struct for OneOfPrimitiveTypeChild
 type OneOfPrimitiveTypeChild struct {
 	Name *string `json:"name,omitempty"`
@@ -41,7 +44,7 @@ func NewOneOfPrimitiveTypeChildWithDefaults() *OneOfPrimitiveTypeChild {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *OneOfPrimitiveTypeChild) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *OneOfPrimitiveTypeChild) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OneOfPrimitiveTypeChild) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *OneOfPrimitiveTypeChild) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *OneOfPrimitiveTypeChild) SetName(v string) {
 }
 
 func (o OneOfPrimitiveTypeChild) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o OneOfPrimitiveTypeChild) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *OneOfPrimitiveTypeChild) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_order.go b/samples/openapi3/client/petstore/go/go-petstore/model_order.go
index 4cc42b7a5b1..2dc7f72e14a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_order.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_order.go
@@ -15,6 +15,9 @@ import (
 	"time"
 )
 
+// checks if the Order type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Order{}
+
 // Order struct for Order
 type Order struct {
 	Id *int64 `json:"id,omitempty"`
@@ -52,7 +55,7 @@ func NewOrderWithDefaults() *Order {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Order) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -62,15 +65,15 @@ func (o *Order) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Order) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -84,7 +87,7 @@ func (o *Order) SetId(v int64) {
 
 // GetPetId returns the PetId field value if set, zero value otherwise.
 func (o *Order) GetPetId() int64 {
-	if o == nil || isNil(o.PetId) {
+	if o == nil || o.PetId == nil {
 		var ret int64
 		return ret
 	}
@@ -94,15 +97,15 @@ func (o *Order) GetPetId() int64 {
 // GetPetIdOk returns a tuple with the PetId field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetPetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.PetId) {
-    return nil, false
+	if o == nil || o.PetId == nil {
+		return nil, false
 	}
 	return o.PetId, true
 }
 
 // HasPetId returns a boolean if a field has been set.
 func (o *Order) HasPetId() bool {
-	if o != nil && !isNil(o.PetId) {
+	if o != nil && o.PetId != nil {
 		return true
 	}
 
@@ -116,7 +119,7 @@ func (o *Order) SetPetId(v int64) {
 
 // GetQuantity returns the Quantity field value if set, zero value otherwise.
 func (o *Order) GetQuantity() int32 {
-	if o == nil || isNil(o.Quantity) {
+	if o == nil || o.Quantity == nil {
 		var ret int32
 		return ret
 	}
@@ -126,15 +129,15 @@ func (o *Order) GetQuantity() int32 {
 // GetQuantityOk returns a tuple with the Quantity field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetQuantityOk() (*int32, bool) {
-	if o == nil || isNil(o.Quantity) {
-    return nil, false
+	if o == nil || o.Quantity == nil {
+		return nil, false
 	}
 	return o.Quantity, true
 }
 
 // HasQuantity returns a boolean if a field has been set.
 func (o *Order) HasQuantity() bool {
-	if o != nil && !isNil(o.Quantity) {
+	if o != nil && o.Quantity != nil {
 		return true
 	}
 
@@ -148,7 +151,7 @@ func (o *Order) SetQuantity(v int32) {
 
 // GetShipDate returns the ShipDate field value if set, zero value otherwise.
 func (o *Order) GetShipDate() time.Time {
-	if o == nil || isNil(o.ShipDate) {
+	if o == nil || o.ShipDate == nil {
 		var ret time.Time
 		return ret
 	}
@@ -158,15 +161,15 @@ func (o *Order) GetShipDate() time.Time {
 // GetShipDateOk returns a tuple with the ShipDate field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetShipDateOk() (*time.Time, bool) {
-	if o == nil || isNil(o.ShipDate) {
-    return nil, false
+	if o == nil || o.ShipDate == nil {
+		return nil, false
 	}
 	return o.ShipDate, true
 }
 
 // HasShipDate returns a boolean if a field has been set.
 func (o *Order) HasShipDate() bool {
-	if o != nil && !isNil(o.ShipDate) {
+	if o != nil && o.ShipDate != nil {
 		return true
 	}
 
@@ -180,7 +183,7 @@ func (o *Order) SetShipDate(v time.Time) {
 
 // GetStatus returns the Status field value if set, zero value otherwise.
 func (o *Order) GetStatus() string {
-	if o == nil || isNil(o.Status) {
+	if o == nil || o.Status == nil {
 		var ret string
 		return ret
 	}
@@ -190,15 +193,15 @@ func (o *Order) GetStatus() string {
 // GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetStatusOk() (*string, bool) {
-	if o == nil || isNil(o.Status) {
-    return nil, false
+	if o == nil || o.Status == nil {
+		return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Order) HasStatus() bool {
-	if o != nil && !isNil(o.Status) {
+	if o != nil && o.Status != nil {
 		return true
 	}
 
@@ -212,7 +215,7 @@ func (o *Order) SetStatus(v string) {
 
 // GetComplete returns the Complete field value if set, zero value otherwise.
 func (o *Order) GetComplete() bool {
-	if o == nil || isNil(o.Complete) {
+	if o == nil || o.Complete == nil {
 		var ret bool
 		return ret
 	}
@@ -222,15 +225,15 @@ func (o *Order) GetComplete() bool {
 // GetCompleteOk returns a tuple with the Complete field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetCompleteOk() (*bool, bool) {
-	if o == nil || isNil(o.Complete) {
-    return nil, false
+	if o == nil || o.Complete == nil {
+		return nil, false
 	}
 	return o.Complete, true
 }
 
 // HasComplete returns a boolean if a field has been set.
 func (o *Order) HasComplete() bool {
-	if o != nil && !isNil(o.Complete) {
+	if o != nil && o.Complete != nil {
 		return true
 	}
 
@@ -243,31 +246,36 @@ func (o *Order) SetComplete(v bool) {
 }
 
 func (o Order) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Order) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.PetId) {
-		toSerialize["petId"] = o.PetId
+	if o.PetId != nil {
+		toSerialize["petId"] = *o.PetId
 	}
-	if !isNil(o.Quantity) {
-		toSerialize["quantity"] = o.Quantity
+	if o.Quantity != nil {
+		toSerialize["quantity"] = *o.Quantity
 	}
-	if !isNil(o.ShipDate) {
-		toSerialize["shipDate"] = o.ShipDate
+	if o.ShipDate != nil {
+		toSerialize["shipDate"] = *o.ShipDate
 	}
-	if !isNil(o.Status) {
-		toSerialize["status"] = o.Status
+	if o.Status != nil {
+		toSerialize["status"] = *o.Status
 	}
-	if !isNil(o.Complete) {
-		toSerialize["complete"] = o.Complete
+	if o.Complete != nil {
+		toSerialize["complete"] = *o.Complete
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Order) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
index aaa82cf01d4..8d2899c5d74 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the OuterComposite type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &OuterComposite{}
+
 // OuterComposite struct for OuterComposite
 type OuterComposite struct {
 	MyNumber *float32 `json:"my_number,omitempty"`
@@ -43,7 +46,7 @@ func NewOuterCompositeWithDefaults() *OuterComposite {
 
 // GetMyNumber returns the MyNumber field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyNumber() float32 {
-	if o == nil || isNil(o.MyNumber) {
+	if o == nil || o.MyNumber == nil {
 		var ret float32
 		return ret
 	}
@@ -53,15 +56,15 @@ func (o *OuterComposite) GetMyNumber() float32 {
 // GetMyNumberOk returns a tuple with the MyNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyNumberOk() (*float32, bool) {
-	if o == nil || isNil(o.MyNumber) {
-    return nil, false
+	if o == nil || o.MyNumber == nil {
+		return nil, false
 	}
 	return o.MyNumber, true
 }
 
 // HasMyNumber returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyNumber() bool {
-	if o != nil && !isNil(o.MyNumber) {
+	if o != nil && o.MyNumber != nil {
 		return true
 	}
 
@@ -75,7 +78,7 @@ func (o *OuterComposite) SetMyNumber(v float32) {
 
 // GetMyString returns the MyString field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyString() string {
-	if o == nil || isNil(o.MyString) {
+	if o == nil || o.MyString == nil {
 		var ret string
 		return ret
 	}
@@ -85,15 +88,15 @@ func (o *OuterComposite) GetMyString() string {
 // GetMyStringOk returns a tuple with the MyString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyStringOk() (*string, bool) {
-	if o == nil || isNil(o.MyString) {
-    return nil, false
+	if o == nil || o.MyString == nil {
+		return nil, false
 	}
 	return o.MyString, true
 }
 
 // HasMyString returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyString() bool {
-	if o != nil && !isNil(o.MyString) {
+	if o != nil && o.MyString != nil {
 		return true
 	}
 
@@ -107,7 +110,7 @@ func (o *OuterComposite) SetMyString(v string) {
 
 // GetMyBoolean returns the MyBoolean field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyBoolean() bool {
-	if o == nil || isNil(o.MyBoolean) {
+	if o == nil || o.MyBoolean == nil {
 		var ret bool
 		return ret
 	}
@@ -117,15 +120,15 @@ func (o *OuterComposite) GetMyBoolean() bool {
 // GetMyBooleanOk returns a tuple with the MyBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyBooleanOk() (*bool, bool) {
-	if o == nil || isNil(o.MyBoolean) {
-    return nil, false
+	if o == nil || o.MyBoolean == nil {
+		return nil, false
 	}
 	return o.MyBoolean, true
 }
 
 // HasMyBoolean returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyBoolean() bool {
-	if o != nil && !isNil(o.MyBoolean) {
+	if o != nil && o.MyBoolean != nil {
 		return true
 	}
 
@@ -138,22 +141,27 @@ func (o *OuterComposite) SetMyBoolean(v bool) {
 }
 
 func (o OuterComposite) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o OuterComposite) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.MyNumber) {
-		toSerialize["my_number"] = o.MyNumber
+	if o.MyNumber != nil {
+		toSerialize["my_number"] = *o.MyNumber
 	}
-	if !isNil(o.MyString) {
-		toSerialize["my_string"] = o.MyString
+	if o.MyString != nil {
+		toSerialize["my_string"] = *o.MyString
 	}
-	if !isNil(o.MyBoolean) {
-		toSerialize["my_boolean"] = o.MyBoolean
+	if o.MyBoolean != nil {
+		toSerialize["my_boolean"] = *o.MyBoolean
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *OuterComposite) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
index f0a086d7f3f..d60b4864291 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Pet type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Pet{}
+
 // Pet struct for Pet
 type Pet struct {
 	Id *int64 `json:"id,omitempty"`
@@ -50,7 +53,7 @@ func NewPetWithDefaults() *Pet {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Pet) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -60,15 +63,15 @@ func (o *Pet) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Pet) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -82,7 +85,7 @@ func (o *Pet) SetId(v int64) {
 
 // GetCategory returns the Category field value if set, zero value otherwise.
 func (o *Pet) GetCategory() Category {
-	if o == nil || isNil(o.Category) {
+	if o == nil || o.Category == nil {
 		var ret Category
 		return ret
 	}
@@ -92,15 +95,15 @@ func (o *Pet) GetCategory() Category {
 // GetCategoryOk returns a tuple with the Category field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetCategoryOk() (*Category, bool) {
-	if o == nil || isNil(o.Category) {
-    return nil, false
+	if o == nil || o.Category == nil {
+		return nil, false
 	}
 	return o.Category, true
 }
 
 // HasCategory returns a boolean if a field has been set.
 func (o *Pet) HasCategory() bool {
-	if o != nil && !isNil(o.Category) {
+	if o != nil && o.Category != nil {
 		return true
 	}
 
@@ -126,7 +129,7 @@ func (o *Pet) GetName() string {
 // and a boolean to check if the value has been set.
 func (o *Pet) GetNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.Name, true
 }
@@ -150,7 +153,7 @@ func (o *Pet) GetPhotoUrls() []string {
 // and a boolean to check if the value has been set.
 func (o *Pet) GetPhotoUrlsOk() ([]string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return o.PhotoUrls, true
 }
@@ -162,7 +165,7 @@ func (o *Pet) SetPhotoUrls(v []string) {
 
 // GetTags returns the Tags field value if set, zero value otherwise.
 func (o *Pet) GetTags() []Tag {
-	if o == nil || isNil(o.Tags) {
+	if o == nil || o.Tags == nil {
 		var ret []Tag
 		return ret
 	}
@@ -172,15 +175,15 @@ func (o *Pet) GetTags() []Tag {
 // GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetTagsOk() ([]Tag, bool) {
-	if o == nil || isNil(o.Tags) {
-    return nil, false
+	if o == nil || o.Tags == nil {
+		return nil, false
 	}
 	return o.Tags, true
 }
 
 // HasTags returns a boolean if a field has been set.
 func (o *Pet) HasTags() bool {
-	if o != nil && !isNil(o.Tags) {
+	if o != nil && o.Tags != nil {
 		return true
 	}
 
@@ -195,7 +198,7 @@ func (o *Pet) SetTags(v []Tag) {
 // GetStatus returns the Status field value if set, zero value otherwise.
 // Deprecated
 func (o *Pet) GetStatus() string {
-	if o == nil || isNil(o.Status) {
+	if o == nil || o.Status == nil {
 		var ret string
 		return ret
 	}
@@ -206,15 +209,15 @@ func (o *Pet) GetStatus() string {
 // and a boolean to check if the value has been set.
 // Deprecated
 func (o *Pet) GetStatusOk() (*string, bool) {
-	if o == nil || isNil(o.Status) {
-    return nil, false
+	if o == nil || o.Status == nil {
+		return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Pet) HasStatus() bool {
-	if o != nil && !isNil(o.Status) {
+	if o != nil && o.Status != nil {
 		return true
 	}
 
@@ -228,31 +231,36 @@ func (o *Pet) SetStatus(v string) {
 }
 
 func (o Pet) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Pet) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.Category) {
-		toSerialize["category"] = o.Category
+	if o.Category != nil {
+		toSerialize["category"] = *o.Category
 	}
 	if true {
-		toSerialize["name"] = o.Name
+		toSerialize["name"] = *o.Name
 	}
 	if true {
-		toSerialize["photoUrls"] = o.PhotoUrls
+		toSerialize["photoUrls"] = *o.PhotoUrls
 	}
-	if !isNil(o.Tags) {
-		toSerialize["tags"] = o.Tags
+	if o.Tags != nil {
+		toSerialize["tags"] = *o.Tags
 	}
-	if !isNil(o.Status) {
-		toSerialize["status"] = o.Status
+	if o.Status != nil {
+		toSerialize["status"] = *o.Status
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Pet) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
index bebaf5ac671..13db5b0ed16 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ReadOnlyFirst type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ReadOnlyFirst{}
+
 // ReadOnlyFirst struct for ReadOnlyFirst
 type ReadOnlyFirst struct {
 	Bar *string `json:"bar,omitempty"`
@@ -42,7 +45,7 @@ func NewReadOnlyFirstWithDefaults() *ReadOnlyFirst {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBar() string {
-	if o == nil || isNil(o.Bar) {
+	if o == nil || o.Bar == nil {
 		var ret string
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *ReadOnlyFirst) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBarOk() (*string, bool) {
-	if o == nil || isNil(o.Bar) {
-    return nil, false
+	if o == nil || o.Bar == nil {
+		return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBar() bool {
-	if o != nil && !isNil(o.Bar) {
+	if o != nil && o.Bar != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *ReadOnlyFirst) SetBar(v string) {
 
 // GetBaz returns the Baz field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBaz() string {
-	if o == nil || isNil(o.Baz) {
+	if o == nil || o.Baz == nil {
 		var ret string
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *ReadOnlyFirst) GetBaz() string {
 // GetBazOk returns a tuple with the Baz field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBazOk() (*string, bool) {
-	if o == nil || isNil(o.Baz) {
-    return nil, false
+	if o == nil || o.Baz == nil {
+		return nil, false
 	}
 	return o.Baz, true
 }
 
 // HasBaz returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBaz() bool {
-	if o != nil && !isNil(o.Baz) {
+	if o != nil && o.Baz != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *ReadOnlyFirst) SetBaz(v string) {
 }
 
 func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ReadOnlyFirst) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Bar) {
-		toSerialize["bar"] = o.Bar
+	if o.Bar != nil {
+		toSerialize["bar"] = *o.Bar
 	}
-	if !isNil(o.Baz) {
-		toSerialize["baz"] = o.Baz
+	if o.Baz != nil {
+		toSerialize["baz"] = *o.Baz
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ReadOnlyFirst) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
index 2b82163ca7c..bb0f8b69061 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the ReadOnlyWithDefault type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &ReadOnlyWithDefault{}
+
 // ReadOnlyWithDefault struct for ReadOnlyWithDefault
 type ReadOnlyWithDefault struct {
 	Prop1 *string `json:"prop1,omitempty"`
@@ -59,7 +62,7 @@ func NewReadOnlyWithDefaultWithDefaults() *ReadOnlyWithDefault {
 
 // GetProp1 returns the Prop1 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetProp1() string {
-	if o == nil || isNil(o.Prop1) {
+	if o == nil || o.Prop1 == nil {
 		var ret string
 		return ret
 	}
@@ -69,15 +72,15 @@ func (o *ReadOnlyWithDefault) GetProp1() string {
 // GetProp1Ok returns a tuple with the Prop1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetProp1Ok() (*string, bool) {
-	if o == nil || isNil(o.Prop1) {
-    return nil, false
+	if o == nil || o.Prop1 == nil {
+		return nil, false
 	}
 	return o.Prop1, true
 }
 
 // HasProp1 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasProp1() bool {
-	if o != nil && !isNil(o.Prop1) {
+	if o != nil && o.Prop1 != nil {
 		return true
 	}
 
@@ -91,7 +94,7 @@ func (o *ReadOnlyWithDefault) SetProp1(v string) {
 
 // GetProp2 returns the Prop2 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetProp2() string {
-	if o == nil || isNil(o.Prop2) {
+	if o == nil || o.Prop2 == nil {
 		var ret string
 		return ret
 	}
@@ -101,15 +104,15 @@ func (o *ReadOnlyWithDefault) GetProp2() string {
 // GetProp2Ok returns a tuple with the Prop2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetProp2Ok() (*string, bool) {
-	if o == nil || isNil(o.Prop2) {
-    return nil, false
+	if o == nil || o.Prop2 == nil {
+		return nil, false
 	}
 	return o.Prop2, true
 }
 
 // HasProp2 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasProp2() bool {
-	if o != nil && !isNil(o.Prop2) {
+	if o != nil && o.Prop2 != nil {
 		return true
 	}
 
@@ -123,7 +126,7 @@ func (o *ReadOnlyWithDefault) SetProp2(v string) {
 
 // GetProp3 returns the Prop3 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetProp3() string {
-	if o == nil || isNil(o.Prop3) {
+	if o == nil || o.Prop3 == nil {
 		var ret string
 		return ret
 	}
@@ -133,15 +136,15 @@ func (o *ReadOnlyWithDefault) GetProp3() string {
 // GetProp3Ok returns a tuple with the Prop3 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetProp3Ok() (*string, bool) {
-	if o == nil || isNil(o.Prop3) {
-    return nil, false
+	if o == nil || o.Prop3 == nil {
+		return nil, false
 	}
 	return o.Prop3, true
 }
 
 // HasProp3 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasProp3() bool {
-	if o != nil && !isNil(o.Prop3) {
+	if o != nil && o.Prop3 != nil {
 		return true
 	}
 
@@ -155,7 +158,7 @@ func (o *ReadOnlyWithDefault) SetProp3(v string) {
 
 // GetBoolProp1 returns the BoolProp1 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetBoolProp1() bool {
-	if o == nil || isNil(o.BoolProp1) {
+	if o == nil || o.BoolProp1 == nil {
 		var ret bool
 		return ret
 	}
@@ -165,15 +168,15 @@ func (o *ReadOnlyWithDefault) GetBoolProp1() bool {
 // GetBoolProp1Ok returns a tuple with the BoolProp1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetBoolProp1Ok() (*bool, bool) {
-	if o == nil || isNil(o.BoolProp1) {
-    return nil, false
+	if o == nil || o.BoolProp1 == nil {
+		return nil, false
 	}
 	return o.BoolProp1, true
 }
 
 // HasBoolProp1 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasBoolProp1() bool {
-	if o != nil && !isNil(o.BoolProp1) {
+	if o != nil && o.BoolProp1 != nil {
 		return true
 	}
 
@@ -187,7 +190,7 @@ func (o *ReadOnlyWithDefault) SetBoolProp1(v bool) {
 
 // GetBoolProp2 returns the BoolProp2 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetBoolProp2() bool {
-	if o == nil || isNil(o.BoolProp2) {
+	if o == nil || o.BoolProp2 == nil {
 		var ret bool
 		return ret
 	}
@@ -197,15 +200,15 @@ func (o *ReadOnlyWithDefault) GetBoolProp2() bool {
 // GetBoolProp2Ok returns a tuple with the BoolProp2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetBoolProp2Ok() (*bool, bool) {
-	if o == nil || isNil(o.BoolProp2) {
-    return nil, false
+	if o == nil || o.BoolProp2 == nil {
+		return nil, false
 	}
 	return o.BoolProp2, true
 }
 
 // HasBoolProp2 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasBoolProp2() bool {
-	if o != nil && !isNil(o.BoolProp2) {
+	if o != nil && o.BoolProp2 != nil {
 		return true
 	}
 
@@ -219,7 +222,7 @@ func (o *ReadOnlyWithDefault) SetBoolProp2(v bool) {
 
 // GetIntProp1 returns the IntProp1 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetIntProp1() float32 {
-	if o == nil || isNil(o.IntProp1) {
+	if o == nil || o.IntProp1 == nil {
 		var ret float32
 		return ret
 	}
@@ -229,15 +232,15 @@ func (o *ReadOnlyWithDefault) GetIntProp1() float32 {
 // GetIntProp1Ok returns a tuple with the IntProp1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetIntProp1Ok() (*float32, bool) {
-	if o == nil || isNil(o.IntProp1) {
-    return nil, false
+	if o == nil || o.IntProp1 == nil {
+		return nil, false
 	}
 	return o.IntProp1, true
 }
 
 // HasIntProp1 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasIntProp1() bool {
-	if o != nil && !isNil(o.IntProp1) {
+	if o != nil && o.IntProp1 != nil {
 		return true
 	}
 
@@ -251,7 +254,7 @@ func (o *ReadOnlyWithDefault) SetIntProp1(v float32) {
 
 // GetIntProp2 returns the IntProp2 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetIntProp2() float32 {
-	if o == nil || isNil(o.IntProp2) {
+	if o == nil || o.IntProp2 == nil {
 		var ret float32
 		return ret
 	}
@@ -261,15 +264,15 @@ func (o *ReadOnlyWithDefault) GetIntProp2() float32 {
 // GetIntProp2Ok returns a tuple with the IntProp2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetIntProp2Ok() (*float32, bool) {
-	if o == nil || isNil(o.IntProp2) {
-    return nil, false
+	if o == nil || o.IntProp2 == nil {
+		return nil, false
 	}
 	return o.IntProp2, true
 }
 
 // HasIntProp2 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasIntProp2() bool {
-	if o != nil && !isNil(o.IntProp2) {
+	if o != nil && o.IntProp2 != nil {
 		return true
 	}
 
@@ -282,34 +285,39 @@ func (o *ReadOnlyWithDefault) SetIntProp2(v float32) {
 }
 
 func (o ReadOnlyWithDefault) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o ReadOnlyWithDefault) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Prop1) {
-		toSerialize["prop1"] = o.Prop1
+	if o.Prop1 != nil {
+		toSerialize["prop1"] = *o.Prop1
 	}
-	if !isNil(o.Prop2) {
-		toSerialize["prop2"] = o.Prop2
+	if o.Prop2 != nil {
+		toSerialize["prop2"] = *o.Prop2
 	}
-	if !isNil(o.Prop3) {
-		toSerialize["prop3"] = o.Prop3
+	if o.Prop3 != nil {
+		toSerialize["prop3"] = *o.Prop3
 	}
-	if !isNil(o.BoolProp1) {
-		toSerialize["boolProp1"] = o.BoolProp1
+	if o.BoolProp1 != nil {
+		toSerialize["boolProp1"] = *o.BoolProp1
 	}
-	if !isNil(o.BoolProp2) {
-		toSerialize["boolProp2"] = o.BoolProp2
+	if o.BoolProp2 != nil {
+		toSerialize["boolProp2"] = *o.BoolProp2
 	}
-	if !isNil(o.IntProp1) {
-		toSerialize["intProp1"] = o.IntProp1
+	if o.IntProp1 != nil {
+		toSerialize["intProp1"] = *o.IntProp1
 	}
-	if !isNil(o.IntProp2) {
-		toSerialize["intProp2"] = o.IntProp2
+	if o.IntProp2 != nil {
+		toSerialize["intProp2"] = *o.IntProp2
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *ReadOnlyWithDefault) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_return.go b/samples/openapi3/client/petstore/go/go-petstore/model_return.go
index cafa2b58861..dcfdd44683a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_return.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_return.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Return type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Return{}
+
 // Return Model for testing reserved words
 type Return struct {
 	Return *int32 `json:"return,omitempty"`
@@ -41,7 +44,7 @@ func NewReturnWithDefaults() *Return {
 
 // GetReturn returns the Return field value if set, zero value otherwise.
 func (o *Return) GetReturn() int32 {
-	if o == nil || isNil(o.Return) {
+	if o == nil || o.Return == nil {
 		var ret int32
 		return ret
 	}
@@ -51,15 +54,15 @@ func (o *Return) GetReturn() int32 {
 // GetReturnOk returns a tuple with the Return field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Return) GetReturnOk() (*int32, bool) {
-	if o == nil || isNil(o.Return) {
-    return nil, false
+	if o == nil || o.Return == nil {
+		return nil, false
 	}
 	return o.Return, true
 }
 
 // HasReturn returns a boolean if a field has been set.
 func (o *Return) HasReturn() bool {
-	if o != nil && !isNil(o.Return) {
+	if o != nil && o.Return != nil {
 		return true
 	}
 
@@ -72,16 +75,21 @@ func (o *Return) SetReturn(v int32) {
 }
 
 func (o Return) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Return) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Return) {
-		toSerialize["return"] = o.Return
+	if o.Return != nil {
+		toSerialize["return"] = *o.Return
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Return) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
index 6e91817d4be..d49f0e2c581 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Tag type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Tag{}
+
 // Tag struct for Tag
 type Tag struct {
 	Id *int64 `json:"id,omitempty"`
@@ -42,7 +45,7 @@ func NewTagWithDefaults() *Tag {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Tag) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -52,15 +55,15 @@ func (o *Tag) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Tag) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -74,7 +77,7 @@ func (o *Tag) SetId(v int64) {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *Tag) GetName() string {
-	if o == nil || isNil(o.Name) {
+	if o == nil || o.Name == nil {
 		var ret string
 		return ret
 	}
@@ -84,15 +87,15 @@ func (o *Tag) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetNameOk() (*string, bool) {
-	if o == nil || isNil(o.Name) {
-    return nil, false
+	if o == nil || o.Name == nil {
+		return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *Tag) HasName() bool {
-	if o != nil && !isNil(o.Name) {
+	if o != nil && o.Name != nil {
 		return true
 	}
 
@@ -105,19 +108,24 @@ func (o *Tag) SetName(v string) {
 }
 
 func (o Tag) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Tag) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.Name) {
-		toSerialize["name"] = o.Name
+	if o.Name != nil {
+		toSerialize["name"] = *o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Tag) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_user.go b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
index 321ae5e03b1..1c562213a77 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_user.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the User type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &User{}
+
 // User struct for User
 type User struct {
 	Id *int64 `json:"id,omitempty"`
@@ -57,7 +60,7 @@ func NewUserWithDefaults() *User {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *User) GetId() int64 {
-	if o == nil || isNil(o.Id) {
+	if o == nil || o.Id == nil {
 		var ret int64
 		return ret
 	}
@@ -67,15 +70,15 @@ func (o *User) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetIdOk() (*int64, bool) {
-	if o == nil || isNil(o.Id) {
-    return nil, false
+	if o == nil || o.Id == nil {
+		return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *User) HasId() bool {
-	if o != nil && !isNil(o.Id) {
+	if o != nil && o.Id != nil {
 		return true
 	}
 
@@ -89,7 +92,7 @@ func (o *User) SetId(v int64) {
 
 // GetUsername returns the Username field value if set, zero value otherwise.
 func (o *User) GetUsername() string {
-	if o == nil || isNil(o.Username) {
+	if o == nil || o.Username == nil {
 		var ret string
 		return ret
 	}
@@ -99,15 +102,15 @@ func (o *User) GetUsername() string {
 // GetUsernameOk returns a tuple with the Username field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUsernameOk() (*string, bool) {
-	if o == nil || isNil(o.Username) {
-    return nil, false
+	if o == nil || o.Username == nil {
+		return nil, false
 	}
 	return o.Username, true
 }
 
 // HasUsername returns a boolean if a field has been set.
 func (o *User) HasUsername() bool {
-	if o != nil && !isNil(o.Username) {
+	if o != nil && o.Username != nil {
 		return true
 	}
 
@@ -121,7 +124,7 @@ func (o *User) SetUsername(v string) {
 
 // GetFirstName returns the FirstName field value if set, zero value otherwise.
 func (o *User) GetFirstName() string {
-	if o == nil || isNil(o.FirstName) {
+	if o == nil || o.FirstName == nil {
 		var ret string
 		return ret
 	}
@@ -131,15 +134,15 @@ func (o *User) GetFirstName() string {
 // GetFirstNameOk returns a tuple with the FirstName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetFirstNameOk() (*string, bool) {
-	if o == nil || isNil(o.FirstName) {
-    return nil, false
+	if o == nil || o.FirstName == nil {
+		return nil, false
 	}
 	return o.FirstName, true
 }
 
 // HasFirstName returns a boolean if a field has been set.
 func (o *User) HasFirstName() bool {
-	if o != nil && !isNil(o.FirstName) {
+	if o != nil && o.FirstName != nil {
 		return true
 	}
 
@@ -153,7 +156,7 @@ func (o *User) SetFirstName(v string) {
 
 // GetLastName returns the LastName field value if set, zero value otherwise.
 func (o *User) GetLastName() string {
-	if o == nil || isNil(o.LastName) {
+	if o == nil || o.LastName == nil {
 		var ret string
 		return ret
 	}
@@ -163,15 +166,15 @@ func (o *User) GetLastName() string {
 // GetLastNameOk returns a tuple with the LastName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetLastNameOk() (*string, bool) {
-	if o == nil || isNil(o.LastName) {
-    return nil, false
+	if o == nil || o.LastName == nil {
+		return nil, false
 	}
 	return o.LastName, true
 }
 
 // HasLastName returns a boolean if a field has been set.
 func (o *User) HasLastName() bool {
-	if o != nil && !isNil(o.LastName) {
+	if o != nil && o.LastName != nil {
 		return true
 	}
 
@@ -185,7 +188,7 @@ func (o *User) SetLastName(v string) {
 
 // GetEmail returns the Email field value if set, zero value otherwise.
 func (o *User) GetEmail() string {
-	if o == nil || isNil(o.Email) {
+	if o == nil || o.Email == nil {
 		var ret string
 		return ret
 	}
@@ -195,15 +198,15 @@ func (o *User) GetEmail() string {
 // GetEmailOk returns a tuple with the Email field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetEmailOk() (*string, bool) {
-	if o == nil || isNil(o.Email) {
-    return nil, false
+	if o == nil || o.Email == nil {
+		return nil, false
 	}
 	return o.Email, true
 }
 
 // HasEmail returns a boolean if a field has been set.
 func (o *User) HasEmail() bool {
-	if o != nil && !isNil(o.Email) {
+	if o != nil && o.Email != nil {
 		return true
 	}
 
@@ -217,7 +220,7 @@ func (o *User) SetEmail(v string) {
 
 // GetPassword returns the Password field value if set, zero value otherwise.
 func (o *User) GetPassword() string {
-	if o == nil || isNil(o.Password) {
+	if o == nil || o.Password == nil {
 		var ret string
 		return ret
 	}
@@ -227,15 +230,15 @@ func (o *User) GetPassword() string {
 // GetPasswordOk returns a tuple with the Password field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPasswordOk() (*string, bool) {
-	if o == nil || isNil(o.Password) {
-    return nil, false
+	if o == nil || o.Password == nil {
+		return nil, false
 	}
 	return o.Password, true
 }
 
 // HasPassword returns a boolean if a field has been set.
 func (o *User) HasPassword() bool {
-	if o != nil && !isNil(o.Password) {
+	if o != nil && o.Password != nil {
 		return true
 	}
 
@@ -249,7 +252,7 @@ func (o *User) SetPassword(v string) {
 
 // GetPhone returns the Phone field value if set, zero value otherwise.
 func (o *User) GetPhone() string {
-	if o == nil || isNil(o.Phone) {
+	if o == nil || o.Phone == nil {
 		var ret string
 		return ret
 	}
@@ -259,15 +262,15 @@ func (o *User) GetPhone() string {
 // GetPhoneOk returns a tuple with the Phone field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPhoneOk() (*string, bool) {
-	if o == nil || isNil(o.Phone) {
-    return nil, false
+	if o == nil || o.Phone == nil {
+		return nil, false
 	}
 	return o.Phone, true
 }
 
 // HasPhone returns a boolean if a field has been set.
 func (o *User) HasPhone() bool {
-	if o != nil && !isNil(o.Phone) {
+	if o != nil && o.Phone != nil {
 		return true
 	}
 
@@ -281,7 +284,7 @@ func (o *User) SetPhone(v string) {
 
 // GetUserStatus returns the UserStatus field value if set, zero value otherwise.
 func (o *User) GetUserStatus() int32 {
-	if o == nil || isNil(o.UserStatus) {
+	if o == nil || o.UserStatus == nil {
 		var ret int32
 		return ret
 	}
@@ -291,15 +294,15 @@ func (o *User) GetUserStatus() int32 {
 // GetUserStatusOk returns a tuple with the UserStatus field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUserStatusOk() (*int32, bool) {
-	if o == nil || isNil(o.UserStatus) {
-    return nil, false
+	if o == nil || o.UserStatus == nil {
+		return nil, false
 	}
 	return o.UserStatus, true
 }
 
 // HasUserStatus returns a boolean if a field has been set.
 func (o *User) HasUserStatus() bool {
-	if o != nil && !isNil(o.UserStatus) {
+	if o != nil && o.UserStatus != nil {
 		return true
 	}
 
@@ -313,7 +316,7 @@ func (o *User) SetUserStatus(v int32) {
 
 // GetArbitraryObject returns the ArbitraryObject field value if set, zero value otherwise.
 func (o *User) GetArbitraryObject() map[string]interface{} {
-	if o == nil || isNil(o.ArbitraryObject) {
+	if o == nil || o.ArbitraryObject == nil {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -323,15 +326,15 @@ func (o *User) GetArbitraryObject() map[string]interface{} {
 // GetArbitraryObjectOk returns a tuple with the ArbitraryObject field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetArbitraryObjectOk() (map[string]interface{}, bool) {
-	if o == nil || isNil(o.ArbitraryObject) {
-    return map[string]interface{}{}, false
+	if o == nil || o.ArbitraryObject == nil {
+		return nil, false
 	}
 	return o.ArbitraryObject, true
 }
 
 // HasArbitraryObject returns a boolean if a field has been set.
 func (o *User) HasArbitraryObject() bool {
-	if o != nil && !isNil(o.ArbitraryObject) {
+	if o != nil && o.ArbitraryObject != nil {
 		return true
 	}
 
@@ -356,15 +359,15 @@ func (o *User) GetArbitraryNullableObject() map[string]interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *User) GetArbitraryNullableObjectOk() (map[string]interface{}, bool) {
-	if o == nil || isNil(o.ArbitraryNullableObject) {
-    return map[string]interface{}{}, false
+	if o == nil || o.ArbitraryNullableObject == nil {
+		return nil, false
 	}
 	return o.ArbitraryNullableObject, true
 }
 
 // HasArbitraryNullableObject returns a boolean if a field has been set.
 func (o *User) HasArbitraryNullableObject() bool {
-	if o != nil && isNil(o.ArbitraryNullableObject) {
+	if o != nil && o.ArbitraryNullableObject != nil {
 		return true
 	}
 
@@ -389,15 +392,15 @@ func (o *User) GetArbitraryTypeValue() interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *User) GetArbitraryTypeValueOk() (*interface{}, bool) {
-	if o == nil || isNil(o.ArbitraryTypeValue) {
-    return nil, false
+	if o == nil || o.ArbitraryTypeValue == nil {
+		return nil, false
 	}
 	return &o.ArbitraryTypeValue, true
 }
 
 // HasArbitraryTypeValue returns a boolean if a field has been set.
 func (o *User) HasArbitraryTypeValue() bool {
-	if o != nil && isNil(o.ArbitraryTypeValue) {
+	if o != nil && o.ArbitraryTypeValue != nil {
 		return true
 	}
 
@@ -422,15 +425,15 @@ func (o *User) GetArbitraryNullableTypeValue() interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *User) GetArbitraryNullableTypeValueOk() (*interface{}, bool) {
-	if o == nil || isNil(o.ArbitraryNullableTypeValue) {
-    return nil, false
+	if o == nil || o.ArbitraryNullableTypeValue == nil {
+		return nil, false
 	}
 	return &o.ArbitraryNullableTypeValue, true
 }
 
 // HasArbitraryNullableTypeValue returns a boolean if a field has been set.
 func (o *User) HasArbitraryNullableTypeValue() bool {
-	if o != nil && isNil(o.ArbitraryNullableTypeValue) {
+	if o != nil && o.ArbitraryNullableTypeValue != nil {
 		return true
 	}
 
@@ -443,49 +446,54 @@ func (o *User) SetArbitraryNullableTypeValue(v interface{}) {
 }
 
 func (o User) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o User) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Id) {
-		toSerialize["id"] = o.Id
+	if o.Id != nil {
+		toSerialize["id"] = *o.Id
 	}
-	if !isNil(o.Username) {
-		toSerialize["username"] = o.Username
+	if o.Username != nil {
+		toSerialize["username"] = *o.Username
 	}
-	if !isNil(o.FirstName) {
-		toSerialize["firstName"] = o.FirstName
+	if o.FirstName != nil {
+		toSerialize["firstName"] = *o.FirstName
 	}
-	if !isNil(o.LastName) {
-		toSerialize["lastName"] = o.LastName
+	if o.LastName != nil {
+		toSerialize["lastName"] = *o.LastName
 	}
-	if !isNil(o.Email) {
-		toSerialize["email"] = o.Email
+	if o.Email != nil {
+		toSerialize["email"] = *o.Email
 	}
-	if !isNil(o.Password) {
-		toSerialize["password"] = o.Password
+	if o.Password != nil {
+		toSerialize["password"] = *o.Password
 	}
-	if !isNil(o.Phone) {
-		toSerialize["phone"] = o.Phone
+	if o.Phone != nil {
+		toSerialize["phone"] = *o.Phone
 	}
-	if !isNil(o.UserStatus) {
-		toSerialize["userStatus"] = o.UserStatus
+	if o.UserStatus != nil {
+		toSerialize["userStatus"] = *o.UserStatus
 	}
-	if !isNil(o.ArbitraryObject) {
-		toSerialize["arbitraryObject"] = o.ArbitraryObject
+	if o.ArbitraryObject != nil {
+		toSerialize["arbitraryObject"] = *o.ArbitraryObject
 	}
 	if o.ArbitraryNullableObject != nil {
-		toSerialize["arbitraryNullableObject"] = o.ArbitraryNullableObject
+		toSerialize["arbitraryNullableObject"] = *o.ArbitraryNullableObject
 	}
 	if o.ArbitraryTypeValue != nil {
-		toSerialize["arbitraryTypeValue"] = o.ArbitraryTypeValue
+		toSerialize["arbitraryTypeValue"] = *o.ArbitraryTypeValue
 	}
 	if o.ArbitraryNullableTypeValue != nil {
-		toSerialize["arbitraryNullableTypeValue"] = o.ArbitraryNullableTypeValue
+		toSerialize["arbitraryNullableTypeValue"] = *o.ArbitraryNullableTypeValue
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *User) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
index 2b585199f94..fb6c363d9e7 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Whale type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Whale{}
+
 // Whale struct for Whale
 type Whale struct {
 	HasBaleen *bool `json:"hasBaleen,omitempty"`
@@ -44,7 +47,7 @@ func NewWhaleWithDefaults() *Whale {
 
 // GetHasBaleen returns the HasBaleen field value if set, zero value otherwise.
 func (o *Whale) GetHasBaleen() bool {
-	if o == nil || isNil(o.HasBaleen) {
+	if o == nil || o.HasBaleen == nil {
 		var ret bool
 		return ret
 	}
@@ -54,15 +57,15 @@ func (o *Whale) GetHasBaleen() bool {
 // GetHasBaleenOk returns a tuple with the HasBaleen field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Whale) GetHasBaleenOk() (*bool, bool) {
-	if o == nil || isNil(o.HasBaleen) {
-    return nil, false
+	if o == nil || o.HasBaleen == nil {
+		return nil, false
 	}
 	return o.HasBaleen, true
 }
 
 // HasHasBaleen returns a boolean if a field has been set.
 func (o *Whale) HasHasBaleen() bool {
-	if o != nil && !isNil(o.HasBaleen) {
+	if o != nil && o.HasBaleen != nil {
 		return true
 	}
 
@@ -76,7 +79,7 @@ func (o *Whale) SetHasBaleen(v bool) {
 
 // GetHasTeeth returns the HasTeeth field value if set, zero value otherwise.
 func (o *Whale) GetHasTeeth() bool {
-	if o == nil || isNil(o.HasTeeth) {
+	if o == nil || o.HasTeeth == nil {
 		var ret bool
 		return ret
 	}
@@ -86,15 +89,15 @@ func (o *Whale) GetHasTeeth() bool {
 // GetHasTeethOk returns a tuple with the HasTeeth field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Whale) GetHasTeethOk() (*bool, bool) {
-	if o == nil || isNil(o.HasTeeth) {
-    return nil, false
+	if o == nil || o.HasTeeth == nil {
+		return nil, false
 	}
 	return o.HasTeeth, true
 }
 
 // HasHasTeeth returns a boolean if a field has been set.
 func (o *Whale) HasHasTeeth() bool {
-	if o != nil && !isNil(o.HasTeeth) {
+	if o != nil && o.HasTeeth != nil {
 		return true
 	}
 
@@ -120,7 +123,7 @@ func (o *Whale) GetClassName() string {
 // and a boolean to check if the value has been set.
 func (o *Whale) GetClassNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.ClassName, true
 }
@@ -131,22 +134,27 @@ func (o *Whale) SetClassName(v string) {
 }
 
 func (o Whale) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Whale) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.HasBaleen) {
-		toSerialize["hasBaleen"] = o.HasBaleen
+	if o.HasBaleen != nil {
+		toSerialize["hasBaleen"] = *o.HasBaleen
 	}
-	if !isNil(o.HasTeeth) {
-		toSerialize["hasTeeth"] = o.HasTeeth
+	if o.HasTeeth != nil {
+		toSerialize["hasTeeth"] = *o.HasTeeth
 	}
 	if true {
-		toSerialize["className"] = o.ClassName
+		toSerialize["className"] = *o.ClassName
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Whale) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
index 3664895873e..058877bae4b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Zebra type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Zebra{}
+
 // Zebra struct for Zebra
 type Zebra struct {
 	Type *string `json:"type,omitempty"`
@@ -43,7 +46,7 @@ func NewZebraWithDefaults() *Zebra {
 
 // GetType returns the Type field value if set, zero value otherwise.
 func (o *Zebra) GetType() string {
-	if o == nil || isNil(o.Type) {
+	if o == nil || o.Type == nil {
 		var ret string
 		return ret
 	}
@@ -53,15 +56,15 @@ func (o *Zebra) GetType() string {
 // GetTypeOk returns a tuple with the Type field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Zebra) GetTypeOk() (*string, bool) {
-	if o == nil || isNil(o.Type) {
-    return nil, false
+	if o == nil || o.Type == nil {
+		return nil, false
 	}
 	return o.Type, true
 }
 
 // HasType returns a boolean if a field has been set.
 func (o *Zebra) HasType() bool {
-	if o != nil && !isNil(o.Type) {
+	if o != nil && o.Type != nil {
 		return true
 	}
 
@@ -87,7 +90,7 @@ func (o *Zebra) GetClassName() string {
 // and a boolean to check if the value has been set.
 func (o *Zebra) GetClassNameOk() (*string, bool) {
 	if o == nil {
-    return nil, false
+		return nil, false
 	}
 	return &o.ClassName, true
 }
@@ -98,19 +101,24 @@ func (o *Zebra) SetClassName(v string) {
 }
 
 func (o Zebra) MarshalJSON() ([]byte, error) {
+	toSerialize := o.ToMap()
+	return json.Marshal(toSerialize)
+}
+
+func (o Zebra) ToMap() map[string]interface{} {
 	toSerialize := map[string]interface{}{}
-	if !isNil(o.Type) {
-		toSerialize["type"] = o.Type
+	if o.Type != nil {
+		toSerialize["type"] = *o.Type
 	}
 	if true {
-		toSerialize["className"] = o.ClassName
+		toSerialize["className"] = *o.ClassName
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize
 }
 
 func (o *Zebra) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/utils.go b/samples/openapi3/client/petstore/go/go-petstore/utils.go
index 866bbf7f1eb..ba83c9efcf3 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/utils.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/utils.go
@@ -340,4 +340,7 @@ func isNil(i interface{}) bool {
         return reflect.ValueOf(i).IsZero()
     }
     return false
-}
\ No newline at end of file
+}
+type MappedNullable interface {
+	ToMap() map[string]interface{}
+}
-- 
GitLab


From 0b6e2034da04ca8bacbf9a8076c822536e40b0ac Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Wed, 12 Oct 2022 17:49:23 -0400
Subject: [PATCH 03/15] fix generation

---
 .../src/main/resources/go/api.mustache        |  20 ++--
 .../src/main/resources/go/client.mustache     | 101 ++++++++++++------
 .../main/resources/go/model_simple.mustache   |  31 ++++--
 .../src/main/resources/go/utils.mustache      |   2 +-
 4 files changed, 102 insertions(+), 52 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index 92a2d062efd..a4351ee200a 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -124,7 +124,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 	}
 
 	localVarPath := localBasePath + "{{{path}}}"{{#pathParams}}
-	localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", url.PathEscape(parameterToString(r.{{paramName}}, "{{collectionFormat}}")), -1){{/pathParams}}
+	localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", url.PathEscape(parameterToString(r.{{paramName}}, "{{paramName}}", "{{collectionFormat}}")), -1){{/pathParams}}
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -189,15 +189,15 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				parameterToString(localVarQueryParams, "{{baseName}}", s.Index(i), "{{collectionFormat}}")
+				parameterAddToQuery(localVarQueryParams, "{{baseName}}", s.Index(i), "{{collectionFormat}}")
 			}
 		} else {
-                        parameterToString(localVarQueryParams, "{{baseName}}", t, "{{collectionFormat}}")
+			parameterAddToQuery(localVarQueryParams, "{{baseName}}", t, "{{collectionFormat}}")
 		}
 	}
 	{{/isCollectionFormatMulti}}
 	{{^isCollectionFormatMulti}}
-	localVarQueryParams.Add("{{baseName}}", parameterToString(*r.{{paramName}}, "{{collectionFormat}}"))
+	parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	{{/isCollectionFormatMulti}}
 	{{/required}}
 	{{^required}}
@@ -210,11 +210,11 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 				parameterAddToQuery(localVarQueryParams, "{{baseName}}", s.Index(i), "{{collectionFormat}}")
 			}
 		} else {
-                        parameterAddToQuery(localVarQueryParams, "{{baseName}}", t, "{{collectionFormat}}")
+			parameterAddToQuery(localVarQueryParams, "{{baseName}}", t, "{{collectionFormat}}")
 		}
 	{{/isCollectionFormatMulti}}
 	{{^isCollectionFormatMulti}}
-                parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
+	parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	{{/isCollectionFormatMulti}}
 	}
 	{{/required}}
@@ -242,11 +242,11 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 	}
 {{#headerParams}}
 	{{#required}}
-	localVarHeaderParams["{{baseName}}"] = parameterToString(*r.{{paramName}}, "{{collectionFormat}}")
+	parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	{{/required}}
 	{{^required}}
 	if r.{{paramName}} != nil {
-		localVarHeaderParams["{{baseName}}"] = parameterToString(*r.{{paramName}}, "{{collectionFormat}}")
+		parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	}
 	{{/required}}
 {{/headerParams}}
@@ -277,7 +277,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 {{/isFile}}
 {{^isFile}}
 {{#required}}
-	localVarFormParams.Add("{{baseName}}", parameterToString(*r.{{paramName}}, "{{collectionFormat}}"))
+	parameterAddToQuery(localVarFormParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 {{/required}}
 {{^required}}
 {{#isModel}}
@@ -291,7 +291,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 {{/isModel}}
 {{^isModel}}
 	if r.{{paramName}} != nil {
-		localVarFormParams.Add("{{baseName}}", parameterToString(*r.{{paramName}}, "{{collectionFormat}}"))
+		parameterAddToQuery(localVarFormParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	}
 {{/isModel}}
 {{/required}}
diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index 9bc1089ea46..3acf6c12a0a 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -132,9 +132,28 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
+func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
+	u := url.Values{}
+	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
+	return u.Encode()
+}
+
+func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+	switch valuesMap := queryParams.(type) {
+	case url.Values:
+		fmt.Printf("value1 %v,%v\n", keyPrefix, obj)
+		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+		break
+	case map[string]string:
+		fmt.Printf("value2 %v,%v\n", keyPrefix, obj)
+		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
+		break
+	}
+}
+
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -151,62 +170,80 @@ func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
 		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
 		if len(sliceValue) > 0 {
-			var ifaceValue = make([]interface{}, 0, len(sliceValue))
 			for v := range sliceValue {
-				ifaceValue = append(ifaceValue, v)
+				parameterAddToHolder(queryParams, keyPrefix, v)
 			}
-			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
 		}
 		return
 
 	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
 		var param,ok = obj.(MappedNullable)
 		if ok {
-			dataMap := param.ToMap()
-			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			fmt.Printf(">> map: %v\n", dataMap)
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
 
 	} else if t, ok := obj.(time.Time); ok {
-		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
-	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
-	if len(param) == 0 {
+func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
+	if param == nil {
 		return
 	}
-	for key,value := range param {
-		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	var kind = reflect.TypeOf(param).Kind()
+	if kind == reflect.Slice {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
 		}
-	}
-}
+		var lenIndValue = indValue.Len()
+		fmt.Printf("slice len %d\n", lenIndValue)
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			fmt.Printf("slice %v,%v\n", i, arrayValue.Interface())
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+		}
+		return
 
-// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
-func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
-	if len(param) == 0 {
+	} else if kind == reflect.Map {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		
+		iter := indValue.MapRange()
+		for iter.Next() {
+			k,v := iter.Key(), iter.Value()
+			fmt.Printf("map %v,%v\n", k.String(), v.Interface())
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+		}
 		return
-	}
-	for index,value := range param {
-		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	} else if kind == reflect.Ptr {
+		var param,ok = param.(MappedNullable)
+		if ok {
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			fmt.Printf(">> map: %v\n", dataMap)
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+			return
 		}
 	}
+
+	// primitive value
+	parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
index bf10fd1f546..26445c9d861 100644
--- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
@@ -251,22 +251,25 @@ func (o *{{classname}}) Unset{{name}}() {
 {{/required}}
 {{/vars}}
 func (o {{classname}}) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o {{classname}}) ToMap() map[string]interface{} {
+func (o {{classname}}) ToMap() (map[string]interface{}, error) {
 	toSerialize := {{#isArray}}make([]interface{}, len(o.Items)){{/isArray}}{{^isArray}}map[string]interface{}{}{{/isArray}}
 	{{#parent}}
 	{{^isMap}}
 	{{^isArray}}
 	serialized{{parent}}, err{{parent}} := json.Marshal(o.{{parent}})
 	if err{{parent}} != nil {
-		return []byte{}, err{{parent}}
+		return map[string]interface{}{}, err{{parent}}
 	}
 	err{{parent}} = json.Unmarshal([]byte(serialized{{parent}}), &toSerialize)
 	if err{{parent}} != nil {
-		return []byte{}, err{{parent}}
+		return map[string]interface{}{}, err{{parent}}
 	}
 	{{/isArray}}
 	{{/isMap}}
@@ -286,16 +289,26 @@ func (o {{classname}}) ToMap() map[string]interface{} {
 	}
 	{{/vendorExtensions.x-golang-is-container}}
 	{{^vendorExtensions.x-golang-is-container}}
-	if {{#required}}true{{/required}}{{^required}}o.{{name}}.IsSet(){{/required}} {
-		toSerialize["{{baseName}}"] = *o.{{name}}.Get()
+	{{#required}}
+	toSerialize["{{baseName}}"] = o.{{name}}.Get()
+	{{/required}}
+	{{^required}}
+	if o.{{name}}.IsSet() {
+		toSerialize["{{baseName}}"] = o.{{name}}.Get()
 	}
+	{{/required}}
 	{{/vendorExtensions.x-golang-is-container}}
 	{{/isNullable}}
 	{{! if argument is not nullable, don't set it if it is nil}}
 	{{^isNullable}}
-	if {{#required}}true{{/required}}{{^required}}o.{{name}} != nil{{/required}} {
-		toSerialize["{{baseName}}"] = *o.{{name}}
+	{{#required}}
+	toSerialize["{{baseName}}"] = o.{{name}}
+	{{/required}}
+	{{^required}}
+	if o.{{name}} != nil {
+		toSerialize["{{baseName}}"] = o.{{name}}
 	}
+	{{/required}}
 	{{/isNullable}}
 	{{/vars}}
 	{{#isAdditionalPropertiesTrue}}
@@ -305,7 +318,7 @@ func (o {{classname}}) ToMap() map[string]interface{} {
 	}
 
 	{{/isAdditionalPropertiesTrue}}
-	return toSerialize
+	return toSerialize, nil
 }
 
 {{#isAdditionalPropertiesTrue}}
diff --git a/modules/openapi-generator/src/main/resources/go/utils.mustache b/modules/openapi-generator/src/main/resources/go/utils.mustache
index b570eccc44f..03c71a9bf79 100644
--- a/modules/openapi-generator/src/main/resources/go/utils.mustache
+++ b/modules/openapi-generator/src/main/resources/go/utils.mustache
@@ -331,5 +331,5 @@ func isNil(i interface{}) bool {
     }
     return false
 }type MappedNullable interface {
-	ToMap() map[string]interface{}
+	ToMap() (map[string]interface{}, error)
 }
-- 
GitLab


From 4422d08dbf7cc76ceaee8992da69e94f368c3591 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Wed, 12 Oct 2022 17:50:19 -0400
Subject: [PATCH 04/15] fix generation

---
 .../openapi-generator/src/main/resources/go/client.mustache | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index 3acf6c12a0a..3d78704bdbe 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -141,11 +141,9 @@ func parameterToString( obj interface{}, keyPrefix string, collectionFormat stri
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
 	switch valuesMap := queryParams.(type) {
 	case url.Values:
-		fmt.Printf("value1 %v,%v\n", keyPrefix, obj)
 		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
 		break
 	case map[string]string:
-		fmt.Printf("value2 %v,%v\n", keyPrefix, obj)
 		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
 		break
 	}
@@ -183,7 +181,6 @@ func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interfac
 			if err != nil {
 				return
 			}
-			fmt.Printf(">> map: %v\n", dataMap)
 			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
@@ -211,7 +208,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 		fmt.Printf("slice len %d\n", lenIndValue)
 		for i:=0;i<lenIndValue;i++ {
 			var arrayValue = indValue.Index(i)
-			fmt.Printf("slice %v,%v\n", i, arrayValue.Interface())
 			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
 		}
 		return
@@ -225,7 +221,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 		iter := indValue.MapRange()
 		for iter.Next() {
 			k,v := iter.Key(), iter.Value()
-			fmt.Printf("map %v,%v\n", k.String(), v.Interface())
 			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
 		}
 		return
@@ -236,7 +231,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 			if err != nil {
 				return
 			}
-			fmt.Printf(">> map: %v\n", dataMap)
 			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
-- 
GitLab


From 426b5deb67889e081d16d9d2e149acba885cb6d1 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Wed, 12 Oct 2022 17:51:41 -0400
Subject: [PATCH 05/15] generated samples

# Conflicts:
#	samples/client/petstore/go/go-petstore/model_200_response.go
#	samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
#	samples/client/petstore/go/go-petstore/model_client.go
---
 .../petstore/go/go-petstore/api_fake.go       | 72 +++++++-------
 .../client/petstore/go/go-petstore/api_pet.go | 24 ++---
 .../petstore/go/go-petstore/api_store.go      |  4 +-
 .../petstore/go/go-petstore/api_user.go       | 10 +-
 .../client/petstore/go/go-petstore/client.go  | 95 ++++++++++++-------
 .../go/go-petstore/model_200_response.go      | 13 ++-
 .../model_additional_properties_any_type.go   | 11 ++-
 .../model_additional_properties_array.go      | 11 ++-
 .../model_additional_properties_boolean.go    | 11 ++-
 .../model_additional_properties_class.go      | 31 +++---
 .../model_additional_properties_integer.go    | 11 ++-
 .../model_additional_properties_number.go     | 11 ++-
 .../model_additional_properties_object.go     | 11 ++-
 .../model_additional_properties_string.go     | 11 ++-
 .../petstore/go/go-petstore/model_animal.go   | 15 +--
 .../go/go-petstore/model_api_response.go      | 15 +--
 .../model_array_of_array_of_number_only.go    | 11 ++-
 .../go-petstore/model_array_of_number_only.go | 11 ++-
 .../go/go-petstore/model_array_test_.go       | 15 +--
 .../petstore/go/go-petstore/model_big_cat.go  | 15 +--
 .../go/go-petstore/model_big_cat_all_of.go    | 11 ++-
 .../go/go-petstore/model_capitalization.go    | 21 ++--
 .../petstore/go/go-petstore/model_cat.go      | 15 +--
 .../go/go-petstore/model_cat_all_of.go        | 11 ++-
 .../petstore/go/go-petstore/model_category.go | 15 +--
 .../go/go-petstore/model_class_model.go       | 11 ++-
 .../petstore/go/go-petstore/model_client.go   | 11 ++-
 .../petstore/go/go-petstore/model_dog.go      | 15 +--
 .../go/go-petstore/model_dog_all_of.go        | 11 ++-
 .../go/go-petstore/model_enum_arrays.go       | 13 ++-
 .../go/go-petstore/model_enum_test_.go        | 21 ++--
 .../petstore/go/go-petstore/model_file.go     | 11 ++-
 .../model_file_schema_test_class.go           | 13 ++-
 .../go/go-petstore/model_format_test_.go      | 45 ++++-----
 .../go-petstore/model_has_only_read_only.go   | 13 ++-
 .../petstore/go/go-petstore/model_list.go     | 11 ++-
 .../go/go-petstore/model_map_test_.go         | 17 ++--
 ...perties_and_additional_properties_class.go | 15 +--
 .../petstore/go/go-petstore/model_name.go     | 19 ++--
 .../go/go-petstore/model_number_only.go       | 11 ++-
 .../petstore/go/go-petstore/model_order.go    | 21 ++--
 .../go/go-petstore/model_outer_composite.go   | 15 +--
 .../petstore/go/go-petstore/model_pet.go      | 25 +++--
 .../go/go-petstore/model_read_only_first.go   | 13 ++-
 .../petstore/go/go-petstore/model_return.go   | 11 ++-
 .../go-petstore/model_special_model_name.go   | 11 ++-
 .../petstore/go/go-petstore/model_tag.go      | 13 ++-
 .../go-petstore/model_type_holder_default.go  | 29 +++---
 .../go-petstore/model_type_holder_example.go  | 33 +++----
 .../petstore/go/go-petstore/model_user.go     | 25 ++---
 .../petstore/go/go-petstore/model_xml_item.go | 67 ++++++-------
 .../client/petstore/go/go-petstore/utils.go   |  2 +-
 .../x-auth-id-alias/go-experimental/client.go | 95 ++++++++++++-------
 .../x-auth-id-alias/go-experimental/utils.go  |  2 +-
 .../petstore/go/go-petstore/api_fake.go       | 80 ++++++++--------
 .../client/petstore/go/go-petstore/api_pet.go | 24 ++---
 .../petstore/go/go-petstore/api_store.go      |  4 +-
 .../petstore/go/go-petstore/api_user.go       | 10 +-
 .../client/petstore/go/go-petstore/client.go  | 95 ++++++++++++-------
 .../go/go-petstore/model_200_response.go      | 13 ++-
 .../model__foo_get_default_response.go        | 11 ++-
 .../go-petstore/model__special_model_name_.go | 11 ++-
 .../model_additional_properties_class.go      | 13 ++-
 .../petstore/go/go-petstore/model_animal.go   | 15 +--
 .../go/go-petstore/model_api_response.go      | 15 +--
 .../petstore/go/go-petstore/model_apple.go    | 11 ++-
 .../go/go-petstore/model_apple_req.go         | 15 +--
 .../model_array_of_array_of_number_only.go    | 11 ++-
 .../go-petstore/model_array_of_number_only.go | 11 ++-
 .../go/go-petstore/model_array_test_.go       | 15 +--
 .../petstore/go/go-petstore/model_banana.go   | 11 ++-
 .../go/go-petstore/model_banana_req.go        | 15 +--
 .../go/go-petstore/model_capitalization.go    | 21 ++--
 .../petstore/go/go-petstore/model_cat.go      | 15 +--
 .../go/go-petstore/model_cat_all_of.go        | 11 ++-
 .../petstore/go/go-petstore/model_category.go | 15 +--
 .../go/go-petstore/model_class_model.go       | 11 ++-
 .../petstore/go/go-petstore/model_client.go   | 11 ++-
 .../petstore/go/go-petstore/model_dog.go      | 15 +--
 .../go/go-petstore/model_dog_all_of.go        | 11 ++-
 .../model_duplicated_prop_child.go            | 15 +--
 .../model_duplicated_prop_child_all_of.go     | 11 ++-
 .../model_duplicated_prop_parent.go           | 13 +--
 .../go/go-petstore/model_enum_arrays.go       | 13 ++-
 .../go/go-petstore/model_enum_test_.go        | 27 +++---
 .../petstore/go/go-petstore/model_file.go     | 11 ++-
 .../model_file_schema_test_class.go           | 13 ++-
 .../petstore/go/go-petstore/model_foo.go      | 11 ++-
 .../go/go-petstore/model_format_test_.go      | 47 ++++-----
 .../go-petstore/model_has_only_read_only.go   | 13 ++-
 .../go-petstore/model_health_check_result.go  | 11 ++-
 .../petstore/go/go-petstore/model_list.go     | 11 ++-
 .../go/go-petstore/model_map_of_file_test_.go | 11 ++-
 .../go/go-petstore/model_map_test_.go         | 17 ++--
 ...perties_and_additional_properties_class.go | 15 +--
 .../petstore/go/go-petstore/model_name.go     | 19 ++--
 .../go/go-petstore/model_nullable_all_of.go   | 11 ++-
 .../model_nullable_all_of_child.go            | 11 ++-
 .../go/go-petstore/model_nullable_class.go    | 25 ++---
 .../go/go-petstore/model_number_only.go       | 11 ++-
 .../model_one_of_primitive_type_child.go      | 11 ++-
 .../petstore/go/go-petstore/model_order.go    | 21 ++--
 .../go/go-petstore/model_outer_composite.go   | 15 +--
 .../petstore/go/go-petstore/model_pet.go      | 25 +++--
 .../go/go-petstore/model_read_only_first.go   | 13 ++-
 .../model_read_only_with_default.go           | 23 +++--
 .../petstore/go/go-petstore/model_return.go   | 11 ++-
 .../petstore/go/go-petstore/model_tag.go      | 13 ++-
 .../petstore/go/go-petstore/model_user.go     | 27 +++---
 .../petstore/go/go-petstore/model_whale.go    | 17 ++--
 .../petstore/go/go-petstore/model_zebra.go    | 15 +--
 .../client/petstore/go/go-petstore/utils.go   |  2 +-
 112 files changed, 1197 insertions(+), 882 deletions(-)

diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go
index b7dd6b55ddb..1396efd6451 100644
--- a/samples/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/client/petstore/go/go-petstore/api_fake.go
@@ -902,7 +902,7 @@ func (a *FakeApiService) TestBodyWithQueryParamsExecute(r ApiTestBodyWithQueryPa
 		return nil, reportError("body is required and must be specified")
 	}
 
-	localVarQueryParams.Add("query", parameterToString(*r.query, ""))
+	parameterAddToQuery(localVarQueryParams, "query", r.query, "")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/json"}
 
@@ -1247,24 +1247,24 @@ func (a *FakeApiService) TestEndpointParametersExecute(r ApiTestEndpointParamete
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.integer != nil {
-		localVarFormParams.Add("integer", parameterToString(*r.integer, ""))
+		parameterAddToQuery(localVarFormParams, "integer", r.integer, "")
 	}
 	if r.int32_ != nil {
-		localVarFormParams.Add("int32", parameterToString(*r.int32_, ""))
+		parameterAddToQuery(localVarFormParams, "int32", r.int32_, "")
 	}
 	if r.int64_ != nil {
-		localVarFormParams.Add("int64", parameterToString(*r.int64_, ""))
+		parameterAddToQuery(localVarFormParams, "int64", r.int64_, "")
 	}
-	localVarFormParams.Add("number", parameterToString(*r.number, ""))
+	parameterAddToQuery(localVarFormParams, "number", r.number, "")
 	if r.float != nil {
-		localVarFormParams.Add("float", parameterToString(*r.float, ""))
+		parameterAddToQuery(localVarFormParams, "float", r.float, "")
 	}
-	localVarFormParams.Add("double", parameterToString(*r.double, ""))
+	parameterAddToQuery(localVarFormParams, "double", r.double, "")
 	if r.string_ != nil {
-		localVarFormParams.Add("string", parameterToString(*r.string_, ""))
+		parameterAddToQuery(localVarFormParams, "string", r.string_, "")
 	}
-	localVarFormParams.Add("pattern_without_delimiter", parameterToString(*r.patternWithoutDelimiter, ""))
-	localVarFormParams.Add("byte", parameterToString(*r.byte_, ""))
+	parameterAddToQuery(localVarFormParams, "pattern_without_delimiter", r.patternWithoutDelimiter, "")
+	parameterAddToQuery(localVarFormParams, "byte", r.byte_, "")
 	var binaryLocalVarFormFileName string
 	var binaryLocalVarFileName     string
 	var binaryLocalVarFileBytes    []byte
@@ -1283,16 +1283,16 @@ func (a *FakeApiService) TestEndpointParametersExecute(r ApiTestEndpointParamete
 	}
 	formFiles = append(formFiles, formFile{fileBytes: binaryLocalVarFileBytes, fileName: binaryLocalVarFileName, formFileName: binaryLocalVarFormFileName})
 	if r.date != nil {
-		localVarFormParams.Add("date", parameterToString(*r.date, ""))
+		parameterAddToQuery(localVarFormParams, "date", r.date, "")
 	}
 	if r.dateTime != nil {
-		localVarFormParams.Add("dateTime", parameterToString(*r.dateTime, ""))
+		parameterAddToQuery(localVarFormParams, "dateTime", r.dateTime, "")
 	}
 	if r.password != nil {
-		localVarFormParams.Add("password", parameterToString(*r.password, ""))
+		parameterAddToQuery(localVarFormParams, "password", r.password, "")
 	}
 	if r.callback != nil {
-		localVarFormParams.Add("callback", parameterToString(*r.callback, ""))
+		parameterAddToQuery(localVarFormParams, "callback", r.callback, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -1422,16 +1422,16 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 	localVarFormParams := url.Values{}
 
 	if r.enumQueryStringArray != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_string_array", r.enumQueryStringArray, "csv")
+	parameterAddToQuery(localVarQueryParams, "enum_query_string_array", r.enumQueryStringArray, "csv")
 	}
 	if r.enumQueryString != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
+	parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
 	}
 	if r.enumQueryInteger != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
+	parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
 	}
 	if r.enumQueryDouble != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
+	parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/x-www-form-urlencoded"}
@@ -1451,16 +1451,16 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.enumHeaderStringArray != nil {
-		localVarHeaderParams["enum_header_string_array"] = parameterToString(*r.enumHeaderStringArray, "csv")
+		parameterAddToQuery(localVarQueryParams, "enum_header_string_array", r.enumHeaderStringArray, "csv")
 	}
 	if r.enumHeaderString != nil {
-		localVarHeaderParams["enum_header_string"] = parameterToString(*r.enumHeaderString, "")
+		parameterAddToQuery(localVarQueryParams, "enum_header_string", r.enumHeaderString, "")
 	}
 	if r.enumFormStringArray != nil {
-		localVarFormParams.Add("enum_form_string_array", parameterToString(*r.enumFormStringArray, "csv"))
+		parameterAddToQuery(localVarFormParams, "enum_form_string_array", r.enumFormStringArray, "csv")
 	}
 	if r.enumFormString != nil {
-		localVarFormParams.Add("enum_form_string", parameterToString(*r.enumFormString, ""))
+		parameterAddToQuery(localVarFormParams, "enum_form_string", r.enumFormString, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -1584,13 +1584,13 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 		return nil, reportError("requiredInt64Group is required and must be specified")
 	}
 
-	localVarQueryParams.Add("required_string_group", parameterToString(*r.requiredStringGroup, ""))
-	localVarQueryParams.Add("required_int64_group", parameterToString(*r.requiredInt64Group, ""))
+	parameterAddToQuery(localVarQueryParams, "required_string_group", r.requiredStringGroup, "")
+	parameterAddToQuery(localVarQueryParams, "required_int64_group", r.requiredInt64Group, "")
 	if r.stringGroup != nil {
-                parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
+	parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
 	}
 	if r.int64Group != nil {
-                parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
+	parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
@@ -1609,9 +1609,9 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	if localVarHTTPHeaderAccept != "" {
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
-	localVarHeaderParams["required_boolean_group"] = parameterToString(*r.requiredBooleanGroup, "")
+	parameterAddToQuery(localVarQueryParams, "required_boolean_group", r.requiredBooleanGroup, "")
 	if r.booleanGroup != nil {
-		localVarHeaderParams["boolean_group"] = parameterToString(*r.booleanGroup, "")
+		parameterAddToQuery(localVarQueryParams, "boolean_group", r.booleanGroup, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -1817,8 +1817,8 @@ func (a *FakeApiService) TestJsonFormDataExecute(r ApiTestJsonFormDataRequest) (
 	if localVarHTTPHeaderAccept != "" {
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
-	localVarFormParams.Add("param", parameterToString(*r.param, ""))
-	localVarFormParams.Add("param2", parameterToString(*r.param2, ""))
+	parameterAddToQuery(localVarFormParams, "param", r.param, "")
+	parameterAddToQuery(localVarFormParams, "param2", r.param2, "")
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
 		return nil, err
@@ -1935,19 +1935,19 @@ func (a *FakeApiService) TestQueryParameterCollectionFormatExecute(r ApiTestQuer
 		return nil, reportError("context is required and must be specified")
 	}
 
-	localVarQueryParams.Add("pipe", parameterToString(*r.pipe, "csv"))
-	localVarQueryParams.Add("ioutil", parameterToString(*r.ioutil, "csv"))
-	localVarQueryParams.Add("http", parameterToString(*r.http, "ssv"))
-	localVarQueryParams.Add("url", parameterToString(*r.url, "csv"))
+	parameterAddToQuery(localVarQueryParams, "pipe", r.pipe, "csv")
+	parameterAddToQuery(localVarQueryParams, "ioutil", r.ioutil, "csv")
+	parameterAddToQuery(localVarQueryParams, "http", r.http, "ssv")
+	parameterAddToQuery(localVarQueryParams, "url", r.url, "csv")
 	{
 		t := *r.context
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				parameterToString(localVarQueryParams, "context", s.Index(i), "multi")
+				parameterAddToQuery(localVarQueryParams, "context", s.Index(i), "multi")
 			}
 		} else {
-                        parameterToString(localVarQueryParams, "context", t, "multi")
+			parameterAddToQuery(localVarQueryParams, "context", t, "multi")
 		}
 	}
 	// to determine the Content-Type header
diff --git a/samples/client/petstore/go/go-petstore/api_pet.go b/samples/client/petstore/go/go-petstore/api_pet.go
index 014e56171f2..cfa15ca8956 100644
--- a/samples/client/petstore/go/go-petstore/api_pet.go
+++ b/samples/client/petstore/go/go-petstore/api_pet.go
@@ -288,7 +288,7 @@ func (a *PetApiService) DeletePetExecute(r ApiDeletePetRequest) (*http.Response,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -312,7 +312,7 @@ func (a *PetApiService) DeletePetExecute(r ApiDeletePetRequest) (*http.Response,
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.apiKey != nil {
-		localVarHeaderParams["api_key"] = parameterToString(*r.apiKey, "")
+		parameterAddToQuery(localVarQueryParams, "api_key", r.apiKey, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -397,7 +397,7 @@ func (a *PetApiService) FindPetsByStatusExecute(r ApiFindPetsByStatusRequest) ([
 		return localVarReturnValue, nil, reportError("status is required and must be specified")
 	}
 
-	localVarQueryParams.Add("status", parameterToString(*r.status, "csv"))
+	parameterAddToQuery(localVarQueryParams, "status", r.status, "csv")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
 
@@ -510,7 +510,7 @@ func (a *PetApiService) FindPetsByTagsExecute(r ApiFindPetsByTagsRequest) ([]Pet
 		return localVarReturnValue, nil, reportError("tags is required and must be specified")
 	}
 
-	localVarQueryParams.Add("tags", parameterToString(*r.tags, "csv"))
+	parameterAddToQuery(localVarQueryParams, "tags", r.tags, "csv")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
 
@@ -608,7 +608,7 @@ func (a *PetApiService) GetPetByIdExecute(r ApiGetPetByIdRequest) (*Pet, *http.R
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -833,7 +833,7 @@ func (a *PetApiService) UpdatePetWithFormExecute(r ApiUpdatePetWithFormRequest)
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -857,10 +857,10 @@ func (a *PetApiService) UpdatePetWithFormExecute(r ApiUpdatePetWithFormRequest)
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.name != nil {
-		localVarFormParams.Add("name", parameterToString(*r.name, ""))
+		parameterAddToQuery(localVarFormParams, "name", r.name, "")
 	}
 	if r.status != nil {
-		localVarFormParams.Add("status", parameterToString(*r.status, ""))
+		parameterAddToQuery(localVarFormParams, "status", r.status, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -945,7 +945,7 @@ func (a *PetApiService) UploadFileExecute(r ApiUploadFileRequest) (*ApiResponse,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}/uploadImage"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -969,7 +969,7 @@ func (a *PetApiService) UploadFileExecute(r ApiUploadFileRequest) (*ApiResponse,
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.additionalMetadata != nil {
-		localVarFormParams.Add("additionalMetadata", parameterToString(*r.additionalMetadata, ""))
+		parameterAddToQuery(localVarFormParams, "additionalMetadata", r.additionalMetadata, "")
 	}
 	var fileLocalVarFormFileName string
 	var fileLocalVarFileName     string
@@ -1080,7 +1080,7 @@ func (a *PetApiService) UploadFileWithRequiredFileExecute(r ApiUploadFileWithReq
 	}
 
 	localVarPath := localBasePath + "/fake/{petId}/uploadImageWithRequiredFile"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -1107,7 +1107,7 @@ func (a *PetApiService) UploadFileWithRequiredFileExecute(r ApiUploadFileWithReq
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.additionalMetadata != nil {
-		localVarFormParams.Add("additionalMetadata", parameterToString(*r.additionalMetadata, ""))
+		parameterAddToQuery(localVarFormParams, "additionalMetadata", r.additionalMetadata, "")
 	}
 	var requiredFileLocalVarFormFileName string
 	var requiredFileLocalVarFileName     string
diff --git a/samples/client/petstore/go/go-petstore/api_store.go b/samples/client/petstore/go/go-petstore/api_store.go
index 3ad1421086f..1327e2b9b62 100644
--- a/samples/client/petstore/go/go-petstore/api_store.go
+++ b/samples/client/petstore/go/go-petstore/api_store.go
@@ -122,7 +122,7 @@ func (a *StoreApiService) DeleteOrderExecute(r ApiDeleteOrderRequest) (*http.Res
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -329,7 +329,7 @@ func (a *StoreApiService) GetOrderByIdExecute(r ApiGetOrderByIdRequest) (*Order,
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/client/petstore/go/go-petstore/api_user.go b/samples/client/petstore/go/go-petstore/api_user.go
index 5709e41a182..8d80f74ceba 100644
--- a/samples/client/petstore/go/go-petstore/api_user.go
+++ b/samples/client/petstore/go/go-petstore/api_user.go
@@ -462,7 +462,7 @@ func (a *UserApiService) DeleteUserExecute(r ApiDeleteUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -554,7 +554,7 @@ func (a *UserApiService) GetUserByNameExecute(r ApiGetUserByNameRequest) (*User,
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -677,8 +677,8 @@ func (a *UserApiService) LoginUserExecute(r ApiLoginUserRequest) (string, *http.
 		return localVarReturnValue, nil, reportError("password is required and must be specified")
 	}
 
-	localVarQueryParams.Add("username", parameterToString(*r.username, ""))
-	localVarQueryParams.Add("password", parameterToString(*r.password, ""))
+	parameterAddToQuery(localVarQueryParams, "username", r.username, "")
+	parameterAddToQuery(localVarQueryParams, "password", r.password, "")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
 
@@ -867,7 +867,7 @@ func (a *UserApiService) UpdateUserExecute(r ApiUpdateUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go
index 61121d7ba86..c87e8addecd 100644
--- a/samples/client/petstore/go/go-petstore/client.go
+++ b/samples/client/petstore/go/go-petstore/client.go
@@ -140,9 +140,26 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
+func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
+	u := url.Values{}
+	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
+	return u.Encode()
+}
+
+func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+	switch valuesMap := queryParams.(type) {
+	case url.Values:
+		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+		break
+	case map[string]string:
+		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
+		break
+	}
+}
+
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -159,62 +176,76 @@ func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
 		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
 		if len(sliceValue) > 0 {
-			var ifaceValue = make([]interface{}, 0, len(sliceValue))
 			for v := range sliceValue {
-				ifaceValue = append(ifaceValue, v)
+				parameterAddToHolder(queryParams, keyPrefix, v)
 			}
-			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
 		}
 		return
 
 	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
 		var param,ok = obj.(MappedNullable)
 		if ok {
-			dataMap := param.ToMap()
-			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
 
 	} else if t, ok := obj.(time.Time); ok {
-		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
-	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
-	if len(param) == 0 {
+func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
+	if param == nil {
 		return
 	}
-	for key,value := range param {
-		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	var kind = reflect.TypeOf(param).Kind()
+	if kind == reflect.Slice {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
 		}
-	}
-}
+		var lenIndValue = indValue.Len()
+		fmt.Printf("slice len %d\n", lenIndValue)
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+		}
+		return
 
-// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
-func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
-	if len(param) == 0 {
+	} else if kind == reflect.Map {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		
+		iter := indValue.MapRange()
+		for iter.Next() {
+			k,v := iter.Key(), iter.Value()
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+		}
 		return
-	}
-	for index,value := range param {
-		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	} else if kind == reflect.Ptr {
+		var param,ok = param.(MappedNullable)
+		if ok {
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+			return
 		}
 	}
+
+	// primitive value
+	parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/samples/client/petstore/go/go-petstore/model_200_response.go b/samples/client/petstore/go/go-petstore/model_200_response.go
index 11e8dc46eb4..d3eb4d88309 100644
--- a/samples/client/petstore/go/go-petstore/model_200_response.go
+++ b/samples/client/petstore/go/go-petstore/model_200_response.go
@@ -105,19 +105,22 @@ func (o *Model200Response) SetClass(v string) {
 }
 
 func (o Model200Response) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Model200Response) ToMap() map[string]interface{} {
+func (o Model200Response) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Name) {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
 	if !isNil(o.Class) {
-		toSerialize["class"] = *o.Class
+		toSerialize["class"] = o.Class
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableModel200Response struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
index fb464b6c172..b58d15224e6 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesAnyType) SetName(v string) {
 }
 
 func (o AdditionalPropertiesAnyType) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesAnyType) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesAnyType) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Name) {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesAnyType struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
index a1e5f97858a..e7f69e1c32c 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesArray) SetName(v string) {
 }
 
 func (o AdditionalPropertiesArray) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesArray) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesArray) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesArray struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
index af99e19671b..57a68467dc4 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesBoolean) SetName(v string) {
 }
 
 func (o AdditionalPropertiesBoolean) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesBoolean) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesBoolean) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesBoolean struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
index 54fa3c635ea..f79b6557872 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
@@ -402,46 +402,49 @@ func (o *AdditionalPropertiesClass) SetAnytype3(v map[string]interface{}) {
 }
 
 func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesClass) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.MapString != nil {
-		toSerialize["map_string"] = *o.MapString
+		toSerialize["map_string"] = o.MapString
 	}
 	if o.MapNumber != nil {
-		toSerialize["map_number"] = *o.MapNumber
+		toSerialize["map_number"] = o.MapNumber
 	}
 	if o.MapInteger != nil {
-		toSerialize["map_integer"] = *o.MapInteger
+		toSerialize["map_integer"] = o.MapInteger
 	}
 	if o.MapBoolean != nil {
-		toSerialize["map_boolean"] = *o.MapBoolean
+		toSerialize["map_boolean"] = o.MapBoolean
 	}
 	if o.MapArrayInteger != nil {
-		toSerialize["map_array_integer"] = *o.MapArrayInteger
+		toSerialize["map_array_integer"] = o.MapArrayInteger
 	}
 	if o.MapArrayAnytype != nil {
-		toSerialize["map_array_anytype"] = *o.MapArrayAnytype
+		toSerialize["map_array_anytype"] = o.MapArrayAnytype
 	}
 	if o.MapMapString != nil {
-		toSerialize["map_map_string"] = *o.MapMapString
+		toSerialize["map_map_string"] = o.MapMapString
 	}
 	if o.MapMapAnytype != nil {
-		toSerialize["map_map_anytype"] = *o.MapMapAnytype
+		toSerialize["map_map_anytype"] = o.MapMapAnytype
 	}
 	if o.Anytype1 != nil {
-		toSerialize["anytype_1"] = *o.Anytype1
+		toSerialize["anytype_1"] = o.Anytype1
 	}
 	if o.Anytype2 != nil {
-		toSerialize["anytype_2"] = *o.Anytype2
+		toSerialize["anytype_2"] = o.Anytype2
 	}
 	if o.Anytype3 != nil {
-		toSerialize["anytype_3"] = *o.Anytype3
+		toSerialize["anytype_3"] = o.Anytype3
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesClass struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
index ddf23105e93..d38de6d73e2 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesInteger) SetName(v string) {
 }
 
 func (o AdditionalPropertiesInteger) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesInteger) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesInteger) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesInteger struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
index 667b492c5ec..61eda1f13c6 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesNumber) SetName(v string) {
 }
 
 func (o AdditionalPropertiesNumber) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesNumber) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesNumber) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesNumber struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
index 8b305e63c82..bfec70f0189 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesObject) SetName(v string) {
 }
 
 func (o AdditionalPropertiesObject) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesObject) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesObject) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesObject struct {
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
index 4e010565792..3cc21daad82 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
@@ -72,16 +72,19 @@ func (o *AdditionalPropertiesString) SetName(v string) {
 }
 
 func (o AdditionalPropertiesString) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesString) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesString) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAdditionalPropertiesString struct {
diff --git a/samples/client/petstore/go/go-petstore/model_animal.go b/samples/client/petstore/go/go-petstore/model_animal.go
index 38736d0c620..5384f87f660 100644
--- a/samples/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/client/petstore/go/go-petstore/model_animal.go
@@ -102,19 +102,20 @@ func (o *Animal) SetColor(v string) {
 }
 
 func (o Animal) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Animal) ToMap() map[string]interface{} {
+func (o Animal) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["className"] = *o.ClassName
-	}
+	toSerialize["className"] = o.ClassName
 	if o.Color != nil {
-		toSerialize["color"] = *o.Color
+		toSerialize["color"] = o.Color
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableAnimal struct {
diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go
index ac2bef0ac2b..9092b2133e6 100644
--- a/samples/client/petstore/go/go-petstore/model_api_response.go
+++ b/samples/client/petstore/go/go-petstore/model_api_response.go
@@ -138,22 +138,25 @@ func (o *ApiResponse) SetMessage(v string) {
 }
 
 func (o ApiResponse) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ApiResponse) ToMap() map[string]interface{} {
+func (o ApiResponse) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Code != nil {
-		toSerialize["code"] = *o.Code
+		toSerialize["code"] = o.Code
 	}
 	if o.Type != nil {
-		toSerialize["type"] = *o.Type
+		toSerialize["type"] = o.Type
 	}
 	if o.Message != nil {
-		toSerialize["message"] = *o.Message
+		toSerialize["message"] = o.Message
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableApiResponse struct {
diff --git a/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
index 7f241e946e3..64b203ae7fe 100644
--- a/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
@@ -72,16 +72,19 @@ func (o *ArrayOfArrayOfNumberOnly) SetArrayArrayNumber(v [][]float32) {
 }
 
 func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ArrayOfArrayOfNumberOnly) ToMap() map[string]interface{} {
+func (o ArrayOfArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.ArrayArrayNumber != nil {
-		toSerialize["ArrayArrayNumber"] = *o.ArrayArrayNumber
+		toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableArrayOfArrayOfNumberOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
index 8ef33ca44d4..f3c236df0fe 100644
--- a/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
@@ -72,16 +72,19 @@ func (o *ArrayOfNumberOnly) SetArrayNumber(v []float32) {
 }
 
 func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ArrayOfNumberOnly) ToMap() map[string]interface{} {
+func (o ArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.ArrayNumber != nil {
-		toSerialize["ArrayNumber"] = *o.ArrayNumber
+		toSerialize["ArrayNumber"] = o.ArrayNumber
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableArrayOfNumberOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_array_test_.go b/samples/client/petstore/go/go-petstore/model_array_test_.go
index dac8e9eeaaa..0fd1d8ee54f 100644
--- a/samples/client/petstore/go/go-petstore/model_array_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_array_test_.go
@@ -138,22 +138,25 @@ func (o *ArrayTest) SetArrayArrayOfModel(v [][]ReadOnlyFirst) {
 }
 
 func (o ArrayTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ArrayTest) ToMap() map[string]interface{} {
+func (o ArrayTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.ArrayOfString != nil {
-		toSerialize["array_of_string"] = *o.ArrayOfString
+		toSerialize["array_of_string"] = o.ArrayOfString
 	}
 	if o.ArrayArrayOfInteger != nil {
-		toSerialize["array_array_of_integer"] = *o.ArrayArrayOfInteger
+		toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger
 	}
 	if o.ArrayArrayOfModel != nil {
-		toSerialize["array_array_of_model"] = *o.ArrayArrayOfModel
+		toSerialize["array_array_of_model"] = o.ArrayArrayOfModel
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableArrayTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_big_cat.go b/samples/client/petstore/go/go-petstore/model_big_cat.go
index 04df2c94a0c..dcd3379aecf 100644
--- a/samples/client/petstore/go/go-petstore/model_big_cat.go
+++ b/samples/client/petstore/go/go-petstore/model_big_cat.go
@@ -76,24 +76,27 @@ func (o *BigCat) SetKind(v string) {
 }
 
 func (o BigCat) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o BigCat) ToMap() map[string]interface{} {
+func (o BigCat) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	serializedCat, errCat := json.Marshal(o.Cat)
 	if errCat != nil {
-		return []byte{}, errCat
+		return map[string]interface{}{}, errCat
 	}
 	errCat = json.Unmarshal([]byte(serializedCat), &toSerialize)
 	if errCat != nil {
-		return []byte{}, errCat
+		return map[string]interface{}{}, errCat
 	}
 	if o.Kind != nil {
-		toSerialize["kind"] = *o.Kind
+		toSerialize["kind"] = o.Kind
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableBigCat struct {
diff --git a/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go b/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
index bff2ad62e00..c664e704810 100644
--- a/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
@@ -72,16 +72,19 @@ func (o *BigCatAllOf) SetKind(v string) {
 }
 
 func (o BigCatAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o BigCatAllOf) ToMap() map[string]interface{} {
+func (o BigCatAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Kind != nil {
-		toSerialize["kind"] = *o.Kind
+		toSerialize["kind"] = o.Kind
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableBigCatAllOf struct {
diff --git a/samples/client/petstore/go/go-petstore/model_capitalization.go b/samples/client/petstore/go/go-petstore/model_capitalization.go
index 89019319977..ffb168d1ad3 100644
--- a/samples/client/petstore/go/go-petstore/model_capitalization.go
+++ b/samples/client/petstore/go/go-petstore/model_capitalization.go
@@ -238,31 +238,34 @@ func (o *Capitalization) SetATT_NAME(v string) {
 }
 
 func (o Capitalization) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Capitalization) ToMap() map[string]interface{} {
+func (o Capitalization) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.SmallCamel != nil {
-		toSerialize["smallCamel"] = *o.SmallCamel
+		toSerialize["smallCamel"] = o.SmallCamel
 	}
 	if o.CapitalCamel != nil {
-		toSerialize["CapitalCamel"] = *o.CapitalCamel
+		toSerialize["CapitalCamel"] = o.CapitalCamel
 	}
 	if o.SmallSnake != nil {
-		toSerialize["small_Snake"] = *o.SmallSnake
+		toSerialize["small_Snake"] = o.SmallSnake
 	}
 	if o.CapitalSnake != nil {
-		toSerialize["Capital_Snake"] = *o.CapitalSnake
+		toSerialize["Capital_Snake"] = o.CapitalSnake
 	}
 	if o.SCAETHFlowPoints != nil {
-		toSerialize["SCA_ETH_Flow_Points"] = *o.SCAETHFlowPoints
+		toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints
 	}
 	if o.ATT_NAME != nil {
-		toSerialize["ATT_NAME"] = *o.ATT_NAME
+		toSerialize["ATT_NAME"] = o.ATT_NAME
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableCapitalization struct {
diff --git a/samples/client/petstore/go/go-petstore/model_cat.go b/samples/client/petstore/go/go-petstore/model_cat.go
index 1c9a9ad3fef..5996bb71f13 100644
--- a/samples/client/petstore/go/go-petstore/model_cat.go
+++ b/samples/client/petstore/go/go-petstore/model_cat.go
@@ -76,24 +76,27 @@ func (o *Cat) SetDeclawed(v bool) {
 }
 
 func (o Cat) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Cat) ToMap() map[string]interface{} {
+func (o Cat) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	errAnimal = json.Unmarshal([]byte(serializedAnimal), &toSerialize)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	if o.Declawed != nil {
-		toSerialize["declawed"] = *o.Declawed
+		toSerialize["declawed"] = o.Declawed
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableCat struct {
diff --git a/samples/client/petstore/go/go-petstore/model_cat_all_of.go b/samples/client/petstore/go/go-petstore/model_cat_all_of.go
index a0135f62932..e63fb6ad252 100644
--- a/samples/client/petstore/go/go-petstore/model_cat_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_cat_all_of.go
@@ -72,16 +72,19 @@ func (o *CatAllOf) SetDeclawed(v bool) {
 }
 
 func (o CatAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o CatAllOf) ToMap() map[string]interface{} {
+func (o CatAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Declawed != nil {
-		toSerialize["declawed"] = *o.Declawed
+		toSerialize["declawed"] = o.Declawed
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableCatAllOf struct {
diff --git a/samples/client/petstore/go/go-petstore/model_category.go b/samples/client/petstore/go/go-petstore/model_category.go
index 65bf1213e51..909ad5376fa 100644
--- a/samples/client/petstore/go/go-petstore/model_category.go
+++ b/samples/client/petstore/go/go-petstore/model_category.go
@@ -100,19 +100,20 @@ func (o *Category) SetName(v string) {
 }
 
 func (o Category) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Category) ToMap() map[string]interface{} {
+func (o Category) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
-	}
-	if true {
-		toSerialize["name"] = *o.Name
+		toSerialize["id"] = o.Id
 	}
-	return toSerialize
+	toSerialize["name"] = o.Name
+	return toSerialize, nil
 }
 
 type NullableCategory struct {
diff --git a/samples/client/petstore/go/go-petstore/model_class_model.go b/samples/client/petstore/go/go-petstore/model_class_model.go
index 0c2743ef8a0..e08ae79ce24 100644
--- a/samples/client/petstore/go/go-petstore/model_class_model.go
+++ b/samples/client/petstore/go/go-petstore/model_class_model.go
@@ -72,16 +72,19 @@ func (o *ClassModel) SetClass(v string) {
 }
 
 func (o ClassModel) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ClassModel) ToMap() map[string]interface{} {
+func (o ClassModel) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Class != nil {
-		toSerialize["_class"] = *o.Class
+		toSerialize["_class"] = o.Class
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableClassModel struct {
diff --git a/samples/client/petstore/go/go-petstore/model_client.go b/samples/client/petstore/go/go-petstore/model_client.go
index f0dc6b41738..ff27c1adf99 100644
--- a/samples/client/petstore/go/go-petstore/model_client.go
+++ b/samples/client/petstore/go/go-petstore/model_client.go
@@ -72,16 +72,19 @@ func (o *Client) SetClient(v string) {
 }
 
 func (o Client) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Client) ToMap() map[string]interface{} {
+func (o Client) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Client) {
-		toSerialize["client"] = *o.Client
+		toSerialize["client"] = o.Client
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableClient struct {
diff --git a/samples/client/petstore/go/go-petstore/model_dog.go b/samples/client/petstore/go/go-petstore/model_dog.go
index 1180fb9efde..2d1b3d29ef6 100644
--- a/samples/client/petstore/go/go-petstore/model_dog.go
+++ b/samples/client/petstore/go/go-petstore/model_dog.go
@@ -76,24 +76,27 @@ func (o *Dog) SetBreed(v string) {
 }
 
 func (o Dog) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Dog) ToMap() map[string]interface{} {
+func (o Dog) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	errAnimal = json.Unmarshal([]byte(serializedAnimal), &toSerialize)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	if o.Breed != nil {
-		toSerialize["breed"] = *o.Breed
+		toSerialize["breed"] = o.Breed
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableDog struct {
diff --git a/samples/client/petstore/go/go-petstore/model_dog_all_of.go b/samples/client/petstore/go/go-petstore/model_dog_all_of.go
index c31616fc129..e06b6eb50ed 100644
--- a/samples/client/petstore/go/go-petstore/model_dog_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_dog_all_of.go
@@ -72,16 +72,19 @@ func (o *DogAllOf) SetBreed(v string) {
 }
 
 func (o DogAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o DogAllOf) ToMap() map[string]interface{} {
+func (o DogAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Breed != nil {
-		toSerialize["breed"] = *o.Breed
+		toSerialize["breed"] = o.Breed
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableDogAllOf struct {
diff --git a/samples/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/client/petstore/go/go-petstore/model_enum_arrays.go
index c2727b8daf7..03b697271c7 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_arrays.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_arrays.go
@@ -105,19 +105,22 @@ func (o *EnumArrays) SetArrayEnum(v []string) {
 }
 
 func (o EnumArrays) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o EnumArrays) ToMap() map[string]interface{} {
+func (o EnumArrays) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.JustSymbol != nil {
-		toSerialize["just_symbol"] = *o.JustSymbol
+		toSerialize["just_symbol"] = o.JustSymbol
 	}
 	if o.ArrayEnum != nil {
-		toSerialize["array_enum"] = *o.ArrayEnum
+		toSerialize["array_enum"] = o.ArrayEnum
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableEnumArrays struct {
diff --git a/samples/client/petstore/go/go-petstore/model_enum_test_.go b/samples/client/petstore/go/go-petstore/model_enum_test_.go
index f07dd6ca950..3e796876962 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_test_.go
@@ -197,28 +197,29 @@ func (o *EnumTest) SetOuterEnum(v OuterEnum) {
 }
 
 func (o EnumTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o EnumTest) ToMap() map[string]interface{} {
+func (o EnumTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.EnumString != nil {
-		toSerialize["enum_string"] = *o.EnumString
-	}
-	if true {
-		toSerialize["enum_string_required"] = *o.EnumStringRequired
+		toSerialize["enum_string"] = o.EnumString
 	}
+	toSerialize["enum_string_required"] = o.EnumStringRequired
 	if o.EnumInteger != nil {
-		toSerialize["enum_integer"] = *o.EnumInteger
+		toSerialize["enum_integer"] = o.EnumInteger
 	}
 	if o.EnumNumber != nil {
-		toSerialize["enum_number"] = *o.EnumNumber
+		toSerialize["enum_number"] = o.EnumNumber
 	}
 	if o.OuterEnum != nil {
-		toSerialize["outerEnum"] = *o.OuterEnum
+		toSerialize["outerEnum"] = o.OuterEnum
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableEnumTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_file.go b/samples/client/petstore/go/go-petstore/model_file.go
index ee59c77788a..850d23cf9c8 100644
--- a/samples/client/petstore/go/go-petstore/model_file.go
+++ b/samples/client/petstore/go/go-petstore/model_file.go
@@ -73,16 +73,19 @@ func (o *File) SetSourceURI(v string) {
 }
 
 func (o File) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o File) ToMap() map[string]interface{} {
+func (o File) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.SourceURI != nil {
-		toSerialize["sourceURI"] = *o.SourceURI
+		toSerialize["sourceURI"] = o.SourceURI
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableFile struct {
diff --git a/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
index c047aac8348..99068968709 100644
--- a/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
+++ b/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
@@ -105,19 +105,22 @@ func (o *FileSchemaTestClass) SetFiles(v []File) {
 }
 
 func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o FileSchemaTestClass) ToMap() map[string]interface{} {
+func (o FileSchemaTestClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.File != nil {
-		toSerialize["file"] = *o.File
+		toSerialize["file"] = o.File
 	}
 	if o.Files != nil {
-		toSerialize["files"] = *o.Files
+		toSerialize["files"] = o.Files
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableFileSchemaTestClass struct {
diff --git a/samples/client/petstore/go/go-petstore/model_format_test_.go b/samples/client/petstore/go/go-petstore/model_format_test_.go
index 77a69bc0b10..58f8403eb90 100644
--- a/samples/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_format_test_.go
@@ -475,55 +475,50 @@ func (o *FormatTest) SetBigDecimal(v float64) {
 }
 
 func (o FormatTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o FormatTest) ToMap() map[string]interface{} {
+func (o FormatTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Integer != nil {
-		toSerialize["integer"] = *o.Integer
+		toSerialize["integer"] = o.Integer
 	}
 	if o.Int32 != nil {
-		toSerialize["int32"] = *o.Int32
+		toSerialize["int32"] = o.Int32
 	}
 	if o.Int64 != nil {
-		toSerialize["int64"] = *o.Int64
-	}
-	if true {
-		toSerialize["number"] = *o.Number
+		toSerialize["int64"] = o.Int64
 	}
+	toSerialize["number"] = o.Number
 	if o.Float != nil {
-		toSerialize["float"] = *o.Float
+		toSerialize["float"] = o.Float
 	}
 	if o.Double != nil {
-		toSerialize["double"] = *o.Double
+		toSerialize["double"] = o.Double
 	}
 	if o.String != nil {
-		toSerialize["string"] = *o.String
-	}
-	if true {
-		toSerialize["byte"] = *o.Byte
+		toSerialize["string"] = o.String
 	}
+	toSerialize["byte"] = o.Byte
 	if o.Binary != nil {
-		toSerialize["binary"] = *o.Binary
-	}
-	if true {
-		toSerialize["date"] = *o.Date
+		toSerialize["binary"] = o.Binary
 	}
+	toSerialize["date"] = o.Date
 	if o.DateTime != nil {
-		toSerialize["dateTime"] = *o.DateTime
+		toSerialize["dateTime"] = o.DateTime
 	}
 	if o.Uuid != nil {
-		toSerialize["uuid"] = *o.Uuid
-	}
-	if true {
-		toSerialize["password"] = *o.Password
+		toSerialize["uuid"] = o.Uuid
 	}
+	toSerialize["password"] = o.Password
 	if o.BigDecimal != nil {
-		toSerialize["BigDecimal"] = *o.BigDecimal
+		toSerialize["BigDecimal"] = o.BigDecimal
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableFormatTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
index b051916c891..e526efa5da6 100644
--- a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
+++ b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
@@ -105,19 +105,22 @@ func (o *HasOnlyReadOnly) SetFoo(v string) {
 }
 
 func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o HasOnlyReadOnly) ToMap() map[string]interface{} {
+func (o HasOnlyReadOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Bar != nil {
-		toSerialize["bar"] = *o.Bar
+		toSerialize["bar"] = o.Bar
 	}
 	if o.Foo != nil {
-		toSerialize["foo"] = *o.Foo
+		toSerialize["foo"] = o.Foo
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableHasOnlyReadOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_list.go b/samples/client/petstore/go/go-petstore/model_list.go
index db9fbabf794..bd79b185316 100644
--- a/samples/client/petstore/go/go-petstore/model_list.go
+++ b/samples/client/petstore/go/go-petstore/model_list.go
@@ -72,16 +72,19 @@ func (o *List) SetVar123List(v string) {
 }
 
 func (o List) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o List) ToMap() map[string]interface{} {
+func (o List) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Var123List != nil {
-		toSerialize["123-list"] = *o.Var123List
+		toSerialize["123-list"] = o.Var123List
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableList struct {
diff --git a/samples/client/petstore/go/go-petstore/model_map_test_.go b/samples/client/petstore/go/go-petstore/model_map_test_.go
index cb4b8f86278..888a864c1c6 100644
--- a/samples/client/petstore/go/go-petstore/model_map_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_map_test_.go
@@ -171,25 +171,28 @@ func (o *MapTest) SetIndirectMap(v map[string]bool) {
 }
 
 func (o MapTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o MapTest) ToMap() map[string]interface{} {
+func (o MapTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.MapMapOfString != nil {
-		toSerialize["map_map_of_string"] = *o.MapMapOfString
+		toSerialize["map_map_of_string"] = o.MapMapOfString
 	}
 	if o.MapOfEnumString != nil {
-		toSerialize["map_of_enum_string"] = *o.MapOfEnumString
+		toSerialize["map_of_enum_string"] = o.MapOfEnumString
 	}
 	if o.DirectMap != nil {
-		toSerialize["direct_map"] = *o.DirectMap
+		toSerialize["direct_map"] = o.DirectMap
 	}
 	if o.IndirectMap != nil {
-		toSerialize["indirect_map"] = *o.IndirectMap
+		toSerialize["indirect_map"] = o.IndirectMap
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableMapTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
index 426b09d2c55..4e42d2223a4 100644
--- a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
+++ b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
@@ -139,22 +139,25 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetMap(v map[string]Animal
 }
 
 func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() map[string]interface{} {
+func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Uuid != nil {
-		toSerialize["uuid"] = *o.Uuid
+		toSerialize["uuid"] = o.Uuid
 	}
 	if o.DateTime != nil {
-		toSerialize["dateTime"] = *o.DateTime
+		toSerialize["dateTime"] = o.DateTime
 	}
 	if o.Map != nil {
-		toSerialize["map"] = *o.Map
+		toSerialize["map"] = o.Map
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableMixedPropertiesAndAdditionalPropertiesClass struct {
diff --git a/samples/client/petstore/go/go-petstore/model_name.go b/samples/client/petstore/go/go-petstore/model_name.go
index 7c5140c31b1..f3943d49dd7 100644
--- a/samples/client/petstore/go/go-petstore/model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_name.go
@@ -164,25 +164,26 @@ func (o *Name) SetVar123Number(v int32) {
 }
 
 func (o Name) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Name) ToMap() map[string]interface{} {
+func (o Name) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["name"] = *o.Name
-	}
+	toSerialize["name"] = o.Name
 	if o.SnakeCase != nil {
-		toSerialize["snake_case"] = *o.SnakeCase
+		toSerialize["snake_case"] = o.SnakeCase
 	}
 	if o.Property != nil {
-		toSerialize["property"] = *o.Property
+		toSerialize["property"] = o.Property
 	}
 	if o.Var123Number != nil {
-		toSerialize["123Number"] = *o.Var123Number
+		toSerialize["123Number"] = o.Var123Number
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableName struct {
diff --git a/samples/client/petstore/go/go-petstore/model_number_only.go b/samples/client/petstore/go/go-petstore/model_number_only.go
index a9e6c5622d6..fd2e0c83e4d 100644
--- a/samples/client/petstore/go/go-petstore/model_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_number_only.go
@@ -72,16 +72,19 @@ func (o *NumberOnly) SetJustNumber(v float32) {
 }
 
 func (o NumberOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o NumberOnly) ToMap() map[string]interface{} {
+func (o NumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.JustNumber != nil {
-		toSerialize["JustNumber"] = *o.JustNumber
+		toSerialize["JustNumber"] = o.JustNumber
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableNumberOnly struct {
diff --git a/samples/client/petstore/go/go-petstore/model_order.go b/samples/client/petstore/go/go-petstore/model_order.go
index 3b8b21eec5b..783da73c9bd 100644
--- a/samples/client/petstore/go/go-petstore/model_order.go
+++ b/samples/client/petstore/go/go-petstore/model_order.go
@@ -243,31 +243,34 @@ func (o *Order) SetComplete(v bool) {
 }
 
 func (o Order) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Order) ToMap() map[string]interface{} {
+func (o Order) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.PetId != nil {
-		toSerialize["petId"] = *o.PetId
+		toSerialize["petId"] = o.PetId
 	}
 	if o.Quantity != nil {
-		toSerialize["quantity"] = *o.Quantity
+		toSerialize["quantity"] = o.Quantity
 	}
 	if o.ShipDate != nil {
-		toSerialize["shipDate"] = *o.ShipDate
+		toSerialize["shipDate"] = o.ShipDate
 	}
 	if o.Status != nil {
-		toSerialize["status"] = *o.Status
+		toSerialize["status"] = o.Status
 	}
 	if o.Complete != nil {
-		toSerialize["complete"] = *o.Complete
+		toSerialize["complete"] = o.Complete
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableOrder struct {
diff --git a/samples/client/petstore/go/go-petstore/model_outer_composite.go b/samples/client/petstore/go/go-petstore/model_outer_composite.go
index 94127a2815d..13682bc04a3 100644
--- a/samples/client/petstore/go/go-petstore/model_outer_composite.go
+++ b/samples/client/petstore/go/go-petstore/model_outer_composite.go
@@ -138,22 +138,25 @@ func (o *OuterComposite) SetMyBoolean(v bool) {
 }
 
 func (o OuterComposite) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o OuterComposite) ToMap() map[string]interface{} {
+func (o OuterComposite) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.MyNumber != nil {
-		toSerialize["my_number"] = *o.MyNumber
+		toSerialize["my_number"] = o.MyNumber
 	}
 	if o.MyString != nil {
-		toSerialize["my_string"] = *o.MyString
+		toSerialize["my_string"] = o.MyString
 	}
 	if o.MyBoolean != nil {
-		toSerialize["my_boolean"] = *o.MyBoolean
+		toSerialize["my_boolean"] = o.MyBoolean
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableOuterComposite struct {
diff --git a/samples/client/petstore/go/go-petstore/model_pet.go b/samples/client/petstore/go/go-petstore/model_pet.go
index c5617bd9405..9580aef4ffc 100644
--- a/samples/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/client/petstore/go/go-petstore/model_pet.go
@@ -224,31 +224,30 @@ func (o *Pet) SetStatus(v string) {
 }
 
 func (o Pet) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Pet) ToMap() map[string]interface{} {
+func (o Pet) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.Category != nil {
-		toSerialize["category"] = *o.Category
-	}
-	if true {
-		toSerialize["name"] = *o.Name
-	}
-	if true {
-		toSerialize["photoUrls"] = *o.PhotoUrls
+		toSerialize["category"] = o.Category
 	}
+	toSerialize["name"] = o.Name
+	toSerialize["photoUrls"] = o.PhotoUrls
 	if o.Tags != nil {
-		toSerialize["tags"] = *o.Tags
+		toSerialize["tags"] = o.Tags
 	}
 	if o.Status != nil {
-		toSerialize["status"] = *o.Status
+		toSerialize["status"] = o.Status
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullablePet struct {
diff --git a/samples/client/petstore/go/go-petstore/model_read_only_first.go b/samples/client/petstore/go/go-petstore/model_read_only_first.go
index 028d81d0115..7ca2bf61470 100644
--- a/samples/client/petstore/go/go-petstore/model_read_only_first.go
+++ b/samples/client/petstore/go/go-petstore/model_read_only_first.go
@@ -105,19 +105,22 @@ func (o *ReadOnlyFirst) SetBaz(v string) {
 }
 
 func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ReadOnlyFirst) ToMap() map[string]interface{} {
+func (o ReadOnlyFirst) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Bar != nil {
-		toSerialize["bar"] = *o.Bar
+		toSerialize["bar"] = o.Bar
 	}
 	if o.Baz != nil {
-		toSerialize["baz"] = *o.Baz
+		toSerialize["baz"] = o.Baz
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableReadOnlyFirst struct {
diff --git a/samples/client/petstore/go/go-petstore/model_return.go b/samples/client/petstore/go/go-petstore/model_return.go
index 0f1b3691bf7..2060072ff72 100644
--- a/samples/client/petstore/go/go-petstore/model_return.go
+++ b/samples/client/petstore/go/go-petstore/model_return.go
@@ -72,16 +72,19 @@ func (o *Return) SetReturn(v int32) {
 }
 
 func (o Return) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Return) ToMap() map[string]interface{} {
+func (o Return) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Return != nil {
-		toSerialize["return"] = *o.Return
+		toSerialize["return"] = o.Return
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableReturn struct {
diff --git a/samples/client/petstore/go/go-petstore/model_special_model_name.go b/samples/client/petstore/go/go-petstore/model_special_model_name.go
index 2c921b69838..730a8966914 100644
--- a/samples/client/petstore/go/go-petstore/model_special_model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_special_model_name.go
@@ -72,16 +72,19 @@ func (o *SpecialModelName) SetSpecialPropertyName(v int64) {
 }
 
 func (o SpecialModelName) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o SpecialModelName) ToMap() map[string]interface{} {
+func (o SpecialModelName) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.SpecialPropertyName != nil {
-		toSerialize["$special[property.name]"] = *o.SpecialPropertyName
+		toSerialize["$special[property.name]"] = o.SpecialPropertyName
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableSpecialModelName struct {
diff --git a/samples/client/petstore/go/go-petstore/model_tag.go b/samples/client/petstore/go/go-petstore/model_tag.go
index 7b2a52904be..a8cc2da8820 100644
--- a/samples/client/petstore/go/go-petstore/model_tag.go
+++ b/samples/client/petstore/go/go-petstore/model_tag.go
@@ -105,19 +105,22 @@ func (o *Tag) SetName(v string) {
 }
 
 func (o Tag) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Tag) ToMap() map[string]interface{} {
+func (o Tag) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableTag struct {
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_default.go b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
index 998451518a1..3214aac6a22 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_default.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
@@ -173,28 +173,21 @@ func (o *TypeHolderDefault) SetArrayItem(v []int32) {
 }
 
 func (o TypeHolderDefault) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o TypeHolderDefault) ToMap() map[string]interface{} {
+func (o TypeHolderDefault) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["string_item"] = *o.StringItem
-	}
-	if true {
-		toSerialize["number_item"] = *o.NumberItem
-	}
-	if true {
-		toSerialize["integer_item"] = *o.IntegerItem
-	}
-	if true {
-		toSerialize["bool_item"] = *o.BoolItem
-	}
-	if true {
-		toSerialize["array_item"] = *o.ArrayItem
-	}
-	return toSerialize
+	toSerialize["string_item"] = o.StringItem
+	toSerialize["number_item"] = o.NumberItem
+	toSerialize["integer_item"] = o.IntegerItem
+	toSerialize["bool_item"] = o.BoolItem
+	toSerialize["array_item"] = o.ArrayItem
+	return toSerialize, nil
 }
 
 type NullableTypeHolderDefault struct {
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_example.go b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
index d531f5f50f0..e2b89b6bc72 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_example.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
@@ -195,31 +195,22 @@ func (o *TypeHolderExample) SetArrayItem(v []int32) {
 }
 
 func (o TypeHolderExample) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o TypeHolderExample) ToMap() map[string]interface{} {
+func (o TypeHolderExample) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["string_item"] = *o.StringItem
-	}
-	if true {
-		toSerialize["number_item"] = *o.NumberItem
-	}
-	if true {
-		toSerialize["float_item"] = *o.FloatItem
-	}
-	if true {
-		toSerialize["integer_item"] = *o.IntegerItem
-	}
-	if true {
-		toSerialize["bool_item"] = *o.BoolItem
-	}
-	if true {
-		toSerialize["array_item"] = *o.ArrayItem
-	}
-	return toSerialize
+	toSerialize["string_item"] = o.StringItem
+	toSerialize["number_item"] = o.NumberItem
+	toSerialize["float_item"] = o.FloatItem
+	toSerialize["integer_item"] = o.IntegerItem
+	toSerialize["bool_item"] = o.BoolItem
+	toSerialize["array_item"] = o.ArrayItem
+	return toSerialize, nil
 }
 
 type NullableTypeHolderExample struct {
diff --git a/samples/client/petstore/go/go-petstore/model_user.go b/samples/client/petstore/go/go-petstore/model_user.go
index 3b48b7e9ada..10c8f3b337d 100644
--- a/samples/client/petstore/go/go-petstore/model_user.go
+++ b/samples/client/petstore/go/go-petstore/model_user.go
@@ -304,37 +304,40 @@ func (o *User) SetUserStatus(v int32) {
 }
 
 func (o User) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o User) ToMap() map[string]interface{} {
+func (o User) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.Username != nil {
-		toSerialize["username"] = *o.Username
+		toSerialize["username"] = o.Username
 	}
 	if o.FirstName != nil {
-		toSerialize["firstName"] = *o.FirstName
+		toSerialize["firstName"] = o.FirstName
 	}
 	if o.LastName != nil {
-		toSerialize["lastName"] = *o.LastName
+		toSerialize["lastName"] = o.LastName
 	}
 	if o.Email != nil {
-		toSerialize["email"] = *o.Email
+		toSerialize["email"] = o.Email
 	}
 	if o.Password != nil {
-		toSerialize["password"] = *o.Password
+		toSerialize["password"] = o.Password
 	}
 	if o.Phone != nil {
-		toSerialize["phone"] = *o.Phone
+		toSerialize["phone"] = o.Phone
 	}
 	if o.UserStatus != nil {
-		toSerialize["userStatus"] = *o.UserStatus
+		toSerialize["userStatus"] = o.UserStatus
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableUser struct {
diff --git a/samples/client/petstore/go/go-petstore/model_xml_item.go b/samples/client/petstore/go/go-petstore/model_xml_item.go
index 5378ce76a6e..ef5a06d7db1 100644
--- a/samples/client/petstore/go/go-petstore/model_xml_item.go
+++ b/samples/client/petstore/go/go-petstore/model_xml_item.go
@@ -996,100 +996,103 @@ func (o *XmlItem) SetPrefixNsWrappedArray(v []int32) {
 }
 
 func (o XmlItem) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o XmlItem) ToMap() map[string]interface{} {
+func (o XmlItem) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.AttributeString != nil {
-		toSerialize["attribute_string"] = *o.AttributeString
+		toSerialize["attribute_string"] = o.AttributeString
 	}
 	if o.AttributeNumber != nil {
-		toSerialize["attribute_number"] = *o.AttributeNumber
+		toSerialize["attribute_number"] = o.AttributeNumber
 	}
 	if o.AttributeInteger != nil {
-		toSerialize["attribute_integer"] = *o.AttributeInteger
+		toSerialize["attribute_integer"] = o.AttributeInteger
 	}
 	if o.AttributeBoolean != nil {
-		toSerialize["attribute_boolean"] = *o.AttributeBoolean
+		toSerialize["attribute_boolean"] = o.AttributeBoolean
 	}
 	if o.WrappedArray != nil {
-		toSerialize["wrapped_array"] = *o.WrappedArray
+		toSerialize["wrapped_array"] = o.WrappedArray
 	}
 	if o.NameString != nil {
-		toSerialize["name_string"] = *o.NameString
+		toSerialize["name_string"] = o.NameString
 	}
 	if o.NameNumber != nil {
-		toSerialize["name_number"] = *o.NameNumber
+		toSerialize["name_number"] = o.NameNumber
 	}
 	if o.NameInteger != nil {
-		toSerialize["name_integer"] = *o.NameInteger
+		toSerialize["name_integer"] = o.NameInteger
 	}
 	if o.NameBoolean != nil {
-		toSerialize["name_boolean"] = *o.NameBoolean
+		toSerialize["name_boolean"] = o.NameBoolean
 	}
 	if o.NameArray != nil {
-		toSerialize["name_array"] = *o.NameArray
+		toSerialize["name_array"] = o.NameArray
 	}
 	if o.NameWrappedArray != nil {
-		toSerialize["name_wrapped_array"] = *o.NameWrappedArray
+		toSerialize["name_wrapped_array"] = o.NameWrappedArray
 	}
 	if o.PrefixString != nil {
-		toSerialize["prefix_string"] = *o.PrefixString
+		toSerialize["prefix_string"] = o.PrefixString
 	}
 	if o.PrefixNumber != nil {
-		toSerialize["prefix_number"] = *o.PrefixNumber
+		toSerialize["prefix_number"] = o.PrefixNumber
 	}
 	if o.PrefixInteger != nil {
-		toSerialize["prefix_integer"] = *o.PrefixInteger
+		toSerialize["prefix_integer"] = o.PrefixInteger
 	}
 	if o.PrefixBoolean != nil {
-		toSerialize["prefix_boolean"] = *o.PrefixBoolean
+		toSerialize["prefix_boolean"] = o.PrefixBoolean
 	}
 	if o.PrefixArray != nil {
-		toSerialize["prefix_array"] = *o.PrefixArray
+		toSerialize["prefix_array"] = o.PrefixArray
 	}
 	if o.PrefixWrappedArray != nil {
-		toSerialize["prefix_wrapped_array"] = *o.PrefixWrappedArray
+		toSerialize["prefix_wrapped_array"] = o.PrefixWrappedArray
 	}
 	if o.NamespaceString != nil {
-		toSerialize["namespace_string"] = *o.NamespaceString
+		toSerialize["namespace_string"] = o.NamespaceString
 	}
 	if o.NamespaceNumber != nil {
-		toSerialize["namespace_number"] = *o.NamespaceNumber
+		toSerialize["namespace_number"] = o.NamespaceNumber
 	}
 	if o.NamespaceInteger != nil {
-		toSerialize["namespace_integer"] = *o.NamespaceInteger
+		toSerialize["namespace_integer"] = o.NamespaceInteger
 	}
 	if o.NamespaceBoolean != nil {
-		toSerialize["namespace_boolean"] = *o.NamespaceBoolean
+		toSerialize["namespace_boolean"] = o.NamespaceBoolean
 	}
 	if o.NamespaceArray != nil {
-		toSerialize["namespace_array"] = *o.NamespaceArray
+		toSerialize["namespace_array"] = o.NamespaceArray
 	}
 	if o.NamespaceWrappedArray != nil {
-		toSerialize["namespace_wrapped_array"] = *o.NamespaceWrappedArray
+		toSerialize["namespace_wrapped_array"] = o.NamespaceWrappedArray
 	}
 	if o.PrefixNsString != nil {
-		toSerialize["prefix_ns_string"] = *o.PrefixNsString
+		toSerialize["prefix_ns_string"] = o.PrefixNsString
 	}
 	if o.PrefixNsNumber != nil {
-		toSerialize["prefix_ns_number"] = *o.PrefixNsNumber
+		toSerialize["prefix_ns_number"] = o.PrefixNsNumber
 	}
 	if o.PrefixNsInteger != nil {
-		toSerialize["prefix_ns_integer"] = *o.PrefixNsInteger
+		toSerialize["prefix_ns_integer"] = o.PrefixNsInteger
 	}
 	if o.PrefixNsBoolean != nil {
-		toSerialize["prefix_ns_boolean"] = *o.PrefixNsBoolean
+		toSerialize["prefix_ns_boolean"] = o.PrefixNsBoolean
 	}
 	if o.PrefixNsArray != nil {
-		toSerialize["prefix_ns_array"] = *o.PrefixNsArray
+		toSerialize["prefix_ns_array"] = o.PrefixNsArray
 	}
 	if o.PrefixNsWrappedArray != nil {
-		toSerialize["prefix_ns_wrapped_array"] = *o.PrefixNsWrappedArray
+		toSerialize["prefix_ns_wrapped_array"] = o.PrefixNsWrappedArray
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableXmlItem struct {
diff --git a/samples/client/petstore/go/go-petstore/utils.go b/samples/client/petstore/go/go-petstore/utils.go
index ba83c9efcf3..436c8135423 100644
--- a/samples/client/petstore/go/go-petstore/utils.go
+++ b/samples/client/petstore/go/go-petstore/utils.go
@@ -342,5 +342,5 @@ func isNil(i interface{}) bool {
     return false
 }
 type MappedNullable interface {
-	ToMap() map[string]interface{}
+	ToMap() (map[string]interface{}, error)
 }
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
index ff967dc2057..14100fd60bc 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
@@ -125,9 +125,26 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
+func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
+	u := url.Values{}
+	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
+	return u.Encode()
+}
+
+func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+	switch valuesMap := queryParams.(type) {
+	case url.Values:
+		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+		break
+	case map[string]string:
+		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
+		break
+	}
+}
+
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -144,62 +161,76 @@ func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
 		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
 		if len(sliceValue) > 0 {
-			var ifaceValue = make([]interface{}, 0, len(sliceValue))
 			for v := range sliceValue {
-				ifaceValue = append(ifaceValue, v)
+				parameterAddToHolder(queryParams, keyPrefix, v)
 			}
-			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
 		}
 		return
 
 	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
 		var param,ok = obj.(MappedNullable)
 		if ok {
-			dataMap := param.ToMap()
-			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
 
 	} else if t, ok := obj.(time.Time); ok {
-		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
-	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
-	if len(param) == 0 {
+func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
+	if param == nil {
 		return
 	}
-	for key,value := range param {
-		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	var kind = reflect.TypeOf(param).Kind()
+	if kind == reflect.Slice {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
 		}
-	}
-}
+		var lenIndValue = indValue.Len()
+		fmt.Printf("slice len %d\n", lenIndValue)
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+		}
+		return
 
-// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
-func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
-	if len(param) == 0 {
+	} else if kind == reflect.Map {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		
+		iter := indValue.MapRange()
+		for iter.Next() {
+			k,v := iter.Key(), iter.Value()
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+		}
 		return
-	}
-	for index,value := range param {
-		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	} else if kind == reflect.Ptr {
+		var param,ok = param.(MappedNullable)
+		if ok {
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+			return
 		}
 	}
+
+	// primitive value
+	parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
index c0c6b2cb309..91e1cea41d3 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
@@ -342,5 +342,5 @@ func isNil(i interface{}) bool {
     return false
 }
 type MappedNullable interface {
-	ToMap() map[string]interface{}
+	ToMap() (map[string]interface{}, error)
 }
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
index 68343374529..8828752193a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
@@ -917,7 +917,7 @@ func (a *FakeApiService) TestBodyWithQueryParamsExecute(r ApiTestBodyWithQueryPa
 		return nil, reportError("user is required and must be specified")
 	}
 
-	localVarQueryParams.Add("query", parameterToString(*r.query, ""))
+	parameterAddToQuery(localVarQueryParams, "query", r.query, "")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/json"}
 
@@ -1263,24 +1263,24 @@ func (a *FakeApiService) TestEndpointParametersExecute(r ApiTestEndpointParamete
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.integer != nil {
-		localVarFormParams.Add("integer", parameterToString(*r.integer, ""))
+		parameterAddToQuery(localVarFormParams, "integer", r.integer, "")
 	}
 	if r.int32_ != nil {
-		localVarFormParams.Add("int32", parameterToString(*r.int32_, ""))
+		parameterAddToQuery(localVarFormParams, "int32", r.int32_, "")
 	}
 	if r.int64_ != nil {
-		localVarFormParams.Add("int64", parameterToString(*r.int64_, ""))
+		parameterAddToQuery(localVarFormParams, "int64", r.int64_, "")
 	}
-	localVarFormParams.Add("number", parameterToString(*r.number, ""))
+	parameterAddToQuery(localVarFormParams, "number", r.number, "")
 	if r.float != nil {
-		localVarFormParams.Add("float", parameterToString(*r.float, ""))
+		parameterAddToQuery(localVarFormParams, "float", r.float, "")
 	}
-	localVarFormParams.Add("double", parameterToString(*r.double, ""))
+	parameterAddToQuery(localVarFormParams, "double", r.double, "")
 	if r.string_ != nil {
-		localVarFormParams.Add("string", parameterToString(*r.string_, ""))
+		parameterAddToQuery(localVarFormParams, "string", r.string_, "")
 	}
-	localVarFormParams.Add("pattern_without_delimiter", parameterToString(*r.patternWithoutDelimiter, ""))
-	localVarFormParams.Add("byte", parameterToString(*r.byte_, ""))
+	parameterAddToQuery(localVarFormParams, "pattern_without_delimiter", r.patternWithoutDelimiter, "")
+	parameterAddToQuery(localVarFormParams, "byte", r.byte_, "")
 	var binaryLocalVarFormFileName string
 	var binaryLocalVarFileName     string
 	var binaryLocalVarFileBytes    []byte
@@ -1299,16 +1299,16 @@ func (a *FakeApiService) TestEndpointParametersExecute(r ApiTestEndpointParamete
 	}
 	formFiles = append(formFiles, formFile{fileBytes: binaryLocalVarFileBytes, fileName: binaryLocalVarFileName, formFileName: binaryLocalVarFormFileName})
 	if r.date != nil {
-		localVarFormParams.Add("date", parameterToString(*r.date, ""))
+		parameterAddToQuery(localVarFormParams, "date", r.date, "")
 	}
 	if r.dateTime != nil {
-		localVarFormParams.Add("dateTime", parameterToString(*r.dateTime, ""))
+		parameterAddToQuery(localVarFormParams, "dateTime", r.dateTime, "")
 	}
 	if r.password != nil {
-		localVarFormParams.Add("password", parameterToString(*r.password, ""))
+		parameterAddToQuery(localVarFormParams, "password", r.password, "")
 	}
 	if r.callback != nil {
-		localVarFormParams.Add("callback", parameterToString(*r.callback, ""))
+		parameterAddToQuery(localVarFormParams, "callback", r.callback, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -1445,17 +1445,17 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 				parameterAddToQuery(localVarQueryParams, "enum_query_string_array", s.Index(i), "multi")
 			}
 		} else {
-                        parameterAddToQuery(localVarQueryParams, "enum_query_string_array", t, "multi")
+			parameterAddToQuery(localVarQueryParams, "enum_query_string_array", t, "multi")
 		}
 	}
 	if r.enumQueryString != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
+	parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
 	}
 	if r.enumQueryInteger != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
+	parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
 	}
 	if r.enumQueryDouble != nil {
-                parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
+	parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/x-www-form-urlencoded"}
@@ -1475,16 +1475,16 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.enumHeaderStringArray != nil {
-		localVarHeaderParams["enum_header_string_array"] = parameterToString(*r.enumHeaderStringArray, "csv")
+		parameterAddToQuery(localVarQueryParams, "enum_header_string_array", r.enumHeaderStringArray, "csv")
 	}
 	if r.enumHeaderString != nil {
-		localVarHeaderParams["enum_header_string"] = parameterToString(*r.enumHeaderString, "")
+		parameterAddToQuery(localVarQueryParams, "enum_header_string", r.enumHeaderString, "")
 	}
 	if r.enumFormStringArray != nil {
-		localVarFormParams.Add("enum_form_string_array", parameterToString(*r.enumFormStringArray, "csv"))
+		parameterAddToQuery(localVarFormParams, "enum_form_string_array", r.enumFormStringArray, "csv")
 	}
 	if r.enumFormString != nil {
-		localVarFormParams.Add("enum_form_string", parameterToString(*r.enumFormString, ""))
+		parameterAddToQuery(localVarFormParams, "enum_form_string", r.enumFormString, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -1608,13 +1608,13 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 		return nil, reportError("requiredInt64Group is required and must be specified")
 	}
 
-	localVarQueryParams.Add("required_string_group", parameterToString(*r.requiredStringGroup, ""))
-	localVarQueryParams.Add("required_int64_group", parameterToString(*r.requiredInt64Group, ""))
+	parameterAddToQuery(localVarQueryParams, "required_string_group", r.requiredStringGroup, "")
+	parameterAddToQuery(localVarQueryParams, "required_int64_group", r.requiredInt64Group, "")
 	if r.stringGroup != nil {
-                parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
+	parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
 	}
 	if r.int64Group != nil {
-                parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
+	parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
@@ -1633,9 +1633,9 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	if localVarHTTPHeaderAccept != "" {
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
-	localVarHeaderParams["required_boolean_group"] = parameterToString(*r.requiredBooleanGroup, "")
+	parameterAddToQuery(localVarQueryParams, "required_boolean_group", r.requiredBooleanGroup, "")
 	if r.booleanGroup != nil {
-		localVarHeaderParams["boolean_group"] = parameterToString(*r.booleanGroup, "")
+		parameterAddToQuery(localVarQueryParams, "boolean_group", r.booleanGroup, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -1855,8 +1855,8 @@ func (a *FakeApiService) TestJsonFormDataExecute(r ApiTestJsonFormDataRequest) (
 	if localVarHTTPHeaderAccept != "" {
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
-	localVarFormParams.Add("param", parameterToString(*r.param, ""))
-	localVarFormParams.Add("param2", parameterToString(*r.param2, ""))
+	parameterAddToQuery(localVarFormParams, "param", r.param, "")
+	parameterAddToQuery(localVarFormParams, "param2", r.param2, "")
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
 		return nil, err
@@ -1978,24 +1978,24 @@ func (a *FakeApiService) TestQueryParameterCollectionFormatExecute(r ApiTestQuer
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				parameterToString(localVarQueryParams, "pipe", s.Index(i), "multi")
+				parameterAddToQuery(localVarQueryParams, "pipe", s.Index(i), "multi")
 			}
 		} else {
-                        parameterToString(localVarQueryParams, "pipe", t, "multi")
+			parameterAddToQuery(localVarQueryParams, "pipe", t, "multi")
 		}
 	}
-	localVarQueryParams.Add("ioutil", parameterToString(*r.ioutil, "csv"))
-	localVarQueryParams.Add("http", parameterToString(*r.http, "ssv"))
-	localVarQueryParams.Add("url", parameterToString(*r.url, "csv"))
+	parameterAddToQuery(localVarQueryParams, "ioutil", r.ioutil, "csv")
+	parameterAddToQuery(localVarQueryParams, "http", r.http, "ssv")
+	parameterAddToQuery(localVarQueryParams, "url", r.url, "csv")
 	{
 		t := *r.context
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				parameterToString(localVarQueryParams, "context", s.Index(i), "multi")
+				parameterAddToQuery(localVarQueryParams, "context", s.Index(i), "multi")
 			}
 		} else {
-                        parameterToString(localVarQueryParams, "context", t, "multi")
+			parameterAddToQuery(localVarQueryParams, "context", t, "multi")
 		}
 	}
 	// to determine the Content-Type header
@@ -2111,10 +2111,10 @@ func (a *FakeApiService) TestUniqueItemsHeaderAndQueryParameterCollectionFormatE
 		if reflect.TypeOf(t).Kind() == reflect.Slice {
 			s := reflect.ValueOf(t)
 			for i := 0; i < s.Len(); i++ {
-				parameterToString(localVarQueryParams, "queryUnique", s.Index(i), "multi")
+				parameterAddToQuery(localVarQueryParams, "queryUnique", s.Index(i), "multi")
 			}
 		} else {
-                        parameterToString(localVarQueryParams, "queryUnique", t, "multi")
+			parameterAddToQuery(localVarQueryParams, "queryUnique", t, "multi")
 		}
 	}
 	// to determine the Content-Type header
@@ -2134,7 +2134,7 @@ func (a *FakeApiService) TestUniqueItemsHeaderAndQueryParameterCollectionFormatE
 	if localVarHTTPHeaderAccept != "" {
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
-	localVarHeaderParams["headerUnique"] = parameterToString(*r.headerUnique, "csv")
+	parameterAddToQuery(localVarQueryParams, "headerUnique", r.headerUnique, "csv")
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
 		return localVarReturnValue, nil, err
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_pet.go b/samples/openapi3/client/petstore/go/go-petstore/api_pet.go
index 1d50da9d7b1..ff042a87bae 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_pet.go
@@ -304,7 +304,7 @@ func (a *PetApiService) DeletePetExecute(r ApiDeletePetRequest) (*http.Response,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -328,7 +328,7 @@ func (a *PetApiService) DeletePetExecute(r ApiDeletePetRequest) (*http.Response,
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.apiKey != nil {
-		localVarHeaderParams["api_key"] = parameterToString(*r.apiKey, "")
+		parameterAddToQuery(localVarQueryParams, "api_key", r.apiKey, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -414,7 +414,7 @@ func (a *PetApiService) FindPetsByStatusExecute(r ApiFindPetsByStatusRequest) ([
 		return localVarReturnValue, nil, reportError("status is required and must be specified")
 	}
 
-	localVarQueryParams.Add("status", parameterToString(*r.status, "csv"))
+	parameterAddToQuery(localVarQueryParams, "status", r.status, "csv")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
 
@@ -527,7 +527,7 @@ func (a *PetApiService) FindPetsByTagsExecute(r ApiFindPetsByTagsRequest) ([]Pet
 		return localVarReturnValue, nil, reportError("tags is required and must be specified")
 	}
 
-	localVarQueryParams.Add("tags", parameterToString(*r.tags, "csv"))
+	parameterAddToQuery(localVarQueryParams, "tags", r.tags, "csv")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
 
@@ -625,7 +625,7 @@ func (a *PetApiService) GetPetByIdExecute(r ApiGetPetByIdRequest) (*Pet, *http.R
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -854,7 +854,7 @@ func (a *PetApiService) UpdatePetWithFormExecute(r ApiUpdatePetWithFormRequest)
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -878,10 +878,10 @@ func (a *PetApiService) UpdatePetWithFormExecute(r ApiUpdatePetWithFormRequest)
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.name != nil {
-		localVarFormParams.Add("name", parameterToString(*r.name, ""))
+		parameterAddToQuery(localVarFormParams, "name", r.name, "")
 	}
 	if r.status != nil {
-		localVarFormParams.Add("status", parameterToString(*r.status, ""))
+		parameterAddToQuery(localVarFormParams, "status", r.status, "")
 	}
 	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
 	if err != nil {
@@ -968,7 +968,7 @@ func (a *PetApiService) UploadFileExecute(r ApiUploadFileRequest) (*ApiResponse,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}/uploadImage"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -992,7 +992,7 @@ func (a *PetApiService) UploadFileExecute(r ApiUploadFileRequest) (*ApiResponse,
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.additionalMetadata != nil {
-		localVarFormParams.Add("additionalMetadata", parameterToString(*r.additionalMetadata, ""))
+		parameterAddToQuery(localVarFormParams, "additionalMetadata", r.additionalMetadata, "")
 	}
 	var fileLocalVarFormFileName string
 	var fileLocalVarFileName     string
@@ -1105,7 +1105,7 @@ func (a *PetApiService) UploadFileWithRequiredFileExecute(r ApiUploadFileWithReq
 	}
 
 	localVarPath := localBasePath + "/fake/{petId}/uploadImageWithRequiredFile"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -1132,7 +1132,7 @@ func (a *PetApiService) UploadFileWithRequiredFileExecute(r ApiUploadFileWithReq
 		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
 	}
 	if r.additionalMetadata != nil {
-		localVarFormParams.Add("additionalMetadata", parameterToString(*r.additionalMetadata, ""))
+		parameterAddToQuery(localVarFormParams, "additionalMetadata", r.additionalMetadata, "")
 	}
 	var requiredFileLocalVarFormFileName string
 	var requiredFileLocalVarFileName     string
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_store.go b/samples/openapi3/client/petstore/go/go-petstore/api_store.go
index a3316523866..7564793f196 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_store.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_store.go
@@ -124,7 +124,7 @@ func (a *StoreApiService) DeleteOrderExecute(r ApiDeleteOrderRequest) (*http.Res
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -331,7 +331,7 @@ func (a *StoreApiService) GetOrderByIdExecute(r ApiGetOrderByIdRequest) (*Order,
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_user.go b/samples/openapi3/client/petstore/go/go-petstore/api_user.go
index 0ac28a9deef..de0d2a3cd7e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_user.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_user.go
@@ -476,7 +476,7 @@ func (a *UserApiService) DeleteUserExecute(r ApiDeleteUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -570,7 +570,7 @@ func (a *UserApiService) GetUserByNameExecute(r ApiGetUserByNameRequest) (*User,
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -695,8 +695,8 @@ func (a *UserApiService) LoginUserExecute(r ApiLoginUserRequest) (string, *http.
 		return localVarReturnValue, nil, reportError("password is required and must be specified")
 	}
 
-	localVarQueryParams.Add("username", parameterToString(*r.username, ""))
-	localVarQueryParams.Add("password", parameterToString(*r.password, ""))
+	parameterAddToQuery(localVarQueryParams, "username", r.username, "")
+	parameterAddToQuery(localVarQueryParams, "password", r.password, "")
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
 
@@ -887,7 +887,7 @@ func (a *UserApiService) UpdateUserExecute(r ApiUpdateUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/client.go b/samples/openapi3/client/petstore/go/go-petstore/client.go
index eaab27a18e1..e19486ec7ee 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/client.go
@@ -143,9 +143,26 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
+func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
+	u := url.Values{}
+	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
+	return u.Encode()
+}
+
+func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+	switch valuesMap := queryParams.(type) {
+	case url.Values:
+		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+		break
+	case map[string]string:
+		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
+		break
+	}
+}
+
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface{}, collectionFormat string) {
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
 	var delimiter string
 
 	switch collectionFormat {
@@ -162,62 +179,76 @@ func parameterAddToQuery(queryParams url.Values, keyPrefix string, obj interface
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
 		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
 		if len(sliceValue) > 0 {
-			var ifaceValue = make([]interface{}, 0, len(sliceValue))
 			for v := range sliceValue {
-				ifaceValue = append(ifaceValue, v)
+				parameterAddToHolder(queryParams, keyPrefix, v)
 			}
-			parameterAddSliceToQuery( queryParams, keyPrefix, ifaceValue )
 		}
 		return
 
 	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
 		var param,ok = obj.(MappedNullable)
 		if ok {
-			dataMap := param.ToMap()
-			parameterAddMapToQuery( queryParams, keyPrefix, dataMap )
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
 
 	} else if t, ok := obj.(time.Time); ok {
-		queryParams.Add( keyPrefix, t.Format(time.RFC3339) )
+		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
-	queryParams.Add( keyPrefix, fmt.Sprintf("%v", obj) )
+	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddMapToQuery(queryParams url.Values, keyPrefix string, param map[string]interface{}) {
-	if len(param) == 0 {
+func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
+	if param == nil {
 		return
 	}
-	for key,value := range param {
-		formattedKey := fmt.Sprintf("%s[%s]", keyPrefix, key)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	var kind = reflect.TypeOf(param).Kind()
+	if kind == reflect.Slice {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
 		}
-	}
-}
+		var lenIndValue = indValue.Len()
+		fmt.Printf("slice len %d\n", lenIndValue)
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+		}
+		return
 
-// parameterAddMapToQuery adds the provided slice to the url parameters list supporting deep object specification
-func parameterAddSliceToQuery(queryParams url.Values, keyPrefix string, param []interface{}) {
-	if len(param) == 0 {
+	} else if kind == reflect.Map {
+		var indValue = reflect.ValueOf(param)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		
+		iter := indValue.MapRange()
+		for iter.Next() {
+			k,v := iter.Key(), iter.Value()
+			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+		}
 		return
-	}
-	for index,value := range param {
-		formattedKey := fmt.Sprintf("%s[%d]", keyPrefix, index)
-		if reflect.TypeOf(value).Kind() == reflect.Slice {
-			parameterAddSliceToQuery( queryParams, formattedKey, value.([]interface{}) )
-		} else if reflect.TypeOf(value).Kind() == reflect.Map {
-			parameterAddMapToQuery( queryParams, formattedKey, value.(map[string]interface{}) )
-		} else {
-			queryParams.Add( formattedKey, fmt.Sprintf("%v", value) )
+	} else if kind == reflect.Ptr {
+		var param,ok = param.(MappedNullable)
+		if ok {
+			dataMap,err := param.ToMap()
+			if err != nil {
+				return
+			}
+			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+			return
 		}
 	}
+
+	// primitive value
+	parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
index dcc0c38ddf1..245b2448f4d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
@@ -108,24 +108,27 @@ func (o *Model200Response) SetClass(v string) {
 }
 
 func (o Model200Response) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Model200Response) ToMap() map[string]interface{} {
+func (o Model200Response) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
 	if o.Class != nil {
-		toSerialize["class"] = *o.Class
+		toSerialize["class"] = o.Class
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Model200Response) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
index 16bb6d2f7a6..21b0f6d7e12 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
@@ -75,21 +75,24 @@ func (o *FooGetDefaultResponse) SetString(v Foo) {
 }
 
 func (o FooGetDefaultResponse) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o FooGetDefaultResponse) ToMap() map[string]interface{} {
+func (o FooGetDefaultResponse) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.String != nil {
-		toSerialize["string"] = *o.String
+		toSerialize["string"] = o.String
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *FooGetDefaultResponse) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
index 6fd4106a838..1665c3afc94 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
@@ -75,21 +75,24 @@ func (o *SpecialModelName) SetSpecialPropertyName(v int64) {
 }
 
 func (o SpecialModelName) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o SpecialModelName) ToMap() map[string]interface{} {
+func (o SpecialModelName) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.SpecialPropertyName != nil {
-		toSerialize["$special[property.name]"] = *o.SpecialPropertyName
+		toSerialize["$special[property.name]"] = o.SpecialPropertyName
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *SpecialModelName) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
index 279f2cfeaac..030b1782899 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
@@ -108,24 +108,27 @@ func (o *AdditionalPropertiesClass) SetMapOfMapProperty(v map[string]map[string]
 }
 
 func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AdditionalPropertiesClass) ToMap() map[string]interface{} {
+func (o AdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.MapProperty != nil {
-		toSerialize["map_property"] = *o.MapProperty
+		toSerialize["map_property"] = o.MapProperty
 	}
 	if o.MapOfMapProperty != nil {
-		toSerialize["map_of_map_property"] = *o.MapOfMapProperty
+		toSerialize["map_of_map_property"] = o.MapOfMapProperty
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *AdditionalPropertiesClass) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
index 2d4dfcf0c39..903fc7b4d8b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
@@ -105,24 +105,25 @@ func (o *Animal) SetColor(v string) {
 }
 
 func (o Animal) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Animal) ToMap() map[string]interface{} {
+func (o Animal) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["className"] = *o.ClassName
-	}
+	toSerialize["className"] = o.ClassName
 	if o.Color != nil {
-		toSerialize["color"] = *o.Color
+		toSerialize["color"] = o.Color
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Animal) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
index 53e28c4db6e..2b949c7f49e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
@@ -141,27 +141,30 @@ func (o *ApiResponse) SetMessage(v string) {
 }
 
 func (o ApiResponse) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ApiResponse) ToMap() map[string]interface{} {
+func (o ApiResponse) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Code != nil {
-		toSerialize["code"] = *o.Code
+		toSerialize["code"] = o.Code
 	}
 	if o.Type != nil {
-		toSerialize["type"] = *o.Type
+		toSerialize["type"] = o.Type
 	}
 	if o.Message != nil {
-		toSerialize["message"] = *o.Message
+		toSerialize["message"] = o.Message
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ApiResponse) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
index a7d90769792..6de9d38fa06 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
@@ -75,21 +75,24 @@ func (o *Apple) SetCultivar(v string) {
 }
 
 func (o Apple) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Apple) ToMap() map[string]interface{} {
+func (o Apple) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Cultivar != nil {
-		toSerialize["cultivar"] = *o.Cultivar
+		toSerialize["cultivar"] = o.Cultivar
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Apple) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
index 738553d3d22..89cf4fb692d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
@@ -101,24 +101,25 @@ func (o *AppleReq) SetMealy(v bool) {
 }
 
 func (o AppleReq) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o AppleReq) ToMap() map[string]interface{} {
+func (o AppleReq) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["cultivar"] = *o.Cultivar
-	}
+	toSerialize["cultivar"] = o.Cultivar
 	if o.Mealy != nil {
-		toSerialize["mealy"] = *o.Mealy
+		toSerialize["mealy"] = o.Mealy
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *AppleReq) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
index 7748a7e9872..8718af2127e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
@@ -75,21 +75,24 @@ func (o *ArrayOfArrayOfNumberOnly) SetArrayArrayNumber(v [][]float32) {
 }
 
 func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ArrayOfArrayOfNumberOnly) ToMap() map[string]interface{} {
+func (o ArrayOfArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.ArrayArrayNumber != nil {
-		toSerialize["ArrayArrayNumber"] = *o.ArrayArrayNumber
+		toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ArrayOfArrayOfNumberOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
index 5ef3eddb80e..24c89bcd36c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
@@ -75,21 +75,24 @@ func (o *ArrayOfNumberOnly) SetArrayNumber(v []float32) {
 }
 
 func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ArrayOfNumberOnly) ToMap() map[string]interface{} {
+func (o ArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.ArrayNumber != nil {
-		toSerialize["ArrayNumber"] = *o.ArrayNumber
+		toSerialize["ArrayNumber"] = o.ArrayNumber
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ArrayOfNumberOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
index 5a5aa0e0450..d4926dd8e0a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
@@ -141,27 +141,30 @@ func (o *ArrayTest) SetArrayArrayOfModel(v [][]ReadOnlyFirst) {
 }
 
 func (o ArrayTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ArrayTest) ToMap() map[string]interface{} {
+func (o ArrayTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.ArrayOfString != nil {
-		toSerialize["array_of_string"] = *o.ArrayOfString
+		toSerialize["array_of_string"] = o.ArrayOfString
 	}
 	if o.ArrayArrayOfInteger != nil {
-		toSerialize["array_array_of_integer"] = *o.ArrayArrayOfInteger
+		toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger
 	}
 	if o.ArrayArrayOfModel != nil {
-		toSerialize["array_array_of_model"] = *o.ArrayArrayOfModel
+		toSerialize["array_array_of_model"] = o.ArrayArrayOfModel
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ArrayTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
index 90571fb50d9..62c50a906da 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
@@ -75,21 +75,24 @@ func (o *Banana) SetLengthCm(v float32) {
 }
 
 func (o Banana) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Banana) ToMap() map[string]interface{} {
+func (o Banana) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.LengthCm != nil {
-		toSerialize["lengthCm"] = *o.LengthCm
+		toSerialize["lengthCm"] = o.LengthCm
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Banana) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
index 7153d24eb7d..6333db14e50 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
@@ -101,24 +101,25 @@ func (o *BananaReq) SetSweet(v bool) {
 }
 
 func (o BananaReq) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o BananaReq) ToMap() map[string]interface{} {
+func (o BananaReq) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["lengthCm"] = *o.LengthCm
-	}
+	toSerialize["lengthCm"] = o.LengthCm
 	if o.Sweet != nil {
-		toSerialize["sweet"] = *o.Sweet
+		toSerialize["sweet"] = o.Sweet
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *BananaReq) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
index a14484cba92..2763a88c52c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
@@ -241,36 +241,39 @@ func (o *Capitalization) SetATT_NAME(v string) {
 }
 
 func (o Capitalization) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Capitalization) ToMap() map[string]interface{} {
+func (o Capitalization) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.SmallCamel != nil {
-		toSerialize["smallCamel"] = *o.SmallCamel
+		toSerialize["smallCamel"] = o.SmallCamel
 	}
 	if o.CapitalCamel != nil {
-		toSerialize["CapitalCamel"] = *o.CapitalCamel
+		toSerialize["CapitalCamel"] = o.CapitalCamel
 	}
 	if o.SmallSnake != nil {
-		toSerialize["small_Snake"] = *o.SmallSnake
+		toSerialize["small_Snake"] = o.SmallSnake
 	}
 	if o.CapitalSnake != nil {
-		toSerialize["Capital_Snake"] = *o.CapitalSnake
+		toSerialize["Capital_Snake"] = o.CapitalSnake
 	}
 	if o.SCAETHFlowPoints != nil {
-		toSerialize["SCA_ETH_Flow_Points"] = *o.SCAETHFlowPoints
+		toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints
 	}
 	if o.ATT_NAME != nil {
-		toSerialize["ATT_NAME"] = *o.ATT_NAME
+		toSerialize["ATT_NAME"] = o.ATT_NAME
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Capitalization) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_cat.go b/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
index d60cfc739cf..9e7a879d26a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
@@ -81,29 +81,32 @@ func (o *Cat) SetDeclawed(v bool) {
 }
 
 func (o Cat) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Cat) ToMap() map[string]interface{} {
+func (o Cat) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	errAnimal = json.Unmarshal([]byte(serializedAnimal), &toSerialize)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	if o.Declawed != nil {
-		toSerialize["declawed"] = *o.Declawed
+		toSerialize["declawed"] = o.Declawed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Cat) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
index f70eb03a0d1..58be534b3cf 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
@@ -75,21 +75,24 @@ func (o *CatAllOf) SetDeclawed(v bool) {
 }
 
 func (o CatAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o CatAllOf) ToMap() map[string]interface{} {
+func (o CatAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Declawed != nil {
-		toSerialize["declawed"] = *o.Declawed
+		toSerialize["declawed"] = o.Declawed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *CatAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_category.go b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
index 22774f69107..528928bb069 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_category.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
@@ -103,24 +103,25 @@ func (o *Category) SetName(v string) {
 }
 
 func (o Category) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Category) ToMap() map[string]interface{} {
+func (o Category) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
-	}
-	if true {
-		toSerialize["name"] = *o.Name
+		toSerialize["id"] = o.Id
 	}
+	toSerialize["name"] = o.Name
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Category) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
index 3c243878587..aa0bc7183f3 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
@@ -75,21 +75,24 @@ func (o *ClassModel) SetClass(v string) {
 }
 
 func (o ClassModel) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ClassModel) ToMap() map[string]interface{} {
+func (o ClassModel) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Class != nil {
-		toSerialize["_class"] = *o.Class
+		toSerialize["_class"] = o.Class
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ClassModel) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_client.go b/samples/openapi3/client/petstore/go/go-petstore/model_client.go
index 3c37f3808f4..3e9607f7e4b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_client.go
@@ -75,21 +75,24 @@ func (o *Client) SetClient(v string) {
 }
 
 func (o Client) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Client) ToMap() map[string]interface{} {
+func (o Client) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Client != nil {
-		toSerialize["client"] = *o.Client
+		toSerialize["client"] = o.Client
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Client) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_dog.go b/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
index b810967e090..9634dd7221c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
@@ -81,29 +81,32 @@ func (o *Dog) SetBreed(v string) {
 }
 
 func (o Dog) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Dog) ToMap() map[string]interface{} {
+func (o Dog) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	serializedAnimal, errAnimal := json.Marshal(o.Animal)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	errAnimal = json.Unmarshal([]byte(serializedAnimal), &toSerialize)
 	if errAnimal != nil {
-		return []byte{}, errAnimal
+		return map[string]interface{}{}, errAnimal
 	}
 	if o.Breed != nil {
-		toSerialize["breed"] = *o.Breed
+		toSerialize["breed"] = o.Breed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Dog) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
index 6a127ea5052..8dfe75bf225 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
@@ -75,21 +75,24 @@ func (o *DogAllOf) SetBreed(v string) {
 }
 
 func (o DogAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o DogAllOf) ToMap() map[string]interface{} {
+func (o DogAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Breed != nil {
-		toSerialize["breed"] = *o.Breed
+		toSerialize["breed"] = o.Breed
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *DogAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
index 7b3ba5e04a8..4e9aa72a2dc 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
@@ -79,29 +79,32 @@ func (o *DuplicatedPropChild) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropChild) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o DuplicatedPropChild) ToMap() map[string]interface{} {
+func (o DuplicatedPropChild) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	serializedDuplicatedPropParent, errDuplicatedPropParent := json.Marshal(o.DuplicatedPropParent)
 	if errDuplicatedPropParent != nil {
-		return []byte{}, errDuplicatedPropParent
+		return map[string]interface{}{}, errDuplicatedPropParent
 	}
 	errDuplicatedPropParent = json.Unmarshal([]byte(serializedDuplicatedPropParent), &toSerialize)
 	if errDuplicatedPropParent != nil {
-		return []byte{}, errDuplicatedPropParent
+		return map[string]interface{}{}, errDuplicatedPropParent
 	}
 	if o.DupProp != nil {
-		toSerialize["dup-prop"] = *o.DupProp
+		toSerialize["dup-prop"] = o.DupProp
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *DuplicatedPropChild) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
index 2e9a1163783..43f0b6a4e03 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
@@ -76,21 +76,24 @@ func (o *DuplicatedPropChildAllOf) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropChildAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o DuplicatedPropChildAllOf) ToMap() map[string]interface{} {
+func (o DuplicatedPropChildAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.DupProp != nil {
-		toSerialize["dup-prop"] = *o.DupProp
+		toSerialize["dup-prop"] = o.DupProp
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *DuplicatedPropChildAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
index 5e8d630e222..359b19587e9 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
@@ -69,21 +69,22 @@ func (o *DuplicatedPropParent) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropParent) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o DuplicatedPropParent) ToMap() map[string]interface{} {
+func (o DuplicatedPropParent) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["dup-prop"] = *o.DupProp
-	}
+	toSerialize["dup-prop"] = o.DupProp
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *DuplicatedPropParent) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
index e410778f23e..f7fffa0bd40 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
@@ -108,24 +108,27 @@ func (o *EnumArrays) SetArrayEnum(v []string) {
 }
 
 func (o EnumArrays) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o EnumArrays) ToMap() map[string]interface{} {
+func (o EnumArrays) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.JustSymbol != nil {
-		toSerialize["just_symbol"] = *o.JustSymbol
+		toSerialize["just_symbol"] = o.JustSymbol
 	}
 	if o.ArrayEnum != nil {
-		toSerialize["array_enum"] = *o.ArrayEnum
+		toSerialize["array_enum"] = o.ArrayEnum
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *EnumArrays) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
index 63655c9561f..4cb77fb669a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
@@ -317,42 +317,43 @@ func (o *EnumTest) SetOuterEnumIntegerDefaultValue(v OuterEnumIntegerDefaultValu
 }
 
 func (o EnumTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o EnumTest) ToMap() map[string]interface{} {
+func (o EnumTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.EnumString != nil {
-		toSerialize["enum_string"] = *o.EnumString
-	}
-	if true {
-		toSerialize["enum_string_required"] = *o.EnumStringRequired
+		toSerialize["enum_string"] = o.EnumString
 	}
+	toSerialize["enum_string_required"] = o.EnumStringRequired
 	if o.EnumInteger != nil {
-		toSerialize["enum_integer"] = *o.EnumInteger
+		toSerialize["enum_integer"] = o.EnumInteger
 	}
 	if o.EnumNumber != nil {
-		toSerialize["enum_number"] = *o.EnumNumber
+		toSerialize["enum_number"] = o.EnumNumber
 	}
 	if o.OuterEnum.IsSet() {
-		toSerialize["outerEnum"] = *o.OuterEnum.Get()
+		toSerialize["outerEnum"] = o.OuterEnum.Get()
 	}
 	if o.OuterEnumInteger != nil {
-		toSerialize["outerEnumInteger"] = *o.OuterEnumInteger
+		toSerialize["outerEnumInteger"] = o.OuterEnumInteger
 	}
 	if o.OuterEnumDefaultValue != nil {
-		toSerialize["outerEnumDefaultValue"] = *o.OuterEnumDefaultValue
+		toSerialize["outerEnumDefaultValue"] = o.OuterEnumDefaultValue
 	}
 	if o.OuterEnumIntegerDefaultValue != nil {
-		toSerialize["outerEnumIntegerDefaultValue"] = *o.OuterEnumIntegerDefaultValue
+		toSerialize["outerEnumIntegerDefaultValue"] = o.OuterEnumIntegerDefaultValue
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *EnumTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file.go b/samples/openapi3/client/petstore/go/go-petstore/model_file.go
index 7a46b0ca5e0..1a83917df17 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_file.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_file.go
@@ -76,21 +76,24 @@ func (o *File) SetSourceURI(v string) {
 }
 
 func (o File) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o File) ToMap() map[string]interface{} {
+func (o File) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.SourceURI != nil {
-		toSerialize["sourceURI"] = *o.SourceURI
+		toSerialize["sourceURI"] = o.SourceURI
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *File) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
index c6105432577..43487a6b2bf 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
@@ -108,24 +108,27 @@ func (o *FileSchemaTestClass) SetFiles(v []File) {
 }
 
 func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o FileSchemaTestClass) ToMap() map[string]interface{} {
+func (o FileSchemaTestClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.File != nil {
-		toSerialize["file"] = *o.File
+		toSerialize["file"] = o.File
 	}
 	if o.Files != nil {
-		toSerialize["files"] = *o.Files
+		toSerialize["files"] = o.Files
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *FileSchemaTestClass) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
index 6d968e73579..5d7c6b339c5 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
@@ -79,21 +79,24 @@ func (o *Foo) SetBar(v string) {
 }
 
 func (o Foo) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Foo) ToMap() map[string]interface{} {
+func (o Foo) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Bar != nil {
-		toSerialize["bar"] = *o.Bar
+		toSerialize["bar"] = o.Bar
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Foo) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
index 3c6826f2989..0217178c5a1 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
@@ -513,63 +513,58 @@ func (o *FormatTest) SetPatternWithDigitsAndDelimiter(v string) {
 }
 
 func (o FormatTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o FormatTest) ToMap() map[string]interface{} {
+func (o FormatTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Integer != nil {
-		toSerialize["integer"] = *o.Integer
+		toSerialize["integer"] = o.Integer
 	}
 	if o.Int32 != nil {
-		toSerialize["int32"] = *o.Int32
+		toSerialize["int32"] = o.Int32
 	}
 	if o.Int64 != nil {
-		toSerialize["int64"] = *o.Int64
-	}
-	if true {
-		toSerialize["number"] = *o.Number
+		toSerialize["int64"] = o.Int64
 	}
+	toSerialize["number"] = o.Number
 	if o.Float != nil {
-		toSerialize["float"] = *o.Float
+		toSerialize["float"] = o.Float
 	}
 	if o.Double != nil {
-		toSerialize["double"] = *o.Double
+		toSerialize["double"] = o.Double
 	}
 	if o.String != nil {
-		toSerialize["string"] = *o.String
-	}
-	if true {
-		toSerialize["byte"] = *o.Byte
+		toSerialize["string"] = o.String
 	}
+	toSerialize["byte"] = o.Byte
 	if o.Binary != nil {
-		toSerialize["binary"] = *o.Binary
-	}
-	if true {
-		toSerialize["date"] = *o.Date
+		toSerialize["binary"] = o.Binary
 	}
+	toSerialize["date"] = o.Date
 	if o.DateTime != nil {
-		toSerialize["dateTime"] = *o.DateTime
+		toSerialize["dateTime"] = o.DateTime
 	}
 	if o.Uuid != nil {
-		toSerialize["uuid"] = *o.Uuid
-	}
-	if true {
-		toSerialize["password"] = *o.Password
+		toSerialize["uuid"] = o.Uuid
 	}
+	toSerialize["password"] = o.Password
 	if o.PatternWithDigits != nil {
-		toSerialize["pattern_with_digits"] = *o.PatternWithDigits
+		toSerialize["pattern_with_digits"] = o.PatternWithDigits
 	}
 	if o.PatternWithDigitsAndDelimiter != nil {
-		toSerialize["pattern_with_digits_and_delimiter"] = *o.PatternWithDigitsAndDelimiter
+		toSerialize["pattern_with_digits_and_delimiter"] = o.PatternWithDigitsAndDelimiter
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *FormatTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
index d705c205845..d1f7cd8de8a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
@@ -108,24 +108,27 @@ func (o *HasOnlyReadOnly) SetFoo(v string) {
 }
 
 func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o HasOnlyReadOnly) ToMap() map[string]interface{} {
+func (o HasOnlyReadOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Bar != nil {
-		toSerialize["bar"] = *o.Bar
+		toSerialize["bar"] = o.Bar
 	}
 	if o.Foo != nil {
-		toSerialize["foo"] = *o.Foo
+		toSerialize["foo"] = o.Foo
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *HasOnlyReadOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go b/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go
index bc519af8d08..21850aca43c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go
@@ -85,21 +85,24 @@ func (o *HealthCheckResult) UnsetNullableMessage() {
 }
 
 func (o HealthCheckResult) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o HealthCheckResult) ToMap() map[string]interface{} {
+func (o HealthCheckResult) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.NullableMessage.IsSet() {
-		toSerialize["NullableMessage"] = *o.NullableMessage.Get()
+		toSerialize["NullableMessage"] = o.NullableMessage.Get()
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *HealthCheckResult) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_list.go b/samples/openapi3/client/petstore/go/go-petstore/model_list.go
index d670f1c19ed..ee44ac2ed7a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_list.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_list.go
@@ -75,21 +75,24 @@ func (o *List) SetVar123List(v string) {
 }
 
 func (o List) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o List) ToMap() map[string]interface{} {
+func (o List) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Var123List != nil {
-		toSerialize["123-list"] = *o.Var123List
+		toSerialize["123-list"] = o.Var123List
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *List) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
index e76d76b74c0..c055bd167cc 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
@@ -77,21 +77,24 @@ func (o *MapOfFileTest) SetPropTest(v map[string]*os.File) {
 }
 
 func (o MapOfFileTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o MapOfFileTest) ToMap() map[string]interface{} {
+func (o MapOfFileTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.PropTest != nil {
-		toSerialize["prop_test"] = *o.PropTest
+		toSerialize["prop_test"] = o.PropTest
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *MapOfFileTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
index e48f4fce9ba..781103a39fc 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
@@ -174,30 +174,33 @@ func (o *MapTest) SetIndirectMap(v map[string]bool) {
 }
 
 func (o MapTest) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o MapTest) ToMap() map[string]interface{} {
+func (o MapTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.MapMapOfString != nil {
-		toSerialize["map_map_of_string"] = *o.MapMapOfString
+		toSerialize["map_map_of_string"] = o.MapMapOfString
 	}
 	if o.MapOfEnumString != nil {
-		toSerialize["map_of_enum_string"] = *o.MapOfEnumString
+		toSerialize["map_of_enum_string"] = o.MapOfEnumString
 	}
 	if o.DirectMap != nil {
-		toSerialize["direct_map"] = *o.DirectMap
+		toSerialize["direct_map"] = o.DirectMap
 	}
 	if o.IndirectMap != nil {
-		toSerialize["indirect_map"] = *o.IndirectMap
+		toSerialize["indirect_map"] = o.IndirectMap
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *MapTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
index 76f19c0a850..2c7857016d7 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
@@ -142,27 +142,30 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetMap(v map[string]Animal
 }
 
 func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() map[string]interface{} {
+func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Uuid != nil {
-		toSerialize["uuid"] = *o.Uuid
+		toSerialize["uuid"] = o.Uuid
 	}
 	if o.DateTime != nil {
-		toSerialize["dateTime"] = *o.DateTime
+		toSerialize["dateTime"] = o.DateTime
 	}
 	if o.Map != nil {
-		toSerialize["map"] = *o.Map
+		toSerialize["map"] = o.Map
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *MixedPropertiesAndAdditionalPropertiesClass) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_name.go b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
index 3f7e5178ba9..fc7c10b9f6f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_name.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
@@ -167,30 +167,31 @@ func (o *Name) SetVar123Number(v int32) {
 }
 
 func (o Name) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Name) ToMap() map[string]interface{} {
+func (o Name) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["name"] = *o.Name
-	}
+	toSerialize["name"] = o.Name
 	if o.SnakeCase != nil {
-		toSerialize["snake_case"] = *o.SnakeCase
+		toSerialize["snake_case"] = o.SnakeCase
 	}
 	if o.Property != nil {
-		toSerialize["property"] = *o.Property
+		toSerialize["property"] = o.Property
 	}
 	if o.Var123Number != nil {
-		toSerialize["123Number"] = *o.Var123Number
+		toSerialize["123Number"] = o.Var123Number
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Name) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go
index 64845e67426..3dc3b1f3813 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go
@@ -85,21 +85,24 @@ func (o *NullableAllOf) UnsetChild() {
 }
 
 func (o NullableAllOf) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o NullableAllOf) ToMap() map[string]interface{} {
+func (o NullableAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Child.IsSet() {
-		toSerialize["child"] = *o.Child.Get()
+		toSerialize["child"] = o.Child.Get()
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *NullableAllOf) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
index 7ec6b4fb09d..e1555200770 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
@@ -75,21 +75,24 @@ func (o *NullableAllOfChild) SetName(v string) {
 }
 
 func (o NullableAllOfChild) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o NullableAllOfChild) ToMap() map[string]interface{} {
+func (o NullableAllOfChild) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *NullableAllOfChild) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
index 7d5ecbf96e5..3f6d2c7a118 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
@@ -504,29 +504,32 @@ func (o *NullableClass) SetObjectItemsNullable(v map[string]map[string]interface
 }
 
 func (o NullableClass) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o NullableClass) ToMap() map[string]interface{} {
+func (o NullableClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.IntegerProp.IsSet() {
-		toSerialize["integer_prop"] = *o.IntegerProp.Get()
+		toSerialize["integer_prop"] = o.IntegerProp.Get()
 	}
 	if o.NumberProp.IsSet() {
-		toSerialize["number_prop"] = *o.NumberProp.Get()
+		toSerialize["number_prop"] = o.NumberProp.Get()
 	}
 	if o.BooleanProp.IsSet() {
-		toSerialize["boolean_prop"] = *o.BooleanProp.Get()
+		toSerialize["boolean_prop"] = o.BooleanProp.Get()
 	}
 	if o.StringProp.IsSet() {
-		toSerialize["string_prop"] = *o.StringProp.Get()
+		toSerialize["string_prop"] = o.StringProp.Get()
 	}
 	if o.DateProp.IsSet() {
-		toSerialize["date_prop"] = *o.DateProp.Get()
+		toSerialize["date_prop"] = o.DateProp.Get()
 	}
 	if o.DatetimeProp.IsSet() {
-		toSerialize["datetime_prop"] = *o.DatetimeProp.Get()
+		toSerialize["datetime_prop"] = o.DatetimeProp.Get()
 	}
 	if o.ArrayNullableProp != nil {
 		toSerialize["array_nullable_prop"] = *o.ArrayNullableProp
@@ -535,7 +538,7 @@ func (o NullableClass) ToMap() map[string]interface{} {
 		toSerialize["array_and_items_nullable_prop"] = *o.ArrayAndItemsNullableProp
 	}
 	if o.ArrayItemsNullable != nil {
-		toSerialize["array_items_nullable"] = *o.ArrayItemsNullable
+		toSerialize["array_items_nullable"] = o.ArrayItemsNullable
 	}
 	if o.ObjectNullableProp != nil {
 		toSerialize["object_nullable_prop"] = *o.ObjectNullableProp
@@ -544,9 +547,9 @@ func (o NullableClass) ToMap() map[string]interface{} {
 		toSerialize["object_and_items_nullable_prop"] = *o.ObjectAndItemsNullableProp
 	}
 	if o.ObjectItemsNullable != nil {
-		toSerialize["object_items_nullable"] = *o.ObjectItemsNullable
+		toSerialize["object_items_nullable"] = o.ObjectItemsNullable
 	}
-	return toSerialize
+	return toSerialize, nil
 }
 
 type NullableNullableClass struct {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
index 9eb2e9eb2d6..1f1d5518ff4 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
@@ -75,21 +75,24 @@ func (o *NumberOnly) SetJustNumber(v float32) {
 }
 
 func (o NumberOnly) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o NumberOnly) ToMap() map[string]interface{} {
+func (o NumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.JustNumber != nil {
-		toSerialize["JustNumber"] = *o.JustNumber
+		toSerialize["JustNumber"] = o.JustNumber
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *NumberOnly) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
index 7d653b92fd9..6f9eb193b34 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
@@ -75,21 +75,24 @@ func (o *OneOfPrimitiveTypeChild) SetName(v string) {
 }
 
 func (o OneOfPrimitiveTypeChild) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o OneOfPrimitiveTypeChild) ToMap() map[string]interface{} {
+func (o OneOfPrimitiveTypeChild) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *OneOfPrimitiveTypeChild) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_order.go b/samples/openapi3/client/petstore/go/go-petstore/model_order.go
index 2dc7f72e14a..1b69573ffb6 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_order.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_order.go
@@ -246,36 +246,39 @@ func (o *Order) SetComplete(v bool) {
 }
 
 func (o Order) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Order) ToMap() map[string]interface{} {
+func (o Order) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.PetId != nil {
-		toSerialize["petId"] = *o.PetId
+		toSerialize["petId"] = o.PetId
 	}
 	if o.Quantity != nil {
-		toSerialize["quantity"] = *o.Quantity
+		toSerialize["quantity"] = o.Quantity
 	}
 	if o.ShipDate != nil {
-		toSerialize["shipDate"] = *o.ShipDate
+		toSerialize["shipDate"] = o.ShipDate
 	}
 	if o.Status != nil {
-		toSerialize["status"] = *o.Status
+		toSerialize["status"] = o.Status
 	}
 	if o.Complete != nil {
-		toSerialize["complete"] = *o.Complete
+		toSerialize["complete"] = o.Complete
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Order) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
index 8d2899c5d74..929b714fe0f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
@@ -141,27 +141,30 @@ func (o *OuterComposite) SetMyBoolean(v bool) {
 }
 
 func (o OuterComposite) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o OuterComposite) ToMap() map[string]interface{} {
+func (o OuterComposite) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.MyNumber != nil {
-		toSerialize["my_number"] = *o.MyNumber
+		toSerialize["my_number"] = o.MyNumber
 	}
 	if o.MyString != nil {
-		toSerialize["my_string"] = *o.MyString
+		toSerialize["my_string"] = o.MyString
 	}
 	if o.MyBoolean != nil {
-		toSerialize["my_boolean"] = *o.MyBoolean
+		toSerialize["my_boolean"] = o.MyBoolean
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *OuterComposite) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
index d60b4864291..0c6642366c7 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
@@ -231,36 +231,35 @@ func (o *Pet) SetStatus(v string) {
 }
 
 func (o Pet) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Pet) ToMap() map[string]interface{} {
+func (o Pet) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.Category != nil {
-		toSerialize["category"] = *o.Category
-	}
-	if true {
-		toSerialize["name"] = *o.Name
-	}
-	if true {
-		toSerialize["photoUrls"] = *o.PhotoUrls
+		toSerialize["category"] = o.Category
 	}
+	toSerialize["name"] = o.Name
+	toSerialize["photoUrls"] = o.PhotoUrls
 	if o.Tags != nil {
-		toSerialize["tags"] = *o.Tags
+		toSerialize["tags"] = o.Tags
 	}
 	if o.Status != nil {
-		toSerialize["status"] = *o.Status
+		toSerialize["status"] = o.Status
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Pet) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
index 13db5b0ed16..9b71f265645 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
@@ -108,24 +108,27 @@ func (o *ReadOnlyFirst) SetBaz(v string) {
 }
 
 func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ReadOnlyFirst) ToMap() map[string]interface{} {
+func (o ReadOnlyFirst) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Bar != nil {
-		toSerialize["bar"] = *o.Bar
+		toSerialize["bar"] = o.Bar
 	}
 	if o.Baz != nil {
-		toSerialize["baz"] = *o.Baz
+		toSerialize["baz"] = o.Baz
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ReadOnlyFirst) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
index bb0f8b69061..d001bb1b726 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
@@ -285,39 +285,42 @@ func (o *ReadOnlyWithDefault) SetIntProp2(v float32) {
 }
 
 func (o ReadOnlyWithDefault) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o ReadOnlyWithDefault) ToMap() map[string]interface{} {
+func (o ReadOnlyWithDefault) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Prop1 != nil {
-		toSerialize["prop1"] = *o.Prop1
+		toSerialize["prop1"] = o.Prop1
 	}
 	if o.Prop2 != nil {
-		toSerialize["prop2"] = *o.Prop2
+		toSerialize["prop2"] = o.Prop2
 	}
 	if o.Prop3 != nil {
-		toSerialize["prop3"] = *o.Prop3
+		toSerialize["prop3"] = o.Prop3
 	}
 	if o.BoolProp1 != nil {
-		toSerialize["boolProp1"] = *o.BoolProp1
+		toSerialize["boolProp1"] = o.BoolProp1
 	}
 	if o.BoolProp2 != nil {
-		toSerialize["boolProp2"] = *o.BoolProp2
+		toSerialize["boolProp2"] = o.BoolProp2
 	}
 	if o.IntProp1 != nil {
-		toSerialize["intProp1"] = *o.IntProp1
+		toSerialize["intProp1"] = o.IntProp1
 	}
 	if o.IntProp2 != nil {
-		toSerialize["intProp2"] = *o.IntProp2
+		toSerialize["intProp2"] = o.IntProp2
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *ReadOnlyWithDefault) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_return.go b/samples/openapi3/client/petstore/go/go-petstore/model_return.go
index dcfdd44683a..3561cfeb544 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_return.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_return.go
@@ -75,21 +75,24 @@ func (o *Return) SetReturn(v int32) {
 }
 
 func (o Return) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Return) ToMap() map[string]interface{} {
+func (o Return) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Return != nil {
-		toSerialize["return"] = *o.Return
+		toSerialize["return"] = o.Return
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Return) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
index d49f0e2c581..012e87aa755 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
@@ -108,24 +108,27 @@ func (o *Tag) SetName(v string) {
 }
 
 func (o Tag) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Tag) ToMap() map[string]interface{} {
+func (o Tag) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.Name != nil {
-		toSerialize["name"] = *o.Name
+		toSerialize["name"] = o.Name
 	}
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Tag) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_user.go b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
index 1c562213a77..de8ef6fc1b0 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_user.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
@@ -446,38 +446,41 @@ func (o *User) SetArbitraryNullableTypeValue(v interface{}) {
 }
 
 func (o User) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o User) ToMap() map[string]interface{} {
+func (o User) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Id != nil {
-		toSerialize["id"] = *o.Id
+		toSerialize["id"] = o.Id
 	}
 	if o.Username != nil {
-		toSerialize["username"] = *o.Username
+		toSerialize["username"] = o.Username
 	}
 	if o.FirstName != nil {
-		toSerialize["firstName"] = *o.FirstName
+		toSerialize["firstName"] = o.FirstName
 	}
 	if o.LastName != nil {
-		toSerialize["lastName"] = *o.LastName
+		toSerialize["lastName"] = o.LastName
 	}
 	if o.Email != nil {
-		toSerialize["email"] = *o.Email
+		toSerialize["email"] = o.Email
 	}
 	if o.Password != nil {
-		toSerialize["password"] = *o.Password
+		toSerialize["password"] = o.Password
 	}
 	if o.Phone != nil {
-		toSerialize["phone"] = *o.Phone
+		toSerialize["phone"] = o.Phone
 	}
 	if o.UserStatus != nil {
-		toSerialize["userStatus"] = *o.UserStatus
+		toSerialize["userStatus"] = o.UserStatus
 	}
 	if o.ArbitraryObject != nil {
-		toSerialize["arbitraryObject"] = *o.ArbitraryObject
+		toSerialize["arbitraryObject"] = o.ArbitraryObject
 	}
 	if o.ArbitraryNullableObject != nil {
 		toSerialize["arbitraryNullableObject"] = *o.ArbitraryNullableObject
@@ -493,7 +496,7 @@ func (o User) ToMap() map[string]interface{} {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *User) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
index fb6c363d9e7..dfdc7469e8f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
@@ -134,27 +134,28 @@ func (o *Whale) SetClassName(v string) {
 }
 
 func (o Whale) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Whale) ToMap() map[string]interface{} {
+func (o Whale) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.HasBaleen != nil {
-		toSerialize["hasBaleen"] = *o.HasBaleen
+		toSerialize["hasBaleen"] = o.HasBaleen
 	}
 	if o.HasTeeth != nil {
-		toSerialize["hasTeeth"] = *o.HasTeeth
-	}
-	if true {
-		toSerialize["className"] = *o.ClassName
+		toSerialize["hasTeeth"] = o.HasTeeth
 	}
+	toSerialize["className"] = o.ClassName
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Whale) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
index 058877bae4b..502f2ba801d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
@@ -101,24 +101,25 @@ func (o *Zebra) SetClassName(v string) {
 }
 
 func (o Zebra) MarshalJSON() ([]byte, error) {
-	toSerialize := o.ToMap()
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
 	return json.Marshal(toSerialize)
 }
 
-func (o Zebra) ToMap() map[string]interface{} {
+func (o Zebra) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if o.Type != nil {
-		toSerialize["type"] = *o.Type
-	}
-	if true {
-		toSerialize["className"] = *o.ClassName
+		toSerialize["type"] = o.Type
 	}
+	toSerialize["className"] = o.ClassName
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return toSerialize
+	return toSerialize, nil
 }
 
 func (o *Zebra) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/utils.go b/samples/openapi3/client/petstore/go/go-petstore/utils.go
index ba83c9efcf3..436c8135423 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/utils.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/utils.go
@@ -342,5 +342,5 @@ func isNil(i interface{}) bool {
     return false
 }
 type MappedNullable interface {
-	ToMap() map[string]interface{}
+	ToMap() (map[string]interface{}, error)
 }
-- 
GitLab


From b11c35fc20776b299c058182df4b8e8b56549bcc Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 15 Oct 2022 06:27:08 -0400
Subject: [PATCH 06/15] Fixed unit tests

---
 .../src/main/resources/go/api.mustache        |  2 +-
 .../src/main/resources/go/client.mustache     | 50 ++++++++++---------
 .../client/petstore/go/go-petstore/api_pet.go | 10 ++--
 .../petstore/go/go-petstore/api_store.go      |  4 +-
 .../petstore/go/go-petstore/api_user.go       |  6 +--
 .../client/petstore/go/go-petstore/client.go  | 50 ++++++++++---------
 samples/client/petstore/go/pet_api_test.go    |  6 +--
 samples/client/petstore/go/store_api_test.go  |  2 +-
 .../x-auth-id-alias/go-experimental/client.go | 50 ++++++++++---------
 .../client/petstore/go/go-petstore/api_pet.go | 10 ++--
 .../petstore/go/go-petstore/api_store.go      |  4 +-
 .../petstore/go/go-petstore/api_user.go       |  6 +--
 .../client/petstore/go/go-petstore/client.go  | 50 ++++++++++---------
 13 files changed, 133 insertions(+), 117 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index a4351ee200a..4f6b5b9039b 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -124,7 +124,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 	}
 
 	localVarPath := localBasePath + "{{{path}}}"{{#pathParams}}
-	localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", url.PathEscape(parameterToString(r.{{paramName}}, "{{paramName}}", "{{collectionFormat}}")), -1){{/pathParams}}
+	localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", url.PathEscape(parameterValueToString(r.{{paramName}}, "{{paramName}}")), -1){{/pathParams}}
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index 3d78704bdbe..ce1e0cb51aa 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -132,10 +132,19 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
-	u := url.Values{}
-	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
-	return u.Encode()
+func parameterValueToString( obj interface{}, key string ) string {
+    if reflect.TypeOf(obj).Kind() != reflect.Ptr {
+        return fmt.Sprintf("%v", obj)
+    }
+    var param,ok = obj.(MappedNullable)
+    if !ok {
+        return ""
+    }
+    dataMap,err := param.ToMap()
+    if err != nil {
+        return ""
+    }
+    return fmt.Sprintf("%v", dataMap[key])
 }
 
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
@@ -152,25 +161,15 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	var delimiter string
-
-	switch collectionFormat {
-	case "pipes":
-		delimiter = "|"
-	case "ssv":
-		delimiter = " "
-	case "tsv":
-		delimiter = "\t"
-	case "csv":
-		delimiter = ","
-	}
-
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
-		if len(sliceValue) > 0 {
-			for v := range sliceValue {
-				parameterAddToHolder(queryParams, keyPrefix, v)
-			}
+		var indValue = reflect.ValueOf(obj)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		var lenIndValue = indValue.Len()
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
 		}
 		return
 
@@ -184,12 +183,18 @@ func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interfac
 			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
+		// scenario of pointer-to-slice
+		var pointed = reflect.ValueOf(obj).Elem()
+		var pointedValue = pointed.Interface()
+		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+		return
 
 	} else if t, ok := obj.(time.Time); ok {
 		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
+	// other value
 	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
@@ -205,7 +210,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 			return
 		}
 		var lenIndValue = indValue.Len()
-		fmt.Printf("slice len %d\n", lenIndValue)
 		for i:=0;i<lenIndValue;i++ {
 			var arrayValue = indValue.Index(i)
 			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
diff --git a/samples/client/petstore/go/go-petstore/api_pet.go b/samples/client/petstore/go/go-petstore/api_pet.go
index cfa15ca8956..7800d85d685 100644
--- a/samples/client/petstore/go/go-petstore/api_pet.go
+++ b/samples/client/petstore/go/go-petstore/api_pet.go
@@ -288,7 +288,7 @@ func (a *PetApiService) DeletePetExecute(r ApiDeletePetRequest) (*http.Response,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -608,7 +608,7 @@ func (a *PetApiService) GetPetByIdExecute(r ApiGetPetByIdRequest) (*Pet, *http.R
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -833,7 +833,7 @@ func (a *PetApiService) UpdatePetWithFormExecute(r ApiUpdatePetWithFormRequest)
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -945,7 +945,7 @@ func (a *PetApiService) UploadFileExecute(r ApiUploadFileRequest) (*ApiResponse,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}/uploadImage"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -1080,7 +1080,7 @@ func (a *PetApiService) UploadFileWithRequiredFileExecute(r ApiUploadFileWithReq
 	}
 
 	localVarPath := localBasePath + "/fake/{petId}/uploadImageWithRequiredFile"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/client/petstore/go/go-petstore/api_store.go b/samples/client/petstore/go/go-petstore/api_store.go
index 1327e2b9b62..39a987378f3 100644
--- a/samples/client/petstore/go/go-petstore/api_store.go
+++ b/samples/client/petstore/go/go-petstore/api_store.go
@@ -122,7 +122,7 @@ func (a *StoreApiService) DeleteOrderExecute(r ApiDeleteOrderRequest) (*http.Res
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterValueToString(r.orderId, "orderId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -329,7 +329,7 @@ func (a *StoreApiService) GetOrderByIdExecute(r ApiGetOrderByIdRequest) (*Order,
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterValueToString(r.orderId, "orderId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/client/petstore/go/go-petstore/api_user.go b/samples/client/petstore/go/go-petstore/api_user.go
index 8d80f74ceba..ae41a15ad98 100644
--- a/samples/client/petstore/go/go-petstore/api_user.go
+++ b/samples/client/petstore/go/go-petstore/api_user.go
@@ -462,7 +462,7 @@ func (a *UserApiService) DeleteUserExecute(r ApiDeleteUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterValueToString(r.username, "username")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -554,7 +554,7 @@ func (a *UserApiService) GetUserByNameExecute(r ApiGetUserByNameRequest) (*User,
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterValueToString(r.username, "username")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -867,7 +867,7 @@ func (a *UserApiService) UpdateUserExecute(r ApiUpdateUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterValueToString(r.username, "username")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go
index c87e8addecd..9b4638f48fe 100644
--- a/samples/client/petstore/go/go-petstore/client.go
+++ b/samples/client/petstore/go/go-petstore/client.go
@@ -140,10 +140,19 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
-	u := url.Values{}
-	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
-	return u.Encode()
+func parameterValueToString( obj interface{}, key string ) string {
+    if reflect.TypeOf(obj).Kind() != reflect.Ptr {
+        return fmt.Sprintf("%v", obj)
+    }
+    var param,ok = obj.(MappedNullable)
+    if !ok {
+        return ""
+    }
+    dataMap,err := param.ToMap()
+    if err != nil {
+        return ""
+    }
+    return fmt.Sprintf("%v", dataMap[key])
 }
 
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
@@ -160,25 +169,15 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	var delimiter string
-
-	switch collectionFormat {
-	case "pipes":
-		delimiter = "|"
-	case "ssv":
-		delimiter = " "
-	case "tsv":
-		delimiter = "\t"
-	case "csv":
-		delimiter = ","
-	}
-
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
-		if len(sliceValue) > 0 {
-			for v := range sliceValue {
-				parameterAddToHolder(queryParams, keyPrefix, v)
-			}
+		var indValue = reflect.ValueOf(obj)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		var lenIndValue = indValue.Len()
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
 		}
 		return
 
@@ -192,12 +191,18 @@ func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interfac
 			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
+		// scenario of pointer-to-slice
+		var pointed = reflect.ValueOf(obj).Elem()
+		var pointedValue = pointed.Interface()
+		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+		return
 
 	} else if t, ok := obj.(time.Time); ok {
 		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
+	// other value
 	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
@@ -213,7 +218,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 			return
 		}
 		var lenIndValue = indValue.Len()
-		fmt.Printf("slice len %d\n", lenIndValue)
 		for i:=0;i<lenIndValue;i++ {
 			var arrayValue = indValue.Index(i)
 			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go
index 0a17cbed8f0..ab4eca994e7 100644
--- a/samples/client/petstore/go/pet_api_test.go
+++ b/samples/client/petstore/go/pet_api_test.go
@@ -14,8 +14,8 @@ import (
 
 var client *sw.APIClient
 
-const testHost = "petstore.swagger.io:80"
-const testScheme = "http"
+const testHost = "petstore.swagger.io:443"
+const testScheme = "https"
 
 func TestMain(m *testing.M) {
 	cfg := sw.NewConfiguration()
@@ -111,7 +111,7 @@ func TestFindPetsByTag(t *testing.T) {
 			assert := assert.New(t)
 			for i := 0; i < len(resp); i++ {
 				if *resp[i].Id == 12830 {
-					assert.Equal(*resp[i].Status, "available", "Pet status should be `pending`")
+					assert.Equal("available", *resp[i].Status, "Pet status should be `available`")
 					found = true
 				}
 			}
diff --git a/samples/client/petstore/go/store_api_test.go b/samples/client/petstore/go/store_api_test.go
index 94ca695c17b..e11254ee6f9 100644
--- a/samples/client/petstore/go/store_api_test.go
+++ b/samples/client/petstore/go/store_api_test.go
@@ -24,7 +24,7 @@ func TestPlaceOrder(t *testing.T) {
 		// Skip parsing time error due to error in Petstore Test Server
 		// https://github.com/OpenAPITools/openapi-generator/issues/1292
 		if regexp.
-			MustCompile(`^parsing time.+cannot parse "\+0000"" as "Z07:00"$`).
+			MustCompile(`as "Z07:00"$`).
 			MatchString(err.Error()) {
 			t.Log("Skipping error for parsing time with `+0000` UTC offset as Petstore Test Server does not return valid RFC 3339 datetime")
 		} else {
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
index 14100fd60bc..d02a410f5f3 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
@@ -125,10 +125,19 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
-	u := url.Values{}
-	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
-	return u.Encode()
+func parameterValueToString( obj interface{}, key string ) string {
+    if reflect.TypeOf(obj).Kind() != reflect.Ptr {
+        return fmt.Sprintf("%v", obj)
+    }
+    var param,ok = obj.(MappedNullable)
+    if !ok {
+        return ""
+    }
+    dataMap,err := param.ToMap()
+    if err != nil {
+        return ""
+    }
+    return fmt.Sprintf("%v", dataMap[key])
 }
 
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
@@ -145,25 +154,15 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	var delimiter string
-
-	switch collectionFormat {
-	case "pipes":
-		delimiter = "|"
-	case "ssv":
-		delimiter = " "
-	case "tsv":
-		delimiter = "\t"
-	case "csv":
-		delimiter = ","
-	}
-
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
-		if len(sliceValue) > 0 {
-			for v := range sliceValue {
-				parameterAddToHolder(queryParams, keyPrefix, v)
-			}
+		var indValue = reflect.ValueOf(obj)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		var lenIndValue = indValue.Len()
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
 		}
 		return
 
@@ -177,12 +176,18 @@ func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interfac
 			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
+		// scenario of pointer-to-slice
+		var pointed = reflect.ValueOf(obj).Elem()
+		var pointedValue = pointed.Interface()
+		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+		return
 
 	} else if t, ok := obj.(time.Time); ok {
 		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
+	// other value
 	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
@@ -198,7 +203,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 			return
 		}
 		var lenIndValue = indValue.Len()
-		fmt.Printf("slice len %d\n", lenIndValue)
 		for i:=0;i<lenIndValue;i++ {
 			var arrayValue = indValue.Index(i)
 			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_pet.go b/samples/openapi3/client/petstore/go/go-petstore/api_pet.go
index ff042a87bae..3d780fd1720 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_pet.go
@@ -304,7 +304,7 @@ func (a *PetApiService) DeletePetExecute(r ApiDeletePetRequest) (*http.Response,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -625,7 +625,7 @@ func (a *PetApiService) GetPetByIdExecute(r ApiGetPetByIdRequest) (*Pet, *http.R
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -854,7 +854,7 @@ func (a *PetApiService) UpdatePetWithFormExecute(r ApiUpdatePetWithFormRequest)
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -968,7 +968,7 @@ func (a *PetApiService) UploadFileExecute(r ApiUploadFileRequest) (*ApiResponse,
 	}
 
 	localVarPath := localBasePath + "/pet/{petId}/uploadImage"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -1105,7 +1105,7 @@ func (a *PetApiService) UploadFileWithRequiredFileExecute(r ApiUploadFileWithReq
 	}
 
 	localVarPath := localBasePath + "/fake/{petId}/uploadImageWithRequiredFile"
-	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterToString(r.petId, "petId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", url.PathEscape(parameterValueToString(r.petId, "petId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_store.go b/samples/openapi3/client/petstore/go/go-petstore/api_store.go
index 7564793f196..a0e562d8fb2 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_store.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_store.go
@@ -124,7 +124,7 @@ func (a *StoreApiService) DeleteOrderExecute(r ApiDeleteOrderRequest) (*http.Res
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterValueToString(r.orderId, "orderId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -331,7 +331,7 @@ func (a *StoreApiService) GetOrderByIdExecute(r ApiGetOrderByIdRequest) (*Order,
 	}
 
 	localVarPath := localBasePath + "/store/order/{order_id}"
-	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterToString(r.orderId, "orderId", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", url.PathEscape(parameterValueToString(r.orderId, "orderId")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_user.go b/samples/openapi3/client/petstore/go/go-petstore/api_user.go
index de0d2a3cd7e..c4bb61f81f8 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_user.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_user.go
@@ -476,7 +476,7 @@ func (a *UserApiService) DeleteUserExecute(r ApiDeleteUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterValueToString(r.username, "username")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -570,7 +570,7 @@ func (a *UserApiService) GetUserByNameExecute(r ApiGetUserByNameRequest) (*User,
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterValueToString(r.username, "username")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
@@ -887,7 +887,7 @@ func (a *UserApiService) UpdateUserExecute(r ApiUpdateUserRequest) (*http.Respon
 	}
 
 	localVarPath := localBasePath + "/user/{username}"
-	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterToString(r.username, "username", "")), -1)
+	localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", url.PathEscape(parameterValueToString(r.username, "username")), -1)
 
 	localVarHeaderParams := make(map[string]string)
 	localVarQueryParams := url.Values{}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/client.go b/samples/openapi3/client/petstore/go/go-petstore/client.go
index e19486ec7ee..3183211ebbf 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/client.go
@@ -143,10 +143,19 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
 	return nil
 }
 
-func parameterToString( obj interface{}, keyPrefix string, collectionFormat string ) string {
-	u := url.Values{}
-	parameterAddToQuery( u, keyPrefix, obj, collectionFormat )
-	return u.Encode()
+func parameterValueToString( obj interface{}, key string ) string {
+    if reflect.TypeOf(obj).Kind() != reflect.Ptr {
+        return fmt.Sprintf("%v", obj)
+    }
+    var param,ok = obj.(MappedNullable)
+    if !ok {
+        return ""
+    }
+    dataMap,err := param.ToMap()
+    if err != nil {
+        return ""
+    }
+    return fmt.Sprintf("%v", dataMap[key])
 }
 
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
@@ -163,25 +172,15 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	var delimiter string
-
-	switch collectionFormat {
-	case "pipes":
-		delimiter = "|"
-	case "ssv":
-		delimiter = " "
-	case "tsv":
-		delimiter = "\t"
-	case "csv":
-		delimiter = ","
-	}
-
 	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		sliceValue := strings.Split(fmt.Sprint(obj), delimiter)
-		if len(sliceValue) > 0 {
-			for v := range sliceValue {
-				parameterAddToHolder(queryParams, keyPrefix, v)
-			}
+		var indValue = reflect.ValueOf(obj)
+		if indValue == reflect.ValueOf(nil) {
+			return
+		}
+		var lenIndValue = indValue.Len()
+		for i:=0;i<lenIndValue;i++ {
+			var arrayValue = indValue.Index(i)
+			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
 		}
 		return
 
@@ -195,12 +194,18 @@ func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interfac
 			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
 			return
 		}
+		// scenario of pointer-to-slice
+		var pointed = reflect.ValueOf(obj).Elem()
+		var pointedValue = pointed.Interface()
+		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+		return
 
 	} else if t, ok := obj.(time.Time); ok {
 		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
 		return
 	}
 
+	// other value
 	parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
@@ -216,7 +221,6 @@ func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param in
 			return
 		}
 		var lenIndValue = indValue.Len()
-		fmt.Printf("slice len %d\n", lenIndValue)
 		for i:=0;i<lenIndValue;i++ {
 			var arrayValue = indValue.Index(i)
 			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-- 
GitLab


From 85907137d9b3bd13de039d277eaae2fcccf89322 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 15 Oct 2022 06:38:54 -0400
Subject: [PATCH 07/15] revert to http connection for tests

---
 samples/client/petstore/go/pet_api_test.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go
index ab4eca994e7..a4b35d01274 100644
--- a/samples/client/petstore/go/pet_api_test.go
+++ b/samples/client/petstore/go/pet_api_test.go
@@ -14,8 +14,8 @@ import (
 
 var client *sw.APIClient
 
-const testHost = "petstore.swagger.io:443"
-const testScheme = "https"
+const testHost = "petstore.swagger.io:80"
+const testScheme = "http"
 
 func TestMain(m *testing.M) {
 	cfg := sw.NewConfiguration()
-- 
GitLab


From 1ea2ddfcb1dbae904275a766cfbba5a22332d549 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 15 Oct 2022 12:51:54 -0400
Subject: [PATCH 08/15] fix model_simple generation

---
 .../src/main/resources/go/model_simple.mustache           | 2 +-
 .../petstore/go/go-petstore/model_nullable_class.go       | 8 ++++----
 .../openapi3/client/petstore/go/go-petstore/model_user.go | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
index 26445c9d861..dcec18ae717 100644
--- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
@@ -285,7 +285,7 @@ func (o {{classname}}) ToMap() (map[string]interface{}, error) {
 	{{#vendorExtensions.x-golang-is-container}}
 	{{! support for container fields is not ideal at this point because of lack of Nullable* types}}
 	if o.{{name}} != nil {
-		toSerialize["{{baseName}}"] = *o.{{name}}
+		toSerialize["{{baseName}}"] = o.{{name}}
 	}
 	{{/vendorExtensions.x-golang-is-container}}
 	{{^vendorExtensions.x-golang-is-container}}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
index 3f6d2c7a118..63efbfae65c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
@@ -532,19 +532,19 @@ func (o NullableClass) ToMap() (map[string]interface{}, error) {
 		toSerialize["datetime_prop"] = o.DatetimeProp.Get()
 	}
 	if o.ArrayNullableProp != nil {
-		toSerialize["array_nullable_prop"] = *o.ArrayNullableProp
+		toSerialize["array_nullable_prop"] = o.ArrayNullableProp
 	}
 	if o.ArrayAndItemsNullableProp != nil {
-		toSerialize["array_and_items_nullable_prop"] = *o.ArrayAndItemsNullableProp
+		toSerialize["array_and_items_nullable_prop"] = o.ArrayAndItemsNullableProp
 	}
 	if o.ArrayItemsNullable != nil {
 		toSerialize["array_items_nullable"] = o.ArrayItemsNullable
 	}
 	if o.ObjectNullableProp != nil {
-		toSerialize["object_nullable_prop"] = *o.ObjectNullableProp
+		toSerialize["object_nullable_prop"] = o.ObjectNullableProp
 	}
 	if o.ObjectAndItemsNullableProp != nil {
-		toSerialize["object_and_items_nullable_prop"] = *o.ObjectAndItemsNullableProp
+		toSerialize["object_and_items_nullable_prop"] = o.ObjectAndItemsNullableProp
 	}
 	if o.ObjectItemsNullable != nil {
 		toSerialize["object_items_nullable"] = o.ObjectItemsNullable
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_user.go b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
index de8ef6fc1b0..c94baca1eda 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_user.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
@@ -483,13 +483,13 @@ func (o User) ToMap() (map[string]interface{}, error) {
 		toSerialize["arbitraryObject"] = o.ArbitraryObject
 	}
 	if o.ArbitraryNullableObject != nil {
-		toSerialize["arbitraryNullableObject"] = *o.ArbitraryNullableObject
+		toSerialize["arbitraryNullableObject"] = o.ArbitraryNullableObject
 	}
 	if o.ArbitraryTypeValue != nil {
-		toSerialize["arbitraryTypeValue"] = *o.ArbitraryTypeValue
+		toSerialize["arbitraryTypeValue"] = o.ArbitraryTypeValue
 	}
 	if o.ArbitraryNullableTypeValue != nil {
-		toSerialize["arbitraryNullableTypeValue"] = *o.ArbitraryNullableTypeValue
+		toSerialize["arbitraryNullableTypeValue"] = o.ArbitraryNullableTypeValue
 	}
 
 	for key, value := range o.AdditionalProperties {
-- 
GitLab


From 2f7993013ef6d2a9921e09f6e5b7d1d53935dc9e Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Tue, 1 Nov 2022 17:19:31 -0400
Subject: [PATCH 09/15] Fix parameter encoding issue

---
 .../src/main/resources/go/client.mustache     | 217 +++++++++++-------
 ...odels-for-testing-with-http-signature.yaml |  25 +-
 .../client/petstore/go/go-petstore/client.go  | 217 +++++++++++-------
 .../x-auth-id-alias/go-experimental/client.go | 217 +++++++++++-------
 .../client/petstore/go/fake_api_test.go       |  46 ++++
 .../client/petstore/go/go-petstore/README.md  |   1 +
 .../petstore/go/go-petstore/api/openapi.yaml  |  25 +-
 .../petstore/go/go-petstore/api_fake.go       | 117 +++++++++-
 .../client/petstore/go/go-petstore/client.go  | 217 +++++++++++-------
 .../petstore/go/go-petstore/docs/FakeApi.md   |  67 +++++-
 10 files changed, 809 insertions(+), 340 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index ce1e0cb51aa..d9d175916a8 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -34,6 +34,8 @@ import (
 var (
 	jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
 	xmlCheck  = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
+    queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
+    queryDescape    = strings.NewReplacer( "%5B", "[", "%5D", "]" )
 )
 
 // APIClient manages communication with the {{appName}} API v{{version}}
@@ -147,101 +149,144 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
+
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
-	switch valuesMap := queryParams.(type) {
-	case url.Values:
-		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
-		break
-	case map[string]string:
-		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
-		break
-	}
+    var v = reflect.ValueOf(obj)
+    var value = ""
+    if v == reflect.ValueOf(nil) {
+        value = "nil"
+    } else {
+        switch v.Kind() {
+			case reflect.Invalid:
+				value = "invalid"
+
+			case reflect.Struct:
+				var param,ok = obj.(MappedNullable)
+				if ok {
+					dataMap,err := param.ToMap()
+					if err != nil {
+						return
+					}
+					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					return
+				}
+				value = v.Type().String() + " value"
+			case reflect.Interface:
+				fallthrough
+            case reflect.Ptr:
+                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+                return
+
+            case reflect.Int, reflect.Int8, reflect.Int16,
+                reflect.Int32, reflect.Int64:
+                value = strconv.FormatInt(v.Int(), 10)
+            case reflect.Uint, reflect.Uint8, reflect.Uint16,
+                reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+                value = strconv.FormatUint(v.Uint(), 10)
+            case reflect.Float32, reflect.Float64:
+                value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
+            case reflect.Bool:
+                value = strconv.FormatBool(v.Bool())
+            case reflect.String:
+                value = v.String()
+            default:
+                value = v.Type().String() + " value"
+        }
+    }
+
+    switch valuesMap := queryParams.(type) {
+        case url.Values:
+            valuesMap.Add( keyPrefix, value )
+            break
+        case map[string]string:
+            valuesMap[keyPrefix] = value
+            break
+    }
 }
 
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		var indValue = reflect.ValueOf(obj)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-		}
-		return
-
-	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-		var param,ok = obj.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-		// scenario of pointer-to-slice
-		var pointed = reflect.ValueOf(obj).Elem()
-		var pointedValue = pointed.Interface()
-		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-		return
-
-	} else if t, ok := obj.(time.Time); ok {
-		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-		return
-	}
+    if reflect.TypeOf(obj).Kind() == reflect.Slice {
+        var indValue = reflect.ValueOf(obj)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
+        }
+        return
+
+    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+        var param,ok = obj.(MappedNullable)
+        if ok {
+            dataMap,err := param.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+        // scenario of pointer indirect value
+        var pointed = reflect.ValueOf(obj).Elem()
+        var pointedValue = pointed.Interface()
+        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+        return
+
+    } else if t, ok := obj.(time.Time); ok {
+        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
+        return
+    }
 
-	// other value
-	parameterAddToHolder(queryParams, keyPrefix, obj)
+    // other value
+    parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
 func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-	if param == nil {
-		return
-	}
-	var kind = reflect.TypeOf(param).Kind()
-	if kind == reflect.Slice {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-		}
-		return
-
-	} else if kind == reflect.Map {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		
-		iter := indValue.MapRange()
-		for iter.Next() {
-			k,v := iter.Key(), iter.Value()
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-		}
-		return
-	} else if kind == reflect.Ptr {
-		var param,ok = param.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-	}
+    if param == nil {
+        return
+    }
+    var kind = reflect.TypeOf(param).Kind()
+    if kind == reflect.Slice {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+        }
+        return
+
+    } else if kind == reflect.Map {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        iter := indValue.MapRange()
+        for iter.Next() {
+            k,v := iter.Key(), iter.Value()
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+        }
+        return
+    } else if kind == reflect.Ptr {
+        var paramNullable,ok = param.(MappedNullable)
+        if ok {
+            dataMap,err := paramNullable.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+    }
 
-	// primitive value
-	parameterAddToHolder(queryParams, keyPrefix, param)
+    // primitive value
+    parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
@@ -393,7 +438,11 @@ func (c *APIClient) prepareRequest(
 	}
 
 	// Encode the parameters.
-	url.RawQuery = query.Encode()
+    url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
+        pieces := strings.Split(s, "=")
+        pieces[0] = queryDescape.Replace(pieces[0])
+        return strings.Join(pieces, "=")
+    })
 
 	// Generate a new request
 	if body != nil {
diff --git a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index 4c7ed5960e1..ddf93a6bb06 100644
--- a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -842,7 +842,7 @@ paths:
         '5XX':
           description: Someting wrong
           content:
-            'applicatino/json':
+            'application/json':
               schema:
                 $ref: '#/components/schemas/OuterNumber'
   /fake/outer/number:
@@ -1155,6 +1155,29 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/HealthCheckResult'
+  /fake/deep_object_test:
+    get:
+      tags:
+        - fake
+      operationId: test_query_deep_object
+      parameters:
+        - name: test_pet
+          in: query
+          required: false
+          style: deepObject
+          schema:
+            $ref: '#/components/schemas/Pet'
+          explode: true
+        - name: inputOptions
+          in: query
+          required: false
+          style: deepObject
+          schema:
+            $ref: '#/components/schemas/Category'
+          explode: true
+      responses:
+        '200':
+          description: OK
 servers:
   - url: 'http://{server}.swagger.io:{port}/v2'
     description: petstore server
diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go
index 9b4638f48fe..989b686bc36 100644
--- a/samples/client/petstore/go/go-petstore/client.go
+++ b/samples/client/petstore/go/go-petstore/client.go
@@ -39,6 +39,8 @@ import (
 var (
 	jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
 	xmlCheck  = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
+    queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
+    queryDescape    = strings.NewReplacer( "%5B", "[", "%5D", "]" )
 )
 
 // APIClient manages communication with the OpenAPI Petstore API v1.0.0
@@ -155,101 +157,144 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
+
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
-	switch valuesMap := queryParams.(type) {
-	case url.Values:
-		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
-		break
-	case map[string]string:
-		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
-		break
-	}
+    var v = reflect.ValueOf(obj)
+    var value = ""
+    if v == reflect.ValueOf(nil) {
+        value = "nil"
+    } else {
+        switch v.Kind() {
+			case reflect.Invalid:
+				value = "invalid"
+
+			case reflect.Struct:
+				var param,ok = obj.(MappedNullable)
+				if ok {
+					dataMap,err := param.ToMap()
+					if err != nil {
+						return
+					}
+					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					return
+				}
+				value = v.Type().String() + " value"
+			case reflect.Interface:
+				fallthrough
+            case reflect.Ptr:
+                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+                return
+
+            case reflect.Int, reflect.Int8, reflect.Int16,
+                reflect.Int32, reflect.Int64:
+                value = strconv.FormatInt(v.Int(), 10)
+            case reflect.Uint, reflect.Uint8, reflect.Uint16,
+                reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+                value = strconv.FormatUint(v.Uint(), 10)
+            case reflect.Float32, reflect.Float64:
+                value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
+            case reflect.Bool:
+                value = strconv.FormatBool(v.Bool())
+            case reflect.String:
+                value = v.String()
+            default:
+                value = v.Type().String() + " value"
+        }
+    }
+
+    switch valuesMap := queryParams.(type) {
+        case url.Values:
+            valuesMap.Add( keyPrefix, value )
+            break
+        case map[string]string:
+            valuesMap[keyPrefix] = value
+            break
+    }
 }
 
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		var indValue = reflect.ValueOf(obj)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-		}
-		return
-
-	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-		var param,ok = obj.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-		// scenario of pointer-to-slice
-		var pointed = reflect.ValueOf(obj).Elem()
-		var pointedValue = pointed.Interface()
-		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-		return
-
-	} else if t, ok := obj.(time.Time); ok {
-		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-		return
-	}
+    if reflect.TypeOf(obj).Kind() == reflect.Slice {
+        var indValue = reflect.ValueOf(obj)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
+        }
+        return
+
+    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+        var param,ok = obj.(MappedNullable)
+        if ok {
+            dataMap,err := param.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+        // scenario of pointer indirect value
+        var pointed = reflect.ValueOf(obj).Elem()
+        var pointedValue = pointed.Interface()
+        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+        return
+
+    } else if t, ok := obj.(time.Time); ok {
+        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
+        return
+    }
 
-	// other value
-	parameterAddToHolder(queryParams, keyPrefix, obj)
+    // other value
+    parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
 func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-	if param == nil {
-		return
-	}
-	var kind = reflect.TypeOf(param).Kind()
-	if kind == reflect.Slice {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-		}
-		return
-
-	} else if kind == reflect.Map {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		
-		iter := indValue.MapRange()
-		for iter.Next() {
-			k,v := iter.Key(), iter.Value()
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-		}
-		return
-	} else if kind == reflect.Ptr {
-		var param,ok = param.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-	}
+    if param == nil {
+        return
+    }
+    var kind = reflect.TypeOf(param).Kind()
+    if kind == reflect.Slice {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+        }
+        return
+
+    } else if kind == reflect.Map {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        iter := indValue.MapRange()
+        for iter.Next() {
+            k,v := iter.Key(), iter.Value()
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+        }
+        return
+    } else if kind == reflect.Ptr {
+        var paramNullable,ok = param.(MappedNullable)
+        if ok {
+            dataMap,err := paramNullable.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+    }
 
-	// primitive value
-	parameterAddToHolder(queryParams, keyPrefix, param)
+    // primitive value
+    parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
@@ -401,7 +446,11 @@ func (c *APIClient) prepareRequest(
 	}
 
 	// Encode the parameters.
-	url.RawQuery = query.Encode()
+    url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
+        pieces := strings.Split(s, "=")
+        pieces[0] = queryDescape.Replace(pieces[0])
+        return strings.Join(pieces, "=")
+    })
 
 	// Generate a new request
 	if body != nil {
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
index d02a410f5f3..95529171bc1 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
@@ -39,6 +39,8 @@ import (
 var (
 	jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
 	xmlCheck  = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
+    queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
+    queryDescape    = strings.NewReplacer( "%5B", "[", "%5D", "]" )
 )
 
 // APIClient manages communication with the OpenAPI Extension x-auth-id-alias API v1.0.0
@@ -140,101 +142,144 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
+
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
-	switch valuesMap := queryParams.(type) {
-	case url.Values:
-		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
-		break
-	case map[string]string:
-		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
-		break
-	}
+    var v = reflect.ValueOf(obj)
+    var value = ""
+    if v == reflect.ValueOf(nil) {
+        value = "nil"
+    } else {
+        switch v.Kind() {
+			case reflect.Invalid:
+				value = "invalid"
+
+			case reflect.Struct:
+				var param,ok = obj.(MappedNullable)
+				if ok {
+					dataMap,err := param.ToMap()
+					if err != nil {
+						return
+					}
+					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					return
+				}
+				value = v.Type().String() + " value"
+			case reflect.Interface:
+				fallthrough
+            case reflect.Ptr:
+                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+                return
+
+            case reflect.Int, reflect.Int8, reflect.Int16,
+                reflect.Int32, reflect.Int64:
+                value = strconv.FormatInt(v.Int(), 10)
+            case reflect.Uint, reflect.Uint8, reflect.Uint16,
+                reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+                value = strconv.FormatUint(v.Uint(), 10)
+            case reflect.Float32, reflect.Float64:
+                value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
+            case reflect.Bool:
+                value = strconv.FormatBool(v.Bool())
+            case reflect.String:
+                value = v.String()
+            default:
+                value = v.Type().String() + " value"
+        }
+    }
+
+    switch valuesMap := queryParams.(type) {
+        case url.Values:
+            valuesMap.Add( keyPrefix, value )
+            break
+        case map[string]string:
+            valuesMap[keyPrefix] = value
+            break
+    }
 }
 
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		var indValue = reflect.ValueOf(obj)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-		}
-		return
-
-	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-		var param,ok = obj.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-		// scenario of pointer-to-slice
-		var pointed = reflect.ValueOf(obj).Elem()
-		var pointedValue = pointed.Interface()
-		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-		return
-
-	} else if t, ok := obj.(time.Time); ok {
-		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-		return
-	}
+    if reflect.TypeOf(obj).Kind() == reflect.Slice {
+        var indValue = reflect.ValueOf(obj)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
+        }
+        return
+
+    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+        var param,ok = obj.(MappedNullable)
+        if ok {
+            dataMap,err := param.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+        // scenario of pointer indirect value
+        var pointed = reflect.ValueOf(obj).Elem()
+        var pointedValue = pointed.Interface()
+        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+        return
+
+    } else if t, ok := obj.(time.Time); ok {
+        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
+        return
+    }
 
-	// other value
-	parameterAddToHolder(queryParams, keyPrefix, obj)
+    // other value
+    parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
 func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-	if param == nil {
-		return
-	}
-	var kind = reflect.TypeOf(param).Kind()
-	if kind == reflect.Slice {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-		}
-		return
-
-	} else if kind == reflect.Map {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		
-		iter := indValue.MapRange()
-		for iter.Next() {
-			k,v := iter.Key(), iter.Value()
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-		}
-		return
-	} else if kind == reflect.Ptr {
-		var param,ok = param.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-	}
+    if param == nil {
+        return
+    }
+    var kind = reflect.TypeOf(param).Kind()
+    if kind == reflect.Slice {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+        }
+        return
+
+    } else if kind == reflect.Map {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        iter := indValue.MapRange()
+        for iter.Next() {
+            k,v := iter.Key(), iter.Value()
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+        }
+        return
+    } else if kind == reflect.Ptr {
+        var paramNullable,ok = param.(MappedNullable)
+        if ok {
+            dataMap,err := paramNullable.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+    }
 
-	// primitive value
-	parameterAddToHolder(queryParams, keyPrefix, param)
+    // primitive value
+    parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
@@ -386,7 +431,11 @@ func (c *APIClient) prepareRequest(
 	}
 
 	// Encode the parameters.
-	url.RawQuery = query.Encode()
+    url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
+        pieces := strings.Split(s, "=")
+        pieces[0] = queryDescape.Replace(pieces[0])
+        return strings.Join(pieces, "=")
+    })
 
 	// Generate a new request
 	if body != nil {
diff --git a/samples/openapi3/client/petstore/go/fake_api_test.go b/samples/openapi3/client/petstore/go/fake_api_test.go
index b25af45ee6c..1aaedf1128a 100644
--- a/samples/openapi3/client/petstore/go/fake_api_test.go
+++ b/samples/openapi3/client/petstore/go/fake_api_test.go
@@ -2,6 +2,7 @@ package main
 
 import (
 	"context"
+	"github.com/stretchr/testify/assert"
 	"testing"
 
 	sw "go-petstore"
@@ -26,3 +27,48 @@ func TestPutBodyWithFileSchema(t *testing.T) {
 		t.Log(r)
 	}
 }
+
+func TestQueryDeepObject(t *testing.T) {
+	req := client.FakeApi.TestQueryDeepObject(context.Background())
+
+	var id = int64(1)
+	var idTag1 = int64(2)
+	var nameTag1 = "tag1"
+	req = req.TestPet(sw.Pet{
+		Id: &id,
+		Name: "Test",
+		PhotoUrls: []string{ "http://localhost" },
+		Tags: []sw.Tag{
+			{
+				Id: &idTag1,
+				Name: &nameTag1,
+				AdditionalProperties: map[string]interface{}{
+					"F1": 1,
+					"F2": "teststring",
+					"F3": nil,
+				},
+			},
+		},
+		AdditionalProperties: map[string]interface{}{
+			"F1": 1,
+			"F2": "teststring",
+			"F3": nil,
+		},
+	})
+	var idcat = int64(1)
+	req = req.InputOptions(sw.Category{
+		Id: &idcat,
+		Name: "TestCat",
+		AdditionalProperties: map[string]interface{}{
+			"F1": 1,
+			"F2": "teststring",
+			"F3": nil,
+		},
+	})
+
+	r, _ := req.Execute()
+
+	assert.Equal(t,
+		"https://petstore.swagger.io:443/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls][0]=http%3A%2F%2Flocalhost&test_pet[tags][0][F1]=1&test_pet[tags][0][F2]=teststring&test_pet[tags][0][id]=2&test_pet[tags][0][name]=tag1",
+		r.Request.URL.String() )
+}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/README.md b/samples/openapi3/client/petstore/go/go-petstore/README.md
index 3d7dd74d300..59c5053315f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/README.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/README.md
@@ -93,6 +93,7 @@ Class | Method | HTTP request | Description
 *FakeApi* | [**TestGroupParameters**](docs/FakeApi.md#testgroupparameters) | **Delete** /fake | Fake endpoint to test group parameters (optional)
 *FakeApi* | [**TestInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties
 *FakeApi* | [**TestJsonFormData**](docs/FakeApi.md#testjsonformdata) | **Get** /fake/jsonFormData | test json serialization of form data
+*FakeApi* | [**TestQueryDeepObject**](docs/FakeApi.md#testquerydeepobject) | **Get** /fake/deep_object_test | 
 *FakeApi* | [**TestQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **Put** /fake/test-query-parameters | 
 *FakeApi* | [**TestUniqueItemsHeaderAndQueryParameterCollectionFormat**](docs/FakeApi.md#testuniqueitemsheaderandqueryparametercollectionformat) | **Put** /fake/test-unique-parameters | 
 *FakeClassnameTags123Api* | [**TestClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **Patch** /fake_classname_test | To test class name in snake case
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml
index 71097efe090..49cf608e47b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml
+++ b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml
@@ -669,7 +669,7 @@ paths:
           description: Someting wrong
         "5XX":
           content:
-            applicatino/json:
+            application/json:
               schema:
                 $ref: '#/components/schemas/OuterNumber'
           description: Someting wrong
@@ -1116,6 +1116,29 @@ paths:
       summary: Health check endpoint
       tags:
       - fake
+  /fake/deep_object_test:
+    get:
+      operationId: test_query_deep_object
+      parameters:
+      - explode: true
+        in: query
+        name: test_pet
+        required: false
+        schema:
+          $ref: '#/components/schemas/Pet'
+        style: deepObject
+      - explode: true
+        in: query
+        name: inputOptions
+        required: false
+        schema:
+          $ref: '#/components/schemas/Category'
+        style: deepObject
+      responses:
+        "200":
+          description: OK
+      tags:
+      - fake
 components:
   requestBodies:
     UserArray:
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
index 8828752193a..633bb2d9abb 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
@@ -199,6 +199,17 @@ type FakeApi interface {
 	// TestJsonFormDataExecute executes the request
 	TestJsonFormDataExecute(r ApiTestJsonFormDataRequest) (*http.Response, error)
 
+	/*
+	TestQueryDeepObject Method for TestQueryDeepObject
+
+	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
+	@return ApiTestQueryDeepObjectRequest
+	*/
+	TestQueryDeepObject(ctx context.Context) ApiTestQueryDeepObjectRequest
+
+	// TestQueryDeepObjectExecute executes the request
+	TestQueryDeepObjectExecute(r ApiTestQueryDeepObjectRequest) (*http.Response, error)
+
 	/*
 	TestQueryParameterCollectionFormat Method for TestQueryParameterCollectionFormat
 
@@ -1626,7 +1637,7 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	}
 
 	// to determine the Accept header
-	localVarHTTPHeaderAccepts := []string{"applicatino/json"}
+	localVarHTTPHeaderAccepts := []string{"application/json"}
 
 	// set Accept header
 	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
@@ -1885,6 +1896,110 @@ func (a *FakeApiService) TestJsonFormDataExecute(r ApiTestJsonFormDataRequest) (
 	return localVarHTTPResponse, nil
 }
 
+type ApiTestQueryDeepObjectRequest struct {
+	ctx context.Context
+	ApiService FakeApi
+	testPet *Pet
+	inputOptions *Category
+}
+
+func (r ApiTestQueryDeepObjectRequest) TestPet(testPet Pet) ApiTestQueryDeepObjectRequest {
+	r.testPet = &testPet
+	return r
+}
+
+func (r ApiTestQueryDeepObjectRequest) InputOptions(inputOptions Category) ApiTestQueryDeepObjectRequest {
+	r.inputOptions = &inputOptions
+	return r
+}
+
+func (r ApiTestQueryDeepObjectRequest) Execute() (*http.Response, error) {
+	return r.ApiService.TestQueryDeepObjectExecute(r)
+}
+
+/*
+TestQueryDeepObject Method for TestQueryDeepObject
+
+ @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
+ @return ApiTestQueryDeepObjectRequest
+*/
+func (a *FakeApiService) TestQueryDeepObject(ctx context.Context) ApiTestQueryDeepObjectRequest {
+	return ApiTestQueryDeepObjectRequest{
+		ApiService: a,
+		ctx: ctx,
+	}
+}
+
+// Execute executes the request
+func (a *FakeApiService) TestQueryDeepObjectExecute(r ApiTestQueryDeepObjectRequest) (*http.Response, error) {
+	var (
+		localVarHTTPMethod   = http.MethodGet
+		localVarPostBody     interface{}
+		formFiles            []formFile
+	)
+
+	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FakeApiService.TestQueryDeepObject")
+	if err != nil {
+		return nil, &GenericOpenAPIError{error: err.Error()}
+	}
+
+	localVarPath := localBasePath + "/fake/deep_object_test"
+
+	localVarHeaderParams := make(map[string]string)
+	localVarQueryParams := url.Values{}
+	localVarFormParams := url.Values{}
+
+	if r.testPet != nil {
+	parameterAddToQuery(localVarQueryParams, "test_pet", r.testPet, "")
+	}
+	if r.inputOptions != nil {
+	parameterAddToQuery(localVarQueryParams, "inputOptions", r.inputOptions, "")
+	}
+	// to determine the Content-Type header
+	localVarHTTPContentTypes := []string{}
+
+	// set Content-Type header
+	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
+	if localVarHTTPContentType != "" {
+		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
+	}
+
+	// to determine the Accept header
+	localVarHTTPHeaderAccepts := []string{}
+
+	// set Accept header
+	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
+	if localVarHTTPHeaderAccept != "" {
+		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
+	}
+	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
+	if err != nil {
+		return nil, err
+	}
+
+	localVarHTTPResponse, err := a.client.callAPI(req)
+	if err != nil || localVarHTTPResponse == nil {
+		return localVarHTTPResponse, err
+	}
+
+	localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
+	localVarHTTPResponse.Body.Close()
+	localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
+	if err != nil {
+		return localVarHTTPResponse, err
+	}
+
+	if localVarHTTPResponse.StatusCode >= 300 {
+		newErr := &GenericOpenAPIError{
+			body:  localVarBody,
+			error: localVarHTTPResponse.Status,
+		}
+		return localVarHTTPResponse, newErr
+	}
+
+	return localVarHTTPResponse, nil
+}
+
 type ApiTestQueryParameterCollectionFormatRequest struct {
 	ctx context.Context
 	ApiService FakeApi
diff --git a/samples/openapi3/client/petstore/go/go-petstore/client.go b/samples/openapi3/client/petstore/go/go-petstore/client.go
index 3183211ebbf..696438c565a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/client.go
@@ -39,6 +39,8 @@ import (
 var (
 	jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
 	xmlCheck  = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
+    queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
+    queryDescape    = strings.NewReplacer( "%5B", "[", "%5D", "]" )
 )
 
 // APIClient manages communication with the OpenAPI Petstore API v1.0.0
@@ -158,101 +160,144 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
+
 func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
-	switch valuesMap := queryParams.(type) {
-	case url.Values:
-		valuesMap.Add( keyPrefix, fmt.Sprintf("%v", obj) )
-		break
-	case map[string]string:
-		valuesMap[keyPrefix] = fmt.Sprintf("%v", obj)
-		break
-	}
+    var v = reflect.ValueOf(obj)
+    var value = ""
+    if v == reflect.ValueOf(nil) {
+        value = "nil"
+    } else {
+        switch v.Kind() {
+			case reflect.Invalid:
+				value = "invalid"
+
+			case reflect.Struct:
+				var param,ok = obj.(MappedNullable)
+				if ok {
+					dataMap,err := param.ToMap()
+					if err != nil {
+						return
+					}
+					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					return
+				}
+				value = v.Type().String() + " value"
+			case reflect.Interface:
+				fallthrough
+            case reflect.Ptr:
+                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+                return
+
+            case reflect.Int, reflect.Int8, reflect.Int16,
+                reflect.Int32, reflect.Int64:
+                value = strconv.FormatInt(v.Int(), 10)
+            case reflect.Uint, reflect.Uint8, reflect.Uint16,
+                reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+                value = strconv.FormatUint(v.Uint(), 10)
+            case reflect.Float32, reflect.Float64:
+                value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
+            case reflect.Bool:
+                value = strconv.FormatBool(v.Bool())
+            case reflect.String:
+                value = v.String()
+            default:
+                value = v.Type().String() + " value"
+        }
+    }
+
+    switch valuesMap := queryParams.(type) {
+        case url.Values:
+            valuesMap.Add( keyPrefix, value )
+            break
+        case map[string]string:
+            valuesMap[keyPrefix] = value
+            break
+    }
 }
 
 // parameterAddToQuery adds the provided object to the url query supporting deep object specification
 // the del delimiter is used to the split the value as list
 func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-	if reflect.TypeOf(obj).Kind() == reflect.Slice {
-		var indValue = reflect.ValueOf(obj)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-		}
-		return
-
-	} else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-		var param,ok = obj.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-		// scenario of pointer-to-slice
-		var pointed = reflect.ValueOf(obj).Elem()
-		var pointedValue = pointed.Interface()
-		parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-		return
-
-	} else if t, ok := obj.(time.Time); ok {
-		parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-		return
-	}
+    if reflect.TypeOf(obj).Kind() == reflect.Slice {
+        var indValue = reflect.ValueOf(obj)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
+        }
+        return
+
+    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
+        var param,ok = obj.(MappedNullable)
+        if ok {
+            dataMap,err := param.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+        // scenario of pointer indirect value
+        var pointed = reflect.ValueOf(obj).Elem()
+        var pointedValue = pointed.Interface()
+        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
+        return
+
+    } else if t, ok := obj.(time.Time); ok {
+        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
+        return
+    }
 
-	// other value
-	parameterAddToHolder(queryParams, keyPrefix, obj)
+    // other value
+    parameterAddToHolder(queryParams, keyPrefix, obj)
 }
 
 // parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
 func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-	if param == nil {
-		return
-	}
-	var kind = reflect.TypeOf(param).Kind()
-	if kind == reflect.Slice {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		var lenIndValue = indValue.Len()
-		for i:=0;i<lenIndValue;i++ {
-			var arrayValue = indValue.Index(i)
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-		}
-		return
-
-	} else if kind == reflect.Map {
-		var indValue = reflect.ValueOf(param)
-		if indValue == reflect.ValueOf(nil) {
-			return
-		}
-		
-		iter := indValue.MapRange()
-		for iter.Next() {
-			k,v := iter.Key(), iter.Value()
-			parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-		}
-		return
-	} else if kind == reflect.Ptr {
-		var param,ok = param.(MappedNullable)
-		if ok {
-			dataMap,err := param.ToMap()
-			if err != nil {
-				return
-			}
-			parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-			return
-		}
-	}
+    if param == nil {
+        return
+    }
+    var kind = reflect.TypeOf(param).Kind()
+    if kind == reflect.Slice {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        var lenIndValue = indValue.Len()
+        for i:=0;i<lenIndValue;i++ {
+            var arrayValue = indValue.Index(i)
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
+        }
+        return
+
+    } else if kind == reflect.Map {
+        var indValue = reflect.ValueOf(param)
+        if indValue == reflect.ValueOf(nil) {
+            return
+        }
+        iter := indValue.MapRange()
+        for iter.Next() {
+            k,v := iter.Key(), iter.Value()
+            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
+        }
+        return
+    } else if kind == reflect.Ptr {
+        var paramNullable,ok = param.(MappedNullable)
+        if ok {
+            dataMap,err := paramNullable.ToMap()
+            if err != nil {
+                return
+            }
+            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+            return
+        }
+    }
 
-	// primitive value
-	parameterAddToHolder(queryParams, keyPrefix, param)
+    // primitive value
+    parameterAddToHolder(queryParams, keyPrefix, param)
 }
 
 // helper for converting interface{} parameters to json strings
@@ -404,7 +449,11 @@ func (c *APIClient) prepareRequest(
 	}
 
 	// Encode the parameters.
-	url.RawQuery = query.Encode()
+    url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
+        pieces := strings.Split(s, "=")
+        pieces[0] = queryDescape.Replace(pieces[0])
+        return strings.Join(pieces, "=")
+    })
 
 	// Generate a new request
 	if body != nil {
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 b7f7f5b0b1b..7f9d080e73e 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
@@ -17,6 +17,7 @@ Method | HTTP request | Description
 [**TestGroupParameters**](FakeApi.md#TestGroupParameters) | **Delete** /fake | Fake endpoint to test group parameters (optional)
 [**TestInlineAdditionalProperties**](FakeApi.md#TestInlineAdditionalProperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties
 [**TestJsonFormData**](FakeApi.md#TestJsonFormData) | **Get** /fake/jsonFormData | test json serialization of form data
+[**TestQueryDeepObject**](FakeApi.md#TestQueryDeepObject) | **Get** /fake/deep_object_test | 
 [**TestQueryParameterCollectionFormat**](FakeApi.md#TestQueryParameterCollectionFormat) | **Put** /fake/test-query-parameters | 
 [**TestUniqueItemsHeaderAndQueryParameterCollectionFormat**](FakeApi.md#TestUniqueItemsHeaderAndQueryParameterCollectionFormat) | **Put** /fake/test-unique-parameters | 
 
@@ -775,7 +776,7 @@ Name | Type | Description  | Notes
 ### HTTP request headers
 
 - **Content-Type**: Not defined
-- **Accept**: applicatino/json
+- **Accept**: application/json
 
 [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
 [[Back to Model list]](../README.md#documentation-for-models)
@@ -912,6 +913,70 @@ No authorization required
 [[Back to README]](../README.md)
 
 
+## TestQueryDeepObject
+
+> TestQueryDeepObject(ctx).TestPet(testPet).InputOptions(inputOptions).Execute()
+
+
+
+### Example
+
+```go
+package main
+
+import (
+    "context"
+    "fmt"
+    "os"
+    openapiclient "./openapi"
+)
+
+func main() {
+    testPet := map[string][]openapiclient.Pet{"key": map[string]interface{}{ ... }} // Pet |  (optional)
+    inputOptions := map[string][]openapiclient.Category{"key": map[string]interface{}{ ... }} // Category |  (optional)
+
+    configuration := openapiclient.NewConfiguration()
+    apiClient := openapiclient.NewAPIClient(configuration)
+    resp, r, err := apiClient.FakeApi.TestQueryDeepObject(context.Background()).TestPet(testPet).InputOptions(inputOptions).Execute()
+    if err != nil {
+        fmt.Fprintf(os.Stderr, "Error when calling `FakeApi.TestQueryDeepObject``: %v\n", err)
+        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
+    }
+}
+```
+
+### Path Parameters
+
+
+
+### Other Parameters
+
+Other parameters are passed through a pointer to a apiTestQueryDeepObjectRequest struct via the builder pattern
+
+
+Name | Type | Description  | Notes
+------------- | ------------- | ------------- | -------------
+ **testPet** | [**Pet**](Pet.md) |  | 
+ **inputOptions** | [**Category**](Category.md) |  | 
+
+### Return type
+
+ (empty response body)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+- **Content-Type**: Not defined
+- **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
+[[Back to Model list]](../README.md#documentation-for-models)
+[[Back to README]](../README.md)
+
+
 ## TestQueryParameterCollectionFormat
 
 > TestQueryParameterCollectionFormat(ctx).Pipe(pipe).Ioutil(ioutil).Http(http).Url(url).Context(context).Execute()
-- 
GitLab


From 3f614fedd508f8cc6c592ebf7a1540d4989a4ec6 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Tue, 1 Nov 2022 17:46:32 -0400
Subject: [PATCH 10/15] simplified routine

---
 .../src/main/resources/go/client.mustache     | 128 +++++-------------
 .../client/petstore/go/go-petstore/client.go  | 128 +++++-------------
 .../x-auth-id-alias/go-experimental/client.go | 128 +++++-------------
 .../client/petstore/go/fake_api_test.go       |   2 +-
 .../client/petstore/go/go-petstore/client.go  | 128 +++++-------------
 5 files changed, 141 insertions(+), 373 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index d9d175916a8..7ed2379281b 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -149,32 +149,59 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
-
-func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+// parameterAddToQuery adds the provided object to the url query supporting deep object syntax
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
     var v = reflect.ValueOf(obj)
     var value = ""
     if v == reflect.ValueOf(nil) {
-        value = "nil"
+        value = "null"
     } else {
         switch v.Kind() {
 			case reflect.Invalid:
 				value = "invalid"
 
 			case reflect.Struct:
-				var param,ok = obj.(MappedNullable)
-				if ok {
-					dataMap,err := param.ToMap()
+				if t,ok := obj.(MappedNullable); ok {
+					dataMap,err := t.ToMap()
 					if err != nil {
 						return
 					}
-					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					parameterAddToQuery(queryParams, keyPrefix, dataMap, collectionType)
+					return
+				}
+				if t, ok := obj.(time.Time); ok {
+					parameterAddToQuery(queryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
 					return
 				}
 				value = v.Type().String() + " value"
+			case reflect.Slice:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				var lenIndValue = indValue.Len()
+				for i:=0;i<lenIndValue;i++ {
+					var arrayValue = indValue.Index(i)
+					parameterAddToQuery(queryParams, keyPrefix, arrayValue.Interface(), collectionType)
+				}
+				return
+
+			case reflect.Map:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				iter := indValue.MapRange()
+				for iter.Next() {
+					k,v := iter.Key(), iter.Value()
+					parameterAddToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
+				}
+				return
+
 			case reflect.Interface:
 				fallthrough
             case reflect.Ptr:
-                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+				parameterAddToQuery(queryParams, keyPrefix, v.Elem().Interface(), collectionType)
                 return
 
             case reflect.Int, reflect.Int8, reflect.Int16,
@@ -204,91 +231,6 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
     }
 }
 
-// parameterAddToQuery adds the provided object to the url query supporting deep object specification
-// the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-    if reflect.TypeOf(obj).Kind() == reflect.Slice {
-        var indValue = reflect.ValueOf(obj)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-        }
-        return
-
-    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-        var param,ok = obj.(MappedNullable)
-        if ok {
-            dataMap,err := param.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-        // scenario of pointer indirect value
-        var pointed = reflect.ValueOf(obj).Elem()
-        var pointedValue = pointed.Interface()
-        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-        return
-
-    } else if t, ok := obj.(time.Time); ok {
-        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-        return
-    }
-
-    // other value
-    parameterAddToHolder(queryParams, keyPrefix, obj)
-}
-
-// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-    if param == nil {
-        return
-    }
-    var kind = reflect.TypeOf(param).Kind()
-    if kind == reflect.Slice {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-        }
-        return
-
-    } else if kind == reflect.Map {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        iter := indValue.MapRange()
-        for iter.Next() {
-            k,v := iter.Key(), iter.Value()
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-        }
-        return
-    } else if kind == reflect.Ptr {
-        var paramNullable,ok = param.(MappedNullable)
-        if ok {
-            dataMap,err := paramNullable.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-    }
-
-    // primitive value
-    parameterAddToHolder(queryParams, keyPrefix, param)
-}
-
 // helper for converting interface{} parameters to json strings
 func parameterToJson(obj interface{}) (string, error) {
 	jsonBuf, err := json.Marshal(obj)
diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go
index 989b686bc36..98151a80bfa 100644
--- a/samples/client/petstore/go/go-petstore/client.go
+++ b/samples/client/petstore/go/go-petstore/client.go
@@ -157,32 +157,59 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
-
-func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+// parameterAddToQuery adds the provided object to the url query supporting deep object syntax
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
     var v = reflect.ValueOf(obj)
     var value = ""
     if v == reflect.ValueOf(nil) {
-        value = "nil"
+        value = "null"
     } else {
         switch v.Kind() {
 			case reflect.Invalid:
 				value = "invalid"
 
 			case reflect.Struct:
-				var param,ok = obj.(MappedNullable)
-				if ok {
-					dataMap,err := param.ToMap()
+				if t,ok := obj.(MappedNullable); ok {
+					dataMap,err := t.ToMap()
 					if err != nil {
 						return
 					}
-					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					parameterAddToQuery(queryParams, keyPrefix, dataMap, collectionType)
+					return
+				}
+				if t, ok := obj.(time.Time); ok {
+					parameterAddToQuery(queryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
 					return
 				}
 				value = v.Type().String() + " value"
+			case reflect.Slice:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				var lenIndValue = indValue.Len()
+				for i:=0;i<lenIndValue;i++ {
+					var arrayValue = indValue.Index(i)
+					parameterAddToQuery(queryParams, keyPrefix, arrayValue.Interface(), collectionType)
+				}
+				return
+
+			case reflect.Map:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				iter := indValue.MapRange()
+				for iter.Next() {
+					k,v := iter.Key(), iter.Value()
+					parameterAddToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
+				}
+				return
+
 			case reflect.Interface:
 				fallthrough
             case reflect.Ptr:
-                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+				parameterAddToQuery(queryParams, keyPrefix, v.Elem().Interface(), collectionType)
                 return
 
             case reflect.Int, reflect.Int8, reflect.Int16,
@@ -212,91 +239,6 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
     }
 }
 
-// parameterAddToQuery adds the provided object to the url query supporting deep object specification
-// the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-    if reflect.TypeOf(obj).Kind() == reflect.Slice {
-        var indValue = reflect.ValueOf(obj)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-        }
-        return
-
-    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-        var param,ok = obj.(MappedNullable)
-        if ok {
-            dataMap,err := param.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-        // scenario of pointer indirect value
-        var pointed = reflect.ValueOf(obj).Elem()
-        var pointedValue = pointed.Interface()
-        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-        return
-
-    } else if t, ok := obj.(time.Time); ok {
-        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-        return
-    }
-
-    // other value
-    parameterAddToHolder(queryParams, keyPrefix, obj)
-}
-
-// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-    if param == nil {
-        return
-    }
-    var kind = reflect.TypeOf(param).Kind()
-    if kind == reflect.Slice {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-        }
-        return
-
-    } else if kind == reflect.Map {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        iter := indValue.MapRange()
-        for iter.Next() {
-            k,v := iter.Key(), iter.Value()
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-        }
-        return
-    } else if kind == reflect.Ptr {
-        var paramNullable,ok = param.(MappedNullable)
-        if ok {
-            dataMap,err := paramNullable.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-    }
-
-    // primitive value
-    parameterAddToHolder(queryParams, keyPrefix, param)
-}
-
 // helper for converting interface{} parameters to json strings
 func parameterToJson(obj interface{}) (string, error) {
 	jsonBuf, err := json.Marshal(obj)
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
index 95529171bc1..7870e8649cc 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
@@ -142,32 +142,59 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
-
-func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+// parameterAddToQuery adds the provided object to the url query supporting deep object syntax
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
     var v = reflect.ValueOf(obj)
     var value = ""
     if v == reflect.ValueOf(nil) {
-        value = "nil"
+        value = "null"
     } else {
         switch v.Kind() {
 			case reflect.Invalid:
 				value = "invalid"
 
 			case reflect.Struct:
-				var param,ok = obj.(MappedNullable)
-				if ok {
-					dataMap,err := param.ToMap()
+				if t,ok := obj.(MappedNullable); ok {
+					dataMap,err := t.ToMap()
 					if err != nil {
 						return
 					}
-					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					parameterAddToQuery(queryParams, keyPrefix, dataMap, collectionType)
+					return
+				}
+				if t, ok := obj.(time.Time); ok {
+					parameterAddToQuery(queryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
 					return
 				}
 				value = v.Type().String() + " value"
+			case reflect.Slice:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				var lenIndValue = indValue.Len()
+				for i:=0;i<lenIndValue;i++ {
+					var arrayValue = indValue.Index(i)
+					parameterAddToQuery(queryParams, keyPrefix, arrayValue.Interface(), collectionType)
+				}
+				return
+
+			case reflect.Map:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				iter := indValue.MapRange()
+				for iter.Next() {
+					k,v := iter.Key(), iter.Value()
+					parameterAddToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
+				}
+				return
+
 			case reflect.Interface:
 				fallthrough
             case reflect.Ptr:
-                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+				parameterAddToQuery(queryParams, keyPrefix, v.Elem().Interface(), collectionType)
                 return
 
             case reflect.Int, reflect.Int8, reflect.Int16,
@@ -197,91 +224,6 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
     }
 }
 
-// parameterAddToQuery adds the provided object to the url query supporting deep object specification
-// the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-    if reflect.TypeOf(obj).Kind() == reflect.Slice {
-        var indValue = reflect.ValueOf(obj)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-        }
-        return
-
-    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-        var param,ok = obj.(MappedNullable)
-        if ok {
-            dataMap,err := param.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-        // scenario of pointer indirect value
-        var pointed = reflect.ValueOf(obj).Elem()
-        var pointedValue = pointed.Interface()
-        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-        return
-
-    } else if t, ok := obj.(time.Time); ok {
-        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-        return
-    }
-
-    // other value
-    parameterAddToHolder(queryParams, keyPrefix, obj)
-}
-
-// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-    if param == nil {
-        return
-    }
-    var kind = reflect.TypeOf(param).Kind()
-    if kind == reflect.Slice {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-        }
-        return
-
-    } else if kind == reflect.Map {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        iter := indValue.MapRange()
-        for iter.Next() {
-            k,v := iter.Key(), iter.Value()
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-        }
-        return
-    } else if kind == reflect.Ptr {
-        var paramNullable,ok = param.(MappedNullable)
-        if ok {
-            dataMap,err := paramNullable.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-    }
-
-    // primitive value
-    parameterAddToHolder(queryParams, keyPrefix, param)
-}
-
 // helper for converting interface{} parameters to json strings
 func parameterToJson(obj interface{}) (string, error) {
 	jsonBuf, err := json.Marshal(obj)
diff --git a/samples/openapi3/client/petstore/go/fake_api_test.go b/samples/openapi3/client/petstore/go/fake_api_test.go
index 1aaedf1128a..e605ac32ff8 100644
--- a/samples/openapi3/client/petstore/go/fake_api_test.go
+++ b/samples/openapi3/client/petstore/go/fake_api_test.go
@@ -69,6 +69,6 @@ func TestQueryDeepObject(t *testing.T) {
 	r, _ := req.Execute()
 
 	assert.Equal(t,
-		"https://petstore.swagger.io:443/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls][0]=http%3A%2F%2Flocalhost&test_pet[tags][0][F1]=1&test_pet[tags][0][F2]=teststring&test_pet[tags][0][id]=2&test_pet[tags][0][name]=tag1",
+		"https://petstore.swagger.io:443/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[F3]=null&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[F3]=null&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls]=http%3A%2F%2Flocalhost&test_pet[tags][F1]=1&test_pet[tags][F2]=teststring&test_pet[tags][F3]=null&test_pet[tags][id]=2&test_pet[tags][name]=tag1",
 		r.Request.URL.String() )
 }
diff --git a/samples/openapi3/client/petstore/go/go-petstore/client.go b/samples/openapi3/client/petstore/go/go-petstore/client.go
index 696438c565a..3bfa75528a9 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/client.go
@@ -160,32 +160,59 @@ func parameterValueToString( obj interface{}, key string ) string {
     return fmt.Sprintf("%v", dataMap[key])
 }
 
-
-func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interface{}) {
+// parameterAddToQuery adds the provided object to the url query supporting deep object syntax
+func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
     var v = reflect.ValueOf(obj)
     var value = ""
     if v == reflect.ValueOf(nil) {
-        value = "nil"
+        value = "null"
     } else {
         switch v.Kind() {
 			case reflect.Invalid:
 				value = "invalid"
 
 			case reflect.Struct:
-				var param,ok = obj.(MappedNullable)
-				if ok {
-					dataMap,err := param.ToMap()
+				if t,ok := obj.(MappedNullable); ok {
+					dataMap,err := t.ToMap()
 					if err != nil {
 						return
 					}
-					parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
+					parameterAddToQuery(queryParams, keyPrefix, dataMap, collectionType)
+					return
+				}
+				if t, ok := obj.(time.Time); ok {
+					parameterAddToQuery(queryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
 					return
 				}
 				value = v.Type().String() + " value"
+			case reflect.Slice:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				var lenIndValue = indValue.Len()
+				for i:=0;i<lenIndValue;i++ {
+					var arrayValue = indValue.Index(i)
+					parameterAddToQuery(queryParams, keyPrefix, arrayValue.Interface(), collectionType)
+				}
+				return
+
+			case reflect.Map:
+				var indValue = reflect.ValueOf(obj)
+				if indValue == reflect.ValueOf(nil) {
+					return
+				}
+				iter := indValue.MapRange()
+				for iter.Next() {
+					k,v := iter.Key(), iter.Value()
+					parameterAddToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
+				}
+				return
+
 			case reflect.Interface:
 				fallthrough
             case reflect.Ptr:
-                parameterAddToHolder(queryParams, keyPrefix, v.Elem().Interface())
+				parameterAddToQuery(queryParams, keyPrefix, v.Elem().Interface(), collectionType)
                 return
 
             case reflect.Int, reflect.Int8, reflect.Int16,
@@ -215,91 +242,6 @@ func parameterAddToHolder(queryParams interface{}, keyPrefix string, obj interfa
     }
 }
 
-// parameterAddToQuery adds the provided object to the url query supporting deep object specification
-// the del delimiter is used to the split the value as list
-func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionFormat string) {
-    if reflect.TypeOf(obj).Kind() == reflect.Slice {
-        var indValue = reflect.ValueOf(obj)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, keyPrefix, arrayValue.Interface())
-        }
-        return
-
-    } else if reflect.TypeOf(obj).Kind() == reflect.Ptr {
-        var param,ok = obj.(MappedNullable)
-        if ok {
-            dataMap,err := param.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-        // scenario of pointer indirect value
-        var pointed = reflect.ValueOf(obj).Elem()
-        var pointedValue = pointed.Interface()
-        parameterAddToQuery(queryParams, keyPrefix, pointedValue, collectionFormat)
-        return
-
-    } else if t, ok := obj.(time.Time); ok {
-        parameterAddToHolder(queryParams, keyPrefix, t.Format(time.RFC3339))
-        return
-    }
-
-    // other value
-    parameterAddToHolder(queryParams, keyPrefix, obj)
-}
-
-// parameterAddMapToQuery adds the provided map to the url parameters list supporting deep object specification
-func parameterAddDataToQuery(queryParams interface{}, keyPrefix string, param interface{}) {
-    if param == nil {
-        return
-    }
-    var kind = reflect.TypeOf(param).Kind()
-    if kind == reflect.Slice {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        var lenIndValue = indValue.Len()
-        for i:=0;i<lenIndValue;i++ {
-            var arrayValue = indValue.Index(i)
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%d]", keyPrefix, i), arrayValue.Interface())
-        }
-        return
-
-    } else if kind == reflect.Map {
-        var indValue = reflect.ValueOf(param)
-        if indValue == reflect.ValueOf(nil) {
-            return
-        }
-        iter := indValue.MapRange()
-        for iter.Next() {
-            k,v := iter.Key(), iter.Value()
-            parameterAddDataToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface())
-        }
-        return
-    } else if kind == reflect.Ptr {
-        var paramNullable,ok = param.(MappedNullable)
-        if ok {
-            dataMap,err := paramNullable.ToMap()
-            if err != nil {
-                return
-            }
-            parameterAddDataToQuery( queryParams, keyPrefix, dataMap )
-            return
-        }
-    }
-
-    // primitive value
-    parameterAddToHolder(queryParams, keyPrefix, param)
-}
-
 // helper for converting interface{} parameters to json strings
 func parameterToJson(obj interface{}) (string, error) {
 	jsonBuf, err := json.Marshal(obj)
-- 
GitLab


From d292e4af701290bd6a8062911bdc3e409c001c48 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Tue, 1 Nov 2022 22:59:03 +0100
Subject: [PATCH 11/15] fix test url

---
 samples/openapi3/client/petstore/go/fake_api_test.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/samples/openapi3/client/petstore/go/fake_api_test.go b/samples/openapi3/client/petstore/go/fake_api_test.go
index e605ac32ff8..bddd01ee304 100644
--- a/samples/openapi3/client/petstore/go/fake_api_test.go
+++ b/samples/openapi3/client/petstore/go/fake_api_test.go
@@ -69,6 +69,6 @@ func TestQueryDeepObject(t *testing.T) {
 	r, _ := req.Execute()
 
 	assert.Equal(t,
-		"https://petstore.swagger.io:443/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[F3]=null&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[F3]=null&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls]=http%3A%2F%2Flocalhost&test_pet[tags][F1]=1&test_pet[tags][F2]=teststring&test_pet[tags][F3]=null&test_pet[tags][id]=2&test_pet[tags][name]=tag1",
+		"http://petstore.swagger.io:80/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[F3]=null&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[F3]=null&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls]=http%3A%2F%2Flocalhost&test_pet[tags][F1]=1&test_pet[tags][F2]=teststring&test_pet[tags][F3]=null&test_pet[tags][id]=2&test_pet[tags][name]=tag1",
 		r.Request.URL.String() )
 }
-- 
GitLab


From effcc4417f3a4c9963d2722602c6a605b612ce7f Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 5 Nov 2022 11:51:27 -0400
Subject: [PATCH 12/15] adapted for latest master, necessary generation

---
 .../src/main/resources/go/api.mustache        |  2 +-
 .../main/resources/go/model_simple.mustache   | 26 +++++++++++++------
 .../src/main/resources/go/utils.mustache      |  4 ++-
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index 4f6b5b9039b..c7840ffe566 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -214,7 +214,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
 		}
 	{{/isCollectionFormatMulti}}
 	{{^isCollectionFormatMulti}}
-	parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
+	    parameterAddToQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
 	{{/isCollectionFormatMulti}}
 	}
 	{{/required}}
diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
index dcec18ae717..b1d2baec452 100644
--- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
@@ -125,9 +125,14 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
 // Deprecated
 {{/deprecated}}
 func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
-	if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
-		return nil, false
-	}
+    if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+    {{^isFreeFormObject}}
+    return nil, false
+    {{/isFreeFormObject}}
+    {{#isFreeFormObject}}
+    return {{vendorExtensions.x-go-base-type}}{}, false
+    {{/isFreeFormObject}}
+    }
 {{#isNullable}}
 {{#vendorExtensions.x-golang-is-container}}
 	return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true
@@ -166,7 +171,7 @@ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
 // Deprecated
 {{/deprecated}}
 func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
-	if o == nil{{^isNullable}} || o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+	if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
 		var ret {{vendorExtensions.x-go-base-type}}
 		return ret
 	}
@@ -192,8 +197,13 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
 // Deprecated
 {{/deprecated}}
 func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
-	if o == nil{{^isNullable}} || o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
-		return nil, false
+	if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+    {{^isFreeFormObject}}
+    return nil, false
+    {{/isFreeFormObject}}
+    {{#isFreeFormObject}}
+    return {{vendorExtensions.x-go-base-type}}{}, false
+    {{/isFreeFormObject}}
 	}
 {{#isNullable}}
 {{#vendorExtensions.x-golang-is-container}}
@@ -210,7 +220,7 @@ func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/is
 
 // Has{{name}} returns a boolean if a field has been set.
 func (o *{{classname}}) Has{{name}}() bool {
-	if o != nil && {{^isNullable}}o.{{name}} != nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}o.{{name}} != nil{{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+	if o != nil && {{^isNullable}}!isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
 		return true
 	}
 
@@ -305,7 +315,7 @@ func (o {{classname}}) ToMap() (map[string]interface{}, error) {
 	toSerialize["{{baseName}}"] = o.{{name}}
 	{{/required}}
 	{{^required}}
-	if o.{{name}} != nil {
+	if !isNil(o.{{name}}) {
 		toSerialize["{{baseName}}"] = o.{{name}}
 	}
 	{{/required}}
diff --git a/modules/openapi-generator/src/main/resources/go/utils.mustache b/modules/openapi-generator/src/main/resources/go/utils.mustache
index 03c71a9bf79..f9239027b92 100644
--- a/modules/openapi-generator/src/main/resources/go/utils.mustache
+++ b/modules/openapi-generator/src/main/resources/go/utils.mustache
@@ -3,6 +3,7 @@ package {{packageName}}
 
 import (
 	"encoding/json"
+    "reflect"
 	"time"
 )
 
@@ -330,6 +331,7 @@ func isNil(i interface{}) bool {
         return reflect.ValueOf(i).IsZero()
     }
     return false
-}type MappedNullable interface {
+}
+type MappedNullable interface {
 	ToMap() (map[string]interface{}, error)
 }
-- 
GitLab


From 66712349dea3b97d4ac4d3565d3000fb9c83520e Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 5 Nov 2022 12:40:49 -0400
Subject: [PATCH 13/15] samples generation

---
 .../petstore/go/go-petstore/api_fake.go       |  12 +-
 .../model_additional_properties_array.go      |  10 +-
 .../model_additional_properties_boolean.go    |  10 +-
 .../model_additional_properties_class.go      | 110 +++----
 .../model_additional_properties_integer.go    |  10 +-
 .../model_additional_properties_number.go     |  10 +-
 .../model_additional_properties_object.go     |  10 +-
 .../model_additional_properties_string.go     |  10 +-
 .../petstore/go/go-petstore/model_animal.go   |  16 +-
 .../go/go-petstore/model_api_response.go      |  30 +-
 .../model_array_of_array_of_number_only.go    |  10 +-
 .../go-petstore/model_array_of_number_only.go |  10 +-
 .../go/go-petstore/model_array_test_.go       |  30 +-
 .../petstore/go/go-petstore/model_big_cat.go  |  10 +-
 .../go/go-petstore/model_big_cat_all_of.go    |  10 +-
 .../go/go-petstore/model_capitalization.go    |  60 ++--
 .../petstore/go/go-petstore/model_cat.go      |  10 +-
 .../go/go-petstore/model_cat_all_of.go        |  10 +-
 .../petstore/go/go-petstore/model_category.go |  16 +-
 .../go/go-petstore/model_class_model.go       |  10 +-
 .../petstore/go/go-petstore/model_dog.go      |  10 +-
 .../go/go-petstore/model_dog_all_of.go        |  10 +-
 .../go/go-petstore/model_enum_arrays.go       |  20 +-
 .../go/go-petstore/model_enum_test_.go        |  46 +--
 .../petstore/go/go-petstore/model_file.go     |  10 +-
 .../model_file_schema_test_class.go           |  20 +-
 .../go/go-petstore/model_format_test_.go      | 124 ++++----
 .../go-petstore/model_has_only_read_only.go   |  20 +-
 .../petstore/go/go-petstore/model_list.go     |  10 +-
 .../go/go-petstore/model_map_test_.go         |  40 +--
 ...perties_and_additional_properties_class.go |  30 +-
 .../petstore/go/go-petstore/model_name.go     |  36 +--
 .../go/go-petstore/model_number_only.go       |  10 +-
 .../petstore/go/go-petstore/model_order.go    |  60 ++--
 .../go/go-petstore/model_outer_composite.go   |  30 +-
 .../petstore/go/go-petstore/model_pet.go      |  52 ++--
 .../go/go-petstore/model_read_only_first.go   |  20 +-
 .../petstore/go/go-petstore/model_return.go   |  10 +-
 .../go-petstore/model_special_model_name.go   |  10 +-
 .../petstore/go/go-petstore/model_tag.go      |  20 +-
 .../go-petstore/model_type_holder_default.go  |  20 +-
 .../go-petstore/model_type_holder_example.go  |  24 +-
 .../petstore/go/go-petstore/model_user.go     |  80 ++---
 .../petstore/go/go-petstore/model_xml_item.go | 290 +++++++++---------
 .../petstore/go/go-petstore/api_fake.go       |  14 +-
 .../go/go-petstore/model_200_response.go      |  20 +-
 .../model__foo_get_default_response.go        |  10 +-
 .../go-petstore/model__special_model_name_.go |  10 +-
 .../model_additional_properties_class.go      |  20 +-
 .../petstore/go/go-petstore/model_animal.go   |  16 +-
 .../go/go-petstore/model_api_response.go      |  30 +-
 .../petstore/go/go-petstore/model_apple.go    |  10 +-
 .../go/go-petstore/model_apple_req.go         |  16 +-
 .../model_array_of_array_of_number_only.go    |  10 +-
 .../go-petstore/model_array_of_number_only.go |  10 +-
 .../go/go-petstore/model_array_test_.go       |  30 +-
 .../petstore/go/go-petstore/model_banana.go   |  10 +-
 .../go/go-petstore/model_banana_req.go        |  16 +-
 .../go/go-petstore/model_capitalization.go    |  60 ++--
 .../petstore/go/go-petstore/model_cat.go      |  10 +-
 .../go/go-petstore/model_cat_all_of.go        |  10 +-
 .../petstore/go/go-petstore/model_category.go |  16 +-
 .../go/go-petstore/model_class_model.go       |  10 +-
 .../petstore/go/go-petstore/model_client.go   |  10 +-
 .../petstore/go/go-petstore/model_dog.go      |  10 +-
 .../go/go-petstore/model_dog_all_of.go        |  10 +-
 .../model_duplicated_prop_child.go            |  10 +-
 .../model_duplicated_prop_child_all_of.go     |  10 +-
 .../model_duplicated_prop_parent.go           |   4 +-
 .../go/go-petstore/model_enum_arrays.go       |  20 +-
 .../go/go-petstore/model_enum_test_.go        |  70 ++---
 .../petstore/go/go-petstore/model_file.go     |  10 +-
 .../model_file_schema_test_class.go           |  20 +-
 .../petstore/go/go-petstore/model_foo.go      |  10 +-
 .../go/go-petstore/model_format_test_.go      | 134 ++++----
 .../go-petstore/model_has_only_read_only.go   |  20 +-
 .../petstore/go/go-petstore/model_list.go     |  10 +-
 .../go/go-petstore/model_map_of_file_test_.go |  10 +-
 .../go/go-petstore/model_map_test_.go         |  40 +--
 ...perties_and_additional_properties_class.go |  30 +-
 .../petstore/go/go-petstore/model_name.go     |  36 +--
 .../model_nullable_all_of_child.go            |  10 +-
 .../go/go-petstore/model_nullable_class.go    |  68 ++--
 .../go/go-petstore/model_number_only.go       |  10 +-
 .../model_one_of_primitive_type_child.go      |  10 +-
 .../petstore/go/go-petstore/model_order.go    |  60 ++--
 .../go/go-petstore/model_outer_composite.go   |  30 +-
 .../petstore/go/go-petstore/model_pet.go      |  52 ++--
 .../go/go-petstore/model_read_only_first.go   |  20 +-
 .../model_read_only_with_default.go           |  70 ++---
 .../petstore/go/go-petstore/model_return.go   |  10 +-
 .../petstore/go/go-petstore/model_tag.go      |  20 +-
 .../petstore/go/go-petstore/model_user.go     | 108 +++----
 .../petstore/go/go-petstore/model_whale.go    |  26 +-
 .../petstore/go/go-petstore/model_zebra.go    |  16 +-
 95 files changed, 1354 insertions(+), 1354 deletions(-)

diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go
index 1396efd6451..85e843d7c30 100644
--- a/samples/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/client/petstore/go/go-petstore/api_fake.go
@@ -1422,16 +1422,16 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 	localVarFormParams := url.Values{}
 
 	if r.enumQueryStringArray != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_string_array", r.enumQueryStringArray, "csv")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_string_array", r.enumQueryStringArray, "csv")
 	}
 	if r.enumQueryString != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
 	}
 	if r.enumQueryInteger != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
 	}
 	if r.enumQueryDouble != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/x-www-form-urlencoded"}
@@ -1587,10 +1587,10 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	parameterAddToQuery(localVarQueryParams, "required_string_group", r.requiredStringGroup, "")
 	parameterAddToQuery(localVarQueryParams, "required_int64_group", r.requiredInt64Group, "")
 	if r.stringGroup != nil {
-	parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
+	    parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
 	}
 	if r.int64Group != nil {
-	parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
+	    parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
index e7f69e1c32c..cc0d3713e32 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go
@@ -41,7 +41,7 @@ func NewAdditionalPropertiesArrayWithDefaults() *AdditionalPropertiesArray {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesArray) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *AdditionalPropertiesArray) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesArray) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesArray) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o AdditionalPropertiesArray) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesArray) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
index 57a68467dc4..455d77693e6 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go
@@ -41,7 +41,7 @@ func NewAdditionalPropertiesBooleanWithDefaults() *AdditionalPropertiesBoolean {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesBoolean) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *AdditionalPropertiesBoolean) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesBoolean) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesBoolean) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o AdditionalPropertiesBoolean) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesBoolean) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
index f79b6557872..dd1e6f85634 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go
@@ -51,7 +51,7 @@ func NewAdditionalPropertiesClassWithDefaults() *AdditionalPropertiesClass {
 
 // GetMapString returns the MapString field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapString() map[string]string {
-	if o == nil || o.MapString == nil {
+	if o == nil || isNil(o.MapString) {
 		var ret map[string]string
 		return ret
 	}
@@ -61,15 +61,15 @@ func (o *AdditionalPropertiesClass) GetMapString() map[string]string {
 // GetMapStringOk returns a tuple with the MapString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapStringOk() (*map[string]string, bool) {
-	if o == nil || o.MapString == nil {
-		return nil, false
+	if o == nil || isNil(o.MapString) {
+    return nil, false
 	}
 	return o.MapString, true
 }
 
 // HasMapString returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapString() bool {
-	if o != nil && o.MapString != nil {
+	if o != nil && !isNil(o.MapString) {
 		return true
 	}
 
@@ -83,7 +83,7 @@ func (o *AdditionalPropertiesClass) SetMapString(v map[string]string) {
 
 // GetMapNumber returns the MapNumber field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapNumber() map[string]float32 {
-	if o == nil || o.MapNumber == nil {
+	if o == nil || isNil(o.MapNumber) {
 		var ret map[string]float32
 		return ret
 	}
@@ -93,15 +93,15 @@ func (o *AdditionalPropertiesClass) GetMapNumber() map[string]float32 {
 // GetMapNumberOk returns a tuple with the MapNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapNumberOk() (*map[string]float32, bool) {
-	if o == nil || o.MapNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.MapNumber) {
+    return nil, false
 	}
 	return o.MapNumber, true
 }
 
 // HasMapNumber returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapNumber() bool {
-	if o != nil && o.MapNumber != nil {
+	if o != nil && !isNil(o.MapNumber) {
 		return true
 	}
 
@@ -115,7 +115,7 @@ func (o *AdditionalPropertiesClass) SetMapNumber(v map[string]float32) {
 
 // GetMapInteger returns the MapInteger field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapInteger() map[string]int32 {
-	if o == nil || o.MapInteger == nil {
+	if o == nil || isNil(o.MapInteger) {
 		var ret map[string]int32
 		return ret
 	}
@@ -125,15 +125,15 @@ func (o *AdditionalPropertiesClass) GetMapInteger() map[string]int32 {
 // GetMapIntegerOk returns a tuple with the MapInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapIntegerOk() (*map[string]int32, bool) {
-	if o == nil || o.MapInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.MapInteger) {
+    return nil, false
 	}
 	return o.MapInteger, true
 }
 
 // HasMapInteger returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapInteger() bool {
-	if o != nil && o.MapInteger != nil {
+	if o != nil && !isNil(o.MapInteger) {
 		return true
 	}
 
@@ -147,7 +147,7 @@ func (o *AdditionalPropertiesClass) SetMapInteger(v map[string]int32) {
 
 // GetMapBoolean returns the MapBoolean field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapBoolean() map[string]bool {
-	if o == nil || o.MapBoolean == nil {
+	if o == nil || isNil(o.MapBoolean) {
 		var ret map[string]bool
 		return ret
 	}
@@ -157,15 +157,15 @@ func (o *AdditionalPropertiesClass) GetMapBoolean() map[string]bool {
 // GetMapBooleanOk returns a tuple with the MapBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapBooleanOk() (*map[string]bool, bool) {
-	if o == nil || o.MapBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.MapBoolean) {
+    return nil, false
 	}
 	return o.MapBoolean, true
 }
 
 // HasMapBoolean returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapBoolean() bool {
-	if o != nil && o.MapBoolean != nil {
+	if o != nil && !isNil(o.MapBoolean) {
 		return true
 	}
 
@@ -179,7 +179,7 @@ func (o *AdditionalPropertiesClass) SetMapBoolean(v map[string]bool) {
 
 // GetMapArrayInteger returns the MapArrayInteger field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapArrayInteger() map[string][]int32 {
-	if o == nil || o.MapArrayInteger == nil {
+	if o == nil || isNil(o.MapArrayInteger) {
 		var ret map[string][]int32
 		return ret
 	}
@@ -189,15 +189,15 @@ func (o *AdditionalPropertiesClass) GetMapArrayInteger() map[string][]int32 {
 // GetMapArrayIntegerOk returns a tuple with the MapArrayInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapArrayIntegerOk() (*map[string][]int32, bool) {
-	if o == nil || o.MapArrayInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.MapArrayInteger) {
+    return nil, false
 	}
 	return o.MapArrayInteger, true
 }
 
 // HasMapArrayInteger returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapArrayInteger() bool {
-	if o != nil && o.MapArrayInteger != nil {
+	if o != nil && !isNil(o.MapArrayInteger) {
 		return true
 	}
 
@@ -211,7 +211,7 @@ func (o *AdditionalPropertiesClass) SetMapArrayInteger(v map[string][]int32) {
 
 // GetMapArrayAnytype returns the MapArrayAnytype field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapArrayAnytype() map[string][]map[string]interface{} {
-	if o == nil || o.MapArrayAnytype == nil {
+	if o == nil || isNil(o.MapArrayAnytype) {
 		var ret map[string][]map[string]interface{}
 		return ret
 	}
@@ -221,15 +221,15 @@ func (o *AdditionalPropertiesClass) GetMapArrayAnytype() map[string][]map[string
 // GetMapArrayAnytypeOk returns a tuple with the MapArrayAnytype field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapArrayAnytypeOk() (*map[string][]map[string]interface{}, bool) {
-	if o == nil || o.MapArrayAnytype == nil {
-		return nil, false
+	if o == nil || isNil(o.MapArrayAnytype) {
+    return nil, false
 	}
 	return o.MapArrayAnytype, true
 }
 
 // HasMapArrayAnytype returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapArrayAnytype() bool {
-	if o != nil && o.MapArrayAnytype != nil {
+	if o != nil && !isNil(o.MapArrayAnytype) {
 		return true
 	}
 
@@ -243,7 +243,7 @@ func (o *AdditionalPropertiesClass) SetMapArrayAnytype(v map[string][]map[string
 
 // GetMapMapString returns the MapMapString field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapMapString() map[string]map[string]string {
-	if o == nil || o.MapMapString == nil {
+	if o == nil || isNil(o.MapMapString) {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -253,15 +253,15 @@ func (o *AdditionalPropertiesClass) GetMapMapString() map[string]map[string]stri
 // GetMapMapStringOk returns a tuple with the MapMapString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapMapStringOk() (*map[string]map[string]string, bool) {
-	if o == nil || o.MapMapString == nil {
-		return nil, false
+	if o == nil || isNil(o.MapMapString) {
+    return nil, false
 	}
 	return o.MapMapString, true
 }
 
 // HasMapMapString returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapMapString() bool {
-	if o != nil && o.MapMapString != nil {
+	if o != nil && !isNil(o.MapMapString) {
 		return true
 	}
 
@@ -275,7 +275,7 @@ func (o *AdditionalPropertiesClass) SetMapMapString(v map[string]map[string]stri
 
 // GetMapMapAnytype returns the MapMapAnytype field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapMapAnytype() map[string]map[string]map[string]interface{} {
-	if o == nil || o.MapMapAnytype == nil {
+	if o == nil || isNil(o.MapMapAnytype) {
 		var ret map[string]map[string]map[string]interface{}
 		return ret
 	}
@@ -285,15 +285,15 @@ func (o *AdditionalPropertiesClass) GetMapMapAnytype() map[string]map[string]map
 // GetMapMapAnytypeOk returns a tuple with the MapMapAnytype field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapMapAnytypeOk() (*map[string]map[string]map[string]interface{}, bool) {
-	if o == nil || o.MapMapAnytype == nil {
-		return nil, false
+	if o == nil || isNil(o.MapMapAnytype) {
+    return nil, false
 	}
 	return o.MapMapAnytype, true
 }
 
 // HasMapMapAnytype returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapMapAnytype() bool {
-	if o != nil && o.MapMapAnytype != nil {
+	if o != nil && !isNil(o.MapMapAnytype) {
 		return true
 	}
 
@@ -307,7 +307,7 @@ func (o *AdditionalPropertiesClass) SetMapMapAnytype(v map[string]map[string]map
 
 // GetAnytype1 returns the Anytype1 field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetAnytype1() map[string]interface{} {
-	if o == nil || o.Anytype1 == nil {
+	if o == nil || isNil(o.Anytype1) {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -317,15 +317,15 @@ func (o *AdditionalPropertiesClass) GetAnytype1() map[string]interface{} {
 // GetAnytype1Ok returns a tuple with the Anytype1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetAnytype1Ok() (map[string]interface{}, bool) {
-	if o == nil || o.Anytype1 == nil {
-		return nil, false
+	if o == nil || isNil(o.Anytype1) {
+    return map[string]interface{}{}, false
 	}
 	return o.Anytype1, true
 }
 
 // HasAnytype1 returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasAnytype1() bool {
-	if o != nil && o.Anytype1 != nil {
+	if o != nil && !isNil(o.Anytype1) {
 		return true
 	}
 
@@ -339,7 +339,7 @@ func (o *AdditionalPropertiesClass) SetAnytype1(v map[string]interface{}) {
 
 // GetAnytype2 returns the Anytype2 field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetAnytype2() map[string]interface{} {
-	if o == nil || o.Anytype2 == nil {
+	if o == nil || isNil(o.Anytype2) {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -349,15 +349,15 @@ func (o *AdditionalPropertiesClass) GetAnytype2() map[string]interface{} {
 // GetAnytype2Ok returns a tuple with the Anytype2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetAnytype2Ok() (map[string]interface{}, bool) {
-	if o == nil || o.Anytype2 == nil {
-		return nil, false
+	if o == nil || isNil(o.Anytype2) {
+    return map[string]interface{}{}, false
 	}
 	return o.Anytype2, true
 }
 
 // HasAnytype2 returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasAnytype2() bool {
-	if o != nil && o.Anytype2 != nil {
+	if o != nil && !isNil(o.Anytype2) {
 		return true
 	}
 
@@ -371,7 +371,7 @@ func (o *AdditionalPropertiesClass) SetAnytype2(v map[string]interface{}) {
 
 // GetAnytype3 returns the Anytype3 field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetAnytype3() map[string]interface{} {
-	if o == nil || o.Anytype3 == nil {
+	if o == nil || isNil(o.Anytype3) {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -381,15 +381,15 @@ func (o *AdditionalPropertiesClass) GetAnytype3() map[string]interface{} {
 // GetAnytype3Ok returns a tuple with the Anytype3 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetAnytype3Ok() (map[string]interface{}, bool) {
-	if o == nil || o.Anytype3 == nil {
-		return nil, false
+	if o == nil || isNil(o.Anytype3) {
+    return map[string]interface{}{}, false
 	}
 	return o.Anytype3, true
 }
 
 // HasAnytype3 returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasAnytype3() bool {
-	if o != nil && o.Anytype3 != nil {
+	if o != nil && !isNil(o.Anytype3) {
 		return true
 	}
 
@@ -411,37 +411,37 @@ func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.MapString != nil {
+	if !isNil(o.MapString) {
 		toSerialize["map_string"] = o.MapString
 	}
-	if o.MapNumber != nil {
+	if !isNil(o.MapNumber) {
 		toSerialize["map_number"] = o.MapNumber
 	}
-	if o.MapInteger != nil {
+	if !isNil(o.MapInteger) {
 		toSerialize["map_integer"] = o.MapInteger
 	}
-	if o.MapBoolean != nil {
+	if !isNil(o.MapBoolean) {
 		toSerialize["map_boolean"] = o.MapBoolean
 	}
-	if o.MapArrayInteger != nil {
+	if !isNil(o.MapArrayInteger) {
 		toSerialize["map_array_integer"] = o.MapArrayInteger
 	}
-	if o.MapArrayAnytype != nil {
+	if !isNil(o.MapArrayAnytype) {
 		toSerialize["map_array_anytype"] = o.MapArrayAnytype
 	}
-	if o.MapMapString != nil {
+	if !isNil(o.MapMapString) {
 		toSerialize["map_map_string"] = o.MapMapString
 	}
-	if o.MapMapAnytype != nil {
+	if !isNil(o.MapMapAnytype) {
 		toSerialize["map_map_anytype"] = o.MapMapAnytype
 	}
-	if o.Anytype1 != nil {
+	if !isNil(o.Anytype1) {
 		toSerialize["anytype_1"] = o.Anytype1
 	}
-	if o.Anytype2 != nil {
+	if !isNil(o.Anytype2) {
 		toSerialize["anytype_2"] = o.Anytype2
 	}
-	if o.Anytype3 != nil {
+	if !isNil(o.Anytype3) {
 		toSerialize["anytype_3"] = o.Anytype3
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
index d38de6d73e2..2a1d4cfeb1d 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go
@@ -41,7 +41,7 @@ func NewAdditionalPropertiesIntegerWithDefaults() *AdditionalPropertiesInteger {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesInteger) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *AdditionalPropertiesInteger) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesInteger) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesInteger) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o AdditionalPropertiesInteger) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesInteger) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
index 61eda1f13c6..d47dd18f491 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go
@@ -41,7 +41,7 @@ func NewAdditionalPropertiesNumberWithDefaults() *AdditionalPropertiesNumber {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesNumber) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *AdditionalPropertiesNumber) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesNumber) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesNumber) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o AdditionalPropertiesNumber) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesNumber) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
index bfec70f0189..b9403564a01 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go
@@ -41,7 +41,7 @@ func NewAdditionalPropertiesObjectWithDefaults() *AdditionalPropertiesObject {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesObject) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *AdditionalPropertiesObject) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesObject) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesObject) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o AdditionalPropertiesObject) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesObject) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
index 3cc21daad82..441d4e78555 100644
--- a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
+++ b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go
@@ -41,7 +41,7 @@ func NewAdditionalPropertiesStringWithDefaults() *AdditionalPropertiesString {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *AdditionalPropertiesString) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *AdditionalPropertiesString) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesString) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *AdditionalPropertiesString) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o AdditionalPropertiesString) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesString) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_animal.go b/samples/client/petstore/go/go-petstore/model_animal.go
index 5384f87f660..ba840d0c01b 100644
--- a/samples/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/client/petstore/go/go-petstore/model_animal.go
@@ -58,9 +58,9 @@ func (o *Animal) GetClassName() string {
 // GetClassNameOk returns a tuple with the ClassName field value
 // and a boolean to check if the value has been set.
 func (o *Animal) GetClassNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.ClassName, true
 }
 
@@ -71,7 +71,7 @@ func (o *Animal) SetClassName(v string) {
 
 // GetColor returns the Color field value if set, zero value otherwise.
 func (o *Animal) GetColor() string {
-	if o == nil || o.Color == nil {
+	if o == nil || isNil(o.Color) {
 		var ret string
 		return ret
 	}
@@ -81,15 +81,15 @@ func (o *Animal) GetColor() string {
 // GetColorOk returns a tuple with the Color field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Animal) GetColorOk() (*string, bool) {
-	if o == nil || o.Color == nil {
-		return nil, false
+	if o == nil || isNil(o.Color) {
+    return nil, false
 	}
 	return o.Color, true
 }
 
 // HasColor returns a boolean if a field has been set.
 func (o *Animal) HasColor() bool {
-	if o != nil && o.Color != nil {
+	if o != nil && !isNil(o.Color) {
 		return true
 	}
 
@@ -112,7 +112,7 @@ func (o Animal) MarshalJSON() ([]byte, error) {
 func (o Animal) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	toSerialize["className"] = o.ClassName
-	if o.Color != nil {
+	if !isNil(o.Color) {
 		toSerialize["color"] = o.Color
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go
index 9092b2133e6..77b31849ffa 100644
--- a/samples/client/petstore/go/go-petstore/model_api_response.go
+++ b/samples/client/petstore/go/go-petstore/model_api_response.go
@@ -43,7 +43,7 @@ func NewApiResponseWithDefaults() *ApiResponse {
 
 // GetCode returns the Code field value if set, zero value otherwise.
 func (o *ApiResponse) GetCode() int32 {
-	if o == nil || o.Code == nil {
+	if o == nil || isNil(o.Code) {
 		var ret int32
 		return ret
 	}
@@ -53,15 +53,15 @@ func (o *ApiResponse) GetCode() int32 {
 // GetCodeOk returns a tuple with the Code field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetCodeOk() (*int32, bool) {
-	if o == nil || o.Code == nil {
-		return nil, false
+	if o == nil || isNil(o.Code) {
+    return nil, false
 	}
 	return o.Code, true
 }
 
 // HasCode returns a boolean if a field has been set.
 func (o *ApiResponse) HasCode() bool {
-	if o != nil && o.Code != nil {
+	if o != nil && !isNil(o.Code) {
 		return true
 	}
 
@@ -75,7 +75,7 @@ func (o *ApiResponse) SetCode(v int32) {
 
 // GetType returns the Type field value if set, zero value otherwise.
 func (o *ApiResponse) GetType() string {
-	if o == nil || o.Type == nil {
+	if o == nil || isNil(o.Type) {
 		var ret string
 		return ret
 	}
@@ -85,15 +85,15 @@ func (o *ApiResponse) GetType() string {
 // GetTypeOk returns a tuple with the Type field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetTypeOk() (*string, bool) {
-	if o == nil || o.Type == nil {
-		return nil, false
+	if o == nil || isNil(o.Type) {
+    return nil, false
 	}
 	return o.Type, true
 }
 
 // HasType returns a boolean if a field has been set.
 func (o *ApiResponse) HasType() bool {
-	if o != nil && o.Type != nil {
+	if o != nil && !isNil(o.Type) {
 		return true
 	}
 
@@ -107,7 +107,7 @@ func (o *ApiResponse) SetType(v string) {
 
 // GetMessage returns the Message field value if set, zero value otherwise.
 func (o *ApiResponse) GetMessage() string {
-	if o == nil || o.Message == nil {
+	if o == nil || isNil(o.Message) {
 		var ret string
 		return ret
 	}
@@ -117,15 +117,15 @@ func (o *ApiResponse) GetMessage() string {
 // GetMessageOk returns a tuple with the Message field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetMessageOk() (*string, bool) {
-	if o == nil || o.Message == nil {
-		return nil, false
+	if o == nil || isNil(o.Message) {
+    return nil, false
 	}
 	return o.Message, true
 }
 
 // HasMessage returns a boolean if a field has been set.
 func (o *ApiResponse) HasMessage() bool {
-	if o != nil && o.Message != nil {
+	if o != nil && !isNil(o.Message) {
 		return true
 	}
 
@@ -147,13 +147,13 @@ func (o ApiResponse) MarshalJSON() ([]byte, error) {
 
 func (o ApiResponse) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Code != nil {
+	if !isNil(o.Code) {
 		toSerialize["code"] = o.Code
 	}
-	if o.Type != nil {
+	if !isNil(o.Type) {
 		toSerialize["type"] = o.Type
 	}
-	if o.Message != nil {
+	if !isNil(o.Message) {
 		toSerialize["message"] = o.Message
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
index 64b203ae7fe..7ad7224cf24 100644
--- a/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
@@ -41,7 +41,7 @@ func NewArrayOfArrayOfNumberOnlyWithDefaults() *ArrayOfArrayOfNumberOnly {
 
 // GetArrayArrayNumber returns the ArrayArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
-	if o == nil || o.ArrayArrayNumber == nil {
+	if o == nil || isNil(o.ArrayArrayNumber) {
 		var ret [][]float32
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
 // GetArrayArrayNumberOk returns a tuple with the ArrayArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumberOk() ([][]float32, bool) {
-	if o == nil || o.ArrayArrayNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayArrayNumber) {
+    return nil, false
 	}
 	return o.ArrayArrayNumber, true
 }
 
 // HasArrayArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfArrayOfNumberOnly) HasArrayArrayNumber() bool {
-	if o != nil && o.ArrayArrayNumber != nil {
+	if o != nil && !isNil(o.ArrayArrayNumber) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
 
 func (o ArrayOfArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.ArrayArrayNumber != nil {
+	if !isNil(o.ArrayArrayNumber) {
 		toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
index f3c236df0fe..36928cc8468 100644
--- a/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_array_of_number_only.go
@@ -41,7 +41,7 @@ func NewArrayOfNumberOnlyWithDefaults() *ArrayOfNumberOnly {
 
 // GetArrayNumber returns the ArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
-	if o == nil || o.ArrayNumber == nil {
+	if o == nil || isNil(o.ArrayNumber) {
 		var ret []float32
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
 // GetArrayNumberOk returns a tuple with the ArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfNumberOnly) GetArrayNumberOk() ([]float32, bool) {
-	if o == nil || o.ArrayNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayNumber) {
+    return nil, false
 	}
 	return o.ArrayNumber, true
 }
 
 // HasArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfNumberOnly) HasArrayNumber() bool {
-	if o != nil && o.ArrayNumber != nil {
+	if o != nil && !isNil(o.ArrayNumber) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
 
 func (o ArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.ArrayNumber != nil {
+	if !isNil(o.ArrayNumber) {
 		toSerialize["ArrayNumber"] = o.ArrayNumber
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_array_test_.go b/samples/client/petstore/go/go-petstore/model_array_test_.go
index 0fd1d8ee54f..68fd0e312ea 100644
--- a/samples/client/petstore/go/go-petstore/model_array_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_array_test_.go
@@ -43,7 +43,7 @@ func NewArrayTestWithDefaults() *ArrayTest {
 
 // GetArrayOfString returns the ArrayOfString field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayOfString() []string {
-	if o == nil || o.ArrayOfString == nil {
+	if o == nil || isNil(o.ArrayOfString) {
 		var ret []string
 		return ret
 	}
@@ -53,15 +53,15 @@ func (o *ArrayTest) GetArrayOfString() []string {
 // GetArrayOfStringOk returns a tuple with the ArrayOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayOfStringOk() ([]string, bool) {
-	if o == nil || o.ArrayOfString == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayOfString) {
+    return nil, false
 	}
 	return o.ArrayOfString, true
 }
 
 // HasArrayOfString returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayOfString() bool {
-	if o != nil && o.ArrayOfString != nil {
+	if o != nil && !isNil(o.ArrayOfString) {
 		return true
 	}
 
@@ -75,7 +75,7 @@ func (o *ArrayTest) SetArrayOfString(v []string) {
 
 // GetArrayArrayOfInteger returns the ArrayArrayOfInteger field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
-	if o == nil || o.ArrayArrayOfInteger == nil {
+	if o == nil || isNil(o.ArrayArrayOfInteger) {
 		var ret [][]int64
 		return ret
 	}
@@ -85,15 +85,15 @@ func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
 // GetArrayArrayOfIntegerOk returns a tuple with the ArrayArrayOfInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfIntegerOk() ([][]int64, bool) {
-	if o == nil || o.ArrayArrayOfInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayArrayOfInteger) {
+    return nil, false
 	}
 	return o.ArrayArrayOfInteger, true
 }
 
 // HasArrayArrayOfInteger returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfInteger() bool {
-	if o != nil && o.ArrayArrayOfInteger != nil {
+	if o != nil && !isNil(o.ArrayArrayOfInteger) {
 		return true
 	}
 
@@ -107,7 +107,7 @@ func (o *ArrayTest) SetArrayArrayOfInteger(v [][]int64) {
 
 // GetArrayArrayOfModel returns the ArrayArrayOfModel field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
-	if o == nil || o.ArrayArrayOfModel == nil {
+	if o == nil || isNil(o.ArrayArrayOfModel) {
 		var ret [][]ReadOnlyFirst
 		return ret
 	}
@@ -117,15 +117,15 @@ func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
 // GetArrayArrayOfModelOk returns a tuple with the ArrayArrayOfModel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfModelOk() ([][]ReadOnlyFirst, bool) {
-	if o == nil || o.ArrayArrayOfModel == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayArrayOfModel) {
+    return nil, false
 	}
 	return o.ArrayArrayOfModel, true
 }
 
 // HasArrayArrayOfModel returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfModel() bool {
-	if o != nil && o.ArrayArrayOfModel != nil {
+	if o != nil && !isNil(o.ArrayArrayOfModel) {
 		return true
 	}
 
@@ -147,13 +147,13 @@ func (o ArrayTest) MarshalJSON() ([]byte, error) {
 
 func (o ArrayTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.ArrayOfString != nil {
+	if !isNil(o.ArrayOfString) {
 		toSerialize["array_of_string"] = o.ArrayOfString
 	}
-	if o.ArrayArrayOfInteger != nil {
+	if !isNil(o.ArrayArrayOfInteger) {
 		toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger
 	}
-	if o.ArrayArrayOfModel != nil {
+	if !isNil(o.ArrayArrayOfModel) {
 		toSerialize["array_array_of_model"] = o.ArrayArrayOfModel
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_big_cat.go b/samples/client/petstore/go/go-petstore/model_big_cat.go
index dcd3379aecf..3bfb9fcd9f5 100644
--- a/samples/client/petstore/go/go-petstore/model_big_cat.go
+++ b/samples/client/petstore/go/go-petstore/model_big_cat.go
@@ -45,7 +45,7 @@ func NewBigCatWithDefaults() *BigCat {
 
 // GetKind returns the Kind field value if set, zero value otherwise.
 func (o *BigCat) GetKind() string {
-	if o == nil || o.Kind == nil {
+	if o == nil || isNil(o.Kind) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *BigCat) GetKind() string {
 // GetKindOk returns a tuple with the Kind field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *BigCat) GetKindOk() (*string, bool) {
-	if o == nil || o.Kind == nil {
-		return nil, false
+	if o == nil || isNil(o.Kind) {
+    return nil, false
 	}
 	return o.Kind, true
 }
 
 // HasKind returns a boolean if a field has been set.
 func (o *BigCat) HasKind() bool {
-	if o != nil && o.Kind != nil {
+	if o != nil && !isNil(o.Kind) {
 		return true
 	}
 
@@ -93,7 +93,7 @@ func (o BigCat) ToMap() (map[string]interface{}, error) {
 	if errCat != nil {
 		return map[string]interface{}{}, errCat
 	}
-	if o.Kind != nil {
+	if !isNil(o.Kind) {
 		toSerialize["kind"] = o.Kind
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go b/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
index c664e704810..55f2d644e08 100644
--- a/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_big_cat_all_of.go
@@ -41,7 +41,7 @@ func NewBigCatAllOfWithDefaults() *BigCatAllOf {
 
 // GetKind returns the Kind field value if set, zero value otherwise.
 func (o *BigCatAllOf) GetKind() string {
-	if o == nil || o.Kind == nil {
+	if o == nil || isNil(o.Kind) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *BigCatAllOf) GetKind() string {
 // GetKindOk returns a tuple with the Kind field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *BigCatAllOf) GetKindOk() (*string, bool) {
-	if o == nil || o.Kind == nil {
-		return nil, false
+	if o == nil || isNil(o.Kind) {
+    return nil, false
 	}
 	return o.Kind, true
 }
 
 // HasKind returns a boolean if a field has been set.
 func (o *BigCatAllOf) HasKind() bool {
-	if o != nil && o.Kind != nil {
+	if o != nil && !isNil(o.Kind) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o BigCatAllOf) MarshalJSON() ([]byte, error) {
 
 func (o BigCatAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Kind != nil {
+	if !isNil(o.Kind) {
 		toSerialize["kind"] = o.Kind
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_capitalization.go b/samples/client/petstore/go/go-petstore/model_capitalization.go
index ffb168d1ad3..64bbd7b63b7 100644
--- a/samples/client/petstore/go/go-petstore/model_capitalization.go
+++ b/samples/client/petstore/go/go-petstore/model_capitalization.go
@@ -47,7 +47,7 @@ func NewCapitalizationWithDefaults() *Capitalization {
 
 // GetSmallCamel returns the SmallCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallCamel() string {
-	if o == nil || o.SmallCamel == nil {
+	if o == nil || isNil(o.SmallCamel) {
 		var ret string
 		return ret
 	}
@@ -57,15 +57,15 @@ func (o *Capitalization) GetSmallCamel() string {
 // GetSmallCamelOk returns a tuple with the SmallCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallCamelOk() (*string, bool) {
-	if o == nil || o.SmallCamel == nil {
-		return nil, false
+	if o == nil || isNil(o.SmallCamel) {
+    return nil, false
 	}
 	return o.SmallCamel, true
 }
 
 // HasSmallCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallCamel() bool {
-	if o != nil && o.SmallCamel != nil {
+	if o != nil && !isNil(o.SmallCamel) {
 		return true
 	}
 
@@ -79,7 +79,7 @@ func (o *Capitalization) SetSmallCamel(v string) {
 
 // GetCapitalCamel returns the CapitalCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalCamel() string {
-	if o == nil || o.CapitalCamel == nil {
+	if o == nil || isNil(o.CapitalCamel) {
 		var ret string
 		return ret
 	}
@@ -89,15 +89,15 @@ func (o *Capitalization) GetCapitalCamel() string {
 // GetCapitalCamelOk returns a tuple with the CapitalCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalCamelOk() (*string, bool) {
-	if o == nil || o.CapitalCamel == nil {
-		return nil, false
+	if o == nil || isNil(o.CapitalCamel) {
+    return nil, false
 	}
 	return o.CapitalCamel, true
 }
 
 // HasCapitalCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalCamel() bool {
-	if o != nil && o.CapitalCamel != nil {
+	if o != nil && !isNil(o.CapitalCamel) {
 		return true
 	}
 
@@ -111,7 +111,7 @@ func (o *Capitalization) SetCapitalCamel(v string) {
 
 // GetSmallSnake returns the SmallSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallSnake() string {
-	if o == nil || o.SmallSnake == nil {
+	if o == nil || isNil(o.SmallSnake) {
 		var ret string
 		return ret
 	}
@@ -121,15 +121,15 @@ func (o *Capitalization) GetSmallSnake() string {
 // GetSmallSnakeOk returns a tuple with the SmallSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallSnakeOk() (*string, bool) {
-	if o == nil || o.SmallSnake == nil {
-		return nil, false
+	if o == nil || isNil(o.SmallSnake) {
+    return nil, false
 	}
 	return o.SmallSnake, true
 }
 
 // HasSmallSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallSnake() bool {
-	if o != nil && o.SmallSnake != nil {
+	if o != nil && !isNil(o.SmallSnake) {
 		return true
 	}
 
@@ -143,7 +143,7 @@ func (o *Capitalization) SetSmallSnake(v string) {
 
 // GetCapitalSnake returns the CapitalSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalSnake() string {
-	if o == nil || o.CapitalSnake == nil {
+	if o == nil || isNil(o.CapitalSnake) {
 		var ret string
 		return ret
 	}
@@ -153,15 +153,15 @@ func (o *Capitalization) GetCapitalSnake() string {
 // GetCapitalSnakeOk returns a tuple with the CapitalSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalSnakeOk() (*string, bool) {
-	if o == nil || o.CapitalSnake == nil {
-		return nil, false
+	if o == nil || isNil(o.CapitalSnake) {
+    return nil, false
 	}
 	return o.CapitalSnake, true
 }
 
 // HasCapitalSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalSnake() bool {
-	if o != nil && o.CapitalSnake != nil {
+	if o != nil && !isNil(o.CapitalSnake) {
 		return true
 	}
 
@@ -175,7 +175,7 @@ func (o *Capitalization) SetCapitalSnake(v string) {
 
 // GetSCAETHFlowPoints returns the SCAETHFlowPoints field value if set, zero value otherwise.
 func (o *Capitalization) GetSCAETHFlowPoints() string {
-	if o == nil || o.SCAETHFlowPoints == nil {
+	if o == nil || isNil(o.SCAETHFlowPoints) {
 		var ret string
 		return ret
 	}
@@ -185,15 +185,15 @@ func (o *Capitalization) GetSCAETHFlowPoints() string {
 // GetSCAETHFlowPointsOk returns a tuple with the SCAETHFlowPoints field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSCAETHFlowPointsOk() (*string, bool) {
-	if o == nil || o.SCAETHFlowPoints == nil {
-		return nil, false
+	if o == nil || isNil(o.SCAETHFlowPoints) {
+    return nil, false
 	}
 	return o.SCAETHFlowPoints, true
 }
 
 // HasSCAETHFlowPoints returns a boolean if a field has been set.
 func (o *Capitalization) HasSCAETHFlowPoints() bool {
-	if o != nil && o.SCAETHFlowPoints != nil {
+	if o != nil && !isNil(o.SCAETHFlowPoints) {
 		return true
 	}
 
@@ -207,7 +207,7 @@ func (o *Capitalization) SetSCAETHFlowPoints(v string) {
 
 // GetATT_NAME returns the ATT_NAME field value if set, zero value otherwise.
 func (o *Capitalization) GetATT_NAME() string {
-	if o == nil || o.ATT_NAME == nil {
+	if o == nil || isNil(o.ATT_NAME) {
 		var ret string
 		return ret
 	}
@@ -217,15 +217,15 @@ func (o *Capitalization) GetATT_NAME() string {
 // GetATT_NAMEOk returns a tuple with the ATT_NAME field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetATT_NAMEOk() (*string, bool) {
-	if o == nil || o.ATT_NAME == nil {
-		return nil, false
+	if o == nil || isNil(o.ATT_NAME) {
+    return nil, false
 	}
 	return o.ATT_NAME, true
 }
 
 // HasATT_NAME returns a boolean if a field has been set.
 func (o *Capitalization) HasATT_NAME() bool {
-	if o != nil && o.ATT_NAME != nil {
+	if o != nil && !isNil(o.ATT_NAME) {
 		return true
 	}
 
@@ -247,22 +247,22 @@ func (o Capitalization) MarshalJSON() ([]byte, error) {
 
 func (o Capitalization) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.SmallCamel != nil {
+	if !isNil(o.SmallCamel) {
 		toSerialize["smallCamel"] = o.SmallCamel
 	}
-	if o.CapitalCamel != nil {
+	if !isNil(o.CapitalCamel) {
 		toSerialize["CapitalCamel"] = o.CapitalCamel
 	}
-	if o.SmallSnake != nil {
+	if !isNil(o.SmallSnake) {
 		toSerialize["small_Snake"] = o.SmallSnake
 	}
-	if o.CapitalSnake != nil {
+	if !isNil(o.CapitalSnake) {
 		toSerialize["Capital_Snake"] = o.CapitalSnake
 	}
-	if o.SCAETHFlowPoints != nil {
+	if !isNil(o.SCAETHFlowPoints) {
 		toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints
 	}
-	if o.ATT_NAME != nil {
+	if !isNil(o.ATT_NAME) {
 		toSerialize["ATT_NAME"] = o.ATT_NAME
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_cat.go b/samples/client/petstore/go/go-petstore/model_cat.go
index 5996bb71f13..c3e1e9660f1 100644
--- a/samples/client/petstore/go/go-petstore/model_cat.go
+++ b/samples/client/petstore/go/go-petstore/model_cat.go
@@ -45,7 +45,7 @@ func NewCatWithDefaults() *Cat {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *Cat) GetDeclawed() bool {
-	if o == nil || o.Declawed == nil {
+	if o == nil || isNil(o.Declawed) {
 		var ret bool
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *Cat) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Cat) GetDeclawedOk() (*bool, bool) {
-	if o == nil || o.Declawed == nil {
-		return nil, false
+	if o == nil || isNil(o.Declawed) {
+    return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *Cat) HasDeclawed() bool {
-	if o != nil && o.Declawed != nil {
+	if o != nil && !isNil(o.Declawed) {
 		return true
 	}
 
@@ -93,7 +93,7 @@ func (o Cat) ToMap() (map[string]interface{}, error) {
 	if errAnimal != nil {
 		return map[string]interface{}{}, errAnimal
 	}
-	if o.Declawed != nil {
+	if !isNil(o.Declawed) {
 		toSerialize["declawed"] = o.Declawed
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_cat_all_of.go b/samples/client/petstore/go/go-petstore/model_cat_all_of.go
index e63fb6ad252..a819bd20d6b 100644
--- a/samples/client/petstore/go/go-petstore/model_cat_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_cat_all_of.go
@@ -41,7 +41,7 @@ func NewCatAllOfWithDefaults() *CatAllOf {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *CatAllOf) GetDeclawed() bool {
-	if o == nil || o.Declawed == nil {
+	if o == nil || isNil(o.Declawed) {
 		var ret bool
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *CatAllOf) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *CatAllOf) GetDeclawedOk() (*bool, bool) {
-	if o == nil || o.Declawed == nil {
-		return nil, false
+	if o == nil || isNil(o.Declawed) {
+    return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *CatAllOf) HasDeclawed() bool {
-	if o != nil && o.Declawed != nil {
+	if o != nil && !isNil(o.Declawed) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o CatAllOf) MarshalJSON() ([]byte, error) {
 
 func (o CatAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Declawed != nil {
+	if !isNil(o.Declawed) {
 		toSerialize["declawed"] = o.Declawed
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_category.go b/samples/client/petstore/go/go-petstore/model_category.go
index 909ad5376fa..fbd9ec79579 100644
--- a/samples/client/petstore/go/go-petstore/model_category.go
+++ b/samples/client/petstore/go/go-petstore/model_category.go
@@ -45,7 +45,7 @@ func NewCategoryWithDefaults() *Category {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Category) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *Category) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Category) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Category) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -88,9 +88,9 @@ func (o *Category) GetName() string {
 // GetNameOk returns a tuple with the Name field value
 // and a boolean to check if the value has been set.
 func (o *Category) GetNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Name, true
 }
 
@@ -109,7 +109,7 @@ func (o Category) MarshalJSON() ([]byte, error) {
 
 func (o Category) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
 	toSerialize["name"] = o.Name
diff --git a/samples/client/petstore/go/go-petstore/model_class_model.go b/samples/client/petstore/go/go-petstore/model_class_model.go
index e08ae79ce24..9b00e6b90b1 100644
--- a/samples/client/petstore/go/go-petstore/model_class_model.go
+++ b/samples/client/petstore/go/go-petstore/model_class_model.go
@@ -41,7 +41,7 @@ func NewClassModelWithDefaults() *ClassModel {
 
 // GetClass returns the Class field value if set, zero value otherwise.
 func (o *ClassModel) GetClass() string {
-	if o == nil || o.Class == nil {
+	if o == nil || isNil(o.Class) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *ClassModel) GetClass() string {
 // GetClassOk returns a tuple with the Class field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ClassModel) GetClassOk() (*string, bool) {
-	if o == nil || o.Class == nil {
-		return nil, false
+	if o == nil || isNil(o.Class) {
+    return nil, false
 	}
 	return o.Class, true
 }
 
 // HasClass returns a boolean if a field has been set.
 func (o *ClassModel) HasClass() bool {
-	if o != nil && o.Class != nil {
+	if o != nil && !isNil(o.Class) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o ClassModel) MarshalJSON() ([]byte, error) {
 
 func (o ClassModel) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Class != nil {
+	if !isNil(o.Class) {
 		toSerialize["_class"] = o.Class
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_dog.go b/samples/client/petstore/go/go-petstore/model_dog.go
index 2d1b3d29ef6..1ff3a51237e 100644
--- a/samples/client/petstore/go/go-petstore/model_dog.go
+++ b/samples/client/petstore/go/go-petstore/model_dog.go
@@ -45,7 +45,7 @@ func NewDogWithDefaults() *Dog {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *Dog) GetBreed() string {
-	if o == nil || o.Breed == nil {
+	if o == nil || isNil(o.Breed) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *Dog) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Dog) GetBreedOk() (*string, bool) {
-	if o == nil || o.Breed == nil {
-		return nil, false
+	if o == nil || isNil(o.Breed) {
+    return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *Dog) HasBreed() bool {
-	if o != nil && o.Breed != nil {
+	if o != nil && !isNil(o.Breed) {
 		return true
 	}
 
@@ -93,7 +93,7 @@ func (o Dog) ToMap() (map[string]interface{}, error) {
 	if errAnimal != nil {
 		return map[string]interface{}{}, errAnimal
 	}
-	if o.Breed != nil {
+	if !isNil(o.Breed) {
 		toSerialize["breed"] = o.Breed
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_dog_all_of.go b/samples/client/petstore/go/go-petstore/model_dog_all_of.go
index e06b6eb50ed..54f139e1bbd 100644
--- a/samples/client/petstore/go/go-petstore/model_dog_all_of.go
+++ b/samples/client/petstore/go/go-petstore/model_dog_all_of.go
@@ -41,7 +41,7 @@ func NewDogAllOfWithDefaults() *DogAllOf {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *DogAllOf) GetBreed() string {
-	if o == nil || o.Breed == nil {
+	if o == nil || isNil(o.Breed) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *DogAllOf) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DogAllOf) GetBreedOk() (*string, bool) {
-	if o == nil || o.Breed == nil {
-		return nil, false
+	if o == nil || isNil(o.Breed) {
+    return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *DogAllOf) HasBreed() bool {
-	if o != nil && o.Breed != nil {
+	if o != nil && !isNil(o.Breed) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o DogAllOf) MarshalJSON() ([]byte, error) {
 
 func (o DogAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Breed != nil {
+	if !isNil(o.Breed) {
 		toSerialize["breed"] = o.Breed
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/client/petstore/go/go-petstore/model_enum_arrays.go
index 03b697271c7..ec6cecef279 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_arrays.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_arrays.go
@@ -42,7 +42,7 @@ func NewEnumArraysWithDefaults() *EnumArrays {
 
 // GetJustSymbol returns the JustSymbol field value if set, zero value otherwise.
 func (o *EnumArrays) GetJustSymbol() string {
-	if o == nil || o.JustSymbol == nil {
+	if o == nil || isNil(o.JustSymbol) {
 		var ret string
 		return ret
 	}
@@ -52,15 +52,15 @@ func (o *EnumArrays) GetJustSymbol() string {
 // GetJustSymbolOk returns a tuple with the JustSymbol field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetJustSymbolOk() (*string, bool) {
-	if o == nil || o.JustSymbol == nil {
-		return nil, false
+	if o == nil || isNil(o.JustSymbol) {
+    return nil, false
 	}
 	return o.JustSymbol, true
 }
 
 // HasJustSymbol returns a boolean if a field has been set.
 func (o *EnumArrays) HasJustSymbol() bool {
-	if o != nil && o.JustSymbol != nil {
+	if o != nil && !isNil(o.JustSymbol) {
 		return true
 	}
 
@@ -74,7 +74,7 @@ func (o *EnumArrays) SetJustSymbol(v string) {
 
 // GetArrayEnum returns the ArrayEnum field value if set, zero value otherwise.
 func (o *EnumArrays) GetArrayEnum() []string {
-	if o == nil || o.ArrayEnum == nil {
+	if o == nil || isNil(o.ArrayEnum) {
 		var ret []string
 		return ret
 	}
@@ -84,15 +84,15 @@ func (o *EnumArrays) GetArrayEnum() []string {
 // GetArrayEnumOk returns a tuple with the ArrayEnum field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetArrayEnumOk() ([]string, bool) {
-	if o == nil || o.ArrayEnum == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayEnum) {
+    return nil, false
 	}
 	return o.ArrayEnum, true
 }
 
 // HasArrayEnum returns a boolean if a field has been set.
 func (o *EnumArrays) HasArrayEnum() bool {
-	if o != nil && o.ArrayEnum != nil {
+	if o != nil && !isNil(o.ArrayEnum) {
 		return true
 	}
 
@@ -114,10 +114,10 @@ func (o EnumArrays) MarshalJSON() ([]byte, error) {
 
 func (o EnumArrays) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.JustSymbol != nil {
+	if !isNil(o.JustSymbol) {
 		toSerialize["just_symbol"] = o.JustSymbol
 	}
-	if o.ArrayEnum != nil {
+	if !isNil(o.ArrayEnum) {
 		toSerialize["array_enum"] = o.ArrayEnum
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_enum_test_.go b/samples/client/petstore/go/go-petstore/model_enum_test_.go
index 3e796876962..284e5ebeb2a 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_test_.go
@@ -46,7 +46,7 @@ func NewEnumTestWithDefaults() *EnumTest {
 
 // GetEnumString returns the EnumString field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumString() string {
-	if o == nil || o.EnumString == nil {
+	if o == nil || isNil(o.EnumString) {
 		var ret string
 		return ret
 	}
@@ -56,15 +56,15 @@ func (o *EnumTest) GetEnumString() string {
 // GetEnumStringOk returns a tuple with the EnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringOk() (*string, bool) {
-	if o == nil || o.EnumString == nil {
-		return nil, false
+	if o == nil || isNil(o.EnumString) {
+    return nil, false
 	}
 	return o.EnumString, true
 }
 
 // HasEnumString returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumString() bool {
-	if o != nil && o.EnumString != nil {
+	if o != nil && !isNil(o.EnumString) {
 		return true
 	}
 
@@ -89,9 +89,9 @@ func (o *EnumTest) GetEnumStringRequired() string {
 // GetEnumStringRequiredOk returns a tuple with the EnumStringRequired field value
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringRequiredOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.EnumStringRequired, true
 }
 
@@ -102,7 +102,7 @@ func (o *EnumTest) SetEnumStringRequired(v string) {
 
 // GetEnumInteger returns the EnumInteger field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumInteger() int32 {
-	if o == nil || o.EnumInteger == nil {
+	if o == nil || isNil(o.EnumInteger) {
 		var ret int32
 		return ret
 	}
@@ -112,15 +112,15 @@ func (o *EnumTest) GetEnumInteger() int32 {
 // GetEnumIntegerOk returns a tuple with the EnumInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumIntegerOk() (*int32, bool) {
-	if o == nil || o.EnumInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.EnumInteger) {
+    return nil, false
 	}
 	return o.EnumInteger, true
 }
 
 // HasEnumInteger returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumInteger() bool {
-	if o != nil && o.EnumInteger != nil {
+	if o != nil && !isNil(o.EnumInteger) {
 		return true
 	}
 
@@ -134,7 +134,7 @@ func (o *EnumTest) SetEnumInteger(v int32) {
 
 // GetEnumNumber returns the EnumNumber field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumNumber() float64 {
-	if o == nil || o.EnumNumber == nil {
+	if o == nil || isNil(o.EnumNumber) {
 		var ret float64
 		return ret
 	}
@@ -144,15 +144,15 @@ func (o *EnumTest) GetEnumNumber() float64 {
 // GetEnumNumberOk returns a tuple with the EnumNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumNumberOk() (*float64, bool) {
-	if o == nil || o.EnumNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.EnumNumber) {
+    return nil, false
 	}
 	return o.EnumNumber, true
 }
 
 // HasEnumNumber returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumNumber() bool {
-	if o != nil && o.EnumNumber != nil {
+	if o != nil && !isNil(o.EnumNumber) {
 		return true
 	}
 
@@ -166,7 +166,7 @@ func (o *EnumTest) SetEnumNumber(v float64) {
 
 // GetOuterEnum returns the OuterEnum field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnum() OuterEnum {
-	if o == nil || o.OuterEnum == nil {
+	if o == nil || isNil(o.OuterEnum) {
 		var ret OuterEnum
 		return ret
 	}
@@ -176,15 +176,15 @@ func (o *EnumTest) GetOuterEnum() OuterEnum {
 // GetOuterEnumOk returns a tuple with the OuterEnum field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumOk() (*OuterEnum, bool) {
-	if o == nil || o.OuterEnum == nil {
-		return nil, false
+	if o == nil || isNil(o.OuterEnum) {
+    return nil, false
 	}
 	return o.OuterEnum, true
 }
 
 // HasOuterEnum returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnum() bool {
-	if o != nil && o.OuterEnum != nil {
+	if o != nil && !isNil(o.OuterEnum) {
 		return true
 	}
 
@@ -206,17 +206,17 @@ func (o EnumTest) MarshalJSON() ([]byte, error) {
 
 func (o EnumTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.EnumString != nil {
+	if !isNil(o.EnumString) {
 		toSerialize["enum_string"] = o.EnumString
 	}
 	toSerialize["enum_string_required"] = o.EnumStringRequired
-	if o.EnumInteger != nil {
+	if !isNil(o.EnumInteger) {
 		toSerialize["enum_integer"] = o.EnumInteger
 	}
-	if o.EnumNumber != nil {
+	if !isNil(o.EnumNumber) {
 		toSerialize["enum_number"] = o.EnumNumber
 	}
-	if o.OuterEnum != nil {
+	if !isNil(o.OuterEnum) {
 		toSerialize["outerEnum"] = o.OuterEnum
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_file.go b/samples/client/petstore/go/go-petstore/model_file.go
index 850d23cf9c8..6aa32ea36bf 100644
--- a/samples/client/petstore/go/go-petstore/model_file.go
+++ b/samples/client/petstore/go/go-petstore/model_file.go
@@ -42,7 +42,7 @@ func NewFileWithDefaults() *File {
 
 // GetSourceURI returns the SourceURI field value if set, zero value otherwise.
 func (o *File) GetSourceURI() string {
-	if o == nil || o.SourceURI == nil {
+	if o == nil || isNil(o.SourceURI) {
 		var ret string
 		return ret
 	}
@@ -52,15 +52,15 @@ func (o *File) GetSourceURI() string {
 // GetSourceURIOk returns a tuple with the SourceURI field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *File) GetSourceURIOk() (*string, bool) {
-	if o == nil || o.SourceURI == nil {
-		return nil, false
+	if o == nil || isNil(o.SourceURI) {
+    return nil, false
 	}
 	return o.SourceURI, true
 }
 
 // HasSourceURI returns a boolean if a field has been set.
 func (o *File) HasSourceURI() bool {
-	if o != nil && o.SourceURI != nil {
+	if o != nil && !isNil(o.SourceURI) {
 		return true
 	}
 
@@ -82,7 +82,7 @@ func (o File) MarshalJSON() ([]byte, error) {
 
 func (o File) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.SourceURI != nil {
+	if !isNil(o.SourceURI) {
 		toSerialize["sourceURI"] = o.SourceURI
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
index 99068968709..52f16cbb5e7 100644
--- a/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
+++ b/samples/client/petstore/go/go-petstore/model_file_schema_test_class.go
@@ -42,7 +42,7 @@ func NewFileSchemaTestClassWithDefaults() *FileSchemaTestClass {
 
 // GetFile returns the File field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFile() File {
-	if o == nil || o.File == nil {
+	if o == nil || isNil(o.File) {
 		var ret File
 		return ret
 	}
@@ -52,15 +52,15 @@ func (o *FileSchemaTestClass) GetFile() File {
 // GetFileOk returns a tuple with the File field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFileOk() (*File, bool) {
-	if o == nil || o.File == nil {
-		return nil, false
+	if o == nil || isNil(o.File) {
+    return nil, false
 	}
 	return o.File, true
 }
 
 // HasFile returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFile() bool {
-	if o != nil && o.File != nil {
+	if o != nil && !isNil(o.File) {
 		return true
 	}
 
@@ -74,7 +74,7 @@ func (o *FileSchemaTestClass) SetFile(v File) {
 
 // GetFiles returns the Files field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFiles() []File {
-	if o == nil || o.Files == nil {
+	if o == nil || isNil(o.Files) {
 		var ret []File
 		return ret
 	}
@@ -84,15 +84,15 @@ func (o *FileSchemaTestClass) GetFiles() []File {
 // GetFilesOk returns a tuple with the Files field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFilesOk() ([]File, bool) {
-	if o == nil || o.Files == nil {
-		return nil, false
+	if o == nil || isNil(o.Files) {
+    return nil, false
 	}
 	return o.Files, true
 }
 
 // HasFiles returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFiles() bool {
-	if o != nil && o.Files != nil {
+	if o != nil && !isNil(o.Files) {
 		return true
 	}
 
@@ -114,10 +114,10 @@ func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) {
 
 func (o FileSchemaTestClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.File != nil {
+	if !isNil(o.File) {
 		toSerialize["file"] = o.File
 	}
-	if o.Files != nil {
+	if !isNil(o.Files) {
 		toSerialize["files"] = o.Files
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_format_test_.go b/samples/client/petstore/go/go-petstore/model_format_test_.go
index 58f8403eb90..71b086714f3 100644
--- a/samples/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_format_test_.go
@@ -60,7 +60,7 @@ func NewFormatTestWithDefaults() *FormatTest {
 
 // GetInteger returns the Integer field value if set, zero value otherwise.
 func (o *FormatTest) GetInteger() int32 {
-	if o == nil || o.Integer == nil {
+	if o == nil || isNil(o.Integer) {
 		var ret int32
 		return ret
 	}
@@ -70,15 +70,15 @@ func (o *FormatTest) GetInteger() int32 {
 // GetIntegerOk returns a tuple with the Integer field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetIntegerOk() (*int32, bool) {
-	if o == nil || o.Integer == nil {
-		return nil, false
+	if o == nil || isNil(o.Integer) {
+    return nil, false
 	}
 	return o.Integer, true
 }
 
 // HasInteger returns a boolean if a field has been set.
 func (o *FormatTest) HasInteger() bool {
-	if o != nil && o.Integer != nil {
+	if o != nil && !isNil(o.Integer) {
 		return true
 	}
 
@@ -92,7 +92,7 @@ func (o *FormatTest) SetInteger(v int32) {
 
 // GetInt32 returns the Int32 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt32() int32 {
-	if o == nil || o.Int32 == nil {
+	if o == nil || isNil(o.Int32) {
 		var ret int32
 		return ret
 	}
@@ -102,15 +102,15 @@ func (o *FormatTest) GetInt32() int32 {
 // GetInt32Ok returns a tuple with the Int32 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt32Ok() (*int32, bool) {
-	if o == nil || o.Int32 == nil {
-		return nil, false
+	if o == nil || isNil(o.Int32) {
+    return nil, false
 	}
 	return o.Int32, true
 }
 
 // HasInt32 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt32() bool {
-	if o != nil && o.Int32 != nil {
+	if o != nil && !isNil(o.Int32) {
 		return true
 	}
 
@@ -124,7 +124,7 @@ func (o *FormatTest) SetInt32(v int32) {
 
 // GetInt64 returns the Int64 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt64() int64 {
-	if o == nil || o.Int64 == nil {
+	if o == nil || isNil(o.Int64) {
 		var ret int64
 		return ret
 	}
@@ -134,15 +134,15 @@ func (o *FormatTest) GetInt64() int64 {
 // GetInt64Ok returns a tuple with the Int64 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt64Ok() (*int64, bool) {
-	if o == nil || o.Int64 == nil {
-		return nil, false
+	if o == nil || isNil(o.Int64) {
+    return nil, false
 	}
 	return o.Int64, true
 }
 
 // HasInt64 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt64() bool {
-	if o != nil && o.Int64 != nil {
+	if o != nil && !isNil(o.Int64) {
 		return true
 	}
 
@@ -167,9 +167,9 @@ func (o *FormatTest) GetNumber() float32 {
 // GetNumberOk returns a tuple with the Number field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetNumberOk() (*float32, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Number, true
 }
 
@@ -180,7 +180,7 @@ func (o *FormatTest) SetNumber(v float32) {
 
 // GetFloat returns the Float field value if set, zero value otherwise.
 func (o *FormatTest) GetFloat() float32 {
-	if o == nil || o.Float == nil {
+	if o == nil || isNil(o.Float) {
 		var ret float32
 		return ret
 	}
@@ -190,15 +190,15 @@ func (o *FormatTest) GetFloat() float32 {
 // GetFloatOk returns a tuple with the Float field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetFloatOk() (*float32, bool) {
-	if o == nil || o.Float == nil {
-		return nil, false
+	if o == nil || isNil(o.Float) {
+    return nil, false
 	}
 	return o.Float, true
 }
 
 // HasFloat returns a boolean if a field has been set.
 func (o *FormatTest) HasFloat() bool {
-	if o != nil && o.Float != nil {
+	if o != nil && !isNil(o.Float) {
 		return true
 	}
 
@@ -212,7 +212,7 @@ func (o *FormatTest) SetFloat(v float32) {
 
 // GetDouble returns the Double field value if set, zero value otherwise.
 func (o *FormatTest) GetDouble() float64 {
-	if o == nil || o.Double == nil {
+	if o == nil || isNil(o.Double) {
 		var ret float64
 		return ret
 	}
@@ -222,15 +222,15 @@ func (o *FormatTest) GetDouble() float64 {
 // GetDoubleOk returns a tuple with the Double field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDoubleOk() (*float64, bool) {
-	if o == nil || o.Double == nil {
-		return nil, false
+	if o == nil || isNil(o.Double) {
+    return nil, false
 	}
 	return o.Double, true
 }
 
 // HasDouble returns a boolean if a field has been set.
 func (o *FormatTest) HasDouble() bool {
-	if o != nil && o.Double != nil {
+	if o != nil && !isNil(o.Double) {
 		return true
 	}
 
@@ -244,7 +244,7 @@ func (o *FormatTest) SetDouble(v float64) {
 
 // GetString returns the String field value if set, zero value otherwise.
 func (o *FormatTest) GetString() string {
-	if o == nil || o.String == nil {
+	if o == nil || isNil(o.String) {
 		var ret string
 		return ret
 	}
@@ -254,15 +254,15 @@ func (o *FormatTest) GetString() string {
 // GetStringOk returns a tuple with the String field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetStringOk() (*string, bool) {
-	if o == nil || o.String == nil {
-		return nil, false
+	if o == nil || isNil(o.String) {
+    return nil, false
 	}
 	return o.String, true
 }
 
 // HasString returns a boolean if a field has been set.
 func (o *FormatTest) HasString() bool {
-	if o != nil && o.String != nil {
+	if o != nil && !isNil(o.String) {
 		return true
 	}
 
@@ -287,9 +287,9 @@ func (o *FormatTest) GetByte() string {
 // GetByteOk returns a tuple with the Byte field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetByteOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Byte, true
 }
 
@@ -300,7 +300,7 @@ func (o *FormatTest) SetByte(v string) {
 
 // GetBinary returns the Binary field value if set, zero value otherwise.
 func (o *FormatTest) GetBinary() *os.File {
-	if o == nil || o.Binary == nil {
+	if o == nil || isNil(o.Binary) {
 		var ret *os.File
 		return ret
 	}
@@ -310,15 +310,15 @@ func (o *FormatTest) GetBinary() *os.File {
 // GetBinaryOk returns a tuple with the Binary field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetBinaryOk() (**os.File, bool) {
-	if o == nil || o.Binary == nil {
-		return nil, false
+	if o == nil || isNil(o.Binary) {
+    return nil, false
 	}
 	return o.Binary, true
 }
 
 // HasBinary returns a boolean if a field has been set.
 func (o *FormatTest) HasBinary() bool {
-	if o != nil && o.Binary != nil {
+	if o != nil && !isNil(o.Binary) {
 		return true
 	}
 
@@ -343,9 +343,9 @@ func (o *FormatTest) GetDate() string {
 // GetDateOk returns a tuple with the Date field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Date, true
 }
 
@@ -356,7 +356,7 @@ func (o *FormatTest) SetDate(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *FormatTest) GetDateTime() time.Time {
-	if o == nil || o.DateTime == nil {
+	if o == nil || isNil(o.DateTime) {
 		var ret time.Time
 		return ret
 	}
@@ -366,15 +366,15 @@ func (o *FormatTest) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || o.DateTime == nil {
-		return nil, false
+	if o == nil || isNil(o.DateTime) {
+    return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *FormatTest) HasDateTime() bool {
-	if o != nil && o.DateTime != nil {
+	if o != nil && !isNil(o.DateTime) {
 		return true
 	}
 
@@ -388,7 +388,7 @@ func (o *FormatTest) SetDateTime(v time.Time) {
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *FormatTest) GetUuid() string {
-	if o == nil || o.Uuid == nil {
+	if o == nil || isNil(o.Uuid) {
 		var ret string
 		return ret
 	}
@@ -398,15 +398,15 @@ func (o *FormatTest) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetUuidOk() (*string, bool) {
-	if o == nil || o.Uuid == nil {
-		return nil, false
+	if o == nil || isNil(o.Uuid) {
+    return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *FormatTest) HasUuid() bool {
-	if o != nil && o.Uuid != nil {
+	if o != nil && !isNil(o.Uuid) {
 		return true
 	}
 
@@ -431,9 +431,9 @@ func (o *FormatTest) GetPassword() string {
 // GetPasswordOk returns a tuple with the Password field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPasswordOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Password, true
 }
 
@@ -444,7 +444,7 @@ func (o *FormatTest) SetPassword(v string) {
 
 // GetBigDecimal returns the BigDecimal field value if set, zero value otherwise.
 func (o *FormatTest) GetBigDecimal() float64 {
-	if o == nil || o.BigDecimal == nil {
+	if o == nil || isNil(o.BigDecimal) {
 		var ret float64
 		return ret
 	}
@@ -454,15 +454,15 @@ func (o *FormatTest) GetBigDecimal() float64 {
 // GetBigDecimalOk returns a tuple with the BigDecimal field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetBigDecimalOk() (*float64, bool) {
-	if o == nil || o.BigDecimal == nil {
-		return nil, false
+	if o == nil || isNil(o.BigDecimal) {
+    return nil, false
 	}
 	return o.BigDecimal, true
 }
 
 // HasBigDecimal returns a boolean if a field has been set.
 func (o *FormatTest) HasBigDecimal() bool {
-	if o != nil && o.BigDecimal != nil {
+	if o != nil && !isNil(o.BigDecimal) {
 		return true
 	}
 
@@ -484,38 +484,38 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 
 func (o FormatTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Integer != nil {
+	if !isNil(o.Integer) {
 		toSerialize["integer"] = o.Integer
 	}
-	if o.Int32 != nil {
+	if !isNil(o.Int32) {
 		toSerialize["int32"] = o.Int32
 	}
-	if o.Int64 != nil {
+	if !isNil(o.Int64) {
 		toSerialize["int64"] = o.Int64
 	}
 	toSerialize["number"] = o.Number
-	if o.Float != nil {
+	if !isNil(o.Float) {
 		toSerialize["float"] = o.Float
 	}
-	if o.Double != nil {
+	if !isNil(o.Double) {
 		toSerialize["double"] = o.Double
 	}
-	if o.String != nil {
+	if !isNil(o.String) {
 		toSerialize["string"] = o.String
 	}
 	toSerialize["byte"] = o.Byte
-	if o.Binary != nil {
+	if !isNil(o.Binary) {
 		toSerialize["binary"] = o.Binary
 	}
 	toSerialize["date"] = o.Date
-	if o.DateTime != nil {
+	if !isNil(o.DateTime) {
 		toSerialize["dateTime"] = o.DateTime
 	}
-	if o.Uuid != nil {
+	if !isNil(o.Uuid) {
 		toSerialize["uuid"] = o.Uuid
 	}
 	toSerialize["password"] = o.Password
-	if o.BigDecimal != nil {
+	if !isNil(o.BigDecimal) {
 		toSerialize["BigDecimal"] = o.BigDecimal
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
index e526efa5da6..42e9ae58a0d 100644
--- a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
+++ b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go
@@ -42,7 +42,7 @@ func NewHasOnlyReadOnlyWithDefaults() *HasOnlyReadOnly {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetBar() string {
-	if o == nil || o.Bar == nil {
+	if o == nil || isNil(o.Bar) {
 		var ret string
 		return ret
 	}
@@ -52,15 +52,15 @@ func (o *HasOnlyReadOnly) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetBarOk() (*string, bool) {
-	if o == nil || o.Bar == nil {
-		return nil, false
+	if o == nil || isNil(o.Bar) {
+    return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasBar() bool {
-	if o != nil && o.Bar != nil {
+	if o != nil && !isNil(o.Bar) {
 		return true
 	}
 
@@ -74,7 +74,7 @@ func (o *HasOnlyReadOnly) SetBar(v string) {
 
 // GetFoo returns the Foo field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetFoo() string {
-	if o == nil || o.Foo == nil {
+	if o == nil || isNil(o.Foo) {
 		var ret string
 		return ret
 	}
@@ -84,15 +84,15 @@ func (o *HasOnlyReadOnly) GetFoo() string {
 // GetFooOk returns a tuple with the Foo field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetFooOk() (*string, bool) {
-	if o == nil || o.Foo == nil {
-		return nil, false
+	if o == nil || isNil(o.Foo) {
+    return nil, false
 	}
 	return o.Foo, true
 }
 
 // HasFoo returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasFoo() bool {
-	if o != nil && o.Foo != nil {
+	if o != nil && !isNil(o.Foo) {
 		return true
 	}
 
@@ -114,10 +114,10 @@ func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) {
 
 func (o HasOnlyReadOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Bar != nil {
+	if !isNil(o.Bar) {
 		toSerialize["bar"] = o.Bar
 	}
-	if o.Foo != nil {
+	if !isNil(o.Foo) {
 		toSerialize["foo"] = o.Foo
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_list.go b/samples/client/petstore/go/go-petstore/model_list.go
index bd79b185316..4de1c4a1ed5 100644
--- a/samples/client/petstore/go/go-petstore/model_list.go
+++ b/samples/client/petstore/go/go-petstore/model_list.go
@@ -41,7 +41,7 @@ func NewListWithDefaults() *List {
 
 // GetVar123List returns the Var123List field value if set, zero value otherwise.
 func (o *List) GetVar123List() string {
-	if o == nil || o.Var123List == nil {
+	if o == nil || isNil(o.Var123List) {
 		var ret string
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *List) GetVar123List() string {
 // GetVar123ListOk returns a tuple with the Var123List field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *List) GetVar123ListOk() (*string, bool) {
-	if o == nil || o.Var123List == nil {
-		return nil, false
+	if o == nil || isNil(o.Var123List) {
+    return nil, false
 	}
 	return o.Var123List, true
 }
 
 // HasVar123List returns a boolean if a field has been set.
 func (o *List) HasVar123List() bool {
-	if o != nil && o.Var123List != nil {
+	if o != nil && !isNil(o.Var123List) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o List) MarshalJSON() ([]byte, error) {
 
 func (o List) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Var123List != nil {
+	if !isNil(o.Var123List) {
 		toSerialize["123-list"] = o.Var123List
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_map_test_.go b/samples/client/petstore/go/go-petstore/model_map_test_.go
index 888a864c1c6..ba8ec13cbbd 100644
--- a/samples/client/petstore/go/go-petstore/model_map_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_map_test_.go
@@ -44,7 +44,7 @@ func NewMapTestWithDefaults() *MapTest {
 
 // GetMapMapOfString returns the MapMapOfString field value if set, zero value otherwise.
 func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
-	if o == nil || o.MapMapOfString == nil {
+	if o == nil || isNil(o.MapMapOfString) {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
 // GetMapMapOfStringOk returns a tuple with the MapMapOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapMapOfStringOk() (*map[string]map[string]string, bool) {
-	if o == nil || o.MapMapOfString == nil {
-		return nil, false
+	if o == nil || isNil(o.MapMapOfString) {
+    return nil, false
 	}
 	return o.MapMapOfString, true
 }
 
 // HasMapMapOfString returns a boolean if a field has been set.
 func (o *MapTest) HasMapMapOfString() bool {
-	if o != nil && o.MapMapOfString != nil {
+	if o != nil && !isNil(o.MapMapOfString) {
 		return true
 	}
 
@@ -76,7 +76,7 @@ func (o *MapTest) SetMapMapOfString(v map[string]map[string]string) {
 
 // GetMapOfEnumString returns the MapOfEnumString field value if set, zero value otherwise.
 func (o *MapTest) GetMapOfEnumString() map[string]string {
-	if o == nil || o.MapOfEnumString == nil {
+	if o == nil || isNil(o.MapOfEnumString) {
 		var ret map[string]string
 		return ret
 	}
@@ -86,15 +86,15 @@ func (o *MapTest) GetMapOfEnumString() map[string]string {
 // GetMapOfEnumStringOk returns a tuple with the MapOfEnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapOfEnumStringOk() (*map[string]string, bool) {
-	if o == nil || o.MapOfEnumString == nil {
-		return nil, false
+	if o == nil || isNil(o.MapOfEnumString) {
+    return nil, false
 	}
 	return o.MapOfEnumString, true
 }
 
 // HasMapOfEnumString returns a boolean if a field has been set.
 func (o *MapTest) HasMapOfEnumString() bool {
-	if o != nil && o.MapOfEnumString != nil {
+	if o != nil && !isNil(o.MapOfEnumString) {
 		return true
 	}
 
@@ -108,7 +108,7 @@ func (o *MapTest) SetMapOfEnumString(v map[string]string) {
 
 // GetDirectMap returns the DirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetDirectMap() map[string]bool {
-	if o == nil || o.DirectMap == nil {
+	if o == nil || isNil(o.DirectMap) {
 		var ret map[string]bool
 		return ret
 	}
@@ -118,15 +118,15 @@ func (o *MapTest) GetDirectMap() map[string]bool {
 // GetDirectMapOk returns a tuple with the DirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetDirectMapOk() (*map[string]bool, bool) {
-	if o == nil || o.DirectMap == nil {
-		return nil, false
+	if o == nil || isNil(o.DirectMap) {
+    return nil, false
 	}
 	return o.DirectMap, true
 }
 
 // HasDirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasDirectMap() bool {
-	if o != nil && o.DirectMap != nil {
+	if o != nil && !isNil(o.DirectMap) {
 		return true
 	}
 
@@ -140,7 +140,7 @@ func (o *MapTest) SetDirectMap(v map[string]bool) {
 
 // GetIndirectMap returns the IndirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetIndirectMap() map[string]bool {
-	if o == nil || o.IndirectMap == nil {
+	if o == nil || isNil(o.IndirectMap) {
 		var ret map[string]bool
 		return ret
 	}
@@ -150,15 +150,15 @@ func (o *MapTest) GetIndirectMap() map[string]bool {
 // GetIndirectMapOk returns a tuple with the IndirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetIndirectMapOk() (*map[string]bool, bool) {
-	if o == nil || o.IndirectMap == nil {
-		return nil, false
+	if o == nil || isNil(o.IndirectMap) {
+    return nil, false
 	}
 	return o.IndirectMap, true
 }
 
 // HasIndirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasIndirectMap() bool {
-	if o != nil && o.IndirectMap != nil {
+	if o != nil && !isNil(o.IndirectMap) {
 		return true
 	}
 
@@ -180,16 +180,16 @@ func (o MapTest) MarshalJSON() ([]byte, error) {
 
 func (o MapTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.MapMapOfString != nil {
+	if !isNil(o.MapMapOfString) {
 		toSerialize["map_map_of_string"] = o.MapMapOfString
 	}
-	if o.MapOfEnumString != nil {
+	if !isNil(o.MapOfEnumString) {
 		toSerialize["map_of_enum_string"] = o.MapOfEnumString
 	}
-	if o.DirectMap != nil {
+	if !isNil(o.DirectMap) {
 		toSerialize["direct_map"] = o.DirectMap
 	}
-	if o.IndirectMap != nil {
+	if !isNil(o.IndirectMap) {
 		toSerialize["indirect_map"] = o.IndirectMap
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
index 4e42d2223a4..809e062c6db 100644
--- a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
+++ b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
@@ -44,7 +44,7 @@ func NewMixedPropertiesAndAdditionalPropertiesClassWithDefaults() *MixedProperti
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
-	if o == nil || o.Uuid == nil {
+	if o == nil || isNil(o.Uuid) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuidOk() (*string, bool) {
-	if o == nil || o.Uuid == nil {
-		return nil, false
+	if o == nil || isNil(o.Uuid) {
+    return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasUuid() bool {
-	if o != nil && o.Uuid != nil {
+	if o != nil && !isNil(o.Uuid) {
 		return true
 	}
 
@@ -76,7 +76,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetUuid(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
-	if o == nil || o.DateTime == nil {
+	if o == nil || isNil(o.DateTime) {
 		var ret time.Time
 		return ret
 	}
@@ -86,15 +86,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || o.DateTime == nil {
-		return nil, false
+	if o == nil || isNil(o.DateTime) {
+    return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasDateTime() bool {
-	if o != nil && o.DateTime != nil {
+	if o != nil && !isNil(o.DateTime) {
 		return true
 	}
 
@@ -108,7 +108,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetDateTime(v time.Time) {
 
 // GetMap returns the Map field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal {
-	if o == nil || o.Map == nil {
+	if o == nil || isNil(o.Map) {
 		var ret map[string]Animal
 		return ret
 	}
@@ -118,15 +118,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal
 // GetMapOk returns a tuple with the Map field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMapOk() (*map[string]Animal, bool) {
-	if o == nil || o.Map == nil {
-		return nil, false
+	if o == nil || isNil(o.Map) {
+    return nil, false
 	}
 	return o.Map, true
 }
 
 // HasMap returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasMap() bool {
-	if o != nil && o.Map != nil {
+	if o != nil && !isNil(o.Map) {
 		return true
 	}
 
@@ -148,13 +148,13 @@ func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, erro
 
 func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Uuid != nil {
+	if !isNil(o.Uuid) {
 		toSerialize["uuid"] = o.Uuid
 	}
-	if o.DateTime != nil {
+	if !isNil(o.DateTime) {
 		toSerialize["dateTime"] = o.DateTime
 	}
-	if o.Map != nil {
+	if !isNil(o.Map) {
 		toSerialize["map"] = o.Map
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_name.go b/samples/client/petstore/go/go-petstore/model_name.go
index f3943d49dd7..bc5a5c276ac 100644
--- a/samples/client/petstore/go/go-petstore/model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_name.go
@@ -56,9 +56,9 @@ func (o *Name) GetName() int32 {
 // GetNameOk returns a tuple with the Name field value
 // and a boolean to check if the value has been set.
 func (o *Name) GetNameOk() (*int32, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Name, true
 }
 
@@ -69,7 +69,7 @@ func (o *Name) SetName(v int32) {
 
 // GetSnakeCase returns the SnakeCase field value if set, zero value otherwise.
 func (o *Name) GetSnakeCase() int32 {
-	if o == nil || o.SnakeCase == nil {
+	if o == nil || isNil(o.SnakeCase) {
 		var ret int32
 		return ret
 	}
@@ -79,15 +79,15 @@ func (o *Name) GetSnakeCase() int32 {
 // GetSnakeCaseOk returns a tuple with the SnakeCase field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetSnakeCaseOk() (*int32, bool) {
-	if o == nil || o.SnakeCase == nil {
-		return nil, false
+	if o == nil || isNil(o.SnakeCase) {
+    return nil, false
 	}
 	return o.SnakeCase, true
 }
 
 // HasSnakeCase returns a boolean if a field has been set.
 func (o *Name) HasSnakeCase() bool {
-	if o != nil && o.SnakeCase != nil {
+	if o != nil && !isNil(o.SnakeCase) {
 		return true
 	}
 
@@ -101,7 +101,7 @@ func (o *Name) SetSnakeCase(v int32) {
 
 // GetProperty returns the Property field value if set, zero value otherwise.
 func (o *Name) GetProperty() string {
-	if o == nil || o.Property == nil {
+	if o == nil || isNil(o.Property) {
 		var ret string
 		return ret
 	}
@@ -111,15 +111,15 @@ func (o *Name) GetProperty() string {
 // GetPropertyOk returns a tuple with the Property field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetPropertyOk() (*string, bool) {
-	if o == nil || o.Property == nil {
-		return nil, false
+	if o == nil || isNil(o.Property) {
+    return nil, false
 	}
 	return o.Property, true
 }
 
 // HasProperty returns a boolean if a field has been set.
 func (o *Name) HasProperty() bool {
-	if o != nil && o.Property != nil {
+	if o != nil && !isNil(o.Property) {
 		return true
 	}
 
@@ -133,7 +133,7 @@ func (o *Name) SetProperty(v string) {
 
 // GetVar123Number returns the Var123Number field value if set, zero value otherwise.
 func (o *Name) GetVar123Number() int32 {
-	if o == nil || o.Var123Number == nil {
+	if o == nil || isNil(o.Var123Number) {
 		var ret int32
 		return ret
 	}
@@ -143,15 +143,15 @@ func (o *Name) GetVar123Number() int32 {
 // GetVar123NumberOk returns a tuple with the Var123Number field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetVar123NumberOk() (*int32, bool) {
-	if o == nil || o.Var123Number == nil {
-		return nil, false
+	if o == nil || isNil(o.Var123Number) {
+    return nil, false
 	}
 	return o.Var123Number, true
 }
 
 // HasVar123Number returns a boolean if a field has been set.
 func (o *Name) HasVar123Number() bool {
-	if o != nil && o.Var123Number != nil {
+	if o != nil && !isNil(o.Var123Number) {
 		return true
 	}
 
@@ -174,13 +174,13 @@ func (o Name) MarshalJSON() ([]byte, error) {
 func (o Name) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	toSerialize["name"] = o.Name
-	if o.SnakeCase != nil {
+	if !isNil(o.SnakeCase) {
 		toSerialize["snake_case"] = o.SnakeCase
 	}
-	if o.Property != nil {
+	if !isNil(o.Property) {
 		toSerialize["property"] = o.Property
 	}
-	if o.Var123Number != nil {
+	if !isNil(o.Var123Number) {
 		toSerialize["123Number"] = o.Var123Number
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_number_only.go b/samples/client/petstore/go/go-petstore/model_number_only.go
index fd2e0c83e4d..703c12254c0 100644
--- a/samples/client/petstore/go/go-petstore/model_number_only.go
+++ b/samples/client/petstore/go/go-petstore/model_number_only.go
@@ -41,7 +41,7 @@ func NewNumberOnlyWithDefaults() *NumberOnly {
 
 // GetJustNumber returns the JustNumber field value if set, zero value otherwise.
 func (o *NumberOnly) GetJustNumber() float32 {
-	if o == nil || o.JustNumber == nil {
+	if o == nil || isNil(o.JustNumber) {
 		var ret float32
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *NumberOnly) GetJustNumber() float32 {
 // GetJustNumberOk returns a tuple with the JustNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NumberOnly) GetJustNumberOk() (*float32, bool) {
-	if o == nil || o.JustNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.JustNumber) {
+    return nil, false
 	}
 	return o.JustNumber, true
 }
 
 // HasJustNumber returns a boolean if a field has been set.
 func (o *NumberOnly) HasJustNumber() bool {
-	if o != nil && o.JustNumber != nil {
+	if o != nil && !isNil(o.JustNumber) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o NumberOnly) MarshalJSON() ([]byte, error) {
 
 func (o NumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.JustNumber != nil {
+	if !isNil(o.JustNumber) {
 		toSerialize["JustNumber"] = o.JustNumber
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_order.go b/samples/client/petstore/go/go-petstore/model_order.go
index 783da73c9bd..9dea895388b 100644
--- a/samples/client/petstore/go/go-petstore/model_order.go
+++ b/samples/client/petstore/go/go-petstore/model_order.go
@@ -52,7 +52,7 @@ func NewOrderWithDefaults() *Order {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Order) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -62,15 +62,15 @@ func (o *Order) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Order) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o *Order) SetId(v int64) {
 
 // GetPetId returns the PetId field value if set, zero value otherwise.
 func (o *Order) GetPetId() int64 {
-	if o == nil || o.PetId == nil {
+	if o == nil || isNil(o.PetId) {
 		var ret int64
 		return ret
 	}
@@ -94,15 +94,15 @@ func (o *Order) GetPetId() int64 {
 // GetPetIdOk returns a tuple with the PetId field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetPetIdOk() (*int64, bool) {
-	if o == nil || o.PetId == nil {
-		return nil, false
+	if o == nil || isNil(o.PetId) {
+    return nil, false
 	}
 	return o.PetId, true
 }
 
 // HasPetId returns a boolean if a field has been set.
 func (o *Order) HasPetId() bool {
-	if o != nil && o.PetId != nil {
+	if o != nil && !isNil(o.PetId) {
 		return true
 	}
 
@@ -116,7 +116,7 @@ func (o *Order) SetPetId(v int64) {
 
 // GetQuantity returns the Quantity field value if set, zero value otherwise.
 func (o *Order) GetQuantity() int32 {
-	if o == nil || o.Quantity == nil {
+	if o == nil || isNil(o.Quantity) {
 		var ret int32
 		return ret
 	}
@@ -126,15 +126,15 @@ func (o *Order) GetQuantity() int32 {
 // GetQuantityOk returns a tuple with the Quantity field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetQuantityOk() (*int32, bool) {
-	if o == nil || o.Quantity == nil {
-		return nil, false
+	if o == nil || isNil(o.Quantity) {
+    return nil, false
 	}
 	return o.Quantity, true
 }
 
 // HasQuantity returns a boolean if a field has been set.
 func (o *Order) HasQuantity() bool {
-	if o != nil && o.Quantity != nil {
+	if o != nil && !isNil(o.Quantity) {
 		return true
 	}
 
@@ -148,7 +148,7 @@ func (o *Order) SetQuantity(v int32) {
 
 // GetShipDate returns the ShipDate field value if set, zero value otherwise.
 func (o *Order) GetShipDate() time.Time {
-	if o == nil || o.ShipDate == nil {
+	if o == nil || isNil(o.ShipDate) {
 		var ret time.Time
 		return ret
 	}
@@ -158,15 +158,15 @@ func (o *Order) GetShipDate() time.Time {
 // GetShipDateOk returns a tuple with the ShipDate field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetShipDateOk() (*time.Time, bool) {
-	if o == nil || o.ShipDate == nil {
-		return nil, false
+	if o == nil || isNil(o.ShipDate) {
+    return nil, false
 	}
 	return o.ShipDate, true
 }
 
 // HasShipDate returns a boolean if a field has been set.
 func (o *Order) HasShipDate() bool {
-	if o != nil && o.ShipDate != nil {
+	if o != nil && !isNil(o.ShipDate) {
 		return true
 	}
 
@@ -180,7 +180,7 @@ func (o *Order) SetShipDate(v time.Time) {
 
 // GetStatus returns the Status field value if set, zero value otherwise.
 func (o *Order) GetStatus() string {
-	if o == nil || o.Status == nil {
+	if o == nil || isNil(o.Status) {
 		var ret string
 		return ret
 	}
@@ -190,15 +190,15 @@ func (o *Order) GetStatus() string {
 // GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetStatusOk() (*string, bool) {
-	if o == nil || o.Status == nil {
-		return nil, false
+	if o == nil || isNil(o.Status) {
+    return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Order) HasStatus() bool {
-	if o != nil && o.Status != nil {
+	if o != nil && !isNil(o.Status) {
 		return true
 	}
 
@@ -212,7 +212,7 @@ func (o *Order) SetStatus(v string) {
 
 // GetComplete returns the Complete field value if set, zero value otherwise.
 func (o *Order) GetComplete() bool {
-	if o == nil || o.Complete == nil {
+	if o == nil || isNil(o.Complete) {
 		var ret bool
 		return ret
 	}
@@ -222,15 +222,15 @@ func (o *Order) GetComplete() bool {
 // GetCompleteOk returns a tuple with the Complete field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetCompleteOk() (*bool, bool) {
-	if o == nil || o.Complete == nil {
-		return nil, false
+	if o == nil || isNil(o.Complete) {
+    return nil, false
 	}
 	return o.Complete, true
 }
 
 // HasComplete returns a boolean if a field has been set.
 func (o *Order) HasComplete() bool {
-	if o != nil && o.Complete != nil {
+	if o != nil && !isNil(o.Complete) {
 		return true
 	}
 
@@ -252,22 +252,22 @@ func (o Order) MarshalJSON() ([]byte, error) {
 
 func (o Order) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.PetId != nil {
+	if !isNil(o.PetId) {
 		toSerialize["petId"] = o.PetId
 	}
-	if o.Quantity != nil {
+	if !isNil(o.Quantity) {
 		toSerialize["quantity"] = o.Quantity
 	}
-	if o.ShipDate != nil {
+	if !isNil(o.ShipDate) {
 		toSerialize["shipDate"] = o.ShipDate
 	}
-	if o.Status != nil {
+	if !isNil(o.Status) {
 		toSerialize["status"] = o.Status
 	}
-	if o.Complete != nil {
+	if !isNil(o.Complete) {
 		toSerialize["complete"] = o.Complete
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_outer_composite.go b/samples/client/petstore/go/go-petstore/model_outer_composite.go
index 13682bc04a3..55a5d6770c5 100644
--- a/samples/client/petstore/go/go-petstore/model_outer_composite.go
+++ b/samples/client/petstore/go/go-petstore/model_outer_composite.go
@@ -43,7 +43,7 @@ func NewOuterCompositeWithDefaults() *OuterComposite {
 
 // GetMyNumber returns the MyNumber field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyNumber() float32 {
-	if o == nil || o.MyNumber == nil {
+	if o == nil || isNil(o.MyNumber) {
 		var ret float32
 		return ret
 	}
@@ -53,15 +53,15 @@ func (o *OuterComposite) GetMyNumber() float32 {
 // GetMyNumberOk returns a tuple with the MyNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyNumberOk() (*float32, bool) {
-	if o == nil || o.MyNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.MyNumber) {
+    return nil, false
 	}
 	return o.MyNumber, true
 }
 
 // HasMyNumber returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyNumber() bool {
-	if o != nil && o.MyNumber != nil {
+	if o != nil && !isNil(o.MyNumber) {
 		return true
 	}
 
@@ -75,7 +75,7 @@ func (o *OuterComposite) SetMyNumber(v float32) {
 
 // GetMyString returns the MyString field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyString() string {
-	if o == nil || o.MyString == nil {
+	if o == nil || isNil(o.MyString) {
 		var ret string
 		return ret
 	}
@@ -85,15 +85,15 @@ func (o *OuterComposite) GetMyString() string {
 // GetMyStringOk returns a tuple with the MyString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyStringOk() (*string, bool) {
-	if o == nil || o.MyString == nil {
-		return nil, false
+	if o == nil || isNil(o.MyString) {
+    return nil, false
 	}
 	return o.MyString, true
 }
 
 // HasMyString returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyString() bool {
-	if o != nil && o.MyString != nil {
+	if o != nil && !isNil(o.MyString) {
 		return true
 	}
 
@@ -107,7 +107,7 @@ func (o *OuterComposite) SetMyString(v string) {
 
 // GetMyBoolean returns the MyBoolean field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyBoolean() bool {
-	if o == nil || o.MyBoolean == nil {
+	if o == nil || isNil(o.MyBoolean) {
 		var ret bool
 		return ret
 	}
@@ -117,15 +117,15 @@ func (o *OuterComposite) GetMyBoolean() bool {
 // GetMyBooleanOk returns a tuple with the MyBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyBooleanOk() (*bool, bool) {
-	if o == nil || o.MyBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.MyBoolean) {
+    return nil, false
 	}
 	return o.MyBoolean, true
 }
 
 // HasMyBoolean returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyBoolean() bool {
-	if o != nil && o.MyBoolean != nil {
+	if o != nil && !isNil(o.MyBoolean) {
 		return true
 	}
 
@@ -147,13 +147,13 @@ func (o OuterComposite) MarshalJSON() ([]byte, error) {
 
 func (o OuterComposite) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.MyNumber != nil {
+	if !isNil(o.MyNumber) {
 		toSerialize["my_number"] = o.MyNumber
 	}
-	if o.MyString != nil {
+	if !isNil(o.MyString) {
 		toSerialize["my_string"] = o.MyString
 	}
-	if o.MyBoolean != nil {
+	if !isNil(o.MyBoolean) {
 		toSerialize["my_boolean"] = o.MyBoolean
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_pet.go b/samples/client/petstore/go/go-petstore/model_pet.go
index 9580aef4ffc..1092fdabced 100644
--- a/samples/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/client/petstore/go/go-petstore/model_pet.go
@@ -49,7 +49,7 @@ func NewPetWithDefaults() *Pet {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Pet) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -59,15 +59,15 @@ func (o *Pet) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Pet) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o *Pet) SetId(v int64) {
 
 // GetCategory returns the Category field value if set, zero value otherwise.
 func (o *Pet) GetCategory() Category {
-	if o == nil || o.Category == nil {
+	if o == nil || isNil(o.Category) {
 		var ret Category
 		return ret
 	}
@@ -91,15 +91,15 @@ func (o *Pet) GetCategory() Category {
 // GetCategoryOk returns a tuple with the Category field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetCategoryOk() (*Category, bool) {
-	if o == nil || o.Category == nil {
-		return nil, false
+	if o == nil || isNil(o.Category) {
+    return nil, false
 	}
 	return o.Category, true
 }
 
 // HasCategory returns a boolean if a field has been set.
 func (o *Pet) HasCategory() bool {
-	if o != nil && o.Category != nil {
+	if o != nil && !isNil(o.Category) {
 		return true
 	}
 
@@ -124,9 +124,9 @@ func (o *Pet) GetName() string {
 // GetNameOk returns a tuple with the Name field value
 // and a boolean to check if the value has been set.
 func (o *Pet) GetNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Name, true
 }
 
@@ -148,9 +148,9 @@ func (o *Pet) GetPhotoUrls() []string {
 // GetPhotoUrlsOk returns a tuple with the PhotoUrls field value
 // and a boolean to check if the value has been set.
 func (o *Pet) GetPhotoUrlsOk() ([]string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return o.PhotoUrls, true
 }
 
@@ -161,7 +161,7 @@ func (o *Pet) SetPhotoUrls(v []string) {
 
 // GetTags returns the Tags field value if set, zero value otherwise.
 func (o *Pet) GetTags() []Tag {
-	if o == nil || o.Tags == nil {
+	if o == nil || isNil(o.Tags) {
 		var ret []Tag
 		return ret
 	}
@@ -171,15 +171,15 @@ func (o *Pet) GetTags() []Tag {
 // GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetTagsOk() ([]Tag, bool) {
-	if o == nil || o.Tags == nil {
-		return nil, false
+	if o == nil || isNil(o.Tags) {
+    return nil, false
 	}
 	return o.Tags, true
 }
 
 // HasTags returns a boolean if a field has been set.
 func (o *Pet) HasTags() bool {
-	if o != nil && o.Tags != nil {
+	if o != nil && !isNil(o.Tags) {
 		return true
 	}
 
@@ -193,7 +193,7 @@ func (o *Pet) SetTags(v []Tag) {
 
 // GetStatus returns the Status field value if set, zero value otherwise.
 func (o *Pet) GetStatus() string {
-	if o == nil || o.Status == nil {
+	if o == nil || isNil(o.Status) {
 		var ret string
 		return ret
 	}
@@ -203,15 +203,15 @@ func (o *Pet) GetStatus() string {
 // GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetStatusOk() (*string, bool) {
-	if o == nil || o.Status == nil {
-		return nil, false
+	if o == nil || isNil(o.Status) {
+    return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Pet) HasStatus() bool {
-	if o != nil && o.Status != nil {
+	if o != nil && !isNil(o.Status) {
 		return true
 	}
 
@@ -233,18 +233,18 @@ func (o Pet) MarshalJSON() ([]byte, error) {
 
 func (o Pet) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.Category != nil {
+	if !isNil(o.Category) {
 		toSerialize["category"] = o.Category
 	}
 	toSerialize["name"] = o.Name
 	toSerialize["photoUrls"] = o.PhotoUrls
-	if o.Tags != nil {
+	if !isNil(o.Tags) {
 		toSerialize["tags"] = o.Tags
 	}
-	if o.Status != nil {
+	if !isNil(o.Status) {
 		toSerialize["status"] = o.Status
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_read_only_first.go b/samples/client/petstore/go/go-petstore/model_read_only_first.go
index 7ca2bf61470..a9453dddac2 100644
--- a/samples/client/petstore/go/go-petstore/model_read_only_first.go
+++ b/samples/client/petstore/go/go-petstore/model_read_only_first.go
@@ -42,7 +42,7 @@ func NewReadOnlyFirstWithDefaults() *ReadOnlyFirst {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBar() string {
-	if o == nil || o.Bar == nil {
+	if o == nil || isNil(o.Bar) {
 		var ret string
 		return ret
 	}
@@ -52,15 +52,15 @@ func (o *ReadOnlyFirst) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBarOk() (*string, bool) {
-	if o == nil || o.Bar == nil {
-		return nil, false
+	if o == nil || isNil(o.Bar) {
+    return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBar() bool {
-	if o != nil && o.Bar != nil {
+	if o != nil && !isNil(o.Bar) {
 		return true
 	}
 
@@ -74,7 +74,7 @@ func (o *ReadOnlyFirst) SetBar(v string) {
 
 // GetBaz returns the Baz field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBaz() string {
-	if o == nil || o.Baz == nil {
+	if o == nil || isNil(o.Baz) {
 		var ret string
 		return ret
 	}
@@ -84,15 +84,15 @@ func (o *ReadOnlyFirst) GetBaz() string {
 // GetBazOk returns a tuple with the Baz field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBazOk() (*string, bool) {
-	if o == nil || o.Baz == nil {
-		return nil, false
+	if o == nil || isNil(o.Baz) {
+    return nil, false
 	}
 	return o.Baz, true
 }
 
 // HasBaz returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBaz() bool {
-	if o != nil && o.Baz != nil {
+	if o != nil && !isNil(o.Baz) {
 		return true
 	}
 
@@ -114,10 +114,10 @@ func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) {
 
 func (o ReadOnlyFirst) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Bar != nil {
+	if !isNil(o.Bar) {
 		toSerialize["bar"] = o.Bar
 	}
-	if o.Baz != nil {
+	if !isNil(o.Baz) {
 		toSerialize["baz"] = o.Baz
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_return.go b/samples/client/petstore/go/go-petstore/model_return.go
index 2060072ff72..db091579a21 100644
--- a/samples/client/petstore/go/go-petstore/model_return.go
+++ b/samples/client/petstore/go/go-petstore/model_return.go
@@ -41,7 +41,7 @@ func NewReturnWithDefaults() *Return {
 
 // GetReturn returns the Return field value if set, zero value otherwise.
 func (o *Return) GetReturn() int32 {
-	if o == nil || o.Return == nil {
+	if o == nil || isNil(o.Return) {
 		var ret int32
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *Return) GetReturn() int32 {
 // GetReturnOk returns a tuple with the Return field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Return) GetReturnOk() (*int32, bool) {
-	if o == nil || o.Return == nil {
-		return nil, false
+	if o == nil || isNil(o.Return) {
+    return nil, false
 	}
 	return o.Return, true
 }
 
 // HasReturn returns a boolean if a field has been set.
 func (o *Return) HasReturn() bool {
-	if o != nil && o.Return != nil {
+	if o != nil && !isNil(o.Return) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o Return) MarshalJSON() ([]byte, error) {
 
 func (o Return) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Return != nil {
+	if !isNil(o.Return) {
 		toSerialize["return"] = o.Return
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_special_model_name.go b/samples/client/petstore/go/go-petstore/model_special_model_name.go
index 730a8966914..411ddec108c 100644
--- a/samples/client/petstore/go/go-petstore/model_special_model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_special_model_name.go
@@ -41,7 +41,7 @@ func NewSpecialModelNameWithDefaults() *SpecialModelName {
 
 // GetSpecialPropertyName returns the SpecialPropertyName field value if set, zero value otherwise.
 func (o *SpecialModelName) GetSpecialPropertyName() int64 {
-	if o == nil || o.SpecialPropertyName == nil {
+	if o == nil || isNil(o.SpecialPropertyName) {
 		var ret int64
 		return ret
 	}
@@ -51,15 +51,15 @@ func (o *SpecialModelName) GetSpecialPropertyName() int64 {
 // GetSpecialPropertyNameOk returns a tuple with the SpecialPropertyName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *SpecialModelName) GetSpecialPropertyNameOk() (*int64, bool) {
-	if o == nil || o.SpecialPropertyName == nil {
-		return nil, false
+	if o == nil || isNil(o.SpecialPropertyName) {
+    return nil, false
 	}
 	return o.SpecialPropertyName, true
 }
 
 // HasSpecialPropertyName returns a boolean if a field has been set.
 func (o *SpecialModelName) HasSpecialPropertyName() bool {
-	if o != nil && o.SpecialPropertyName != nil {
+	if o != nil && !isNil(o.SpecialPropertyName) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o SpecialModelName) MarshalJSON() ([]byte, error) {
 
 func (o SpecialModelName) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.SpecialPropertyName != nil {
+	if !isNil(o.SpecialPropertyName) {
 		toSerialize["$special[property.name]"] = o.SpecialPropertyName
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_tag.go b/samples/client/petstore/go/go-petstore/model_tag.go
index a8cc2da8820..79490e71774 100644
--- a/samples/client/petstore/go/go-petstore/model_tag.go
+++ b/samples/client/petstore/go/go-petstore/model_tag.go
@@ -42,7 +42,7 @@ func NewTagWithDefaults() *Tag {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Tag) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -52,15 +52,15 @@ func (o *Tag) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Tag) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -74,7 +74,7 @@ func (o *Tag) SetId(v int64) {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *Tag) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -84,15 +84,15 @@ func (o *Tag) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *Tag) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -114,10 +114,10 @@ func (o Tag) MarshalJSON() ([]byte, error) {
 
 func (o Tag) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_default.go b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
index 3214aac6a22..60b7e8748f0 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_default.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
@@ -65,9 +65,9 @@ func (o *TypeHolderDefault) GetStringItem() string {
 // GetStringItemOk returns a tuple with the StringItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderDefault) GetStringItemOk() (*string, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.StringItem, true
 }
 
@@ -89,9 +89,9 @@ func (o *TypeHolderDefault) GetNumberItem() float32 {
 // GetNumberItemOk returns a tuple with the NumberItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderDefault) GetNumberItemOk() (*float32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.NumberItem, true
 }
 
@@ -113,9 +113,9 @@ func (o *TypeHolderDefault) GetIntegerItem() int32 {
 // GetIntegerItemOk returns a tuple with the IntegerItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderDefault) GetIntegerItemOk() (*int32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.IntegerItem, true
 }
 
@@ -137,9 +137,9 @@ func (o *TypeHolderDefault) GetBoolItem() bool {
 // GetBoolItemOk returns a tuple with the BoolItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderDefault) GetBoolItemOk() (*bool, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.BoolItem, true
 }
 
@@ -161,9 +161,9 @@ func (o *TypeHolderDefault) GetArrayItem() []int32 {
 // GetArrayItemOk returns a tuple with the ArrayItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderDefault) GetArrayItemOk() ([]int32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return o.ArrayItem, true
 }
 
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_example.go b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
index e2b89b6bc72..fee233708ca 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_example.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
@@ -63,9 +63,9 @@ func (o *TypeHolderExample) GetStringItem() string {
 // GetStringItemOk returns a tuple with the StringItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderExample) GetStringItemOk() (*string, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.StringItem, true
 }
 
@@ -87,9 +87,9 @@ func (o *TypeHolderExample) GetNumberItem() float32 {
 // GetNumberItemOk returns a tuple with the NumberItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderExample) GetNumberItemOk() (*float32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.NumberItem, true
 }
 
@@ -111,9 +111,9 @@ func (o *TypeHolderExample) GetFloatItem() float32 {
 // GetFloatItemOk returns a tuple with the FloatItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderExample) GetFloatItemOk() (*float32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.FloatItem, true
 }
 
@@ -135,9 +135,9 @@ func (o *TypeHolderExample) GetIntegerItem() int32 {
 // GetIntegerItemOk returns a tuple with the IntegerItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderExample) GetIntegerItemOk() (*int32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.IntegerItem, true
 }
 
@@ -159,9 +159,9 @@ func (o *TypeHolderExample) GetBoolItem() bool {
 // GetBoolItemOk returns a tuple with the BoolItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderExample) GetBoolItemOk() (*bool, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.BoolItem, true
 }
 
@@ -183,9 +183,9 @@ func (o *TypeHolderExample) GetArrayItem() []int32 {
 // GetArrayItemOk returns a tuple with the ArrayItem field value
 // and a boolean to check if the value has been set.
 func (o *TypeHolderExample) GetArrayItemOk() ([]int32, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return o.ArrayItem, true
 }
 
diff --git a/samples/client/petstore/go/go-petstore/model_user.go b/samples/client/petstore/go/go-petstore/model_user.go
index 10c8f3b337d..a425517aece 100644
--- a/samples/client/petstore/go/go-petstore/model_user.go
+++ b/samples/client/petstore/go/go-petstore/model_user.go
@@ -49,7 +49,7 @@ func NewUserWithDefaults() *User {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *User) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -59,15 +59,15 @@ func (o *User) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *User) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -81,7 +81,7 @@ func (o *User) SetId(v int64) {
 
 // GetUsername returns the Username field value if set, zero value otherwise.
 func (o *User) GetUsername() string {
-	if o == nil || o.Username == nil {
+	if o == nil || isNil(o.Username) {
 		var ret string
 		return ret
 	}
@@ -91,15 +91,15 @@ func (o *User) GetUsername() string {
 // GetUsernameOk returns a tuple with the Username field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUsernameOk() (*string, bool) {
-	if o == nil || o.Username == nil {
-		return nil, false
+	if o == nil || isNil(o.Username) {
+    return nil, false
 	}
 	return o.Username, true
 }
 
 // HasUsername returns a boolean if a field has been set.
 func (o *User) HasUsername() bool {
-	if o != nil && o.Username != nil {
+	if o != nil && !isNil(o.Username) {
 		return true
 	}
 
@@ -113,7 +113,7 @@ func (o *User) SetUsername(v string) {
 
 // GetFirstName returns the FirstName field value if set, zero value otherwise.
 func (o *User) GetFirstName() string {
-	if o == nil || o.FirstName == nil {
+	if o == nil || isNil(o.FirstName) {
 		var ret string
 		return ret
 	}
@@ -123,15 +123,15 @@ func (o *User) GetFirstName() string {
 // GetFirstNameOk returns a tuple with the FirstName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetFirstNameOk() (*string, bool) {
-	if o == nil || o.FirstName == nil {
-		return nil, false
+	if o == nil || isNil(o.FirstName) {
+    return nil, false
 	}
 	return o.FirstName, true
 }
 
 // HasFirstName returns a boolean if a field has been set.
 func (o *User) HasFirstName() bool {
-	if o != nil && o.FirstName != nil {
+	if o != nil && !isNil(o.FirstName) {
 		return true
 	}
 
@@ -145,7 +145,7 @@ func (o *User) SetFirstName(v string) {
 
 // GetLastName returns the LastName field value if set, zero value otherwise.
 func (o *User) GetLastName() string {
-	if o == nil || o.LastName == nil {
+	if o == nil || isNil(o.LastName) {
 		var ret string
 		return ret
 	}
@@ -155,15 +155,15 @@ func (o *User) GetLastName() string {
 // GetLastNameOk returns a tuple with the LastName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetLastNameOk() (*string, bool) {
-	if o == nil || o.LastName == nil {
-		return nil, false
+	if o == nil || isNil(o.LastName) {
+    return nil, false
 	}
 	return o.LastName, true
 }
 
 // HasLastName returns a boolean if a field has been set.
 func (o *User) HasLastName() bool {
-	if o != nil && o.LastName != nil {
+	if o != nil && !isNil(o.LastName) {
 		return true
 	}
 
@@ -177,7 +177,7 @@ func (o *User) SetLastName(v string) {
 
 // GetEmail returns the Email field value if set, zero value otherwise.
 func (o *User) GetEmail() string {
-	if o == nil || o.Email == nil {
+	if o == nil || isNil(o.Email) {
 		var ret string
 		return ret
 	}
@@ -187,15 +187,15 @@ func (o *User) GetEmail() string {
 // GetEmailOk returns a tuple with the Email field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetEmailOk() (*string, bool) {
-	if o == nil || o.Email == nil {
-		return nil, false
+	if o == nil || isNil(o.Email) {
+    return nil, false
 	}
 	return o.Email, true
 }
 
 // HasEmail returns a boolean if a field has been set.
 func (o *User) HasEmail() bool {
-	if o != nil && o.Email != nil {
+	if o != nil && !isNil(o.Email) {
 		return true
 	}
 
@@ -209,7 +209,7 @@ func (o *User) SetEmail(v string) {
 
 // GetPassword returns the Password field value if set, zero value otherwise.
 func (o *User) GetPassword() string {
-	if o == nil || o.Password == nil {
+	if o == nil || isNil(o.Password) {
 		var ret string
 		return ret
 	}
@@ -219,15 +219,15 @@ func (o *User) GetPassword() string {
 // GetPasswordOk returns a tuple with the Password field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPasswordOk() (*string, bool) {
-	if o == nil || o.Password == nil {
-		return nil, false
+	if o == nil || isNil(o.Password) {
+    return nil, false
 	}
 	return o.Password, true
 }
 
 // HasPassword returns a boolean if a field has been set.
 func (o *User) HasPassword() bool {
-	if o != nil && o.Password != nil {
+	if o != nil && !isNil(o.Password) {
 		return true
 	}
 
@@ -241,7 +241,7 @@ func (o *User) SetPassword(v string) {
 
 // GetPhone returns the Phone field value if set, zero value otherwise.
 func (o *User) GetPhone() string {
-	if o == nil || o.Phone == nil {
+	if o == nil || isNil(o.Phone) {
 		var ret string
 		return ret
 	}
@@ -251,15 +251,15 @@ func (o *User) GetPhone() string {
 // GetPhoneOk returns a tuple with the Phone field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPhoneOk() (*string, bool) {
-	if o == nil || o.Phone == nil {
-		return nil, false
+	if o == nil || isNil(o.Phone) {
+    return nil, false
 	}
 	return o.Phone, true
 }
 
 // HasPhone returns a boolean if a field has been set.
 func (o *User) HasPhone() bool {
-	if o != nil && o.Phone != nil {
+	if o != nil && !isNil(o.Phone) {
 		return true
 	}
 
@@ -273,7 +273,7 @@ func (o *User) SetPhone(v string) {
 
 // GetUserStatus returns the UserStatus field value if set, zero value otherwise.
 func (o *User) GetUserStatus() int32 {
-	if o == nil || o.UserStatus == nil {
+	if o == nil || isNil(o.UserStatus) {
 		var ret int32
 		return ret
 	}
@@ -283,15 +283,15 @@ func (o *User) GetUserStatus() int32 {
 // GetUserStatusOk returns a tuple with the UserStatus field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUserStatusOk() (*int32, bool) {
-	if o == nil || o.UserStatus == nil {
-		return nil, false
+	if o == nil || isNil(o.UserStatus) {
+    return nil, false
 	}
 	return o.UserStatus, true
 }
 
 // HasUserStatus returns a boolean if a field has been set.
 func (o *User) HasUserStatus() bool {
-	if o != nil && o.UserStatus != nil {
+	if o != nil && !isNil(o.UserStatus) {
 		return true
 	}
 
@@ -313,28 +313,28 @@ func (o User) MarshalJSON() ([]byte, error) {
 
 func (o User) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.Username != nil {
+	if !isNil(o.Username) {
 		toSerialize["username"] = o.Username
 	}
-	if o.FirstName != nil {
+	if !isNil(o.FirstName) {
 		toSerialize["firstName"] = o.FirstName
 	}
-	if o.LastName != nil {
+	if !isNil(o.LastName) {
 		toSerialize["lastName"] = o.LastName
 	}
-	if o.Email != nil {
+	if !isNil(o.Email) {
 		toSerialize["email"] = o.Email
 	}
-	if o.Password != nil {
+	if !isNil(o.Password) {
 		toSerialize["password"] = o.Password
 	}
-	if o.Phone != nil {
+	if !isNil(o.Phone) {
 		toSerialize["phone"] = o.Phone
 	}
-	if o.UserStatus != nil {
+	if !isNil(o.UserStatus) {
 		toSerialize["userStatus"] = o.UserStatus
 	}
 	return toSerialize, nil
diff --git a/samples/client/petstore/go/go-petstore/model_xml_item.go b/samples/client/petstore/go/go-petstore/model_xml_item.go
index ef5a06d7db1..aed83b79aba 100644
--- a/samples/client/petstore/go/go-petstore/model_xml_item.go
+++ b/samples/client/petstore/go/go-petstore/model_xml_item.go
@@ -69,7 +69,7 @@ func NewXmlItemWithDefaults() *XmlItem {
 
 // GetAttributeString returns the AttributeString field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeString() string {
-	if o == nil || o.AttributeString == nil {
+	if o == nil || isNil(o.AttributeString) {
 		var ret string
 		return ret
 	}
@@ -79,15 +79,15 @@ func (o *XmlItem) GetAttributeString() string {
 // GetAttributeStringOk returns a tuple with the AttributeString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeStringOk() (*string, bool) {
-	if o == nil || o.AttributeString == nil {
-		return nil, false
+	if o == nil || isNil(o.AttributeString) {
+    return nil, false
 	}
 	return o.AttributeString, true
 }
 
 // HasAttributeString returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeString() bool {
-	if o != nil && o.AttributeString != nil {
+	if o != nil && !isNil(o.AttributeString) {
 		return true
 	}
 
@@ -101,7 +101,7 @@ func (o *XmlItem) SetAttributeString(v string) {
 
 // GetAttributeNumber returns the AttributeNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeNumber() float32 {
-	if o == nil || o.AttributeNumber == nil {
+	if o == nil || isNil(o.AttributeNumber) {
 		var ret float32
 		return ret
 	}
@@ -111,15 +111,15 @@ func (o *XmlItem) GetAttributeNumber() float32 {
 // GetAttributeNumberOk returns a tuple with the AttributeNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeNumberOk() (*float32, bool) {
-	if o == nil || o.AttributeNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.AttributeNumber) {
+    return nil, false
 	}
 	return o.AttributeNumber, true
 }
 
 // HasAttributeNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeNumber() bool {
-	if o != nil && o.AttributeNumber != nil {
+	if o != nil && !isNil(o.AttributeNumber) {
 		return true
 	}
 
@@ -133,7 +133,7 @@ func (o *XmlItem) SetAttributeNumber(v float32) {
 
 // GetAttributeInteger returns the AttributeInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeInteger() int32 {
-	if o == nil || o.AttributeInteger == nil {
+	if o == nil || isNil(o.AttributeInteger) {
 		var ret int32
 		return ret
 	}
@@ -143,15 +143,15 @@ func (o *XmlItem) GetAttributeInteger() int32 {
 // GetAttributeIntegerOk returns a tuple with the AttributeInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeIntegerOk() (*int32, bool) {
-	if o == nil || o.AttributeInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.AttributeInteger) {
+    return nil, false
 	}
 	return o.AttributeInteger, true
 }
 
 // HasAttributeInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeInteger() bool {
-	if o != nil && o.AttributeInteger != nil {
+	if o != nil && !isNil(o.AttributeInteger) {
 		return true
 	}
 
@@ -165,7 +165,7 @@ func (o *XmlItem) SetAttributeInteger(v int32) {
 
 // GetAttributeBoolean returns the AttributeBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetAttributeBoolean() bool {
-	if o == nil || o.AttributeBoolean == nil {
+	if o == nil || isNil(o.AttributeBoolean) {
 		var ret bool
 		return ret
 	}
@@ -175,15 +175,15 @@ func (o *XmlItem) GetAttributeBoolean() bool {
 // GetAttributeBooleanOk returns a tuple with the AttributeBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetAttributeBooleanOk() (*bool, bool) {
-	if o == nil || o.AttributeBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.AttributeBoolean) {
+    return nil, false
 	}
 	return o.AttributeBoolean, true
 }
 
 // HasAttributeBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasAttributeBoolean() bool {
-	if o != nil && o.AttributeBoolean != nil {
+	if o != nil && !isNil(o.AttributeBoolean) {
 		return true
 	}
 
@@ -197,7 +197,7 @@ func (o *XmlItem) SetAttributeBoolean(v bool) {
 
 // GetWrappedArray returns the WrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetWrappedArray() []int32 {
-	if o == nil || o.WrappedArray == nil {
+	if o == nil || isNil(o.WrappedArray) {
 		var ret []int32
 		return ret
 	}
@@ -207,15 +207,15 @@ func (o *XmlItem) GetWrappedArray() []int32 {
 // GetWrappedArrayOk returns a tuple with the WrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetWrappedArrayOk() ([]int32, bool) {
-	if o == nil || o.WrappedArray == nil {
-		return nil, false
+	if o == nil || isNil(o.WrappedArray) {
+    return nil, false
 	}
 	return o.WrappedArray, true
 }
 
 // HasWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasWrappedArray() bool {
-	if o != nil && o.WrappedArray != nil {
+	if o != nil && !isNil(o.WrappedArray) {
 		return true
 	}
 
@@ -229,7 +229,7 @@ func (o *XmlItem) SetWrappedArray(v []int32) {
 
 // GetNameString returns the NameString field value if set, zero value otherwise.
 func (o *XmlItem) GetNameString() string {
-	if o == nil || o.NameString == nil {
+	if o == nil || isNil(o.NameString) {
 		var ret string
 		return ret
 	}
@@ -239,15 +239,15 @@ func (o *XmlItem) GetNameString() string {
 // GetNameStringOk returns a tuple with the NameString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameStringOk() (*string, bool) {
-	if o == nil || o.NameString == nil {
-		return nil, false
+	if o == nil || isNil(o.NameString) {
+    return nil, false
 	}
 	return o.NameString, true
 }
 
 // HasNameString returns a boolean if a field has been set.
 func (o *XmlItem) HasNameString() bool {
-	if o != nil && o.NameString != nil {
+	if o != nil && !isNil(o.NameString) {
 		return true
 	}
 
@@ -261,7 +261,7 @@ func (o *XmlItem) SetNameString(v string) {
 
 // GetNameNumber returns the NameNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetNameNumber() float32 {
-	if o == nil || o.NameNumber == nil {
+	if o == nil || isNil(o.NameNumber) {
 		var ret float32
 		return ret
 	}
@@ -271,15 +271,15 @@ func (o *XmlItem) GetNameNumber() float32 {
 // GetNameNumberOk returns a tuple with the NameNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameNumberOk() (*float32, bool) {
-	if o == nil || o.NameNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.NameNumber) {
+    return nil, false
 	}
 	return o.NameNumber, true
 }
 
 // HasNameNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasNameNumber() bool {
-	if o != nil && o.NameNumber != nil {
+	if o != nil && !isNil(o.NameNumber) {
 		return true
 	}
 
@@ -293,7 +293,7 @@ func (o *XmlItem) SetNameNumber(v float32) {
 
 // GetNameInteger returns the NameInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetNameInteger() int32 {
-	if o == nil || o.NameInteger == nil {
+	if o == nil || isNil(o.NameInteger) {
 		var ret int32
 		return ret
 	}
@@ -303,15 +303,15 @@ func (o *XmlItem) GetNameInteger() int32 {
 // GetNameIntegerOk returns a tuple with the NameInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameIntegerOk() (*int32, bool) {
-	if o == nil || o.NameInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.NameInteger) {
+    return nil, false
 	}
 	return o.NameInteger, true
 }
 
 // HasNameInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasNameInteger() bool {
-	if o != nil && o.NameInteger != nil {
+	if o != nil && !isNil(o.NameInteger) {
 		return true
 	}
 
@@ -325,7 +325,7 @@ func (o *XmlItem) SetNameInteger(v int32) {
 
 // GetNameBoolean returns the NameBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetNameBoolean() bool {
-	if o == nil || o.NameBoolean == nil {
+	if o == nil || isNil(o.NameBoolean) {
 		var ret bool
 		return ret
 	}
@@ -335,15 +335,15 @@ func (o *XmlItem) GetNameBoolean() bool {
 // GetNameBooleanOk returns a tuple with the NameBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameBooleanOk() (*bool, bool) {
-	if o == nil || o.NameBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.NameBoolean) {
+    return nil, false
 	}
 	return o.NameBoolean, true
 }
 
 // HasNameBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasNameBoolean() bool {
-	if o != nil && o.NameBoolean != nil {
+	if o != nil && !isNil(o.NameBoolean) {
 		return true
 	}
 
@@ -357,7 +357,7 @@ func (o *XmlItem) SetNameBoolean(v bool) {
 
 // GetNameArray returns the NameArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNameArray() []int32 {
-	if o == nil || o.NameArray == nil {
+	if o == nil || isNil(o.NameArray) {
 		var ret []int32
 		return ret
 	}
@@ -367,15 +367,15 @@ func (o *XmlItem) GetNameArray() []int32 {
 // GetNameArrayOk returns a tuple with the NameArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameArrayOk() ([]int32, bool) {
-	if o == nil || o.NameArray == nil {
-		return nil, false
+	if o == nil || isNil(o.NameArray) {
+    return nil, false
 	}
 	return o.NameArray, true
 }
 
 // HasNameArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNameArray() bool {
-	if o != nil && o.NameArray != nil {
+	if o != nil && !isNil(o.NameArray) {
 		return true
 	}
 
@@ -389,7 +389,7 @@ func (o *XmlItem) SetNameArray(v []int32) {
 
 // GetNameWrappedArray returns the NameWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNameWrappedArray() []int32 {
-	if o == nil || o.NameWrappedArray == nil {
+	if o == nil || isNil(o.NameWrappedArray) {
 		var ret []int32
 		return ret
 	}
@@ -399,15 +399,15 @@ func (o *XmlItem) GetNameWrappedArray() []int32 {
 // GetNameWrappedArrayOk returns a tuple with the NameWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNameWrappedArrayOk() ([]int32, bool) {
-	if o == nil || o.NameWrappedArray == nil {
-		return nil, false
+	if o == nil || isNil(o.NameWrappedArray) {
+    return nil, false
 	}
 	return o.NameWrappedArray, true
 }
 
 // HasNameWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNameWrappedArray() bool {
-	if o != nil && o.NameWrappedArray != nil {
+	if o != nil && !isNil(o.NameWrappedArray) {
 		return true
 	}
 
@@ -421,7 +421,7 @@ func (o *XmlItem) SetNameWrappedArray(v []int32) {
 
 // GetPrefixString returns the PrefixString field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixString() string {
-	if o == nil || o.PrefixString == nil {
+	if o == nil || isNil(o.PrefixString) {
 		var ret string
 		return ret
 	}
@@ -431,15 +431,15 @@ func (o *XmlItem) GetPrefixString() string {
 // GetPrefixStringOk returns a tuple with the PrefixString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixStringOk() (*string, bool) {
-	if o == nil || o.PrefixString == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixString) {
+    return nil, false
 	}
 	return o.PrefixString, true
 }
 
 // HasPrefixString returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixString() bool {
-	if o != nil && o.PrefixString != nil {
+	if o != nil && !isNil(o.PrefixString) {
 		return true
 	}
 
@@ -453,7 +453,7 @@ func (o *XmlItem) SetPrefixString(v string) {
 
 // GetPrefixNumber returns the PrefixNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNumber() float32 {
-	if o == nil || o.PrefixNumber == nil {
+	if o == nil || isNil(o.PrefixNumber) {
 		var ret float32
 		return ret
 	}
@@ -463,15 +463,15 @@ func (o *XmlItem) GetPrefixNumber() float32 {
 // GetPrefixNumberOk returns a tuple with the PrefixNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNumberOk() (*float32, bool) {
-	if o == nil || o.PrefixNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNumber) {
+    return nil, false
 	}
 	return o.PrefixNumber, true
 }
 
 // HasPrefixNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNumber() bool {
-	if o != nil && o.PrefixNumber != nil {
+	if o != nil && !isNil(o.PrefixNumber) {
 		return true
 	}
 
@@ -485,7 +485,7 @@ func (o *XmlItem) SetPrefixNumber(v float32) {
 
 // GetPrefixInteger returns the PrefixInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixInteger() int32 {
-	if o == nil || o.PrefixInteger == nil {
+	if o == nil || isNil(o.PrefixInteger) {
 		var ret int32
 		return ret
 	}
@@ -495,15 +495,15 @@ func (o *XmlItem) GetPrefixInteger() int32 {
 // GetPrefixIntegerOk returns a tuple with the PrefixInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixIntegerOk() (*int32, bool) {
-	if o == nil || o.PrefixInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixInteger) {
+    return nil, false
 	}
 	return o.PrefixInteger, true
 }
 
 // HasPrefixInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixInteger() bool {
-	if o != nil && o.PrefixInteger != nil {
+	if o != nil && !isNil(o.PrefixInteger) {
 		return true
 	}
 
@@ -517,7 +517,7 @@ func (o *XmlItem) SetPrefixInteger(v int32) {
 
 // GetPrefixBoolean returns the PrefixBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixBoolean() bool {
-	if o == nil || o.PrefixBoolean == nil {
+	if o == nil || isNil(o.PrefixBoolean) {
 		var ret bool
 		return ret
 	}
@@ -527,15 +527,15 @@ func (o *XmlItem) GetPrefixBoolean() bool {
 // GetPrefixBooleanOk returns a tuple with the PrefixBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixBooleanOk() (*bool, bool) {
-	if o == nil || o.PrefixBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixBoolean) {
+    return nil, false
 	}
 	return o.PrefixBoolean, true
 }
 
 // HasPrefixBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixBoolean() bool {
-	if o != nil && o.PrefixBoolean != nil {
+	if o != nil && !isNil(o.PrefixBoolean) {
 		return true
 	}
 
@@ -549,7 +549,7 @@ func (o *XmlItem) SetPrefixBoolean(v bool) {
 
 // GetPrefixArray returns the PrefixArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixArray() []int32 {
-	if o == nil || o.PrefixArray == nil {
+	if o == nil || isNil(o.PrefixArray) {
 		var ret []int32
 		return ret
 	}
@@ -559,15 +559,15 @@ func (o *XmlItem) GetPrefixArray() []int32 {
 // GetPrefixArrayOk returns a tuple with the PrefixArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixArrayOk() ([]int32, bool) {
-	if o == nil || o.PrefixArray == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixArray) {
+    return nil, false
 	}
 	return o.PrefixArray, true
 }
 
 // HasPrefixArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixArray() bool {
-	if o != nil && o.PrefixArray != nil {
+	if o != nil && !isNil(o.PrefixArray) {
 		return true
 	}
 
@@ -581,7 +581,7 @@ func (o *XmlItem) SetPrefixArray(v []int32) {
 
 // GetPrefixWrappedArray returns the PrefixWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixWrappedArray() []int32 {
-	if o == nil || o.PrefixWrappedArray == nil {
+	if o == nil || isNil(o.PrefixWrappedArray) {
 		var ret []int32
 		return ret
 	}
@@ -591,15 +591,15 @@ func (o *XmlItem) GetPrefixWrappedArray() []int32 {
 // GetPrefixWrappedArrayOk returns a tuple with the PrefixWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixWrappedArrayOk() ([]int32, bool) {
-	if o == nil || o.PrefixWrappedArray == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixWrappedArray) {
+    return nil, false
 	}
 	return o.PrefixWrappedArray, true
 }
 
 // HasPrefixWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixWrappedArray() bool {
-	if o != nil && o.PrefixWrappedArray != nil {
+	if o != nil && !isNil(o.PrefixWrappedArray) {
 		return true
 	}
 
@@ -613,7 +613,7 @@ func (o *XmlItem) SetPrefixWrappedArray(v []int32) {
 
 // GetNamespaceString returns the NamespaceString field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceString() string {
-	if o == nil || o.NamespaceString == nil {
+	if o == nil || isNil(o.NamespaceString) {
 		var ret string
 		return ret
 	}
@@ -623,15 +623,15 @@ func (o *XmlItem) GetNamespaceString() string {
 // GetNamespaceStringOk returns a tuple with the NamespaceString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceStringOk() (*string, bool) {
-	if o == nil || o.NamespaceString == nil {
-		return nil, false
+	if o == nil || isNil(o.NamespaceString) {
+    return nil, false
 	}
 	return o.NamespaceString, true
 }
 
 // HasNamespaceString returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceString() bool {
-	if o != nil && o.NamespaceString != nil {
+	if o != nil && !isNil(o.NamespaceString) {
 		return true
 	}
 
@@ -645,7 +645,7 @@ func (o *XmlItem) SetNamespaceString(v string) {
 
 // GetNamespaceNumber returns the NamespaceNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceNumber() float32 {
-	if o == nil || o.NamespaceNumber == nil {
+	if o == nil || isNil(o.NamespaceNumber) {
 		var ret float32
 		return ret
 	}
@@ -655,15 +655,15 @@ func (o *XmlItem) GetNamespaceNumber() float32 {
 // GetNamespaceNumberOk returns a tuple with the NamespaceNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceNumberOk() (*float32, bool) {
-	if o == nil || o.NamespaceNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.NamespaceNumber) {
+    return nil, false
 	}
 	return o.NamespaceNumber, true
 }
 
 // HasNamespaceNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceNumber() bool {
-	if o != nil && o.NamespaceNumber != nil {
+	if o != nil && !isNil(o.NamespaceNumber) {
 		return true
 	}
 
@@ -677,7 +677,7 @@ func (o *XmlItem) SetNamespaceNumber(v float32) {
 
 // GetNamespaceInteger returns the NamespaceInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceInteger() int32 {
-	if o == nil || o.NamespaceInteger == nil {
+	if o == nil || isNil(o.NamespaceInteger) {
 		var ret int32
 		return ret
 	}
@@ -687,15 +687,15 @@ func (o *XmlItem) GetNamespaceInteger() int32 {
 // GetNamespaceIntegerOk returns a tuple with the NamespaceInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceIntegerOk() (*int32, bool) {
-	if o == nil || o.NamespaceInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.NamespaceInteger) {
+    return nil, false
 	}
 	return o.NamespaceInteger, true
 }
 
 // HasNamespaceInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceInteger() bool {
-	if o != nil && o.NamespaceInteger != nil {
+	if o != nil && !isNil(o.NamespaceInteger) {
 		return true
 	}
 
@@ -709,7 +709,7 @@ func (o *XmlItem) SetNamespaceInteger(v int32) {
 
 // GetNamespaceBoolean returns the NamespaceBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceBoolean() bool {
-	if o == nil || o.NamespaceBoolean == nil {
+	if o == nil || isNil(o.NamespaceBoolean) {
 		var ret bool
 		return ret
 	}
@@ -719,15 +719,15 @@ func (o *XmlItem) GetNamespaceBoolean() bool {
 // GetNamespaceBooleanOk returns a tuple with the NamespaceBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceBooleanOk() (*bool, bool) {
-	if o == nil || o.NamespaceBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.NamespaceBoolean) {
+    return nil, false
 	}
 	return o.NamespaceBoolean, true
 }
 
 // HasNamespaceBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceBoolean() bool {
-	if o != nil && o.NamespaceBoolean != nil {
+	if o != nil && !isNil(o.NamespaceBoolean) {
 		return true
 	}
 
@@ -741,7 +741,7 @@ func (o *XmlItem) SetNamespaceBoolean(v bool) {
 
 // GetNamespaceArray returns the NamespaceArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceArray() []int32 {
-	if o == nil || o.NamespaceArray == nil {
+	if o == nil || isNil(o.NamespaceArray) {
 		var ret []int32
 		return ret
 	}
@@ -751,15 +751,15 @@ func (o *XmlItem) GetNamespaceArray() []int32 {
 // GetNamespaceArrayOk returns a tuple with the NamespaceArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceArrayOk() ([]int32, bool) {
-	if o == nil || o.NamespaceArray == nil {
-		return nil, false
+	if o == nil || isNil(o.NamespaceArray) {
+    return nil, false
 	}
 	return o.NamespaceArray, true
 }
 
 // HasNamespaceArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceArray() bool {
-	if o != nil && o.NamespaceArray != nil {
+	if o != nil && !isNil(o.NamespaceArray) {
 		return true
 	}
 
@@ -773,7 +773,7 @@ func (o *XmlItem) SetNamespaceArray(v []int32) {
 
 // GetNamespaceWrappedArray returns the NamespaceWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetNamespaceWrappedArray() []int32 {
-	if o == nil || o.NamespaceWrappedArray == nil {
+	if o == nil || isNil(o.NamespaceWrappedArray) {
 		var ret []int32
 		return ret
 	}
@@ -783,15 +783,15 @@ func (o *XmlItem) GetNamespaceWrappedArray() []int32 {
 // GetNamespaceWrappedArrayOk returns a tuple with the NamespaceWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetNamespaceWrappedArrayOk() ([]int32, bool) {
-	if o == nil || o.NamespaceWrappedArray == nil {
-		return nil, false
+	if o == nil || isNil(o.NamespaceWrappedArray) {
+    return nil, false
 	}
 	return o.NamespaceWrappedArray, true
 }
 
 // HasNamespaceWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasNamespaceWrappedArray() bool {
-	if o != nil && o.NamespaceWrappedArray != nil {
+	if o != nil && !isNil(o.NamespaceWrappedArray) {
 		return true
 	}
 
@@ -805,7 +805,7 @@ func (o *XmlItem) SetNamespaceWrappedArray(v []int32) {
 
 // GetPrefixNsString returns the PrefixNsString field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsString() string {
-	if o == nil || o.PrefixNsString == nil {
+	if o == nil || isNil(o.PrefixNsString) {
 		var ret string
 		return ret
 	}
@@ -815,15 +815,15 @@ func (o *XmlItem) GetPrefixNsString() string {
 // GetPrefixNsStringOk returns a tuple with the PrefixNsString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsStringOk() (*string, bool) {
-	if o == nil || o.PrefixNsString == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNsString) {
+    return nil, false
 	}
 	return o.PrefixNsString, true
 }
 
 // HasPrefixNsString returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsString() bool {
-	if o != nil && o.PrefixNsString != nil {
+	if o != nil && !isNil(o.PrefixNsString) {
 		return true
 	}
 
@@ -837,7 +837,7 @@ func (o *XmlItem) SetPrefixNsString(v string) {
 
 // GetPrefixNsNumber returns the PrefixNsNumber field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsNumber() float32 {
-	if o == nil || o.PrefixNsNumber == nil {
+	if o == nil || isNil(o.PrefixNsNumber) {
 		var ret float32
 		return ret
 	}
@@ -847,15 +847,15 @@ func (o *XmlItem) GetPrefixNsNumber() float32 {
 // GetPrefixNsNumberOk returns a tuple with the PrefixNsNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsNumberOk() (*float32, bool) {
-	if o == nil || o.PrefixNsNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNsNumber) {
+    return nil, false
 	}
 	return o.PrefixNsNumber, true
 }
 
 // HasPrefixNsNumber returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsNumber() bool {
-	if o != nil && o.PrefixNsNumber != nil {
+	if o != nil && !isNil(o.PrefixNsNumber) {
 		return true
 	}
 
@@ -869,7 +869,7 @@ func (o *XmlItem) SetPrefixNsNumber(v float32) {
 
 // GetPrefixNsInteger returns the PrefixNsInteger field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsInteger() int32 {
-	if o == nil || o.PrefixNsInteger == nil {
+	if o == nil || isNil(o.PrefixNsInteger) {
 		var ret int32
 		return ret
 	}
@@ -879,15 +879,15 @@ func (o *XmlItem) GetPrefixNsInteger() int32 {
 // GetPrefixNsIntegerOk returns a tuple with the PrefixNsInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsIntegerOk() (*int32, bool) {
-	if o == nil || o.PrefixNsInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNsInteger) {
+    return nil, false
 	}
 	return o.PrefixNsInteger, true
 }
 
 // HasPrefixNsInteger returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsInteger() bool {
-	if o != nil && o.PrefixNsInteger != nil {
+	if o != nil && !isNil(o.PrefixNsInteger) {
 		return true
 	}
 
@@ -901,7 +901,7 @@ func (o *XmlItem) SetPrefixNsInteger(v int32) {
 
 // GetPrefixNsBoolean returns the PrefixNsBoolean field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsBoolean() bool {
-	if o == nil || o.PrefixNsBoolean == nil {
+	if o == nil || isNil(o.PrefixNsBoolean) {
 		var ret bool
 		return ret
 	}
@@ -911,15 +911,15 @@ func (o *XmlItem) GetPrefixNsBoolean() bool {
 // GetPrefixNsBooleanOk returns a tuple with the PrefixNsBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsBooleanOk() (*bool, bool) {
-	if o == nil || o.PrefixNsBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNsBoolean) {
+    return nil, false
 	}
 	return o.PrefixNsBoolean, true
 }
 
 // HasPrefixNsBoolean returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsBoolean() bool {
-	if o != nil && o.PrefixNsBoolean != nil {
+	if o != nil && !isNil(o.PrefixNsBoolean) {
 		return true
 	}
 
@@ -933,7 +933,7 @@ func (o *XmlItem) SetPrefixNsBoolean(v bool) {
 
 // GetPrefixNsArray returns the PrefixNsArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsArray() []int32 {
-	if o == nil || o.PrefixNsArray == nil {
+	if o == nil || isNil(o.PrefixNsArray) {
 		var ret []int32
 		return ret
 	}
@@ -943,15 +943,15 @@ func (o *XmlItem) GetPrefixNsArray() []int32 {
 // GetPrefixNsArrayOk returns a tuple with the PrefixNsArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsArrayOk() ([]int32, bool) {
-	if o == nil || o.PrefixNsArray == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNsArray) {
+    return nil, false
 	}
 	return o.PrefixNsArray, true
 }
 
 // HasPrefixNsArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsArray() bool {
-	if o != nil && o.PrefixNsArray != nil {
+	if o != nil && !isNil(o.PrefixNsArray) {
 		return true
 	}
 
@@ -965,7 +965,7 @@ func (o *XmlItem) SetPrefixNsArray(v []int32) {
 
 // GetPrefixNsWrappedArray returns the PrefixNsWrappedArray field value if set, zero value otherwise.
 func (o *XmlItem) GetPrefixNsWrappedArray() []int32 {
-	if o == nil || o.PrefixNsWrappedArray == nil {
+	if o == nil || isNil(o.PrefixNsWrappedArray) {
 		var ret []int32
 		return ret
 	}
@@ -975,15 +975,15 @@ func (o *XmlItem) GetPrefixNsWrappedArray() []int32 {
 // GetPrefixNsWrappedArrayOk returns a tuple with the PrefixNsWrappedArray field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *XmlItem) GetPrefixNsWrappedArrayOk() ([]int32, bool) {
-	if o == nil || o.PrefixNsWrappedArray == nil {
-		return nil, false
+	if o == nil || isNil(o.PrefixNsWrappedArray) {
+    return nil, false
 	}
 	return o.PrefixNsWrappedArray, true
 }
 
 // HasPrefixNsWrappedArray returns a boolean if a field has been set.
 func (o *XmlItem) HasPrefixNsWrappedArray() bool {
-	if o != nil && o.PrefixNsWrappedArray != nil {
+	if o != nil && !isNil(o.PrefixNsWrappedArray) {
 		return true
 	}
 
@@ -1005,91 +1005,91 @@ func (o XmlItem) MarshalJSON() ([]byte, error) {
 
 func (o XmlItem) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.AttributeString != nil {
+	if !isNil(o.AttributeString) {
 		toSerialize["attribute_string"] = o.AttributeString
 	}
-	if o.AttributeNumber != nil {
+	if !isNil(o.AttributeNumber) {
 		toSerialize["attribute_number"] = o.AttributeNumber
 	}
-	if o.AttributeInteger != nil {
+	if !isNil(o.AttributeInteger) {
 		toSerialize["attribute_integer"] = o.AttributeInteger
 	}
-	if o.AttributeBoolean != nil {
+	if !isNil(o.AttributeBoolean) {
 		toSerialize["attribute_boolean"] = o.AttributeBoolean
 	}
-	if o.WrappedArray != nil {
+	if !isNil(o.WrappedArray) {
 		toSerialize["wrapped_array"] = o.WrappedArray
 	}
-	if o.NameString != nil {
+	if !isNil(o.NameString) {
 		toSerialize["name_string"] = o.NameString
 	}
-	if o.NameNumber != nil {
+	if !isNil(o.NameNumber) {
 		toSerialize["name_number"] = o.NameNumber
 	}
-	if o.NameInteger != nil {
+	if !isNil(o.NameInteger) {
 		toSerialize["name_integer"] = o.NameInteger
 	}
-	if o.NameBoolean != nil {
+	if !isNil(o.NameBoolean) {
 		toSerialize["name_boolean"] = o.NameBoolean
 	}
-	if o.NameArray != nil {
+	if !isNil(o.NameArray) {
 		toSerialize["name_array"] = o.NameArray
 	}
-	if o.NameWrappedArray != nil {
+	if !isNil(o.NameWrappedArray) {
 		toSerialize["name_wrapped_array"] = o.NameWrappedArray
 	}
-	if o.PrefixString != nil {
+	if !isNil(o.PrefixString) {
 		toSerialize["prefix_string"] = o.PrefixString
 	}
-	if o.PrefixNumber != nil {
+	if !isNil(o.PrefixNumber) {
 		toSerialize["prefix_number"] = o.PrefixNumber
 	}
-	if o.PrefixInteger != nil {
+	if !isNil(o.PrefixInteger) {
 		toSerialize["prefix_integer"] = o.PrefixInteger
 	}
-	if o.PrefixBoolean != nil {
+	if !isNil(o.PrefixBoolean) {
 		toSerialize["prefix_boolean"] = o.PrefixBoolean
 	}
-	if o.PrefixArray != nil {
+	if !isNil(o.PrefixArray) {
 		toSerialize["prefix_array"] = o.PrefixArray
 	}
-	if o.PrefixWrappedArray != nil {
+	if !isNil(o.PrefixWrappedArray) {
 		toSerialize["prefix_wrapped_array"] = o.PrefixWrappedArray
 	}
-	if o.NamespaceString != nil {
+	if !isNil(o.NamespaceString) {
 		toSerialize["namespace_string"] = o.NamespaceString
 	}
-	if o.NamespaceNumber != nil {
+	if !isNil(o.NamespaceNumber) {
 		toSerialize["namespace_number"] = o.NamespaceNumber
 	}
-	if o.NamespaceInteger != nil {
+	if !isNil(o.NamespaceInteger) {
 		toSerialize["namespace_integer"] = o.NamespaceInteger
 	}
-	if o.NamespaceBoolean != nil {
+	if !isNil(o.NamespaceBoolean) {
 		toSerialize["namespace_boolean"] = o.NamespaceBoolean
 	}
-	if o.NamespaceArray != nil {
+	if !isNil(o.NamespaceArray) {
 		toSerialize["namespace_array"] = o.NamespaceArray
 	}
-	if o.NamespaceWrappedArray != nil {
+	if !isNil(o.NamespaceWrappedArray) {
 		toSerialize["namespace_wrapped_array"] = o.NamespaceWrappedArray
 	}
-	if o.PrefixNsString != nil {
+	if !isNil(o.PrefixNsString) {
 		toSerialize["prefix_ns_string"] = o.PrefixNsString
 	}
-	if o.PrefixNsNumber != nil {
+	if !isNil(o.PrefixNsNumber) {
 		toSerialize["prefix_ns_number"] = o.PrefixNsNumber
 	}
-	if o.PrefixNsInteger != nil {
+	if !isNil(o.PrefixNsInteger) {
 		toSerialize["prefix_ns_integer"] = o.PrefixNsInteger
 	}
-	if o.PrefixNsBoolean != nil {
+	if !isNil(o.PrefixNsBoolean) {
 		toSerialize["prefix_ns_boolean"] = o.PrefixNsBoolean
 	}
-	if o.PrefixNsArray != nil {
+	if !isNil(o.PrefixNsArray) {
 		toSerialize["prefix_ns_array"] = o.PrefixNsArray
 	}
-	if o.PrefixNsWrappedArray != nil {
+	if !isNil(o.PrefixNsWrappedArray) {
 		toSerialize["prefix_ns_wrapped_array"] = o.PrefixNsWrappedArray
 	}
 	return toSerialize, nil
diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
index 633bb2d9abb..8e22ba9930b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go
@@ -1460,13 +1460,13 @@ func (a *FakeApiService) TestEnumParametersExecute(r ApiTestEnumParametersReques
 		}
 	}
 	if r.enumQueryString != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "")
 	}
 	if r.enumQueryInteger != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "")
 	}
 	if r.enumQueryDouble != nil {
-	parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
+	    parameterAddToQuery(localVarQueryParams, "enum_query_double", r.enumQueryDouble, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{"application/x-www-form-urlencoded"}
@@ -1622,10 +1622,10 @@ func (a *FakeApiService) TestGroupParametersExecute(r ApiTestGroupParametersRequ
 	parameterAddToQuery(localVarQueryParams, "required_string_group", r.requiredStringGroup, "")
 	parameterAddToQuery(localVarQueryParams, "required_int64_group", r.requiredInt64Group, "")
 	if r.stringGroup != nil {
-	parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
+	    parameterAddToQuery(localVarQueryParams, "string_group", r.stringGroup, "")
 	}
 	if r.int64Group != nil {
-	parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
+	    parameterAddToQuery(localVarQueryParams, "int64_group", r.int64Group, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
@@ -1950,10 +1950,10 @@ func (a *FakeApiService) TestQueryDeepObjectExecute(r ApiTestQueryDeepObjectRequ
 	localVarFormParams := url.Values{}
 
 	if r.testPet != nil {
-	parameterAddToQuery(localVarQueryParams, "test_pet", r.testPet, "")
+	    parameterAddToQuery(localVarQueryParams, "test_pet", r.testPet, "")
 	}
 	if r.inputOptions != nil {
-	parameterAddToQuery(localVarQueryParams, "inputOptions", r.inputOptions, "")
+	    parameterAddToQuery(localVarQueryParams, "inputOptions", r.inputOptions, "")
 	}
 	// to determine the Content-Type header
 	localVarHTTPContentTypes := []string{}
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
index 245b2448f4d..40e61d9c02f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go
@@ -45,7 +45,7 @@ func NewModel200ResponseWithDefaults() *Model200Response {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *Model200Response) GetName() int32 {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret int32
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *Model200Response) GetName() int32 {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Model200Response) GetNameOk() (*int32, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *Model200Response) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *Model200Response) SetName(v int32) {
 
 // GetClass returns the Class field value if set, zero value otherwise.
 func (o *Model200Response) GetClass() string {
-	if o == nil || o.Class == nil {
+	if o == nil || isNil(o.Class) {
 		var ret string
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *Model200Response) GetClass() string {
 // GetClassOk returns a tuple with the Class field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Model200Response) GetClassOk() (*string, bool) {
-	if o == nil || o.Class == nil {
-		return nil, false
+	if o == nil || isNil(o.Class) {
+    return nil, false
 	}
 	return o.Class, true
 }
 
 // HasClass returns a boolean if a field has been set.
 func (o *Model200Response) HasClass() bool {
-	if o != nil && o.Class != nil {
+	if o != nil && !isNil(o.Class) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o Model200Response) MarshalJSON() ([]byte, error) {
 
 func (o Model200Response) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
-	if o.Class != nil {
+	if !isNil(o.Class) {
 		toSerialize["class"] = o.Class
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
index 21b0f6d7e12..d89617081f4 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go
@@ -44,7 +44,7 @@ func NewFooGetDefaultResponseWithDefaults() *FooGetDefaultResponse {
 
 // GetString returns the String field value if set, zero value otherwise.
 func (o *FooGetDefaultResponse) GetString() Foo {
-	if o == nil || o.String == nil {
+	if o == nil || isNil(o.String) {
 		var ret Foo
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *FooGetDefaultResponse) GetString() Foo {
 // GetStringOk returns a tuple with the String field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FooGetDefaultResponse) GetStringOk() (*Foo, bool) {
-	if o == nil || o.String == nil {
-		return nil, false
+	if o == nil || isNil(o.String) {
+    return nil, false
 	}
 	return o.String, true
 }
 
 // HasString returns a boolean if a field has been set.
 func (o *FooGetDefaultResponse) HasString() bool {
-	if o != nil && o.String != nil {
+	if o != nil && !isNil(o.String) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o FooGetDefaultResponse) MarshalJSON() ([]byte, error) {
 
 func (o FooGetDefaultResponse) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.String != nil {
+	if !isNil(o.String) {
 		toSerialize["string"] = o.String
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
index 1665c3afc94..1d94ec2af29 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go
@@ -44,7 +44,7 @@ func NewSpecialModelNameWithDefaults() *SpecialModelName {
 
 // GetSpecialPropertyName returns the SpecialPropertyName field value if set, zero value otherwise.
 func (o *SpecialModelName) GetSpecialPropertyName() int64 {
-	if o == nil || o.SpecialPropertyName == nil {
+	if o == nil || isNil(o.SpecialPropertyName) {
 		var ret int64
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *SpecialModelName) GetSpecialPropertyName() int64 {
 // GetSpecialPropertyNameOk returns a tuple with the SpecialPropertyName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *SpecialModelName) GetSpecialPropertyNameOk() (*int64, bool) {
-	if o == nil || o.SpecialPropertyName == nil {
-		return nil, false
+	if o == nil || isNil(o.SpecialPropertyName) {
+    return nil, false
 	}
 	return o.SpecialPropertyName, true
 }
 
 // HasSpecialPropertyName returns a boolean if a field has been set.
 func (o *SpecialModelName) HasSpecialPropertyName() bool {
-	if o != nil && o.SpecialPropertyName != nil {
+	if o != nil && !isNil(o.SpecialPropertyName) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o SpecialModelName) MarshalJSON() ([]byte, error) {
 
 func (o SpecialModelName) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.SpecialPropertyName != nil {
+	if !isNil(o.SpecialPropertyName) {
 		toSerialize["$special[property.name]"] = o.SpecialPropertyName
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
index 030b1782899..5aa3bcdb414 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go
@@ -45,7 +45,7 @@ func NewAdditionalPropertiesClassWithDefaults() *AdditionalPropertiesClass {
 
 // GetMapProperty returns the MapProperty field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapProperty() map[string]string {
-	if o == nil || o.MapProperty == nil {
+	if o == nil || isNil(o.MapProperty) {
 		var ret map[string]string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *AdditionalPropertiesClass) GetMapProperty() map[string]string {
 // GetMapPropertyOk returns a tuple with the MapProperty field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapPropertyOk() (*map[string]string, bool) {
-	if o == nil || o.MapProperty == nil {
-		return nil, false
+	if o == nil || isNil(o.MapProperty) {
+    return nil, false
 	}
 	return o.MapProperty, true
 }
 
 // HasMapProperty returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapProperty() bool {
-	if o != nil && o.MapProperty != nil {
+	if o != nil && !isNil(o.MapProperty) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *AdditionalPropertiesClass) SetMapProperty(v map[string]string) {
 
 // GetMapOfMapProperty returns the MapOfMapProperty field value if set, zero value otherwise.
 func (o *AdditionalPropertiesClass) GetMapOfMapProperty() map[string]map[string]string {
-	if o == nil || o.MapOfMapProperty == nil {
+	if o == nil || isNil(o.MapOfMapProperty) {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *AdditionalPropertiesClass) GetMapOfMapProperty() map[string]map[string]
 // GetMapOfMapPropertyOk returns a tuple with the MapOfMapProperty field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AdditionalPropertiesClass) GetMapOfMapPropertyOk() (*map[string]map[string]string, bool) {
-	if o == nil || o.MapOfMapProperty == nil {
-		return nil, false
+	if o == nil || isNil(o.MapOfMapProperty) {
+    return nil, false
 	}
 	return o.MapOfMapProperty, true
 }
 
 // HasMapOfMapProperty returns a boolean if a field has been set.
 func (o *AdditionalPropertiesClass) HasMapOfMapProperty() bool {
-	if o != nil && o.MapOfMapProperty != nil {
+	if o != nil && !isNil(o.MapOfMapProperty) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) {
 
 func (o AdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.MapProperty != nil {
+	if !isNil(o.MapProperty) {
 		toSerialize["map_property"] = o.MapProperty
 	}
-	if o.MapOfMapProperty != nil {
+	if !isNil(o.MapOfMapProperty) {
 		toSerialize["map_of_map_property"] = o.MapOfMapProperty
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
index 903fc7b4d8b..c7f1d7ae4ee 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
@@ -61,9 +61,9 @@ func (o *Animal) GetClassName() string {
 // GetClassNameOk returns a tuple with the ClassName field value
 // and a boolean to check if the value has been set.
 func (o *Animal) GetClassNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.ClassName, true
 }
 
@@ -74,7 +74,7 @@ func (o *Animal) SetClassName(v string) {
 
 // GetColor returns the Color field value if set, zero value otherwise.
 func (o *Animal) GetColor() string {
-	if o == nil || o.Color == nil {
+	if o == nil || isNil(o.Color) {
 		var ret string
 		return ret
 	}
@@ -84,15 +84,15 @@ func (o *Animal) GetColor() string {
 // GetColorOk returns a tuple with the Color field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Animal) GetColorOk() (*string, bool) {
-	if o == nil || o.Color == nil {
-		return nil, false
+	if o == nil || isNil(o.Color) {
+    return nil, false
 	}
 	return o.Color, true
 }
 
 // HasColor returns a boolean if a field has been set.
 func (o *Animal) HasColor() bool {
-	if o != nil && o.Color != nil {
+	if o != nil && !isNil(o.Color) {
 		return true
 	}
 
@@ -115,7 +115,7 @@ func (o Animal) MarshalJSON() ([]byte, error) {
 func (o Animal) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	toSerialize["className"] = o.ClassName
-	if o.Color != nil {
+	if !isNil(o.Color) {
 		toSerialize["color"] = o.Color
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
index 2b949c7f49e..fcb9043c1ad 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go
@@ -46,7 +46,7 @@ func NewApiResponseWithDefaults() *ApiResponse {
 
 // GetCode returns the Code field value if set, zero value otherwise.
 func (o *ApiResponse) GetCode() int32 {
-	if o == nil || o.Code == nil {
+	if o == nil || isNil(o.Code) {
 		var ret int32
 		return ret
 	}
@@ -56,15 +56,15 @@ func (o *ApiResponse) GetCode() int32 {
 // GetCodeOk returns a tuple with the Code field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetCodeOk() (*int32, bool) {
-	if o == nil || o.Code == nil {
-		return nil, false
+	if o == nil || isNil(o.Code) {
+    return nil, false
 	}
 	return o.Code, true
 }
 
 // HasCode returns a boolean if a field has been set.
 func (o *ApiResponse) HasCode() bool {
-	if o != nil && o.Code != nil {
+	if o != nil && !isNil(o.Code) {
 		return true
 	}
 
@@ -78,7 +78,7 @@ func (o *ApiResponse) SetCode(v int32) {
 
 // GetType returns the Type field value if set, zero value otherwise.
 func (o *ApiResponse) GetType() string {
-	if o == nil || o.Type == nil {
+	if o == nil || isNil(o.Type) {
 		var ret string
 		return ret
 	}
@@ -88,15 +88,15 @@ func (o *ApiResponse) GetType() string {
 // GetTypeOk returns a tuple with the Type field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetTypeOk() (*string, bool) {
-	if o == nil || o.Type == nil {
-		return nil, false
+	if o == nil || isNil(o.Type) {
+    return nil, false
 	}
 	return o.Type, true
 }
 
 // HasType returns a boolean if a field has been set.
 func (o *ApiResponse) HasType() bool {
-	if o != nil && o.Type != nil {
+	if o != nil && !isNil(o.Type) {
 		return true
 	}
 
@@ -110,7 +110,7 @@ func (o *ApiResponse) SetType(v string) {
 
 // GetMessage returns the Message field value if set, zero value otherwise.
 func (o *ApiResponse) GetMessage() string {
-	if o == nil || o.Message == nil {
+	if o == nil || isNil(o.Message) {
 		var ret string
 		return ret
 	}
@@ -120,15 +120,15 @@ func (o *ApiResponse) GetMessage() string {
 // GetMessageOk returns a tuple with the Message field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ApiResponse) GetMessageOk() (*string, bool) {
-	if o == nil || o.Message == nil {
-		return nil, false
+	if o == nil || isNil(o.Message) {
+    return nil, false
 	}
 	return o.Message, true
 }
 
 // HasMessage returns a boolean if a field has been set.
 func (o *ApiResponse) HasMessage() bool {
-	if o != nil && o.Message != nil {
+	if o != nil && !isNil(o.Message) {
 		return true
 	}
 
@@ -150,13 +150,13 @@ func (o ApiResponse) MarshalJSON() ([]byte, error) {
 
 func (o ApiResponse) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Code != nil {
+	if !isNil(o.Code) {
 		toSerialize["code"] = o.Code
 	}
-	if o.Type != nil {
+	if !isNil(o.Type) {
 		toSerialize["type"] = o.Type
 	}
-	if o.Message != nil {
+	if !isNil(o.Message) {
 		toSerialize["message"] = o.Message
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
index 6de9d38fa06..033b83d00a5 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go
@@ -44,7 +44,7 @@ func NewAppleWithDefaults() *Apple {
 
 // GetCultivar returns the Cultivar field value if set, zero value otherwise.
 func (o *Apple) GetCultivar() string {
-	if o == nil || o.Cultivar == nil {
+	if o == nil || isNil(o.Cultivar) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *Apple) GetCultivar() string {
 // GetCultivarOk returns a tuple with the Cultivar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Apple) GetCultivarOk() (*string, bool) {
-	if o == nil || o.Cultivar == nil {
-		return nil, false
+	if o == nil || isNil(o.Cultivar) {
+    return nil, false
 	}
 	return o.Cultivar, true
 }
 
 // HasCultivar returns a boolean if a field has been set.
 func (o *Apple) HasCultivar() bool {
-	if o != nil && o.Cultivar != nil {
+	if o != nil && !isNil(o.Cultivar) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o Apple) MarshalJSON() ([]byte, error) {
 
 func (o Apple) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Cultivar != nil {
+	if !isNil(o.Cultivar) {
 		toSerialize["cultivar"] = o.Cultivar
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
index 89cf4fb692d..d9cc59befd2 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
@@ -57,9 +57,9 @@ func (o *AppleReq) GetCultivar() string {
 // GetCultivarOk returns a tuple with the Cultivar field value
 // and a boolean to check if the value has been set.
 func (o *AppleReq) GetCultivarOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Cultivar, true
 }
 
@@ -70,7 +70,7 @@ func (o *AppleReq) SetCultivar(v string) {
 
 // GetMealy returns the Mealy field value if set, zero value otherwise.
 func (o *AppleReq) GetMealy() bool {
-	if o == nil || o.Mealy == nil {
+	if o == nil || isNil(o.Mealy) {
 		var ret bool
 		return ret
 	}
@@ -80,15 +80,15 @@ func (o *AppleReq) GetMealy() bool {
 // GetMealyOk returns a tuple with the Mealy field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *AppleReq) GetMealyOk() (*bool, bool) {
-	if o == nil || o.Mealy == nil {
-		return nil, false
+	if o == nil || isNil(o.Mealy) {
+    return nil, false
 	}
 	return o.Mealy, true
 }
 
 // HasMealy returns a boolean if a field has been set.
 func (o *AppleReq) HasMealy() bool {
-	if o != nil && o.Mealy != nil {
+	if o != nil && !isNil(o.Mealy) {
 		return true
 	}
 
@@ -111,7 +111,7 @@ func (o AppleReq) MarshalJSON() ([]byte, error) {
 func (o AppleReq) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	toSerialize["cultivar"] = o.Cultivar
-	if o.Mealy != nil {
+	if !isNil(o.Mealy) {
 		toSerialize["mealy"] = o.Mealy
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
index 8718af2127e..db4fe8bfbbb 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go
@@ -44,7 +44,7 @@ func NewArrayOfArrayOfNumberOnlyWithDefaults() *ArrayOfArrayOfNumberOnly {
 
 // GetArrayArrayNumber returns the ArrayArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
-	if o == nil || o.ArrayArrayNumber == nil {
+	if o == nil || isNil(o.ArrayArrayNumber) {
 		var ret [][]float32
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 {
 // GetArrayArrayNumberOk returns a tuple with the ArrayArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumberOk() ([][]float32, bool) {
-	if o == nil || o.ArrayArrayNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayArrayNumber) {
+    return nil, false
 	}
 	return o.ArrayArrayNumber, true
 }
 
 // HasArrayArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfArrayOfNumberOnly) HasArrayArrayNumber() bool {
-	if o != nil && o.ArrayArrayNumber != nil {
+	if o != nil && !isNil(o.ArrayArrayNumber) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
 
 func (o ArrayOfArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.ArrayArrayNumber != nil {
+	if !isNil(o.ArrayArrayNumber) {
 		toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
index 24c89bcd36c..4fe59b91900 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go
@@ -44,7 +44,7 @@ func NewArrayOfNumberOnlyWithDefaults() *ArrayOfNumberOnly {
 
 // GetArrayNumber returns the ArrayNumber field value if set, zero value otherwise.
 func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
-	if o == nil || o.ArrayNumber == nil {
+	if o == nil || isNil(o.ArrayNumber) {
 		var ret []float32
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 {
 // GetArrayNumberOk returns a tuple with the ArrayNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayOfNumberOnly) GetArrayNumberOk() ([]float32, bool) {
-	if o == nil || o.ArrayNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayNumber) {
+    return nil, false
 	}
 	return o.ArrayNumber, true
 }
 
 // HasArrayNumber returns a boolean if a field has been set.
 func (o *ArrayOfNumberOnly) HasArrayNumber() bool {
-	if o != nil && o.ArrayNumber != nil {
+	if o != nil && !isNil(o.ArrayNumber) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) {
 
 func (o ArrayOfNumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.ArrayNumber != nil {
+	if !isNil(o.ArrayNumber) {
 		toSerialize["ArrayNumber"] = o.ArrayNumber
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
index d4926dd8e0a..1e57dfde057 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go
@@ -46,7 +46,7 @@ func NewArrayTestWithDefaults() *ArrayTest {
 
 // GetArrayOfString returns the ArrayOfString field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayOfString() []string {
-	if o == nil || o.ArrayOfString == nil {
+	if o == nil || isNil(o.ArrayOfString) {
 		var ret []string
 		return ret
 	}
@@ -56,15 +56,15 @@ func (o *ArrayTest) GetArrayOfString() []string {
 // GetArrayOfStringOk returns a tuple with the ArrayOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayOfStringOk() ([]string, bool) {
-	if o == nil || o.ArrayOfString == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayOfString) {
+    return nil, false
 	}
 	return o.ArrayOfString, true
 }
 
 // HasArrayOfString returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayOfString() bool {
-	if o != nil && o.ArrayOfString != nil {
+	if o != nil && !isNil(o.ArrayOfString) {
 		return true
 	}
 
@@ -78,7 +78,7 @@ func (o *ArrayTest) SetArrayOfString(v []string) {
 
 // GetArrayArrayOfInteger returns the ArrayArrayOfInteger field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
-	if o == nil || o.ArrayArrayOfInteger == nil {
+	if o == nil || isNil(o.ArrayArrayOfInteger) {
 		var ret [][]int64
 		return ret
 	}
@@ -88,15 +88,15 @@ func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 {
 // GetArrayArrayOfIntegerOk returns a tuple with the ArrayArrayOfInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfIntegerOk() ([][]int64, bool) {
-	if o == nil || o.ArrayArrayOfInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayArrayOfInteger) {
+    return nil, false
 	}
 	return o.ArrayArrayOfInteger, true
 }
 
 // HasArrayArrayOfInteger returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfInteger() bool {
-	if o != nil && o.ArrayArrayOfInteger != nil {
+	if o != nil && !isNil(o.ArrayArrayOfInteger) {
 		return true
 	}
 
@@ -110,7 +110,7 @@ func (o *ArrayTest) SetArrayArrayOfInteger(v [][]int64) {
 
 // GetArrayArrayOfModel returns the ArrayArrayOfModel field value if set, zero value otherwise.
 func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
-	if o == nil || o.ArrayArrayOfModel == nil {
+	if o == nil || isNil(o.ArrayArrayOfModel) {
 		var ret [][]ReadOnlyFirst
 		return ret
 	}
@@ -120,15 +120,15 @@ func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst {
 // GetArrayArrayOfModelOk returns a tuple with the ArrayArrayOfModel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ArrayTest) GetArrayArrayOfModelOk() ([][]ReadOnlyFirst, bool) {
-	if o == nil || o.ArrayArrayOfModel == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayArrayOfModel) {
+    return nil, false
 	}
 	return o.ArrayArrayOfModel, true
 }
 
 // HasArrayArrayOfModel returns a boolean if a field has been set.
 func (o *ArrayTest) HasArrayArrayOfModel() bool {
-	if o != nil && o.ArrayArrayOfModel != nil {
+	if o != nil && !isNil(o.ArrayArrayOfModel) {
 		return true
 	}
 
@@ -150,13 +150,13 @@ func (o ArrayTest) MarshalJSON() ([]byte, error) {
 
 func (o ArrayTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.ArrayOfString != nil {
+	if !isNil(o.ArrayOfString) {
 		toSerialize["array_of_string"] = o.ArrayOfString
 	}
-	if o.ArrayArrayOfInteger != nil {
+	if !isNil(o.ArrayArrayOfInteger) {
 		toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger
 	}
-	if o.ArrayArrayOfModel != nil {
+	if !isNil(o.ArrayArrayOfModel) {
 		toSerialize["array_array_of_model"] = o.ArrayArrayOfModel
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
index 62c50a906da..0e421fd1a96 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go
@@ -44,7 +44,7 @@ func NewBananaWithDefaults() *Banana {
 
 // GetLengthCm returns the LengthCm field value if set, zero value otherwise.
 func (o *Banana) GetLengthCm() float32 {
-	if o == nil || o.LengthCm == nil {
+	if o == nil || isNil(o.LengthCm) {
 		var ret float32
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *Banana) GetLengthCm() float32 {
 // GetLengthCmOk returns a tuple with the LengthCm field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Banana) GetLengthCmOk() (*float32, bool) {
-	if o == nil || o.LengthCm == nil {
-		return nil, false
+	if o == nil || isNil(o.LengthCm) {
+    return nil, false
 	}
 	return o.LengthCm, true
 }
 
 // HasLengthCm returns a boolean if a field has been set.
 func (o *Banana) HasLengthCm() bool {
-	if o != nil && o.LengthCm != nil {
+	if o != nil && !isNil(o.LengthCm) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o Banana) MarshalJSON() ([]byte, error) {
 
 func (o Banana) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.LengthCm != nil {
+	if !isNil(o.LengthCm) {
 		toSerialize["lengthCm"] = o.LengthCm
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
index 6333db14e50..e412e8b727b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
@@ -57,9 +57,9 @@ func (o *BananaReq) GetLengthCm() float32 {
 // GetLengthCmOk returns a tuple with the LengthCm field value
 // and a boolean to check if the value has been set.
 func (o *BananaReq) GetLengthCmOk() (*float32, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.LengthCm, true
 }
 
@@ -70,7 +70,7 @@ func (o *BananaReq) SetLengthCm(v float32) {
 
 // GetSweet returns the Sweet field value if set, zero value otherwise.
 func (o *BananaReq) GetSweet() bool {
-	if o == nil || o.Sweet == nil {
+	if o == nil || isNil(o.Sweet) {
 		var ret bool
 		return ret
 	}
@@ -80,15 +80,15 @@ func (o *BananaReq) GetSweet() bool {
 // GetSweetOk returns a tuple with the Sweet field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *BananaReq) GetSweetOk() (*bool, bool) {
-	if o == nil || o.Sweet == nil {
-		return nil, false
+	if o == nil || isNil(o.Sweet) {
+    return nil, false
 	}
 	return o.Sweet, true
 }
 
 // HasSweet returns a boolean if a field has been set.
 func (o *BananaReq) HasSweet() bool {
-	if o != nil && o.Sweet != nil {
+	if o != nil && !isNil(o.Sweet) {
 		return true
 	}
 
@@ -111,7 +111,7 @@ func (o BananaReq) MarshalJSON() ([]byte, error) {
 func (o BananaReq) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	toSerialize["lengthCm"] = o.LengthCm
-	if o.Sweet != nil {
+	if !isNil(o.Sweet) {
 		toSerialize["sweet"] = o.Sweet
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
index 2763a88c52c..31febb06a75 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go
@@ -50,7 +50,7 @@ func NewCapitalizationWithDefaults() *Capitalization {
 
 // GetSmallCamel returns the SmallCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallCamel() string {
-	if o == nil || o.SmallCamel == nil {
+	if o == nil || isNil(o.SmallCamel) {
 		var ret string
 		return ret
 	}
@@ -60,15 +60,15 @@ func (o *Capitalization) GetSmallCamel() string {
 // GetSmallCamelOk returns a tuple with the SmallCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallCamelOk() (*string, bool) {
-	if o == nil || o.SmallCamel == nil {
-		return nil, false
+	if o == nil || isNil(o.SmallCamel) {
+    return nil, false
 	}
 	return o.SmallCamel, true
 }
 
 // HasSmallCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallCamel() bool {
-	if o != nil && o.SmallCamel != nil {
+	if o != nil && !isNil(o.SmallCamel) {
 		return true
 	}
 
@@ -82,7 +82,7 @@ func (o *Capitalization) SetSmallCamel(v string) {
 
 // GetCapitalCamel returns the CapitalCamel field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalCamel() string {
-	if o == nil || o.CapitalCamel == nil {
+	if o == nil || isNil(o.CapitalCamel) {
 		var ret string
 		return ret
 	}
@@ -92,15 +92,15 @@ func (o *Capitalization) GetCapitalCamel() string {
 // GetCapitalCamelOk returns a tuple with the CapitalCamel field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalCamelOk() (*string, bool) {
-	if o == nil || o.CapitalCamel == nil {
-		return nil, false
+	if o == nil || isNil(o.CapitalCamel) {
+    return nil, false
 	}
 	return o.CapitalCamel, true
 }
 
 // HasCapitalCamel returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalCamel() bool {
-	if o != nil && o.CapitalCamel != nil {
+	if o != nil && !isNil(o.CapitalCamel) {
 		return true
 	}
 
@@ -114,7 +114,7 @@ func (o *Capitalization) SetCapitalCamel(v string) {
 
 // GetSmallSnake returns the SmallSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetSmallSnake() string {
-	if o == nil || o.SmallSnake == nil {
+	if o == nil || isNil(o.SmallSnake) {
 		var ret string
 		return ret
 	}
@@ -124,15 +124,15 @@ func (o *Capitalization) GetSmallSnake() string {
 // GetSmallSnakeOk returns a tuple with the SmallSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSmallSnakeOk() (*string, bool) {
-	if o == nil || o.SmallSnake == nil {
-		return nil, false
+	if o == nil || isNil(o.SmallSnake) {
+    return nil, false
 	}
 	return o.SmallSnake, true
 }
 
 // HasSmallSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasSmallSnake() bool {
-	if o != nil && o.SmallSnake != nil {
+	if o != nil && !isNil(o.SmallSnake) {
 		return true
 	}
 
@@ -146,7 +146,7 @@ func (o *Capitalization) SetSmallSnake(v string) {
 
 // GetCapitalSnake returns the CapitalSnake field value if set, zero value otherwise.
 func (o *Capitalization) GetCapitalSnake() string {
-	if o == nil || o.CapitalSnake == nil {
+	if o == nil || isNil(o.CapitalSnake) {
 		var ret string
 		return ret
 	}
@@ -156,15 +156,15 @@ func (o *Capitalization) GetCapitalSnake() string {
 // GetCapitalSnakeOk returns a tuple with the CapitalSnake field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetCapitalSnakeOk() (*string, bool) {
-	if o == nil || o.CapitalSnake == nil {
-		return nil, false
+	if o == nil || isNil(o.CapitalSnake) {
+    return nil, false
 	}
 	return o.CapitalSnake, true
 }
 
 // HasCapitalSnake returns a boolean if a field has been set.
 func (o *Capitalization) HasCapitalSnake() bool {
-	if o != nil && o.CapitalSnake != nil {
+	if o != nil && !isNil(o.CapitalSnake) {
 		return true
 	}
 
@@ -178,7 +178,7 @@ func (o *Capitalization) SetCapitalSnake(v string) {
 
 // GetSCAETHFlowPoints returns the SCAETHFlowPoints field value if set, zero value otherwise.
 func (o *Capitalization) GetSCAETHFlowPoints() string {
-	if o == nil || o.SCAETHFlowPoints == nil {
+	if o == nil || isNil(o.SCAETHFlowPoints) {
 		var ret string
 		return ret
 	}
@@ -188,15 +188,15 @@ func (o *Capitalization) GetSCAETHFlowPoints() string {
 // GetSCAETHFlowPointsOk returns a tuple with the SCAETHFlowPoints field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetSCAETHFlowPointsOk() (*string, bool) {
-	if o == nil || o.SCAETHFlowPoints == nil {
-		return nil, false
+	if o == nil || isNil(o.SCAETHFlowPoints) {
+    return nil, false
 	}
 	return o.SCAETHFlowPoints, true
 }
 
 // HasSCAETHFlowPoints returns a boolean if a field has been set.
 func (o *Capitalization) HasSCAETHFlowPoints() bool {
-	if o != nil && o.SCAETHFlowPoints != nil {
+	if o != nil && !isNil(o.SCAETHFlowPoints) {
 		return true
 	}
 
@@ -210,7 +210,7 @@ func (o *Capitalization) SetSCAETHFlowPoints(v string) {
 
 // GetATT_NAME returns the ATT_NAME field value if set, zero value otherwise.
 func (o *Capitalization) GetATT_NAME() string {
-	if o == nil || o.ATT_NAME == nil {
+	if o == nil || isNil(o.ATT_NAME) {
 		var ret string
 		return ret
 	}
@@ -220,15 +220,15 @@ func (o *Capitalization) GetATT_NAME() string {
 // GetATT_NAMEOk returns a tuple with the ATT_NAME field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Capitalization) GetATT_NAMEOk() (*string, bool) {
-	if o == nil || o.ATT_NAME == nil {
-		return nil, false
+	if o == nil || isNil(o.ATT_NAME) {
+    return nil, false
 	}
 	return o.ATT_NAME, true
 }
 
 // HasATT_NAME returns a boolean if a field has been set.
 func (o *Capitalization) HasATT_NAME() bool {
-	if o != nil && o.ATT_NAME != nil {
+	if o != nil && !isNil(o.ATT_NAME) {
 		return true
 	}
 
@@ -250,22 +250,22 @@ func (o Capitalization) MarshalJSON() ([]byte, error) {
 
 func (o Capitalization) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.SmallCamel != nil {
+	if !isNil(o.SmallCamel) {
 		toSerialize["smallCamel"] = o.SmallCamel
 	}
-	if o.CapitalCamel != nil {
+	if !isNil(o.CapitalCamel) {
 		toSerialize["CapitalCamel"] = o.CapitalCamel
 	}
-	if o.SmallSnake != nil {
+	if !isNil(o.SmallSnake) {
 		toSerialize["small_Snake"] = o.SmallSnake
 	}
-	if o.CapitalSnake != nil {
+	if !isNil(o.CapitalSnake) {
 		toSerialize["Capital_Snake"] = o.CapitalSnake
 	}
-	if o.SCAETHFlowPoints != nil {
+	if !isNil(o.SCAETHFlowPoints) {
 		toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints
 	}
-	if o.ATT_NAME != nil {
+	if !isNil(o.ATT_NAME) {
 		toSerialize["ATT_NAME"] = o.ATT_NAME
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_cat.go b/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
index 9e7a879d26a..cb162dbcebc 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_cat.go
@@ -50,7 +50,7 @@ func NewCatWithDefaults() *Cat {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *Cat) GetDeclawed() bool {
-	if o == nil || o.Declawed == nil {
+	if o == nil || isNil(o.Declawed) {
 		var ret bool
 		return ret
 	}
@@ -60,15 +60,15 @@ func (o *Cat) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Cat) GetDeclawedOk() (*bool, bool) {
-	if o == nil || o.Declawed == nil {
-		return nil, false
+	if o == nil || isNil(o.Declawed) {
+    return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *Cat) HasDeclawed() bool {
-	if o != nil && o.Declawed != nil {
+	if o != nil && !isNil(o.Declawed) {
 		return true
 	}
 
@@ -98,7 +98,7 @@ func (o Cat) ToMap() (map[string]interface{}, error) {
 	if errAnimal != nil {
 		return map[string]interface{}{}, errAnimal
 	}
-	if o.Declawed != nil {
+	if !isNil(o.Declawed) {
 		toSerialize["declawed"] = o.Declawed
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
index 58be534b3cf..7b342a27744 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_cat_all_of.go
@@ -44,7 +44,7 @@ func NewCatAllOfWithDefaults() *CatAllOf {
 
 // GetDeclawed returns the Declawed field value if set, zero value otherwise.
 func (o *CatAllOf) GetDeclawed() bool {
-	if o == nil || o.Declawed == nil {
+	if o == nil || isNil(o.Declawed) {
 		var ret bool
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *CatAllOf) GetDeclawed() bool {
 // GetDeclawedOk returns a tuple with the Declawed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *CatAllOf) GetDeclawedOk() (*bool, bool) {
-	if o == nil || o.Declawed == nil {
-		return nil, false
+	if o == nil || isNil(o.Declawed) {
+    return nil, false
 	}
 	return o.Declawed, true
 }
 
 // HasDeclawed returns a boolean if a field has been set.
 func (o *CatAllOf) HasDeclawed() bool {
-	if o != nil && o.Declawed != nil {
+	if o != nil && !isNil(o.Declawed) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o CatAllOf) MarshalJSON() ([]byte, error) {
 
 func (o CatAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Declawed != nil {
+	if !isNil(o.Declawed) {
 		toSerialize["declawed"] = o.Declawed
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_category.go b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
index 528928bb069..ec4ea45055f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_category.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
@@ -48,7 +48,7 @@ func NewCategoryWithDefaults() *Category {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Category) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -58,15 +58,15 @@ func (o *Category) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Category) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Category) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -91,9 +91,9 @@ func (o *Category) GetName() string {
 // GetNameOk returns a tuple with the Name field value
 // and a boolean to check if the value has been set.
 func (o *Category) GetNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Name, true
 }
 
@@ -112,7 +112,7 @@ func (o Category) MarshalJSON() ([]byte, error) {
 
 func (o Category) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
 	toSerialize["name"] = o.Name
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
index aa0bc7183f3..a40dadafd6d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go
@@ -44,7 +44,7 @@ func NewClassModelWithDefaults() *ClassModel {
 
 // GetClass returns the Class field value if set, zero value otherwise.
 func (o *ClassModel) GetClass() string {
-	if o == nil || o.Class == nil {
+	if o == nil || isNil(o.Class) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *ClassModel) GetClass() string {
 // GetClassOk returns a tuple with the Class field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ClassModel) GetClassOk() (*string, bool) {
-	if o == nil || o.Class == nil {
-		return nil, false
+	if o == nil || isNil(o.Class) {
+    return nil, false
 	}
 	return o.Class, true
 }
 
 // HasClass returns a boolean if a field has been set.
 func (o *ClassModel) HasClass() bool {
-	if o != nil && o.Class != nil {
+	if o != nil && !isNil(o.Class) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o ClassModel) MarshalJSON() ([]byte, error) {
 
 func (o ClassModel) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Class != nil {
+	if !isNil(o.Class) {
 		toSerialize["_class"] = o.Class
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_client.go b/samples/openapi3/client/petstore/go/go-petstore/model_client.go
index 3e9607f7e4b..aeaf16d5a7f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_client.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_client.go
@@ -44,7 +44,7 @@ func NewClientWithDefaults() *Client {
 
 // GetClient returns the Client field value if set, zero value otherwise.
 func (o *Client) GetClient() string {
-	if o == nil || o.Client == nil {
+	if o == nil || isNil(o.Client) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *Client) GetClient() string {
 // GetClientOk returns a tuple with the Client field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Client) GetClientOk() (*string, bool) {
-	if o == nil || o.Client == nil {
-		return nil, false
+	if o == nil || isNil(o.Client) {
+    return nil, false
 	}
 	return o.Client, true
 }
 
 // HasClient returns a boolean if a field has been set.
 func (o *Client) HasClient() bool {
-	if o != nil && o.Client != nil {
+	if o != nil && !isNil(o.Client) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o Client) MarshalJSON() ([]byte, error) {
 
 func (o Client) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Client != nil {
+	if !isNil(o.Client) {
 		toSerialize["client"] = o.Client
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_dog.go b/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
index 9634dd7221c..fa2855e7e8c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_dog.go
@@ -50,7 +50,7 @@ func NewDogWithDefaults() *Dog {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *Dog) GetBreed() string {
-	if o == nil || o.Breed == nil {
+	if o == nil || isNil(o.Breed) {
 		var ret string
 		return ret
 	}
@@ -60,15 +60,15 @@ func (o *Dog) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Dog) GetBreedOk() (*string, bool) {
-	if o == nil || o.Breed == nil {
-		return nil, false
+	if o == nil || isNil(o.Breed) {
+    return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *Dog) HasBreed() bool {
-	if o != nil && o.Breed != nil {
+	if o != nil && !isNil(o.Breed) {
 		return true
 	}
 
@@ -98,7 +98,7 @@ func (o Dog) ToMap() (map[string]interface{}, error) {
 	if errAnimal != nil {
 		return map[string]interface{}{}, errAnimal
 	}
-	if o.Breed != nil {
+	if !isNil(o.Breed) {
 		toSerialize["breed"] = o.Breed
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
index 8dfe75bf225..73ee724d17a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_dog_all_of.go
@@ -44,7 +44,7 @@ func NewDogAllOfWithDefaults() *DogAllOf {
 
 // GetBreed returns the Breed field value if set, zero value otherwise.
 func (o *DogAllOf) GetBreed() string {
-	if o == nil || o.Breed == nil {
+	if o == nil || isNil(o.Breed) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *DogAllOf) GetBreed() string {
 // GetBreedOk returns a tuple with the Breed field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DogAllOf) GetBreedOk() (*string, bool) {
-	if o == nil || o.Breed == nil {
-		return nil, false
+	if o == nil || isNil(o.Breed) {
+    return nil, false
 	}
 	return o.Breed, true
 }
 
 // HasBreed returns a boolean if a field has been set.
 func (o *DogAllOf) HasBreed() bool {
-	if o != nil && o.Breed != nil {
+	if o != nil && !isNil(o.Breed) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o DogAllOf) MarshalJSON() ([]byte, error) {
 
 func (o DogAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Breed != nil {
+	if !isNil(o.Breed) {
 		toSerialize["breed"] = o.Breed
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
index 4e9aa72a2dc..ede5517398f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child.go
@@ -48,7 +48,7 @@ func NewDuplicatedPropChildWithDefaults() *DuplicatedPropChild {
 
 // GetDupProp returns the DupProp field value if set, zero value otherwise.
 func (o *DuplicatedPropChild) GetDupProp() string {
-	if o == nil || o.DupProp == nil {
+	if o == nil || isNil(o.DupProp) {
 		var ret string
 		return ret
 	}
@@ -58,15 +58,15 @@ func (o *DuplicatedPropChild) GetDupProp() string {
 // GetDupPropOk returns a tuple with the DupProp field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DuplicatedPropChild) GetDupPropOk() (*string, bool) {
-	if o == nil || o.DupProp == nil {
-		return nil, false
+	if o == nil || isNil(o.DupProp) {
+    return nil, false
 	}
 	return o.DupProp, true
 }
 
 // HasDupProp returns a boolean if a field has been set.
 func (o *DuplicatedPropChild) HasDupProp() bool {
-	if o != nil && o.DupProp != nil {
+	if o != nil && !isNil(o.DupProp) {
 		return true
 	}
 
@@ -96,7 +96,7 @@ func (o DuplicatedPropChild) ToMap() (map[string]interface{}, error) {
 	if errDuplicatedPropParent != nil {
 		return map[string]interface{}{}, errDuplicatedPropParent
 	}
-	if o.DupProp != nil {
+	if !isNil(o.DupProp) {
 		toSerialize["dup-prop"] = o.DupProp
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
index 43f0b6a4e03..decea76216b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_child_all_of.go
@@ -45,7 +45,7 @@ func NewDuplicatedPropChildAllOfWithDefaults() *DuplicatedPropChildAllOf {
 
 // GetDupProp returns the DupProp field value if set, zero value otherwise.
 func (o *DuplicatedPropChildAllOf) GetDupProp() string {
-	if o == nil || o.DupProp == nil {
+	if o == nil || isNil(o.DupProp) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *DuplicatedPropChildAllOf) GetDupProp() string {
 // GetDupPropOk returns a tuple with the DupProp field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *DuplicatedPropChildAllOf) GetDupPropOk() (*string, bool) {
-	if o == nil || o.DupProp == nil {
-		return nil, false
+	if o == nil || isNil(o.DupProp) {
+    return nil, false
 	}
 	return o.DupProp, true
 }
 
 // HasDupProp returns a boolean if a field has been set.
 func (o *DuplicatedPropChildAllOf) HasDupProp() bool {
-	if o != nil && o.DupProp != nil {
+	if o != nil && !isNil(o.DupProp) {
 		return true
 	}
 
@@ -85,7 +85,7 @@ func (o DuplicatedPropChildAllOf) MarshalJSON() ([]byte, error) {
 
 func (o DuplicatedPropChildAllOf) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.DupProp != nil {
+	if !isNil(o.DupProp) {
 		toSerialize["dup-prop"] = o.DupProp
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
index 359b19587e9..b009694ace8 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
@@ -57,9 +57,9 @@ func (o *DuplicatedPropParent) GetDupProp() string {
 // GetDupPropOk returns a tuple with the DupProp field value
 // and a boolean to check if the value has been set.
 func (o *DuplicatedPropParent) GetDupPropOk() (*string, bool) {
-	if o == nil {
+    if o == nil {
     return nil, false
-	}
+    }
 	return &o.DupProp, true
 }
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
index f7fffa0bd40..03ad4f1e265 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go
@@ -45,7 +45,7 @@ func NewEnumArraysWithDefaults() *EnumArrays {
 
 // GetJustSymbol returns the JustSymbol field value if set, zero value otherwise.
 func (o *EnumArrays) GetJustSymbol() string {
-	if o == nil || o.JustSymbol == nil {
+	if o == nil || isNil(o.JustSymbol) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *EnumArrays) GetJustSymbol() string {
 // GetJustSymbolOk returns a tuple with the JustSymbol field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetJustSymbolOk() (*string, bool) {
-	if o == nil || o.JustSymbol == nil {
-		return nil, false
+	if o == nil || isNil(o.JustSymbol) {
+    return nil, false
 	}
 	return o.JustSymbol, true
 }
 
 // HasJustSymbol returns a boolean if a field has been set.
 func (o *EnumArrays) HasJustSymbol() bool {
-	if o != nil && o.JustSymbol != nil {
+	if o != nil && !isNil(o.JustSymbol) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *EnumArrays) SetJustSymbol(v string) {
 
 // GetArrayEnum returns the ArrayEnum field value if set, zero value otherwise.
 func (o *EnumArrays) GetArrayEnum() []string {
-	if o == nil || o.ArrayEnum == nil {
+	if o == nil || isNil(o.ArrayEnum) {
 		var ret []string
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *EnumArrays) GetArrayEnum() []string {
 // GetArrayEnumOk returns a tuple with the ArrayEnum field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumArrays) GetArrayEnumOk() ([]string, bool) {
-	if o == nil || o.ArrayEnum == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayEnum) {
+    return nil, false
 	}
 	return o.ArrayEnum, true
 }
 
 // HasArrayEnum returns a boolean if a field has been set.
 func (o *EnumArrays) HasArrayEnum() bool {
-	if o != nil && o.ArrayEnum != nil {
+	if o != nil && !isNil(o.ArrayEnum) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o EnumArrays) MarshalJSON() ([]byte, error) {
 
 func (o EnumArrays) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.JustSymbol != nil {
+	if !isNil(o.JustSymbol) {
 		toSerialize["just_symbol"] = o.JustSymbol
 	}
-	if o.ArrayEnum != nil {
+	if !isNil(o.ArrayEnum) {
 		toSerialize["array_enum"] = o.ArrayEnum
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
index 4cb77fb669a..78702bec195 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
@@ -60,7 +60,7 @@ func NewEnumTestWithDefaults() *EnumTest {
 
 // GetEnumString returns the EnumString field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumString() string {
-	if o == nil || o.EnumString == nil {
+	if o == nil || isNil(o.EnumString) {
 		var ret string
 		return ret
 	}
@@ -70,15 +70,15 @@ func (o *EnumTest) GetEnumString() string {
 // GetEnumStringOk returns a tuple with the EnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringOk() (*string, bool) {
-	if o == nil || o.EnumString == nil {
-		return nil, false
+	if o == nil || isNil(o.EnumString) {
+    return nil, false
 	}
 	return o.EnumString, true
 }
 
 // HasEnumString returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumString() bool {
-	if o != nil && o.EnumString != nil {
+	if o != nil && !isNil(o.EnumString) {
 		return true
 	}
 
@@ -103,9 +103,9 @@ func (o *EnumTest) GetEnumStringRequired() string {
 // GetEnumStringRequiredOk returns a tuple with the EnumStringRequired field value
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumStringRequiredOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.EnumStringRequired, true
 }
 
@@ -116,7 +116,7 @@ func (o *EnumTest) SetEnumStringRequired(v string) {
 
 // GetEnumInteger returns the EnumInteger field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumInteger() int32 {
-	if o == nil || o.EnumInteger == nil {
+	if o == nil || isNil(o.EnumInteger) {
 		var ret int32
 		return ret
 	}
@@ -126,15 +126,15 @@ func (o *EnumTest) GetEnumInteger() int32 {
 // GetEnumIntegerOk returns a tuple with the EnumInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumIntegerOk() (*int32, bool) {
-	if o == nil || o.EnumInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.EnumInteger) {
+    return nil, false
 	}
 	return o.EnumInteger, true
 }
 
 // HasEnumInteger returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumInteger() bool {
-	if o != nil && o.EnumInteger != nil {
+	if o != nil && !isNil(o.EnumInteger) {
 		return true
 	}
 
@@ -148,7 +148,7 @@ func (o *EnumTest) SetEnumInteger(v int32) {
 
 // GetEnumNumber returns the EnumNumber field value if set, zero value otherwise.
 func (o *EnumTest) GetEnumNumber() float64 {
-	if o == nil || o.EnumNumber == nil {
+	if o == nil || isNil(o.EnumNumber) {
 		var ret float64
 		return ret
 	}
@@ -158,15 +158,15 @@ func (o *EnumTest) GetEnumNumber() float64 {
 // GetEnumNumberOk returns a tuple with the EnumNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetEnumNumberOk() (*float64, bool) {
-	if o == nil || o.EnumNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.EnumNumber) {
+    return nil, false
 	}
 	return o.EnumNumber, true
 }
 
 // HasEnumNumber returns a boolean if a field has been set.
 func (o *EnumTest) HasEnumNumber() bool {
-	if o != nil && o.EnumNumber != nil {
+	if o != nil && !isNil(o.EnumNumber) {
 		return true
 	}
 
@@ -180,7 +180,7 @@ func (o *EnumTest) SetEnumNumber(v float64) {
 
 // GetOuterEnum returns the OuterEnum field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *EnumTest) GetOuterEnum() OuterEnum {
-	if o == nil || o.OuterEnum.Get() == nil {
+	if o == nil || isNil(o.OuterEnum.Get()) {
 		var ret OuterEnum
 		return ret
 	}
@@ -192,7 +192,7 @@ func (o *EnumTest) GetOuterEnum() OuterEnum {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *EnumTest) GetOuterEnumOk() (*OuterEnum, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.OuterEnum.Get(), o.OuterEnum.IsSet()
 }
@@ -222,7 +222,7 @@ func (o *EnumTest) UnsetOuterEnum() {
 
 // GetOuterEnumInteger returns the OuterEnumInteger field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnumInteger() OuterEnumInteger {
-	if o == nil || o.OuterEnumInteger == nil {
+	if o == nil || isNil(o.OuterEnumInteger) {
 		var ret OuterEnumInteger
 		return ret
 	}
@@ -232,15 +232,15 @@ func (o *EnumTest) GetOuterEnumInteger() OuterEnumInteger {
 // GetOuterEnumIntegerOk returns a tuple with the OuterEnumInteger field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumIntegerOk() (*OuterEnumInteger, bool) {
-	if o == nil || o.OuterEnumInteger == nil {
-		return nil, false
+	if o == nil || isNil(o.OuterEnumInteger) {
+    return nil, false
 	}
 	return o.OuterEnumInteger, true
 }
 
 // HasOuterEnumInteger returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnumInteger() bool {
-	if o != nil && o.OuterEnumInteger != nil {
+	if o != nil && !isNil(o.OuterEnumInteger) {
 		return true
 	}
 
@@ -254,7 +254,7 @@ func (o *EnumTest) SetOuterEnumInteger(v OuterEnumInteger) {
 
 // GetOuterEnumDefaultValue returns the OuterEnumDefaultValue field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnumDefaultValue() OuterEnumDefaultValue {
-	if o == nil || o.OuterEnumDefaultValue == nil {
+	if o == nil || isNil(o.OuterEnumDefaultValue) {
 		var ret OuterEnumDefaultValue
 		return ret
 	}
@@ -264,15 +264,15 @@ func (o *EnumTest) GetOuterEnumDefaultValue() OuterEnumDefaultValue {
 // GetOuterEnumDefaultValueOk returns a tuple with the OuterEnumDefaultValue field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumDefaultValueOk() (*OuterEnumDefaultValue, bool) {
-	if o == nil || o.OuterEnumDefaultValue == nil {
-		return nil, false
+	if o == nil || isNil(o.OuterEnumDefaultValue) {
+    return nil, false
 	}
 	return o.OuterEnumDefaultValue, true
 }
 
 // HasOuterEnumDefaultValue returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnumDefaultValue() bool {
-	if o != nil && o.OuterEnumDefaultValue != nil {
+	if o != nil && !isNil(o.OuterEnumDefaultValue) {
 		return true
 	}
 
@@ -286,7 +286,7 @@ func (o *EnumTest) SetOuterEnumDefaultValue(v OuterEnumDefaultValue) {
 
 // GetOuterEnumIntegerDefaultValue returns the OuterEnumIntegerDefaultValue field value if set, zero value otherwise.
 func (o *EnumTest) GetOuterEnumIntegerDefaultValue() OuterEnumIntegerDefaultValue {
-	if o == nil || o.OuterEnumIntegerDefaultValue == nil {
+	if o == nil || isNil(o.OuterEnumIntegerDefaultValue) {
 		var ret OuterEnumIntegerDefaultValue
 		return ret
 	}
@@ -296,15 +296,15 @@ func (o *EnumTest) GetOuterEnumIntegerDefaultValue() OuterEnumIntegerDefaultValu
 // GetOuterEnumIntegerDefaultValueOk returns a tuple with the OuterEnumIntegerDefaultValue field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *EnumTest) GetOuterEnumIntegerDefaultValueOk() (*OuterEnumIntegerDefaultValue, bool) {
-	if o == nil || o.OuterEnumIntegerDefaultValue == nil {
-		return nil, false
+	if o == nil || isNil(o.OuterEnumIntegerDefaultValue) {
+    return nil, false
 	}
 	return o.OuterEnumIntegerDefaultValue, true
 }
 
 // HasOuterEnumIntegerDefaultValue returns a boolean if a field has been set.
 func (o *EnumTest) HasOuterEnumIntegerDefaultValue() bool {
-	if o != nil && o.OuterEnumIntegerDefaultValue != nil {
+	if o != nil && !isNil(o.OuterEnumIntegerDefaultValue) {
 		return true
 	}
 
@@ -326,26 +326,26 @@ func (o EnumTest) MarshalJSON() ([]byte, error) {
 
 func (o EnumTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.EnumString != nil {
+	if !isNil(o.EnumString) {
 		toSerialize["enum_string"] = o.EnumString
 	}
 	toSerialize["enum_string_required"] = o.EnumStringRequired
-	if o.EnumInteger != nil {
+	if !isNil(o.EnumInteger) {
 		toSerialize["enum_integer"] = o.EnumInteger
 	}
-	if o.EnumNumber != nil {
+	if !isNil(o.EnumNumber) {
 		toSerialize["enum_number"] = o.EnumNumber
 	}
 	if o.OuterEnum.IsSet() {
 		toSerialize["outerEnum"] = o.OuterEnum.Get()
 	}
-	if o.OuterEnumInteger != nil {
+	if !isNil(o.OuterEnumInteger) {
 		toSerialize["outerEnumInteger"] = o.OuterEnumInteger
 	}
-	if o.OuterEnumDefaultValue != nil {
+	if !isNil(o.OuterEnumDefaultValue) {
 		toSerialize["outerEnumDefaultValue"] = o.OuterEnumDefaultValue
 	}
-	if o.OuterEnumIntegerDefaultValue != nil {
+	if !isNil(o.OuterEnumIntegerDefaultValue) {
 		toSerialize["outerEnumIntegerDefaultValue"] = o.OuterEnumIntegerDefaultValue
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file.go b/samples/openapi3/client/petstore/go/go-petstore/model_file.go
index 1a83917df17..5f77b12eb9d 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_file.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_file.go
@@ -45,7 +45,7 @@ func NewFileWithDefaults() *File {
 
 // GetSourceURI returns the SourceURI field value if set, zero value otherwise.
 func (o *File) GetSourceURI() string {
-	if o == nil || o.SourceURI == nil {
+	if o == nil || isNil(o.SourceURI) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *File) GetSourceURI() string {
 // GetSourceURIOk returns a tuple with the SourceURI field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *File) GetSourceURIOk() (*string, bool) {
-	if o == nil || o.SourceURI == nil {
-		return nil, false
+	if o == nil || isNil(o.SourceURI) {
+    return nil, false
 	}
 	return o.SourceURI, true
 }
 
 // HasSourceURI returns a boolean if a field has been set.
 func (o *File) HasSourceURI() bool {
-	if o != nil && o.SourceURI != nil {
+	if o != nil && !isNil(o.SourceURI) {
 		return true
 	}
 
@@ -85,7 +85,7 @@ func (o File) MarshalJSON() ([]byte, error) {
 
 func (o File) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.SourceURI != nil {
+	if !isNil(o.SourceURI) {
 		toSerialize["sourceURI"] = o.SourceURI
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
index 43487a6b2bf..ea1f4b6e69f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go
@@ -45,7 +45,7 @@ func NewFileSchemaTestClassWithDefaults() *FileSchemaTestClass {
 
 // GetFile returns the File field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFile() File {
-	if o == nil || o.File == nil {
+	if o == nil || isNil(o.File) {
 		var ret File
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *FileSchemaTestClass) GetFile() File {
 // GetFileOk returns a tuple with the File field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFileOk() (*File, bool) {
-	if o == nil || o.File == nil {
-		return nil, false
+	if o == nil || isNil(o.File) {
+    return nil, false
 	}
 	return o.File, true
 }
 
 // HasFile returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFile() bool {
-	if o != nil && o.File != nil {
+	if o != nil && !isNil(o.File) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *FileSchemaTestClass) SetFile(v File) {
 
 // GetFiles returns the Files field value if set, zero value otherwise.
 func (o *FileSchemaTestClass) GetFiles() []File {
-	if o == nil || o.Files == nil {
+	if o == nil || isNil(o.Files) {
 		var ret []File
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *FileSchemaTestClass) GetFiles() []File {
 // GetFilesOk returns a tuple with the Files field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FileSchemaTestClass) GetFilesOk() ([]File, bool) {
-	if o == nil || o.Files == nil {
-		return nil, false
+	if o == nil || isNil(o.Files) {
+    return nil, false
 	}
 	return o.Files, true
 }
 
 // HasFiles returns a boolean if a field has been set.
 func (o *FileSchemaTestClass) HasFiles() bool {
-	if o != nil && o.Files != nil {
+	if o != nil && !isNil(o.Files) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) {
 
 func (o FileSchemaTestClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.File != nil {
+	if !isNil(o.File) {
 		toSerialize["file"] = o.File
 	}
-	if o.Files != nil {
+	if !isNil(o.Files) {
 		toSerialize["files"] = o.Files
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
index 5d7c6b339c5..1831fdcab36 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go
@@ -48,7 +48,7 @@ func NewFooWithDefaults() *Foo {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *Foo) GetBar() string {
-	if o == nil || o.Bar == nil {
+	if o == nil || isNil(o.Bar) {
 		var ret string
 		return ret
 	}
@@ -58,15 +58,15 @@ func (o *Foo) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Foo) GetBarOk() (*string, bool) {
-	if o == nil || o.Bar == nil {
-		return nil, false
+	if o == nil || isNil(o.Bar) {
+    return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *Foo) HasBar() bool {
-	if o != nil && o.Bar != nil {
+	if o != nil && !isNil(o.Bar) {
 		return true
 	}
 
@@ -88,7 +88,7 @@ func (o Foo) MarshalJSON() ([]byte, error) {
 
 func (o Foo) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Bar != nil {
+	if !isNil(o.Bar) {
 		toSerialize["bar"] = o.Bar
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
index 0217178c5a1..d2eb0f6d6cb 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
@@ -66,7 +66,7 @@ func NewFormatTestWithDefaults() *FormatTest {
 
 // GetInteger returns the Integer field value if set, zero value otherwise.
 func (o *FormatTest) GetInteger() int32 {
-	if o == nil || o.Integer == nil {
+	if o == nil || isNil(o.Integer) {
 		var ret int32
 		return ret
 	}
@@ -76,15 +76,15 @@ func (o *FormatTest) GetInteger() int32 {
 // GetIntegerOk returns a tuple with the Integer field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetIntegerOk() (*int32, bool) {
-	if o == nil || o.Integer == nil {
-		return nil, false
+	if o == nil || isNil(o.Integer) {
+    return nil, false
 	}
 	return o.Integer, true
 }
 
 // HasInteger returns a boolean if a field has been set.
 func (o *FormatTest) HasInteger() bool {
-	if o != nil && o.Integer != nil {
+	if o != nil && !isNil(o.Integer) {
 		return true
 	}
 
@@ -98,7 +98,7 @@ func (o *FormatTest) SetInteger(v int32) {
 
 // GetInt32 returns the Int32 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt32() int32 {
-	if o == nil || o.Int32 == nil {
+	if o == nil || isNil(o.Int32) {
 		var ret int32
 		return ret
 	}
@@ -108,15 +108,15 @@ func (o *FormatTest) GetInt32() int32 {
 // GetInt32Ok returns a tuple with the Int32 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt32Ok() (*int32, bool) {
-	if o == nil || o.Int32 == nil {
-		return nil, false
+	if o == nil || isNil(o.Int32) {
+    return nil, false
 	}
 	return o.Int32, true
 }
 
 // HasInt32 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt32() bool {
-	if o != nil && o.Int32 != nil {
+	if o != nil && !isNil(o.Int32) {
 		return true
 	}
 
@@ -130,7 +130,7 @@ func (o *FormatTest) SetInt32(v int32) {
 
 // GetInt64 returns the Int64 field value if set, zero value otherwise.
 func (o *FormatTest) GetInt64() int64 {
-	if o == nil || o.Int64 == nil {
+	if o == nil || isNil(o.Int64) {
 		var ret int64
 		return ret
 	}
@@ -140,15 +140,15 @@ func (o *FormatTest) GetInt64() int64 {
 // GetInt64Ok returns a tuple with the Int64 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetInt64Ok() (*int64, bool) {
-	if o == nil || o.Int64 == nil {
-		return nil, false
+	if o == nil || isNil(o.Int64) {
+    return nil, false
 	}
 	return o.Int64, true
 }
 
 // HasInt64 returns a boolean if a field has been set.
 func (o *FormatTest) HasInt64() bool {
-	if o != nil && o.Int64 != nil {
+	if o != nil && !isNil(o.Int64) {
 		return true
 	}
 
@@ -173,9 +173,9 @@ func (o *FormatTest) GetNumber() float32 {
 // GetNumberOk returns a tuple with the Number field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetNumberOk() (*float32, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Number, true
 }
 
@@ -186,7 +186,7 @@ func (o *FormatTest) SetNumber(v float32) {
 
 // GetFloat returns the Float field value if set, zero value otherwise.
 func (o *FormatTest) GetFloat() float32 {
-	if o == nil || o.Float == nil {
+	if o == nil || isNil(o.Float) {
 		var ret float32
 		return ret
 	}
@@ -196,15 +196,15 @@ func (o *FormatTest) GetFloat() float32 {
 // GetFloatOk returns a tuple with the Float field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetFloatOk() (*float32, bool) {
-	if o == nil || o.Float == nil {
-		return nil, false
+	if o == nil || isNil(o.Float) {
+    return nil, false
 	}
 	return o.Float, true
 }
 
 // HasFloat returns a boolean if a field has been set.
 func (o *FormatTest) HasFloat() bool {
-	if o != nil && o.Float != nil {
+	if o != nil && !isNil(o.Float) {
 		return true
 	}
 
@@ -218,7 +218,7 @@ func (o *FormatTest) SetFloat(v float32) {
 
 // GetDouble returns the Double field value if set, zero value otherwise.
 func (o *FormatTest) GetDouble() float64 {
-	if o == nil || o.Double == nil {
+	if o == nil || isNil(o.Double) {
 		var ret float64
 		return ret
 	}
@@ -228,15 +228,15 @@ func (o *FormatTest) GetDouble() float64 {
 // GetDoubleOk returns a tuple with the Double field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDoubleOk() (*float64, bool) {
-	if o == nil || o.Double == nil {
-		return nil, false
+	if o == nil || isNil(o.Double) {
+    return nil, false
 	}
 	return o.Double, true
 }
 
 // HasDouble returns a boolean if a field has been set.
 func (o *FormatTest) HasDouble() bool {
-	if o != nil && o.Double != nil {
+	if o != nil && !isNil(o.Double) {
 		return true
 	}
 
@@ -250,7 +250,7 @@ func (o *FormatTest) SetDouble(v float64) {
 
 // GetString returns the String field value if set, zero value otherwise.
 func (o *FormatTest) GetString() string {
-	if o == nil || o.String == nil {
+	if o == nil || isNil(o.String) {
 		var ret string
 		return ret
 	}
@@ -260,15 +260,15 @@ func (o *FormatTest) GetString() string {
 // GetStringOk returns a tuple with the String field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetStringOk() (*string, bool) {
-	if o == nil || o.String == nil {
-		return nil, false
+	if o == nil || isNil(o.String) {
+    return nil, false
 	}
 	return o.String, true
 }
 
 // HasString returns a boolean if a field has been set.
 func (o *FormatTest) HasString() bool {
-	if o != nil && o.String != nil {
+	if o != nil && !isNil(o.String) {
 		return true
 	}
 
@@ -293,9 +293,9 @@ func (o *FormatTest) GetByte() string {
 // GetByteOk returns a tuple with the Byte field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetByteOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Byte, true
 }
 
@@ -306,7 +306,7 @@ func (o *FormatTest) SetByte(v string) {
 
 // GetBinary returns the Binary field value if set, zero value otherwise.
 func (o *FormatTest) GetBinary() *os.File {
-	if o == nil || o.Binary == nil {
+	if o == nil || isNil(o.Binary) {
 		var ret *os.File
 		return ret
 	}
@@ -316,15 +316,15 @@ func (o *FormatTest) GetBinary() *os.File {
 // GetBinaryOk returns a tuple with the Binary field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetBinaryOk() (**os.File, bool) {
-	if o == nil || o.Binary == nil {
-		return nil, false
+	if o == nil || isNil(o.Binary) {
+    return nil, false
 	}
 	return o.Binary, true
 }
 
 // HasBinary returns a boolean if a field has been set.
 func (o *FormatTest) HasBinary() bool {
-	if o != nil && o.Binary != nil {
+	if o != nil && !isNil(o.Binary) {
 		return true
 	}
 
@@ -349,9 +349,9 @@ func (o *FormatTest) GetDate() string {
 // GetDateOk returns a tuple with the Date field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Date, true
 }
 
@@ -362,7 +362,7 @@ func (o *FormatTest) SetDate(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *FormatTest) GetDateTime() time.Time {
-	if o == nil || o.DateTime == nil {
+	if o == nil || isNil(o.DateTime) {
 		var ret time.Time
 		return ret
 	}
@@ -372,15 +372,15 @@ func (o *FormatTest) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || o.DateTime == nil {
-		return nil, false
+	if o == nil || isNil(o.DateTime) {
+    return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *FormatTest) HasDateTime() bool {
-	if o != nil && o.DateTime != nil {
+	if o != nil && !isNil(o.DateTime) {
 		return true
 	}
 
@@ -394,7 +394,7 @@ func (o *FormatTest) SetDateTime(v time.Time) {
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *FormatTest) GetUuid() string {
-	if o == nil || o.Uuid == nil {
+	if o == nil || isNil(o.Uuid) {
 		var ret string
 		return ret
 	}
@@ -404,15 +404,15 @@ func (o *FormatTest) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetUuidOk() (*string, bool) {
-	if o == nil || o.Uuid == nil {
-		return nil, false
+	if o == nil || isNil(o.Uuid) {
+    return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *FormatTest) HasUuid() bool {
-	if o != nil && o.Uuid != nil {
+	if o != nil && !isNil(o.Uuid) {
 		return true
 	}
 
@@ -437,9 +437,9 @@ func (o *FormatTest) GetPassword() string {
 // GetPasswordOk returns a tuple with the Password field value
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPasswordOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Password, true
 }
 
@@ -450,7 +450,7 @@ func (o *FormatTest) SetPassword(v string) {
 
 // GetPatternWithDigits returns the PatternWithDigits field value if set, zero value otherwise.
 func (o *FormatTest) GetPatternWithDigits() string {
-	if o == nil || o.PatternWithDigits == nil {
+	if o == nil || isNil(o.PatternWithDigits) {
 		var ret string
 		return ret
 	}
@@ -460,15 +460,15 @@ func (o *FormatTest) GetPatternWithDigits() string {
 // GetPatternWithDigitsOk returns a tuple with the PatternWithDigits field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPatternWithDigitsOk() (*string, bool) {
-	if o == nil || o.PatternWithDigits == nil {
-		return nil, false
+	if o == nil || isNil(o.PatternWithDigits) {
+    return nil, false
 	}
 	return o.PatternWithDigits, true
 }
 
 // HasPatternWithDigits returns a boolean if a field has been set.
 func (o *FormatTest) HasPatternWithDigits() bool {
-	if o != nil && o.PatternWithDigits != nil {
+	if o != nil && !isNil(o.PatternWithDigits) {
 		return true
 	}
 
@@ -482,7 +482,7 @@ func (o *FormatTest) SetPatternWithDigits(v string) {
 
 // GetPatternWithDigitsAndDelimiter returns the PatternWithDigitsAndDelimiter field value if set, zero value otherwise.
 func (o *FormatTest) GetPatternWithDigitsAndDelimiter() string {
-	if o == nil || o.PatternWithDigitsAndDelimiter == nil {
+	if o == nil || isNil(o.PatternWithDigitsAndDelimiter) {
 		var ret string
 		return ret
 	}
@@ -492,15 +492,15 @@ func (o *FormatTest) GetPatternWithDigitsAndDelimiter() string {
 // GetPatternWithDigitsAndDelimiterOk returns a tuple with the PatternWithDigitsAndDelimiter field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *FormatTest) GetPatternWithDigitsAndDelimiterOk() (*string, bool) {
-	if o == nil || o.PatternWithDigitsAndDelimiter == nil {
-		return nil, false
+	if o == nil || isNil(o.PatternWithDigitsAndDelimiter) {
+    return nil, false
 	}
 	return o.PatternWithDigitsAndDelimiter, true
 }
 
 // HasPatternWithDigitsAndDelimiter returns a boolean if a field has been set.
 func (o *FormatTest) HasPatternWithDigitsAndDelimiter() bool {
-	if o != nil && o.PatternWithDigitsAndDelimiter != nil {
+	if o != nil && !isNil(o.PatternWithDigitsAndDelimiter) {
 		return true
 	}
 
@@ -522,41 +522,41 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 
 func (o FormatTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Integer != nil {
+	if !isNil(o.Integer) {
 		toSerialize["integer"] = o.Integer
 	}
-	if o.Int32 != nil {
+	if !isNil(o.Int32) {
 		toSerialize["int32"] = o.Int32
 	}
-	if o.Int64 != nil {
+	if !isNil(o.Int64) {
 		toSerialize["int64"] = o.Int64
 	}
 	toSerialize["number"] = o.Number
-	if o.Float != nil {
+	if !isNil(o.Float) {
 		toSerialize["float"] = o.Float
 	}
-	if o.Double != nil {
+	if !isNil(o.Double) {
 		toSerialize["double"] = o.Double
 	}
-	if o.String != nil {
+	if !isNil(o.String) {
 		toSerialize["string"] = o.String
 	}
 	toSerialize["byte"] = o.Byte
-	if o.Binary != nil {
+	if !isNil(o.Binary) {
 		toSerialize["binary"] = o.Binary
 	}
 	toSerialize["date"] = o.Date
-	if o.DateTime != nil {
+	if !isNil(o.DateTime) {
 		toSerialize["dateTime"] = o.DateTime
 	}
-	if o.Uuid != nil {
+	if !isNil(o.Uuid) {
 		toSerialize["uuid"] = o.Uuid
 	}
 	toSerialize["password"] = o.Password
-	if o.PatternWithDigits != nil {
+	if !isNil(o.PatternWithDigits) {
 		toSerialize["pattern_with_digits"] = o.PatternWithDigits
 	}
-	if o.PatternWithDigitsAndDelimiter != nil {
+	if !isNil(o.PatternWithDigitsAndDelimiter) {
 		toSerialize["pattern_with_digits_and_delimiter"] = o.PatternWithDigitsAndDelimiter
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
index d1f7cd8de8a..862ac759303 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go
@@ -45,7 +45,7 @@ func NewHasOnlyReadOnlyWithDefaults() *HasOnlyReadOnly {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetBar() string {
-	if o == nil || o.Bar == nil {
+	if o == nil || isNil(o.Bar) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *HasOnlyReadOnly) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetBarOk() (*string, bool) {
-	if o == nil || o.Bar == nil {
-		return nil, false
+	if o == nil || isNil(o.Bar) {
+    return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasBar() bool {
-	if o != nil && o.Bar != nil {
+	if o != nil && !isNil(o.Bar) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *HasOnlyReadOnly) SetBar(v string) {
 
 // GetFoo returns the Foo field value if set, zero value otherwise.
 func (o *HasOnlyReadOnly) GetFoo() string {
-	if o == nil || o.Foo == nil {
+	if o == nil || isNil(o.Foo) {
 		var ret string
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *HasOnlyReadOnly) GetFoo() string {
 // GetFooOk returns a tuple with the Foo field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *HasOnlyReadOnly) GetFooOk() (*string, bool) {
-	if o == nil || o.Foo == nil {
-		return nil, false
+	if o == nil || isNil(o.Foo) {
+    return nil, false
 	}
 	return o.Foo, true
 }
 
 // HasFoo returns a boolean if a field has been set.
 func (o *HasOnlyReadOnly) HasFoo() bool {
-	if o != nil && o.Foo != nil {
+	if o != nil && !isNil(o.Foo) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) {
 
 func (o HasOnlyReadOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Bar != nil {
+	if !isNil(o.Bar) {
 		toSerialize["bar"] = o.Bar
 	}
-	if o.Foo != nil {
+	if !isNil(o.Foo) {
 		toSerialize["foo"] = o.Foo
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_list.go b/samples/openapi3/client/petstore/go/go-petstore/model_list.go
index ee44ac2ed7a..3dfb88523ab 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_list.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_list.go
@@ -44,7 +44,7 @@ func NewListWithDefaults() *List {
 
 // GetVar123List returns the Var123List field value if set, zero value otherwise.
 func (o *List) GetVar123List() string {
-	if o == nil || o.Var123List == nil {
+	if o == nil || isNil(o.Var123List) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *List) GetVar123List() string {
 // GetVar123ListOk returns a tuple with the Var123List field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *List) GetVar123ListOk() (*string, bool) {
-	if o == nil || o.Var123List == nil {
-		return nil, false
+	if o == nil || isNil(o.Var123List) {
+    return nil, false
 	}
 	return o.Var123List, true
 }
 
 // HasVar123List returns a boolean if a field has been set.
 func (o *List) HasVar123List() bool {
-	if o != nil && o.Var123List != nil {
+	if o != nil && !isNil(o.Var123List) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o List) MarshalJSON() ([]byte, error) {
 
 func (o List) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Var123List != nil {
+	if !isNil(o.Var123List) {
 		toSerialize["123-list"] = o.Var123List
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
index c055bd167cc..7bd9b3be6a1 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go
@@ -46,7 +46,7 @@ func NewMapOfFileTestWithDefaults() *MapOfFileTest {
 
 // GetPropTest returns the PropTest field value if set, zero value otherwise.
 func (o *MapOfFileTest) GetPropTest() map[string]*os.File {
-	if o == nil || o.PropTest == nil {
+	if o == nil || isNil(o.PropTest) {
 		var ret map[string]*os.File
 		return ret
 	}
@@ -56,15 +56,15 @@ func (o *MapOfFileTest) GetPropTest() map[string]*os.File {
 // GetPropTestOk returns a tuple with the PropTest field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapOfFileTest) GetPropTestOk() (*map[string]*os.File, bool) {
-	if o == nil || o.PropTest == nil {
-		return nil, false
+	if o == nil || isNil(o.PropTest) {
+    return nil, false
 	}
 	return o.PropTest, true
 }
 
 // HasPropTest returns a boolean if a field has been set.
 func (o *MapOfFileTest) HasPropTest() bool {
-	if o != nil && o.PropTest != nil {
+	if o != nil && !isNil(o.PropTest) {
 		return true
 	}
 
@@ -86,7 +86,7 @@ func (o MapOfFileTest) MarshalJSON() ([]byte, error) {
 
 func (o MapOfFileTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.PropTest != nil {
+	if !isNil(o.PropTest) {
 		toSerialize["prop_test"] = o.PropTest
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
index 781103a39fc..93c342f36cc 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go
@@ -47,7 +47,7 @@ func NewMapTestWithDefaults() *MapTest {
 
 // GetMapMapOfString returns the MapMapOfString field value if set, zero value otherwise.
 func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
-	if o == nil || o.MapMapOfString == nil {
+	if o == nil || isNil(o.MapMapOfString) {
 		var ret map[string]map[string]string
 		return ret
 	}
@@ -57,15 +57,15 @@ func (o *MapTest) GetMapMapOfString() map[string]map[string]string {
 // GetMapMapOfStringOk returns a tuple with the MapMapOfString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapMapOfStringOk() (*map[string]map[string]string, bool) {
-	if o == nil || o.MapMapOfString == nil {
-		return nil, false
+	if o == nil || isNil(o.MapMapOfString) {
+    return nil, false
 	}
 	return o.MapMapOfString, true
 }
 
 // HasMapMapOfString returns a boolean if a field has been set.
 func (o *MapTest) HasMapMapOfString() bool {
-	if o != nil && o.MapMapOfString != nil {
+	if o != nil && !isNil(o.MapMapOfString) {
 		return true
 	}
 
@@ -79,7 +79,7 @@ func (o *MapTest) SetMapMapOfString(v map[string]map[string]string) {
 
 // GetMapOfEnumString returns the MapOfEnumString field value if set, zero value otherwise.
 func (o *MapTest) GetMapOfEnumString() map[string]string {
-	if o == nil || o.MapOfEnumString == nil {
+	if o == nil || isNil(o.MapOfEnumString) {
 		var ret map[string]string
 		return ret
 	}
@@ -89,15 +89,15 @@ func (o *MapTest) GetMapOfEnumString() map[string]string {
 // GetMapOfEnumStringOk returns a tuple with the MapOfEnumString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetMapOfEnumStringOk() (*map[string]string, bool) {
-	if o == nil || o.MapOfEnumString == nil {
-		return nil, false
+	if o == nil || isNil(o.MapOfEnumString) {
+    return nil, false
 	}
 	return o.MapOfEnumString, true
 }
 
 // HasMapOfEnumString returns a boolean if a field has been set.
 func (o *MapTest) HasMapOfEnumString() bool {
-	if o != nil && o.MapOfEnumString != nil {
+	if o != nil && !isNil(o.MapOfEnumString) {
 		return true
 	}
 
@@ -111,7 +111,7 @@ func (o *MapTest) SetMapOfEnumString(v map[string]string) {
 
 // GetDirectMap returns the DirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetDirectMap() map[string]bool {
-	if o == nil || o.DirectMap == nil {
+	if o == nil || isNil(o.DirectMap) {
 		var ret map[string]bool
 		return ret
 	}
@@ -121,15 +121,15 @@ func (o *MapTest) GetDirectMap() map[string]bool {
 // GetDirectMapOk returns a tuple with the DirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetDirectMapOk() (*map[string]bool, bool) {
-	if o == nil || o.DirectMap == nil {
-		return nil, false
+	if o == nil || isNil(o.DirectMap) {
+    return nil, false
 	}
 	return o.DirectMap, true
 }
 
 // HasDirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasDirectMap() bool {
-	if o != nil && o.DirectMap != nil {
+	if o != nil && !isNil(o.DirectMap) {
 		return true
 	}
 
@@ -143,7 +143,7 @@ func (o *MapTest) SetDirectMap(v map[string]bool) {
 
 // GetIndirectMap returns the IndirectMap field value if set, zero value otherwise.
 func (o *MapTest) GetIndirectMap() map[string]bool {
-	if o == nil || o.IndirectMap == nil {
+	if o == nil || isNil(o.IndirectMap) {
 		var ret map[string]bool
 		return ret
 	}
@@ -153,15 +153,15 @@ func (o *MapTest) GetIndirectMap() map[string]bool {
 // GetIndirectMapOk returns a tuple with the IndirectMap field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MapTest) GetIndirectMapOk() (*map[string]bool, bool) {
-	if o == nil || o.IndirectMap == nil {
-		return nil, false
+	if o == nil || isNil(o.IndirectMap) {
+    return nil, false
 	}
 	return o.IndirectMap, true
 }
 
 // HasIndirectMap returns a boolean if a field has been set.
 func (o *MapTest) HasIndirectMap() bool {
-	if o != nil && o.IndirectMap != nil {
+	if o != nil && !isNil(o.IndirectMap) {
 		return true
 	}
 
@@ -183,16 +183,16 @@ func (o MapTest) MarshalJSON() ([]byte, error) {
 
 func (o MapTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.MapMapOfString != nil {
+	if !isNil(o.MapMapOfString) {
 		toSerialize["map_map_of_string"] = o.MapMapOfString
 	}
-	if o.MapOfEnumString != nil {
+	if !isNil(o.MapOfEnumString) {
 		toSerialize["map_of_enum_string"] = o.MapOfEnumString
 	}
-	if o.DirectMap != nil {
+	if !isNil(o.DirectMap) {
 		toSerialize["direct_map"] = o.DirectMap
 	}
-	if o.IndirectMap != nil {
+	if !isNil(o.IndirectMap) {
 		toSerialize["indirect_map"] = o.IndirectMap
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
index 2c7857016d7..33f94bfd5e0 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go
@@ -47,7 +47,7 @@ func NewMixedPropertiesAndAdditionalPropertiesClassWithDefaults() *MixedProperti
 
 // GetUuid returns the Uuid field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
-	if o == nil || o.Uuid == nil {
+	if o == nil || isNil(o.Uuid) {
 		var ret string
 		return ret
 	}
@@ -57,15 +57,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string {
 // GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuidOk() (*string, bool) {
-	if o == nil || o.Uuid == nil {
-		return nil, false
+	if o == nil || isNil(o.Uuid) {
+    return nil, false
 	}
 	return o.Uuid, true
 }
 
 // HasUuid returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasUuid() bool {
-	if o != nil && o.Uuid != nil {
+	if o != nil && !isNil(o.Uuid) {
 		return true
 	}
 
@@ -79,7 +79,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetUuid(v string) {
 
 // GetDateTime returns the DateTime field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
-	if o == nil || o.DateTime == nil {
+	if o == nil || isNil(o.DateTime) {
 		var ret time.Time
 		return ret
 	}
@@ -89,15 +89,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time {
 // GetDateTimeOk returns a tuple with the DateTime field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTimeOk() (*time.Time, bool) {
-	if o == nil || o.DateTime == nil {
-		return nil, false
+	if o == nil || isNil(o.DateTime) {
+    return nil, false
 	}
 	return o.DateTime, true
 }
 
 // HasDateTime returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasDateTime() bool {
-	if o != nil && o.DateTime != nil {
+	if o != nil && !isNil(o.DateTime) {
 		return true
 	}
 
@@ -111,7 +111,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetDateTime(v time.Time) {
 
 // GetMap returns the Map field value if set, zero value otherwise.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal {
-	if o == nil || o.Map == nil {
+	if o == nil || isNil(o.Map) {
 		var ret map[string]Animal
 		return ret
 	}
@@ -121,15 +121,15 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal
 // GetMapOk returns a tuple with the Map field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMapOk() (*map[string]Animal, bool) {
-	if o == nil || o.Map == nil {
-		return nil, false
+	if o == nil || isNil(o.Map) {
+    return nil, false
 	}
 	return o.Map, true
 }
 
 // HasMap returns a boolean if a field has been set.
 func (o *MixedPropertiesAndAdditionalPropertiesClass) HasMap() bool {
-	if o != nil && o.Map != nil {
+	if o != nil && !isNil(o.Map) {
 		return true
 	}
 
@@ -151,13 +151,13 @@ func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, erro
 
 func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Uuid != nil {
+	if !isNil(o.Uuid) {
 		toSerialize["uuid"] = o.Uuid
 	}
-	if o.DateTime != nil {
+	if !isNil(o.DateTime) {
 		toSerialize["dateTime"] = o.DateTime
 	}
-	if o.Map != nil {
+	if !isNil(o.Map) {
 		toSerialize["map"] = o.Map
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_name.go b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
index fc7c10b9f6f..07c40335e2b 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_name.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
@@ -59,9 +59,9 @@ func (o *Name) GetName() int32 {
 // GetNameOk returns a tuple with the Name field value
 // and a boolean to check if the value has been set.
 func (o *Name) GetNameOk() (*int32, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Name, true
 }
 
@@ -72,7 +72,7 @@ func (o *Name) SetName(v int32) {
 
 // GetSnakeCase returns the SnakeCase field value if set, zero value otherwise.
 func (o *Name) GetSnakeCase() int32 {
-	if o == nil || o.SnakeCase == nil {
+	if o == nil || isNil(o.SnakeCase) {
 		var ret int32
 		return ret
 	}
@@ -82,15 +82,15 @@ func (o *Name) GetSnakeCase() int32 {
 // GetSnakeCaseOk returns a tuple with the SnakeCase field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetSnakeCaseOk() (*int32, bool) {
-	if o == nil || o.SnakeCase == nil {
-		return nil, false
+	if o == nil || isNil(o.SnakeCase) {
+    return nil, false
 	}
 	return o.SnakeCase, true
 }
 
 // HasSnakeCase returns a boolean if a field has been set.
 func (o *Name) HasSnakeCase() bool {
-	if o != nil && o.SnakeCase != nil {
+	if o != nil && !isNil(o.SnakeCase) {
 		return true
 	}
 
@@ -104,7 +104,7 @@ func (o *Name) SetSnakeCase(v int32) {
 
 // GetProperty returns the Property field value if set, zero value otherwise.
 func (o *Name) GetProperty() string {
-	if o == nil || o.Property == nil {
+	if o == nil || isNil(o.Property) {
 		var ret string
 		return ret
 	}
@@ -114,15 +114,15 @@ func (o *Name) GetProperty() string {
 // GetPropertyOk returns a tuple with the Property field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetPropertyOk() (*string, bool) {
-	if o == nil || o.Property == nil {
-		return nil, false
+	if o == nil || isNil(o.Property) {
+    return nil, false
 	}
 	return o.Property, true
 }
 
 // HasProperty returns a boolean if a field has been set.
 func (o *Name) HasProperty() bool {
-	if o != nil && o.Property != nil {
+	if o != nil && !isNil(o.Property) {
 		return true
 	}
 
@@ -136,7 +136,7 @@ func (o *Name) SetProperty(v string) {
 
 // GetVar123Number returns the Var123Number field value if set, zero value otherwise.
 func (o *Name) GetVar123Number() int32 {
-	if o == nil || o.Var123Number == nil {
+	if o == nil || isNil(o.Var123Number) {
 		var ret int32
 		return ret
 	}
@@ -146,15 +146,15 @@ func (o *Name) GetVar123Number() int32 {
 // GetVar123NumberOk returns a tuple with the Var123Number field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Name) GetVar123NumberOk() (*int32, bool) {
-	if o == nil || o.Var123Number == nil {
-		return nil, false
+	if o == nil || isNil(o.Var123Number) {
+    return nil, false
 	}
 	return o.Var123Number, true
 }
 
 // HasVar123Number returns a boolean if a field has been set.
 func (o *Name) HasVar123Number() bool {
-	if o != nil && o.Var123Number != nil {
+	if o != nil && !isNil(o.Var123Number) {
 		return true
 	}
 
@@ -177,13 +177,13 @@ func (o Name) MarshalJSON() ([]byte, error) {
 func (o Name) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	toSerialize["name"] = o.Name
-	if o.SnakeCase != nil {
+	if !isNil(o.SnakeCase) {
 		toSerialize["snake_case"] = o.SnakeCase
 	}
-	if o.Property != nil {
+	if !isNil(o.Property) {
 		toSerialize["property"] = o.Property
 	}
-	if o.Var123Number != nil {
+	if !isNil(o.Var123Number) {
 		toSerialize["123Number"] = o.Var123Number
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
index e1555200770..44ac93bae57 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go
@@ -44,7 +44,7 @@ func NewNullableAllOfChildWithDefaults() *NullableAllOfChild {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *NullableAllOfChild) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *NullableAllOfChild) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NullableAllOfChild) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *NullableAllOfChild) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o NullableAllOfChild) MarshalJSON() ([]byte, error) {
 
 func (o NullableAllOfChild) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
index 63efbfae65c..750f596c64f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go
@@ -57,7 +57,7 @@ func NewNullableClassWithDefaults() *NullableClass {
 
 // GetIntegerProp returns the IntegerProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetIntegerProp() int32 {
-	if o == nil || o.IntegerProp.Get() == nil {
+	if o == nil || isNil(o.IntegerProp.Get()) {
 		var ret int32
 		return ret
 	}
@@ -69,7 +69,7 @@ func (o *NullableClass) GetIntegerProp() int32 {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetIntegerPropOk() (*int32, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.IntegerProp.Get(), o.IntegerProp.IsSet()
 }
@@ -99,7 +99,7 @@ func (o *NullableClass) UnsetIntegerProp() {
 
 // GetNumberProp returns the NumberProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetNumberProp() float32 {
-	if o == nil || o.NumberProp.Get() == nil {
+	if o == nil || isNil(o.NumberProp.Get()) {
 		var ret float32
 		return ret
 	}
@@ -111,7 +111,7 @@ func (o *NullableClass) GetNumberProp() float32 {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetNumberPropOk() (*float32, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.NumberProp.Get(), o.NumberProp.IsSet()
 }
@@ -141,7 +141,7 @@ func (o *NullableClass) UnsetNumberProp() {
 
 // GetBooleanProp returns the BooleanProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetBooleanProp() bool {
-	if o == nil || o.BooleanProp.Get() == nil {
+	if o == nil || isNil(o.BooleanProp.Get()) {
 		var ret bool
 		return ret
 	}
@@ -153,7 +153,7 @@ func (o *NullableClass) GetBooleanProp() bool {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetBooleanPropOk() (*bool, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.BooleanProp.Get(), o.BooleanProp.IsSet()
 }
@@ -183,7 +183,7 @@ func (o *NullableClass) UnsetBooleanProp() {
 
 // GetStringProp returns the StringProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetStringProp() string {
-	if o == nil || o.StringProp.Get() == nil {
+	if o == nil || isNil(o.StringProp.Get()) {
 		var ret string
 		return ret
 	}
@@ -195,7 +195,7 @@ func (o *NullableClass) GetStringProp() string {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetStringPropOk() (*string, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.StringProp.Get(), o.StringProp.IsSet()
 }
@@ -225,7 +225,7 @@ func (o *NullableClass) UnsetStringProp() {
 
 // GetDateProp returns the DateProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetDateProp() string {
-	if o == nil || o.DateProp.Get() == nil {
+	if o == nil || isNil(o.DateProp.Get()) {
 		var ret string
 		return ret
 	}
@@ -237,7 +237,7 @@ func (o *NullableClass) GetDateProp() string {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetDatePropOk() (*string, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.DateProp.Get(), o.DateProp.IsSet()
 }
@@ -267,7 +267,7 @@ func (o *NullableClass) UnsetDateProp() {
 
 // GetDatetimeProp returns the DatetimeProp field value if set, zero value otherwise (both if not set or set to explicit null).
 func (o *NullableClass) GetDatetimeProp() time.Time {
-	if o == nil || o.DatetimeProp.Get() == nil {
+	if o == nil || isNil(o.DatetimeProp.Get()) {
 		var ret time.Time
 		return ret
 	}
@@ -279,7 +279,7 @@ func (o *NullableClass) GetDatetimeProp() time.Time {
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetDatetimePropOk() (*time.Time, bool) {
 	if o == nil {
-		return nil, false
+    return nil, false
 	}
 	return o.DatetimeProp.Get(), o.DatetimeProp.IsSet()
 }
@@ -320,15 +320,15 @@ func (o *NullableClass) GetArrayNullableProp() []map[string]interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool) {
-	if o == nil || o.ArrayNullableProp == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayNullableProp) {
+    return nil, false
 	}
 	return o.ArrayNullableProp, true
 }
 
 // HasArrayNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasArrayNullableProp() bool {
-	if o != nil && o.ArrayNullableProp != nil {
+	if o != nil && isNil(o.ArrayNullableProp) {
 		return true
 	}
 
@@ -353,15 +353,15 @@ func (o *NullableClass) GetArrayAndItemsNullableProp() []*map[string]interface{}
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]*map[string]interface{}, bool) {
-	if o == nil || o.ArrayAndItemsNullableProp == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayAndItemsNullableProp) {
+    return nil, false
 	}
 	return o.ArrayAndItemsNullableProp, true
 }
 
 // HasArrayAndItemsNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasArrayAndItemsNullableProp() bool {
-	if o != nil && o.ArrayAndItemsNullableProp != nil {
+	if o != nil && isNil(o.ArrayAndItemsNullableProp) {
 		return true
 	}
 
@@ -375,7 +375,7 @@ func (o *NullableClass) SetArrayAndItemsNullableProp(v []*map[string]interface{}
 
 // GetArrayItemsNullable returns the ArrayItemsNullable field value if set, zero value otherwise.
 func (o *NullableClass) GetArrayItemsNullable() []*map[string]interface{} {
-	if o == nil || o.ArrayItemsNullable == nil {
+	if o == nil || isNil(o.ArrayItemsNullable) {
 		var ret []*map[string]interface{}
 		return ret
 	}
@@ -385,15 +385,15 @@ func (o *NullableClass) GetArrayItemsNullable() []*map[string]interface{} {
 // GetArrayItemsNullableOk returns a tuple with the ArrayItemsNullable field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NullableClass) GetArrayItemsNullableOk() ([]*map[string]interface{}, bool) {
-	if o == nil || o.ArrayItemsNullable == nil {
-		return nil, false
+	if o == nil || isNil(o.ArrayItemsNullable) {
+    return nil, false
 	}
 	return o.ArrayItemsNullable, true
 }
 
 // HasArrayItemsNullable returns a boolean if a field has been set.
 func (o *NullableClass) HasArrayItemsNullable() bool {
-	if o != nil && o.ArrayItemsNullable != nil {
+	if o != nil && !isNil(o.ArrayItemsNullable) {
 		return true
 	}
 
@@ -418,15 +418,15 @@ func (o *NullableClass) GetObjectNullableProp() map[string]map[string]interface{
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interface{}, bool) {
-	if o == nil || o.ObjectNullableProp == nil {
-		return nil, false
+	if o == nil || isNil(o.ObjectNullableProp) {
+    return map[string]map[string]interface{}{}, false
 	}
 	return o.ObjectNullableProp, true
 }
 
 // HasObjectNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasObjectNullableProp() bool {
-	if o != nil && o.ObjectNullableProp != nil {
+	if o != nil && isNil(o.ObjectNullableProp) {
 		return true
 	}
 
@@ -451,15 +451,15 @@ func (o *NullableClass) GetObjectAndItemsNullableProp() map[string]map[string]in
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string]interface{}, bool) {
-	if o == nil || o.ObjectAndItemsNullableProp == nil {
-		return nil, false
+	if o == nil || isNil(o.ObjectAndItemsNullableProp) {
+    return map[string]map[string]interface{}{}, false
 	}
 	return o.ObjectAndItemsNullableProp, true
 }
 
 // HasObjectAndItemsNullableProp returns a boolean if a field has been set.
 func (o *NullableClass) HasObjectAndItemsNullableProp() bool {
-	if o != nil && o.ObjectAndItemsNullableProp != nil {
+	if o != nil && isNil(o.ObjectAndItemsNullableProp) {
 		return true
 	}
 
@@ -473,7 +473,7 @@ func (o *NullableClass) SetObjectAndItemsNullableProp(v map[string]map[string]in
 
 // GetObjectItemsNullable returns the ObjectItemsNullable field value if set, zero value otherwise.
 func (o *NullableClass) GetObjectItemsNullable() map[string]map[string]interface{} {
-	if o == nil || o.ObjectItemsNullable == nil {
+	if o == nil || isNil(o.ObjectItemsNullable) {
 		var ret map[string]map[string]interface{}
 		return ret
 	}
@@ -483,15 +483,15 @@ func (o *NullableClass) GetObjectItemsNullable() map[string]map[string]interface
 // GetObjectItemsNullableOk returns a tuple with the ObjectItemsNullable field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NullableClass) GetObjectItemsNullableOk() (map[string]map[string]interface{}, bool) {
-	if o == nil || o.ObjectItemsNullable == nil {
-		return nil, false
+	if o == nil || isNil(o.ObjectItemsNullable) {
+    return map[string]map[string]interface{}{}, false
 	}
 	return o.ObjectItemsNullable, true
 }
 
 // HasObjectItemsNullable returns a boolean if a field has been set.
 func (o *NullableClass) HasObjectItemsNullable() bool {
-	if o != nil && o.ObjectItemsNullable != nil {
+	if o != nil && !isNil(o.ObjectItemsNullable) {
 		return true
 	}
 
@@ -537,7 +537,7 @@ func (o NullableClass) ToMap() (map[string]interface{}, error) {
 	if o.ArrayAndItemsNullableProp != nil {
 		toSerialize["array_and_items_nullable_prop"] = o.ArrayAndItemsNullableProp
 	}
-	if o.ArrayItemsNullable != nil {
+	if !isNil(o.ArrayItemsNullable) {
 		toSerialize["array_items_nullable"] = o.ArrayItemsNullable
 	}
 	if o.ObjectNullableProp != nil {
@@ -546,7 +546,7 @@ func (o NullableClass) ToMap() (map[string]interface{}, error) {
 	if o.ObjectAndItemsNullableProp != nil {
 		toSerialize["object_and_items_nullable_prop"] = o.ObjectAndItemsNullableProp
 	}
-	if o.ObjectItemsNullable != nil {
+	if !isNil(o.ObjectItemsNullable) {
 		toSerialize["object_items_nullable"] = o.ObjectItemsNullable
 	}
 	return toSerialize, nil
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
index 1f1d5518ff4..a45e141bd84 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go
@@ -44,7 +44,7 @@ func NewNumberOnlyWithDefaults() *NumberOnly {
 
 // GetJustNumber returns the JustNumber field value if set, zero value otherwise.
 func (o *NumberOnly) GetJustNumber() float32 {
-	if o == nil || o.JustNumber == nil {
+	if o == nil || isNil(o.JustNumber) {
 		var ret float32
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *NumberOnly) GetJustNumber() float32 {
 // GetJustNumberOk returns a tuple with the JustNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *NumberOnly) GetJustNumberOk() (*float32, bool) {
-	if o == nil || o.JustNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.JustNumber) {
+    return nil, false
 	}
 	return o.JustNumber, true
 }
 
 // HasJustNumber returns a boolean if a field has been set.
 func (o *NumberOnly) HasJustNumber() bool {
-	if o != nil && o.JustNumber != nil {
+	if o != nil && !isNil(o.JustNumber) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o NumberOnly) MarshalJSON() ([]byte, error) {
 
 func (o NumberOnly) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.JustNumber != nil {
+	if !isNil(o.JustNumber) {
 		toSerialize["JustNumber"] = o.JustNumber
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
index 6f9eb193b34..b628286e148 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go
@@ -44,7 +44,7 @@ func NewOneOfPrimitiveTypeChildWithDefaults() *OneOfPrimitiveTypeChild {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *OneOfPrimitiveTypeChild) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *OneOfPrimitiveTypeChild) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OneOfPrimitiveTypeChild) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *OneOfPrimitiveTypeChild) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o OneOfPrimitiveTypeChild) MarshalJSON() ([]byte, error) {
 
 func (o OneOfPrimitiveTypeChild) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_order.go b/samples/openapi3/client/petstore/go/go-petstore/model_order.go
index 1b69573ffb6..a128ad68209 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_order.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_order.go
@@ -55,7 +55,7 @@ func NewOrderWithDefaults() *Order {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Order) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -65,15 +65,15 @@ func (o *Order) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Order) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -87,7 +87,7 @@ func (o *Order) SetId(v int64) {
 
 // GetPetId returns the PetId field value if set, zero value otherwise.
 func (o *Order) GetPetId() int64 {
-	if o == nil || o.PetId == nil {
+	if o == nil || isNil(o.PetId) {
 		var ret int64
 		return ret
 	}
@@ -97,15 +97,15 @@ func (o *Order) GetPetId() int64 {
 // GetPetIdOk returns a tuple with the PetId field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetPetIdOk() (*int64, bool) {
-	if o == nil || o.PetId == nil {
-		return nil, false
+	if o == nil || isNil(o.PetId) {
+    return nil, false
 	}
 	return o.PetId, true
 }
 
 // HasPetId returns a boolean if a field has been set.
 func (o *Order) HasPetId() bool {
-	if o != nil && o.PetId != nil {
+	if o != nil && !isNil(o.PetId) {
 		return true
 	}
 
@@ -119,7 +119,7 @@ func (o *Order) SetPetId(v int64) {
 
 // GetQuantity returns the Quantity field value if set, zero value otherwise.
 func (o *Order) GetQuantity() int32 {
-	if o == nil || o.Quantity == nil {
+	if o == nil || isNil(o.Quantity) {
 		var ret int32
 		return ret
 	}
@@ -129,15 +129,15 @@ func (o *Order) GetQuantity() int32 {
 // GetQuantityOk returns a tuple with the Quantity field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetQuantityOk() (*int32, bool) {
-	if o == nil || o.Quantity == nil {
-		return nil, false
+	if o == nil || isNil(o.Quantity) {
+    return nil, false
 	}
 	return o.Quantity, true
 }
 
 // HasQuantity returns a boolean if a field has been set.
 func (o *Order) HasQuantity() bool {
-	if o != nil && o.Quantity != nil {
+	if o != nil && !isNil(o.Quantity) {
 		return true
 	}
 
@@ -151,7 +151,7 @@ func (o *Order) SetQuantity(v int32) {
 
 // GetShipDate returns the ShipDate field value if set, zero value otherwise.
 func (o *Order) GetShipDate() time.Time {
-	if o == nil || o.ShipDate == nil {
+	if o == nil || isNil(o.ShipDate) {
 		var ret time.Time
 		return ret
 	}
@@ -161,15 +161,15 @@ func (o *Order) GetShipDate() time.Time {
 // GetShipDateOk returns a tuple with the ShipDate field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetShipDateOk() (*time.Time, bool) {
-	if o == nil || o.ShipDate == nil {
-		return nil, false
+	if o == nil || isNil(o.ShipDate) {
+    return nil, false
 	}
 	return o.ShipDate, true
 }
 
 // HasShipDate returns a boolean if a field has been set.
 func (o *Order) HasShipDate() bool {
-	if o != nil && o.ShipDate != nil {
+	if o != nil && !isNil(o.ShipDate) {
 		return true
 	}
 
@@ -183,7 +183,7 @@ func (o *Order) SetShipDate(v time.Time) {
 
 // GetStatus returns the Status field value if set, zero value otherwise.
 func (o *Order) GetStatus() string {
-	if o == nil || o.Status == nil {
+	if o == nil || isNil(o.Status) {
 		var ret string
 		return ret
 	}
@@ -193,15 +193,15 @@ func (o *Order) GetStatus() string {
 // GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetStatusOk() (*string, bool) {
-	if o == nil || o.Status == nil {
-		return nil, false
+	if o == nil || isNil(o.Status) {
+    return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Order) HasStatus() bool {
-	if o != nil && o.Status != nil {
+	if o != nil && !isNil(o.Status) {
 		return true
 	}
 
@@ -215,7 +215,7 @@ func (o *Order) SetStatus(v string) {
 
 // GetComplete returns the Complete field value if set, zero value otherwise.
 func (o *Order) GetComplete() bool {
-	if o == nil || o.Complete == nil {
+	if o == nil || isNil(o.Complete) {
 		var ret bool
 		return ret
 	}
@@ -225,15 +225,15 @@ func (o *Order) GetComplete() bool {
 // GetCompleteOk returns a tuple with the Complete field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Order) GetCompleteOk() (*bool, bool) {
-	if o == nil || o.Complete == nil {
-		return nil, false
+	if o == nil || isNil(o.Complete) {
+    return nil, false
 	}
 	return o.Complete, true
 }
 
 // HasComplete returns a boolean if a field has been set.
 func (o *Order) HasComplete() bool {
-	if o != nil && o.Complete != nil {
+	if o != nil && !isNil(o.Complete) {
 		return true
 	}
 
@@ -255,22 +255,22 @@ func (o Order) MarshalJSON() ([]byte, error) {
 
 func (o Order) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.PetId != nil {
+	if !isNil(o.PetId) {
 		toSerialize["petId"] = o.PetId
 	}
-	if o.Quantity != nil {
+	if !isNil(o.Quantity) {
 		toSerialize["quantity"] = o.Quantity
 	}
-	if o.ShipDate != nil {
+	if !isNil(o.ShipDate) {
 		toSerialize["shipDate"] = o.ShipDate
 	}
-	if o.Status != nil {
+	if !isNil(o.Status) {
 		toSerialize["status"] = o.Status
 	}
-	if o.Complete != nil {
+	if !isNil(o.Complete) {
 		toSerialize["complete"] = o.Complete
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
index 929b714fe0f..d970b1d77d3 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go
@@ -46,7 +46,7 @@ func NewOuterCompositeWithDefaults() *OuterComposite {
 
 // GetMyNumber returns the MyNumber field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyNumber() float32 {
-	if o == nil || o.MyNumber == nil {
+	if o == nil || isNil(o.MyNumber) {
 		var ret float32
 		return ret
 	}
@@ -56,15 +56,15 @@ func (o *OuterComposite) GetMyNumber() float32 {
 // GetMyNumberOk returns a tuple with the MyNumber field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyNumberOk() (*float32, bool) {
-	if o == nil || o.MyNumber == nil {
-		return nil, false
+	if o == nil || isNil(o.MyNumber) {
+    return nil, false
 	}
 	return o.MyNumber, true
 }
 
 // HasMyNumber returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyNumber() bool {
-	if o != nil && o.MyNumber != nil {
+	if o != nil && !isNil(o.MyNumber) {
 		return true
 	}
 
@@ -78,7 +78,7 @@ func (o *OuterComposite) SetMyNumber(v float32) {
 
 // GetMyString returns the MyString field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyString() string {
-	if o == nil || o.MyString == nil {
+	if o == nil || isNil(o.MyString) {
 		var ret string
 		return ret
 	}
@@ -88,15 +88,15 @@ func (o *OuterComposite) GetMyString() string {
 // GetMyStringOk returns a tuple with the MyString field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyStringOk() (*string, bool) {
-	if o == nil || o.MyString == nil {
-		return nil, false
+	if o == nil || isNil(o.MyString) {
+    return nil, false
 	}
 	return o.MyString, true
 }
 
 // HasMyString returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyString() bool {
-	if o != nil && o.MyString != nil {
+	if o != nil && !isNil(o.MyString) {
 		return true
 	}
 
@@ -110,7 +110,7 @@ func (o *OuterComposite) SetMyString(v string) {
 
 // GetMyBoolean returns the MyBoolean field value if set, zero value otherwise.
 func (o *OuterComposite) GetMyBoolean() bool {
-	if o == nil || o.MyBoolean == nil {
+	if o == nil || isNil(o.MyBoolean) {
 		var ret bool
 		return ret
 	}
@@ -120,15 +120,15 @@ func (o *OuterComposite) GetMyBoolean() bool {
 // GetMyBooleanOk returns a tuple with the MyBoolean field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *OuterComposite) GetMyBooleanOk() (*bool, bool) {
-	if o == nil || o.MyBoolean == nil {
-		return nil, false
+	if o == nil || isNil(o.MyBoolean) {
+    return nil, false
 	}
 	return o.MyBoolean, true
 }
 
 // HasMyBoolean returns a boolean if a field has been set.
 func (o *OuterComposite) HasMyBoolean() bool {
-	if o != nil && o.MyBoolean != nil {
+	if o != nil && !isNil(o.MyBoolean) {
 		return true
 	}
 
@@ -150,13 +150,13 @@ func (o OuterComposite) MarshalJSON() ([]byte, error) {
 
 func (o OuterComposite) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.MyNumber != nil {
+	if !isNil(o.MyNumber) {
 		toSerialize["my_number"] = o.MyNumber
 	}
-	if o.MyString != nil {
+	if !isNil(o.MyString) {
 		toSerialize["my_string"] = o.MyString
 	}
-	if o.MyBoolean != nil {
+	if !isNil(o.MyBoolean) {
 		toSerialize["my_boolean"] = o.MyBoolean
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
index 0c6642366c7..9a20830e193 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
@@ -53,7 +53,7 @@ func NewPetWithDefaults() *Pet {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Pet) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -63,15 +63,15 @@ func (o *Pet) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Pet) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -85,7 +85,7 @@ func (o *Pet) SetId(v int64) {
 
 // GetCategory returns the Category field value if set, zero value otherwise.
 func (o *Pet) GetCategory() Category {
-	if o == nil || o.Category == nil {
+	if o == nil || isNil(o.Category) {
 		var ret Category
 		return ret
 	}
@@ -95,15 +95,15 @@ func (o *Pet) GetCategory() Category {
 // GetCategoryOk returns a tuple with the Category field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetCategoryOk() (*Category, bool) {
-	if o == nil || o.Category == nil {
-		return nil, false
+	if o == nil || isNil(o.Category) {
+    return nil, false
 	}
 	return o.Category, true
 }
 
 // HasCategory returns a boolean if a field has been set.
 func (o *Pet) HasCategory() bool {
-	if o != nil && o.Category != nil {
+	if o != nil && !isNil(o.Category) {
 		return true
 	}
 
@@ -128,9 +128,9 @@ func (o *Pet) GetName() string {
 // GetNameOk returns a tuple with the Name field value
 // and a boolean to check if the value has been set.
 func (o *Pet) GetNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.Name, true
 }
 
@@ -152,9 +152,9 @@ func (o *Pet) GetPhotoUrls() []string {
 // GetPhotoUrlsOk returns a tuple with the PhotoUrls field value
 // and a boolean to check if the value has been set.
 func (o *Pet) GetPhotoUrlsOk() ([]string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return o.PhotoUrls, true
 }
 
@@ -165,7 +165,7 @@ func (o *Pet) SetPhotoUrls(v []string) {
 
 // GetTags returns the Tags field value if set, zero value otherwise.
 func (o *Pet) GetTags() []Tag {
-	if o == nil || o.Tags == nil {
+	if o == nil || isNil(o.Tags) {
 		var ret []Tag
 		return ret
 	}
@@ -175,15 +175,15 @@ func (o *Pet) GetTags() []Tag {
 // GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Pet) GetTagsOk() ([]Tag, bool) {
-	if o == nil || o.Tags == nil {
-		return nil, false
+	if o == nil || isNil(o.Tags) {
+    return nil, false
 	}
 	return o.Tags, true
 }
 
 // HasTags returns a boolean if a field has been set.
 func (o *Pet) HasTags() bool {
-	if o != nil && o.Tags != nil {
+	if o != nil && !isNil(o.Tags) {
 		return true
 	}
 
@@ -198,7 +198,7 @@ func (o *Pet) SetTags(v []Tag) {
 // GetStatus returns the Status field value if set, zero value otherwise.
 // Deprecated
 func (o *Pet) GetStatus() string {
-	if o == nil || o.Status == nil {
+	if o == nil || isNil(o.Status) {
 		var ret string
 		return ret
 	}
@@ -209,15 +209,15 @@ func (o *Pet) GetStatus() string {
 // and a boolean to check if the value has been set.
 // Deprecated
 func (o *Pet) GetStatusOk() (*string, bool) {
-	if o == nil || o.Status == nil {
-		return nil, false
+	if o == nil || isNil(o.Status) {
+    return nil, false
 	}
 	return o.Status, true
 }
 
 // HasStatus returns a boolean if a field has been set.
 func (o *Pet) HasStatus() bool {
-	if o != nil && o.Status != nil {
+	if o != nil && !isNil(o.Status) {
 		return true
 	}
 
@@ -240,18 +240,18 @@ func (o Pet) MarshalJSON() ([]byte, error) {
 
 func (o Pet) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.Category != nil {
+	if !isNil(o.Category) {
 		toSerialize["category"] = o.Category
 	}
 	toSerialize["name"] = o.Name
 	toSerialize["photoUrls"] = o.PhotoUrls
-	if o.Tags != nil {
+	if !isNil(o.Tags) {
 		toSerialize["tags"] = o.Tags
 	}
-	if o.Status != nil {
+	if !isNil(o.Status) {
 		toSerialize["status"] = o.Status
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
index 9b71f265645..833d94f1c42 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go
@@ -45,7 +45,7 @@ func NewReadOnlyFirstWithDefaults() *ReadOnlyFirst {
 
 // GetBar returns the Bar field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBar() string {
-	if o == nil || o.Bar == nil {
+	if o == nil || isNil(o.Bar) {
 		var ret string
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *ReadOnlyFirst) GetBar() string {
 // GetBarOk returns a tuple with the Bar field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBarOk() (*string, bool) {
-	if o == nil || o.Bar == nil {
-		return nil, false
+	if o == nil || isNil(o.Bar) {
+    return nil, false
 	}
 	return o.Bar, true
 }
 
 // HasBar returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBar() bool {
-	if o != nil && o.Bar != nil {
+	if o != nil && !isNil(o.Bar) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *ReadOnlyFirst) SetBar(v string) {
 
 // GetBaz returns the Baz field value if set, zero value otherwise.
 func (o *ReadOnlyFirst) GetBaz() string {
-	if o == nil || o.Baz == nil {
+	if o == nil || isNil(o.Baz) {
 		var ret string
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *ReadOnlyFirst) GetBaz() string {
 // GetBazOk returns a tuple with the Baz field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyFirst) GetBazOk() (*string, bool) {
-	if o == nil || o.Baz == nil {
-		return nil, false
+	if o == nil || isNil(o.Baz) {
+    return nil, false
 	}
 	return o.Baz, true
 }
 
 // HasBaz returns a boolean if a field has been set.
 func (o *ReadOnlyFirst) HasBaz() bool {
-	if o != nil && o.Baz != nil {
+	if o != nil && !isNil(o.Baz) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) {
 
 func (o ReadOnlyFirst) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Bar != nil {
+	if !isNil(o.Bar) {
 		toSerialize["bar"] = o.Bar
 	}
-	if o.Baz != nil {
+	if !isNil(o.Baz) {
 		toSerialize["baz"] = o.Baz
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
index d001bb1b726..a4b94e4730f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go
@@ -62,7 +62,7 @@ func NewReadOnlyWithDefaultWithDefaults() *ReadOnlyWithDefault {
 
 // GetProp1 returns the Prop1 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetProp1() string {
-	if o == nil || o.Prop1 == nil {
+	if o == nil || isNil(o.Prop1) {
 		var ret string
 		return ret
 	}
@@ -72,15 +72,15 @@ func (o *ReadOnlyWithDefault) GetProp1() string {
 // GetProp1Ok returns a tuple with the Prop1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetProp1Ok() (*string, bool) {
-	if o == nil || o.Prop1 == nil {
-		return nil, false
+	if o == nil || isNil(o.Prop1) {
+    return nil, false
 	}
 	return o.Prop1, true
 }
 
 // HasProp1 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasProp1() bool {
-	if o != nil && o.Prop1 != nil {
+	if o != nil && !isNil(o.Prop1) {
 		return true
 	}
 
@@ -94,7 +94,7 @@ func (o *ReadOnlyWithDefault) SetProp1(v string) {
 
 // GetProp2 returns the Prop2 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetProp2() string {
-	if o == nil || o.Prop2 == nil {
+	if o == nil || isNil(o.Prop2) {
 		var ret string
 		return ret
 	}
@@ -104,15 +104,15 @@ func (o *ReadOnlyWithDefault) GetProp2() string {
 // GetProp2Ok returns a tuple with the Prop2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetProp2Ok() (*string, bool) {
-	if o == nil || o.Prop2 == nil {
-		return nil, false
+	if o == nil || isNil(o.Prop2) {
+    return nil, false
 	}
 	return o.Prop2, true
 }
 
 // HasProp2 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasProp2() bool {
-	if o != nil && o.Prop2 != nil {
+	if o != nil && !isNil(o.Prop2) {
 		return true
 	}
 
@@ -126,7 +126,7 @@ func (o *ReadOnlyWithDefault) SetProp2(v string) {
 
 // GetProp3 returns the Prop3 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetProp3() string {
-	if o == nil || o.Prop3 == nil {
+	if o == nil || isNil(o.Prop3) {
 		var ret string
 		return ret
 	}
@@ -136,15 +136,15 @@ func (o *ReadOnlyWithDefault) GetProp3() string {
 // GetProp3Ok returns a tuple with the Prop3 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetProp3Ok() (*string, bool) {
-	if o == nil || o.Prop3 == nil {
-		return nil, false
+	if o == nil || isNil(o.Prop3) {
+    return nil, false
 	}
 	return o.Prop3, true
 }
 
 // HasProp3 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasProp3() bool {
-	if o != nil && o.Prop3 != nil {
+	if o != nil && !isNil(o.Prop3) {
 		return true
 	}
 
@@ -158,7 +158,7 @@ func (o *ReadOnlyWithDefault) SetProp3(v string) {
 
 // GetBoolProp1 returns the BoolProp1 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetBoolProp1() bool {
-	if o == nil || o.BoolProp1 == nil {
+	if o == nil || isNil(o.BoolProp1) {
 		var ret bool
 		return ret
 	}
@@ -168,15 +168,15 @@ func (o *ReadOnlyWithDefault) GetBoolProp1() bool {
 // GetBoolProp1Ok returns a tuple with the BoolProp1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetBoolProp1Ok() (*bool, bool) {
-	if o == nil || o.BoolProp1 == nil {
-		return nil, false
+	if o == nil || isNil(o.BoolProp1) {
+    return nil, false
 	}
 	return o.BoolProp1, true
 }
 
 // HasBoolProp1 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasBoolProp1() bool {
-	if o != nil && o.BoolProp1 != nil {
+	if o != nil && !isNil(o.BoolProp1) {
 		return true
 	}
 
@@ -190,7 +190,7 @@ func (o *ReadOnlyWithDefault) SetBoolProp1(v bool) {
 
 // GetBoolProp2 returns the BoolProp2 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetBoolProp2() bool {
-	if o == nil || o.BoolProp2 == nil {
+	if o == nil || isNil(o.BoolProp2) {
 		var ret bool
 		return ret
 	}
@@ -200,15 +200,15 @@ func (o *ReadOnlyWithDefault) GetBoolProp2() bool {
 // GetBoolProp2Ok returns a tuple with the BoolProp2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetBoolProp2Ok() (*bool, bool) {
-	if o == nil || o.BoolProp2 == nil {
-		return nil, false
+	if o == nil || isNil(o.BoolProp2) {
+    return nil, false
 	}
 	return o.BoolProp2, true
 }
 
 // HasBoolProp2 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasBoolProp2() bool {
-	if o != nil && o.BoolProp2 != nil {
+	if o != nil && !isNil(o.BoolProp2) {
 		return true
 	}
 
@@ -222,7 +222,7 @@ func (o *ReadOnlyWithDefault) SetBoolProp2(v bool) {
 
 // GetIntProp1 returns the IntProp1 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetIntProp1() float32 {
-	if o == nil || o.IntProp1 == nil {
+	if o == nil || isNil(o.IntProp1) {
 		var ret float32
 		return ret
 	}
@@ -232,15 +232,15 @@ func (o *ReadOnlyWithDefault) GetIntProp1() float32 {
 // GetIntProp1Ok returns a tuple with the IntProp1 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetIntProp1Ok() (*float32, bool) {
-	if o == nil || o.IntProp1 == nil {
-		return nil, false
+	if o == nil || isNil(o.IntProp1) {
+    return nil, false
 	}
 	return o.IntProp1, true
 }
 
 // HasIntProp1 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasIntProp1() bool {
-	if o != nil && o.IntProp1 != nil {
+	if o != nil && !isNil(o.IntProp1) {
 		return true
 	}
 
@@ -254,7 +254,7 @@ func (o *ReadOnlyWithDefault) SetIntProp1(v float32) {
 
 // GetIntProp2 returns the IntProp2 field value if set, zero value otherwise.
 func (o *ReadOnlyWithDefault) GetIntProp2() float32 {
-	if o == nil || o.IntProp2 == nil {
+	if o == nil || isNil(o.IntProp2) {
 		var ret float32
 		return ret
 	}
@@ -264,15 +264,15 @@ func (o *ReadOnlyWithDefault) GetIntProp2() float32 {
 // GetIntProp2Ok returns a tuple with the IntProp2 field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *ReadOnlyWithDefault) GetIntProp2Ok() (*float32, bool) {
-	if o == nil || o.IntProp2 == nil {
-		return nil, false
+	if o == nil || isNil(o.IntProp2) {
+    return nil, false
 	}
 	return o.IntProp2, true
 }
 
 // HasIntProp2 returns a boolean if a field has been set.
 func (o *ReadOnlyWithDefault) HasIntProp2() bool {
-	if o != nil && o.IntProp2 != nil {
+	if o != nil && !isNil(o.IntProp2) {
 		return true
 	}
 
@@ -294,25 +294,25 @@ func (o ReadOnlyWithDefault) MarshalJSON() ([]byte, error) {
 
 func (o ReadOnlyWithDefault) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Prop1 != nil {
+	if !isNil(o.Prop1) {
 		toSerialize["prop1"] = o.Prop1
 	}
-	if o.Prop2 != nil {
+	if !isNil(o.Prop2) {
 		toSerialize["prop2"] = o.Prop2
 	}
-	if o.Prop3 != nil {
+	if !isNil(o.Prop3) {
 		toSerialize["prop3"] = o.Prop3
 	}
-	if o.BoolProp1 != nil {
+	if !isNil(o.BoolProp1) {
 		toSerialize["boolProp1"] = o.BoolProp1
 	}
-	if o.BoolProp2 != nil {
+	if !isNil(o.BoolProp2) {
 		toSerialize["boolProp2"] = o.BoolProp2
 	}
-	if o.IntProp1 != nil {
+	if !isNil(o.IntProp1) {
 		toSerialize["intProp1"] = o.IntProp1
 	}
-	if o.IntProp2 != nil {
+	if !isNil(o.IntProp2) {
 		toSerialize["intProp2"] = o.IntProp2
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_return.go b/samples/openapi3/client/petstore/go/go-petstore/model_return.go
index 3561cfeb544..b0e61b74f6f 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_return.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_return.go
@@ -44,7 +44,7 @@ func NewReturnWithDefaults() *Return {
 
 // GetReturn returns the Return field value if set, zero value otherwise.
 func (o *Return) GetReturn() int32 {
-	if o == nil || o.Return == nil {
+	if o == nil || isNil(o.Return) {
 		var ret int32
 		return ret
 	}
@@ -54,15 +54,15 @@ func (o *Return) GetReturn() int32 {
 // GetReturnOk returns a tuple with the Return field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Return) GetReturnOk() (*int32, bool) {
-	if o == nil || o.Return == nil {
-		return nil, false
+	if o == nil || isNil(o.Return) {
+    return nil, false
 	}
 	return o.Return, true
 }
 
 // HasReturn returns a boolean if a field has been set.
 func (o *Return) HasReturn() bool {
-	if o != nil && o.Return != nil {
+	if o != nil && !isNil(o.Return) {
 		return true
 	}
 
@@ -84,7 +84,7 @@ func (o Return) MarshalJSON() ([]byte, error) {
 
 func (o Return) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Return != nil {
+	if !isNil(o.Return) {
 		toSerialize["return"] = o.Return
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
index 012e87aa755..1c94feb8c2a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go
@@ -45,7 +45,7 @@ func NewTagWithDefaults() *Tag {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *Tag) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -55,15 +55,15 @@ func (o *Tag) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *Tag) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -77,7 +77,7 @@ func (o *Tag) SetId(v int64) {
 
 // GetName returns the Name field value if set, zero value otherwise.
 func (o *Tag) GetName() string {
-	if o == nil || o.Name == nil {
+	if o == nil || isNil(o.Name) {
 		var ret string
 		return ret
 	}
@@ -87,15 +87,15 @@ func (o *Tag) GetName() string {
 // GetNameOk returns a tuple with the Name field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Tag) GetNameOk() (*string, bool) {
-	if o == nil || o.Name == nil {
-		return nil, false
+	if o == nil || isNil(o.Name) {
+    return nil, false
 	}
 	return o.Name, true
 }
 
 // HasName returns a boolean if a field has been set.
 func (o *Tag) HasName() bool {
-	if o != nil && o.Name != nil {
+	if o != nil && !isNil(o.Name) {
 		return true
 	}
 
@@ -117,10 +117,10 @@ func (o Tag) MarshalJSON() ([]byte, error) {
 
 func (o Tag) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.Name != nil {
+	if !isNil(o.Name) {
 		toSerialize["name"] = o.Name
 	}
 
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_user.go b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
index c94baca1eda..560d658e1a0 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_user.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_user.go
@@ -60,7 +60,7 @@ func NewUserWithDefaults() *User {
 
 // GetId returns the Id field value if set, zero value otherwise.
 func (o *User) GetId() int64 {
-	if o == nil || o.Id == nil {
+	if o == nil || isNil(o.Id) {
 		var ret int64
 		return ret
 	}
@@ -70,15 +70,15 @@ func (o *User) GetId() int64 {
 // GetIdOk returns a tuple with the Id field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetIdOk() (*int64, bool) {
-	if o == nil || o.Id == nil {
-		return nil, false
+	if o == nil || isNil(o.Id) {
+    return nil, false
 	}
 	return o.Id, true
 }
 
 // HasId returns a boolean if a field has been set.
 func (o *User) HasId() bool {
-	if o != nil && o.Id != nil {
+	if o != nil && !isNil(o.Id) {
 		return true
 	}
 
@@ -92,7 +92,7 @@ func (o *User) SetId(v int64) {
 
 // GetUsername returns the Username field value if set, zero value otherwise.
 func (o *User) GetUsername() string {
-	if o == nil || o.Username == nil {
+	if o == nil || isNil(o.Username) {
 		var ret string
 		return ret
 	}
@@ -102,15 +102,15 @@ func (o *User) GetUsername() string {
 // GetUsernameOk returns a tuple with the Username field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUsernameOk() (*string, bool) {
-	if o == nil || o.Username == nil {
-		return nil, false
+	if o == nil || isNil(o.Username) {
+    return nil, false
 	}
 	return o.Username, true
 }
 
 // HasUsername returns a boolean if a field has been set.
 func (o *User) HasUsername() bool {
-	if o != nil && o.Username != nil {
+	if o != nil && !isNil(o.Username) {
 		return true
 	}
 
@@ -124,7 +124,7 @@ func (o *User) SetUsername(v string) {
 
 // GetFirstName returns the FirstName field value if set, zero value otherwise.
 func (o *User) GetFirstName() string {
-	if o == nil || o.FirstName == nil {
+	if o == nil || isNil(o.FirstName) {
 		var ret string
 		return ret
 	}
@@ -134,15 +134,15 @@ func (o *User) GetFirstName() string {
 // GetFirstNameOk returns a tuple with the FirstName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetFirstNameOk() (*string, bool) {
-	if o == nil || o.FirstName == nil {
-		return nil, false
+	if o == nil || isNil(o.FirstName) {
+    return nil, false
 	}
 	return o.FirstName, true
 }
 
 // HasFirstName returns a boolean if a field has been set.
 func (o *User) HasFirstName() bool {
-	if o != nil && o.FirstName != nil {
+	if o != nil && !isNil(o.FirstName) {
 		return true
 	}
 
@@ -156,7 +156,7 @@ func (o *User) SetFirstName(v string) {
 
 // GetLastName returns the LastName field value if set, zero value otherwise.
 func (o *User) GetLastName() string {
-	if o == nil || o.LastName == nil {
+	if o == nil || isNil(o.LastName) {
 		var ret string
 		return ret
 	}
@@ -166,15 +166,15 @@ func (o *User) GetLastName() string {
 // GetLastNameOk returns a tuple with the LastName field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetLastNameOk() (*string, bool) {
-	if o == nil || o.LastName == nil {
-		return nil, false
+	if o == nil || isNil(o.LastName) {
+    return nil, false
 	}
 	return o.LastName, true
 }
 
 // HasLastName returns a boolean if a field has been set.
 func (o *User) HasLastName() bool {
-	if o != nil && o.LastName != nil {
+	if o != nil && !isNil(o.LastName) {
 		return true
 	}
 
@@ -188,7 +188,7 @@ func (o *User) SetLastName(v string) {
 
 // GetEmail returns the Email field value if set, zero value otherwise.
 func (o *User) GetEmail() string {
-	if o == nil || o.Email == nil {
+	if o == nil || isNil(o.Email) {
 		var ret string
 		return ret
 	}
@@ -198,15 +198,15 @@ func (o *User) GetEmail() string {
 // GetEmailOk returns a tuple with the Email field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetEmailOk() (*string, bool) {
-	if o == nil || o.Email == nil {
-		return nil, false
+	if o == nil || isNil(o.Email) {
+    return nil, false
 	}
 	return o.Email, true
 }
 
 // HasEmail returns a boolean if a field has been set.
 func (o *User) HasEmail() bool {
-	if o != nil && o.Email != nil {
+	if o != nil && !isNil(o.Email) {
 		return true
 	}
 
@@ -220,7 +220,7 @@ func (o *User) SetEmail(v string) {
 
 // GetPassword returns the Password field value if set, zero value otherwise.
 func (o *User) GetPassword() string {
-	if o == nil || o.Password == nil {
+	if o == nil || isNil(o.Password) {
 		var ret string
 		return ret
 	}
@@ -230,15 +230,15 @@ func (o *User) GetPassword() string {
 // GetPasswordOk returns a tuple with the Password field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPasswordOk() (*string, bool) {
-	if o == nil || o.Password == nil {
-		return nil, false
+	if o == nil || isNil(o.Password) {
+    return nil, false
 	}
 	return o.Password, true
 }
 
 // HasPassword returns a boolean if a field has been set.
 func (o *User) HasPassword() bool {
-	if o != nil && o.Password != nil {
+	if o != nil && !isNil(o.Password) {
 		return true
 	}
 
@@ -252,7 +252,7 @@ func (o *User) SetPassword(v string) {
 
 // GetPhone returns the Phone field value if set, zero value otherwise.
 func (o *User) GetPhone() string {
-	if o == nil || o.Phone == nil {
+	if o == nil || isNil(o.Phone) {
 		var ret string
 		return ret
 	}
@@ -262,15 +262,15 @@ func (o *User) GetPhone() string {
 // GetPhoneOk returns a tuple with the Phone field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetPhoneOk() (*string, bool) {
-	if o == nil || o.Phone == nil {
-		return nil, false
+	if o == nil || isNil(o.Phone) {
+    return nil, false
 	}
 	return o.Phone, true
 }
 
 // HasPhone returns a boolean if a field has been set.
 func (o *User) HasPhone() bool {
-	if o != nil && o.Phone != nil {
+	if o != nil && !isNil(o.Phone) {
 		return true
 	}
 
@@ -284,7 +284,7 @@ func (o *User) SetPhone(v string) {
 
 // GetUserStatus returns the UserStatus field value if set, zero value otherwise.
 func (o *User) GetUserStatus() int32 {
-	if o == nil || o.UserStatus == nil {
+	if o == nil || isNil(o.UserStatus) {
 		var ret int32
 		return ret
 	}
@@ -294,15 +294,15 @@ func (o *User) GetUserStatus() int32 {
 // GetUserStatusOk returns a tuple with the UserStatus field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetUserStatusOk() (*int32, bool) {
-	if o == nil || o.UserStatus == nil {
-		return nil, false
+	if o == nil || isNil(o.UserStatus) {
+    return nil, false
 	}
 	return o.UserStatus, true
 }
 
 // HasUserStatus returns a boolean if a field has been set.
 func (o *User) HasUserStatus() bool {
-	if o != nil && o.UserStatus != nil {
+	if o != nil && !isNil(o.UserStatus) {
 		return true
 	}
 
@@ -316,7 +316,7 @@ func (o *User) SetUserStatus(v int32) {
 
 // GetArbitraryObject returns the ArbitraryObject field value if set, zero value otherwise.
 func (o *User) GetArbitraryObject() map[string]interface{} {
-	if o == nil || o.ArbitraryObject == nil {
+	if o == nil || isNil(o.ArbitraryObject) {
 		var ret map[string]interface{}
 		return ret
 	}
@@ -326,15 +326,15 @@ func (o *User) GetArbitraryObject() map[string]interface{} {
 // GetArbitraryObjectOk returns a tuple with the ArbitraryObject field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *User) GetArbitraryObjectOk() (map[string]interface{}, bool) {
-	if o == nil || o.ArbitraryObject == nil {
-		return nil, false
+	if o == nil || isNil(o.ArbitraryObject) {
+    return map[string]interface{}{}, false
 	}
 	return o.ArbitraryObject, true
 }
 
 // HasArbitraryObject returns a boolean if a field has been set.
 func (o *User) HasArbitraryObject() bool {
-	if o != nil && o.ArbitraryObject != nil {
+	if o != nil && !isNil(o.ArbitraryObject) {
 		return true
 	}
 
@@ -359,15 +359,15 @@ func (o *User) GetArbitraryNullableObject() map[string]interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *User) GetArbitraryNullableObjectOk() (map[string]interface{}, bool) {
-	if o == nil || o.ArbitraryNullableObject == nil {
-		return nil, false
+	if o == nil || isNil(o.ArbitraryNullableObject) {
+    return map[string]interface{}{}, false
 	}
 	return o.ArbitraryNullableObject, true
 }
 
 // HasArbitraryNullableObject returns a boolean if a field has been set.
 func (o *User) HasArbitraryNullableObject() bool {
-	if o != nil && o.ArbitraryNullableObject != nil {
+	if o != nil && isNil(o.ArbitraryNullableObject) {
 		return true
 	}
 
@@ -392,15 +392,15 @@ func (o *User) GetArbitraryTypeValue() interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *User) GetArbitraryTypeValueOk() (*interface{}, bool) {
-	if o == nil || o.ArbitraryTypeValue == nil {
-		return nil, false
+	if o == nil || isNil(o.ArbitraryTypeValue) {
+    return nil, false
 	}
 	return &o.ArbitraryTypeValue, true
 }
 
 // HasArbitraryTypeValue returns a boolean if a field has been set.
 func (o *User) HasArbitraryTypeValue() bool {
-	if o != nil && o.ArbitraryTypeValue != nil {
+	if o != nil && isNil(o.ArbitraryTypeValue) {
 		return true
 	}
 
@@ -425,15 +425,15 @@ func (o *User) GetArbitraryNullableTypeValue() interface{} {
 // and a boolean to check if the value has been set.
 // NOTE: If the value is an explicit nil, `nil, true` will be returned
 func (o *User) GetArbitraryNullableTypeValueOk() (*interface{}, bool) {
-	if o == nil || o.ArbitraryNullableTypeValue == nil {
-		return nil, false
+	if o == nil || isNil(o.ArbitraryNullableTypeValue) {
+    return nil, false
 	}
 	return &o.ArbitraryNullableTypeValue, true
 }
 
 // HasArbitraryNullableTypeValue returns a boolean if a field has been set.
 func (o *User) HasArbitraryNullableTypeValue() bool {
-	if o != nil && o.ArbitraryNullableTypeValue != nil {
+	if o != nil && isNil(o.ArbitraryNullableTypeValue) {
 		return true
 	}
 
@@ -455,31 +455,31 @@ func (o User) MarshalJSON() ([]byte, error) {
 
 func (o User) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Id != nil {
+	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if o.Username != nil {
+	if !isNil(o.Username) {
 		toSerialize["username"] = o.Username
 	}
-	if o.FirstName != nil {
+	if !isNil(o.FirstName) {
 		toSerialize["firstName"] = o.FirstName
 	}
-	if o.LastName != nil {
+	if !isNil(o.LastName) {
 		toSerialize["lastName"] = o.LastName
 	}
-	if o.Email != nil {
+	if !isNil(o.Email) {
 		toSerialize["email"] = o.Email
 	}
-	if o.Password != nil {
+	if !isNil(o.Password) {
 		toSerialize["password"] = o.Password
 	}
-	if o.Phone != nil {
+	if !isNil(o.Phone) {
 		toSerialize["phone"] = o.Phone
 	}
-	if o.UserStatus != nil {
+	if !isNil(o.UserStatus) {
 		toSerialize["userStatus"] = o.UserStatus
 	}
-	if o.ArbitraryObject != nil {
+	if !isNil(o.ArbitraryObject) {
 		toSerialize["arbitraryObject"] = o.ArbitraryObject
 	}
 	if o.ArbitraryNullableObject != nil {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
index dfdc7469e8f..90e19302f37 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
@@ -47,7 +47,7 @@ func NewWhaleWithDefaults() *Whale {
 
 // GetHasBaleen returns the HasBaleen field value if set, zero value otherwise.
 func (o *Whale) GetHasBaleen() bool {
-	if o == nil || o.HasBaleen == nil {
+	if o == nil || isNil(o.HasBaleen) {
 		var ret bool
 		return ret
 	}
@@ -57,15 +57,15 @@ func (o *Whale) GetHasBaleen() bool {
 // GetHasBaleenOk returns a tuple with the HasBaleen field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Whale) GetHasBaleenOk() (*bool, bool) {
-	if o == nil || o.HasBaleen == nil {
-		return nil, false
+	if o == nil || isNil(o.HasBaleen) {
+    return nil, false
 	}
 	return o.HasBaleen, true
 }
 
 // HasHasBaleen returns a boolean if a field has been set.
 func (o *Whale) HasHasBaleen() bool {
-	if o != nil && o.HasBaleen != nil {
+	if o != nil && !isNil(o.HasBaleen) {
 		return true
 	}
 
@@ -79,7 +79,7 @@ func (o *Whale) SetHasBaleen(v bool) {
 
 // GetHasTeeth returns the HasTeeth field value if set, zero value otherwise.
 func (o *Whale) GetHasTeeth() bool {
-	if o == nil || o.HasTeeth == nil {
+	if o == nil || isNil(o.HasTeeth) {
 		var ret bool
 		return ret
 	}
@@ -89,15 +89,15 @@ func (o *Whale) GetHasTeeth() bool {
 // GetHasTeethOk returns a tuple with the HasTeeth field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Whale) GetHasTeethOk() (*bool, bool) {
-	if o == nil || o.HasTeeth == nil {
-		return nil, false
+	if o == nil || isNil(o.HasTeeth) {
+    return nil, false
 	}
 	return o.HasTeeth, true
 }
 
 // HasHasTeeth returns a boolean if a field has been set.
 func (o *Whale) HasHasTeeth() bool {
-	if o != nil && o.HasTeeth != nil {
+	if o != nil && !isNil(o.HasTeeth) {
 		return true
 	}
 
@@ -122,9 +122,9 @@ func (o *Whale) GetClassName() string {
 // GetClassNameOk returns a tuple with the ClassName field value
 // and a boolean to check if the value has been set.
 func (o *Whale) GetClassNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.ClassName, true
 }
 
@@ -143,10 +143,10 @@ func (o Whale) MarshalJSON() ([]byte, error) {
 
 func (o Whale) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.HasBaleen != nil {
+	if !isNil(o.HasBaleen) {
 		toSerialize["hasBaleen"] = o.HasBaleen
 	}
-	if o.HasTeeth != nil {
+	if !isNil(o.HasTeeth) {
 		toSerialize["hasTeeth"] = o.HasTeeth
 	}
 	toSerialize["className"] = o.ClassName
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
index 502f2ba801d..c4315aa4391 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
@@ -46,7 +46,7 @@ func NewZebraWithDefaults() *Zebra {
 
 // GetType returns the Type field value if set, zero value otherwise.
 func (o *Zebra) GetType() string {
-	if o == nil || o.Type == nil {
+	if o == nil || isNil(o.Type) {
 		var ret string
 		return ret
 	}
@@ -56,15 +56,15 @@ func (o *Zebra) GetType() string {
 // GetTypeOk returns a tuple with the Type field value if set, nil otherwise
 // and a boolean to check if the value has been set.
 func (o *Zebra) GetTypeOk() (*string, bool) {
-	if o == nil || o.Type == nil {
-		return nil, false
+	if o == nil || isNil(o.Type) {
+    return nil, false
 	}
 	return o.Type, true
 }
 
 // HasType returns a boolean if a field has been set.
 func (o *Zebra) HasType() bool {
-	if o != nil && o.Type != nil {
+	if o != nil && !isNil(o.Type) {
 		return true
 	}
 
@@ -89,9 +89,9 @@ func (o *Zebra) GetClassName() string {
 // GetClassNameOk returns a tuple with the ClassName field value
 // and a boolean to check if the value has been set.
 func (o *Zebra) GetClassNameOk() (*string, bool) {
-	if o == nil {
-		return nil, false
-	}
+    if o == nil {
+    return nil, false
+    }
 	return &o.ClassName, true
 }
 
@@ -110,7 +110,7 @@ func (o Zebra) MarshalJSON() ([]byte, error) {
 
 func (o Zebra) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
-	if o.Type != nil {
+	if !isNil(o.Type) {
 		toSerialize["type"] = o.Type
 	}
 	toSerialize["className"] = o.ClassName
-- 
GitLab


From 143b31dcee92c93a4ee08a002f39231841abb466 Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sat, 19 Nov 2022 11:13:31 -0500
Subject: [PATCH 14/15] sync with new master, regenerate samples

---
 .../main/resources/go/model_simple.mustache   |  8 ++---
 .../petstore/go/go-petstore/model_animal.go   | 17 ++++++---
 .../petstore/go/go-petstore/model_category.go | 17 ++++++---
 .../go/go-petstore/model_enum_test_.go        | 17 ++++++---
 .../go/go-petstore/model_format_test_.go      | 29 ++++++++-------
 .../petstore/go/go-petstore/model_name.go     | 17 ++++++---
 .../petstore/go/go-petstore/model_pet.go      | 21 +++++++----
 .../go-petstore/model_type_holder_default.go  | 31 ++++++++--------
 .../go-petstore/model_type_holder_example.go  | 35 +++++++++----------
 .../client/petstore/go/go-petstore/utils.go   |  4 +++
 .../x-auth-id-alias/go-experimental/utils.go  |  4 +++
 .../client/petstore/go/fake_api_test.go       |  8 ++++-
 .../petstore/go/go-petstore/model_animal.go   | 17 ++++++---
 .../go/go-petstore/model_apple_req.go         | 17 ++++++---
 .../go/go-petstore/model_banana_req.go        | 17 ++++++---
 .../petstore/go/go-petstore/model_category.go | 17 ++++++---
 .../model_duplicated_prop_parent.go           | 17 ++++++---
 .../go/go-petstore/model_enum_test_.go        | 17 ++++++---
 .../go/go-petstore/model_format_test_.go      | 29 ++++++++-------
 .../petstore/go/go-petstore/model_name.go     | 17 ++++++---
 .../petstore/go/go-petstore/model_pet.go      | 21 +++++++----
 .../petstore/go/go-petstore/model_whale.go    | 17 ++++++---
 .../petstore/go/go-petstore/model_zebra.go    | 17 ++++++---
 .../client/petstore/go/go-petstore/utils.go   |  4 +++
 24 files changed, 285 insertions(+), 130 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
index c8a9bf61788..9cb1c036337 100644
--- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
@@ -127,10 +127,10 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
 func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
 	if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
 {{^isFreeFormObject}}
-    return nil, false
+		return nil, false
     {{/isFreeFormObject}}
     {{#isFreeFormObject}}
-    return {{vendorExtensions.x-go-base-type}}{}, false
+		return {{vendorExtensions.x-go-base-type}}{}, false
     {{/isFreeFormObject}}
 	}
 {{#isNullable}}
@@ -199,10 +199,10 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
 func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
 	if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
     {{^isFreeFormObject}}
-    return nil, false
+		return nil, false
     {{/isFreeFormObject}}
     {{#isFreeFormObject}}
-    return {{vendorExtensions.x-go-base-type}}{}, false
+		return {{vendorExtensions.x-go-base-type}}{}, false
     {{/isFreeFormObject}}
 	}
 {{#isNullable}}
diff --git a/samples/client/petstore/go/go-petstore/model_animal.go b/samples/client/petstore/go/go-petstore/model_animal.go
index 17d1e225f9d..58a0f7afe31 100644
--- a/samples/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/client/petstore/go/go-petstore/model_animal.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Animal type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Animal{}
+
 // Animal struct for Animal
 type Animal struct {
 	ClassName string `json:"className"`
@@ -99,14 +102,20 @@ func (o *Animal) SetColor(v string) {
 }
 
 func (o Animal) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["className"] = o.ClassName
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Animal) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["className"] = o.ClassName
 	if !isNil(o.Color) {
 		toSerialize["color"] = o.Color
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 type NullableAnimal struct {
diff --git a/samples/client/petstore/go/go-petstore/model_category.go b/samples/client/petstore/go/go-petstore/model_category.go
index fb29e1554ae..3f3971d4230 100644
--- a/samples/client/petstore/go/go-petstore/model_category.go
+++ b/samples/client/petstore/go/go-petstore/model_category.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Category type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Category{}
+
 // Category struct for Category
 type Category struct {
 	Id *int64 `json:"id,omitempty"`
@@ -97,14 +100,20 @@ func (o *Category) SetName(v string) {
 }
 
 func (o Category) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Category) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if true {
-		toSerialize["name"] = o.Name
-	}
-	return json.Marshal(toSerialize)
+	toSerialize["name"] = o.Name
+	return toSerialize, nil
 }
 
 type NullableCategory struct {
diff --git a/samples/client/petstore/go/go-petstore/model_enum_test_.go b/samples/client/petstore/go/go-petstore/model_enum_test_.go
index 99cd7eb4afd..d900de383c6 100644
--- a/samples/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_enum_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the EnumTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &EnumTest{}
+
 // EnumTest struct for EnumTest
 type EnumTest struct {
 	EnumString *string `json:"enum_string,omitempty"`
@@ -194,13 +197,19 @@ func (o *EnumTest) SetOuterEnum(v OuterEnum) {
 }
 
 func (o EnumTest) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o EnumTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.EnumString) {
 		toSerialize["enum_string"] = o.EnumString
 	}
-	if true {
-		toSerialize["enum_string_required"] = o.EnumStringRequired
-	}
+	toSerialize["enum_string_required"] = o.EnumStringRequired
 	if !isNil(o.EnumInteger) {
 		toSerialize["enum_integer"] = o.EnumInteger
 	}
@@ -210,7 +219,7 @@ func (o EnumTest) MarshalJSON() ([]byte, error) {
 	if !isNil(o.OuterEnum) {
 		toSerialize["outerEnum"] = o.OuterEnum
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 type NullableEnumTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_format_test_.go b/samples/client/petstore/go/go-petstore/model_format_test_.go
index c505cdb3a41..0cfe962744c 100644
--- a/samples/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/client/petstore/go/go-petstore/model_format_test_.go
@@ -16,6 +16,9 @@ import (
 	"time"
 )
 
+// checks if the FormatTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FormatTest{}
+
 // FormatTest struct for FormatTest
 type FormatTest struct {
 	Integer *int32 `json:"integer,omitempty"`
@@ -472,6 +475,14 @@ func (o *FormatTest) SetBigDecimal(v float64) {
 }
 
 func (o FormatTest) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o FormatTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Integer) {
 		toSerialize["integer"] = o.Integer
@@ -482,9 +493,7 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 	if !isNil(o.Int64) {
 		toSerialize["int64"] = o.Int64
 	}
-	if true {
-		toSerialize["number"] = o.Number
-	}
+	toSerialize["number"] = o.Number
 	if !isNil(o.Float) {
 		toSerialize["float"] = o.Float
 	}
@@ -494,28 +503,22 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 	if !isNil(o.String) {
 		toSerialize["string"] = o.String
 	}
-	if true {
-		toSerialize["byte"] = o.Byte
-	}
+	toSerialize["byte"] = o.Byte
 	if !isNil(o.Binary) {
 		toSerialize["binary"] = o.Binary
 	}
-	if true {
-		toSerialize["date"] = o.Date
-	}
+	toSerialize["date"] = o.Date
 	if !isNil(o.DateTime) {
 		toSerialize["dateTime"] = o.DateTime
 	}
 	if !isNil(o.Uuid) {
 		toSerialize["uuid"] = o.Uuid
 	}
-	if true {
-		toSerialize["password"] = o.Password
-	}
+	toSerialize["password"] = o.Password
 	if !isNil(o.BigDecimal) {
 		toSerialize["BigDecimal"] = o.BigDecimal
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 type NullableFormatTest struct {
diff --git a/samples/client/petstore/go/go-petstore/model_name.go b/samples/client/petstore/go/go-petstore/model_name.go
index ae54981cd3c..03fb10edfd0 100644
--- a/samples/client/petstore/go/go-petstore/model_name.go
+++ b/samples/client/petstore/go/go-petstore/model_name.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Name type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Name{}
+
 // Name Model for testing model name same as property name
 type Name struct {
 	Name int32 `json:"name"`
@@ -161,10 +164,16 @@ func (o *Name) SetVar123Number(v int32) {
 }
 
 func (o Name) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["name"] = o.Name
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Name) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["name"] = o.Name
 	if !isNil(o.SnakeCase) {
 		toSerialize["snake_case"] = o.SnakeCase
 	}
@@ -174,7 +183,7 @@ func (o Name) MarshalJSON() ([]byte, error) {
 	if !isNil(o.Var123Number) {
 		toSerialize["123Number"] = o.Var123Number
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 type NullableName struct {
diff --git a/samples/client/petstore/go/go-petstore/model_pet.go b/samples/client/petstore/go/go-petstore/model_pet.go
index 900f539b9b4..9fc22cdd45a 100644
--- a/samples/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/client/petstore/go/go-petstore/model_pet.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Pet type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Pet{}
+
 // Pet struct for Pet
 type Pet struct {
 	Id *int64 `json:"id,omitempty"`
@@ -221,6 +224,14 @@ func (o *Pet) SetStatus(v string) {
 }
 
 func (o Pet) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Pet) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
@@ -228,19 +239,15 @@ func (o Pet) MarshalJSON() ([]byte, error) {
 	if !isNil(o.Category) {
 		toSerialize["category"] = o.Category
 	}
-	if true {
-		toSerialize["name"] = o.Name
-	}
-	if true {
-		toSerialize["photoUrls"] = o.PhotoUrls
-	}
+	toSerialize["name"] = o.Name
+	toSerialize["photoUrls"] = o.PhotoUrls
 	if !isNil(o.Tags) {
 		toSerialize["tags"] = o.Tags
 	}
 	if !isNil(o.Status) {
 		toSerialize["status"] = o.Status
 	}
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 type NullablePet struct {
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_default.go b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
index ab921b3f1e5..a06478caad7 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_default.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_default.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the TypeHolderDefault type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &TypeHolderDefault{}
+
 // TypeHolderDefault struct for TypeHolderDefault
 type TypeHolderDefault struct {
 	StringItem string `json:"string_item"`
@@ -170,25 +173,23 @@ func (o *TypeHolderDefault) SetArrayItem(v []int32) {
 }
 
 func (o TypeHolderDefault) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["string_item"] = o.StringItem
-	}
-	if true {
-		toSerialize["number_item"] = o.NumberItem
-	}
-	if true {
-		toSerialize["integer_item"] = o.IntegerItem
-	}
-	if true {
-		toSerialize["bool_item"] = o.BoolItem
-	}
-	if true {
-		toSerialize["array_item"] = o.ArrayItem
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
 	return json.Marshal(toSerialize)
 }
 
+func (o TypeHolderDefault) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["string_item"] = o.StringItem
+	toSerialize["number_item"] = o.NumberItem
+	toSerialize["integer_item"] = o.IntegerItem
+	toSerialize["bool_item"] = o.BoolItem
+	toSerialize["array_item"] = o.ArrayItem
+	return toSerialize, nil
+}
+
 type NullableTypeHolderDefault struct {
 	value *TypeHolderDefault
 	isSet bool
diff --git a/samples/client/petstore/go/go-petstore/model_type_holder_example.go b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
index 9d0979ff148..be5869db9b7 100644
--- a/samples/client/petstore/go/go-petstore/model_type_holder_example.go
+++ b/samples/client/petstore/go/go-petstore/model_type_holder_example.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the TypeHolderExample type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &TypeHolderExample{}
+
 // TypeHolderExample struct for TypeHolderExample
 type TypeHolderExample struct {
 	StringItem string `json:"string_item"`
@@ -192,28 +195,24 @@ func (o *TypeHolderExample) SetArrayItem(v []int32) {
 }
 
 func (o TypeHolderExample) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["string_item"] = o.StringItem
-	}
-	if true {
-		toSerialize["number_item"] = o.NumberItem
-	}
-	if true {
-		toSerialize["float_item"] = o.FloatItem
-	}
-	if true {
-		toSerialize["integer_item"] = o.IntegerItem
-	}
-	if true {
-		toSerialize["bool_item"] = o.BoolItem
-	}
-	if true {
-		toSerialize["array_item"] = o.ArrayItem
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
 	return json.Marshal(toSerialize)
 }
 
+func (o TypeHolderExample) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["string_item"] = o.StringItem
+	toSerialize["number_item"] = o.NumberItem
+	toSerialize["float_item"] = o.FloatItem
+	toSerialize["integer_item"] = o.IntegerItem
+	toSerialize["bool_item"] = o.BoolItem
+	toSerialize["array_item"] = o.ArrayItem
+	return toSerialize, nil
+}
+
 type NullableTypeHolderExample struct {
 	value *TypeHolderExample
 	isSet bool
diff --git a/samples/client/petstore/go/go-petstore/utils.go b/samples/client/petstore/go/go-petstore/utils.go
index f55144e1b47..9e3eb715da4 100644
--- a/samples/client/petstore/go/go-petstore/utils.go
+++ b/samples/client/petstore/go/go-petstore/utils.go
@@ -341,3 +341,7 @@ func isNil(i interface{}) bool {
 	}
 	return false
 }
+
+type MappedNullable interface {
+	ToMap() (map[string]interface{}, error)
+}
diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
index 8a5993e8ebe..79c8148718b 100644
--- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
+++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go
@@ -341,3 +341,7 @@ func isNil(i interface{}) bool {
 	}
 	return false
 }
+
+type MappedNullable interface {
+	ToMap() (map[string]interface{}, error)
+}
diff --git a/samples/openapi3/client/petstore/go/fake_api_test.go b/samples/openapi3/client/petstore/go/fake_api_test.go
index bddd01ee304..99d340cdcd7 100644
--- a/samples/openapi3/client/petstore/go/fake_api_test.go
+++ b/samples/openapi3/client/petstore/go/fake_api_test.go
@@ -8,6 +8,10 @@ import (
 	sw "go-petstore"
 )
 
+const (
+	deepObjectURL = `/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[F3]=null&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[F3]=null&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls]=http%3A%2F%2Flocalhost&test_pet[tags][F1]=1&test_pet[tags][F2]=teststring&test_pet[tags][F3]=null&test_pet[tags][id]=2&test_pet[tags][name]=tag1`
+)
+
 // TestPutBodyWithFileSchema ensures a model with the name 'File'
 // gets converted properly to the petstore.File struct vs. *os.File
 // as specified in typeMapping for 'File'.
@@ -68,7 +72,9 @@ func TestQueryDeepObject(t *testing.T) {
 
 	r, _ := req.Execute()
 
+	var expectedDeepObjectURL = testScheme + "://" + testHost + deepObjectURL
+
 	assert.Equal(t,
-		"http://petstore.swagger.io:80/v2/fake/deep_object_test?inputOptions[F1]=1&inputOptions[F2]=teststring&inputOptions[F3]=null&inputOptions[id]=1&inputOptions[name]=TestCat&test_pet[F1]=1&test_pet[F2]=teststring&test_pet[F3]=null&test_pet[id]=1&test_pet[name]=Test&test_pet[photoUrls]=http%3A%2F%2Flocalhost&test_pet[tags][F1]=1&test_pet[tags][F2]=teststring&test_pet[tags][F3]=null&test_pet[tags][id]=2&test_pet[tags][name]=tag1",
+		expectedDeepObjectURL,
 		r.Request.URL.String() )
 }
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
index 20913dc1d71..a550cb4223a 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Animal type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Animal{}
+
 // Animal struct for Animal
 type Animal struct {
 	ClassName string `json:"className"`
@@ -102,10 +105,16 @@ func (o *Animal) SetColor(v string) {
 }
 
 func (o Animal) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["className"] = o.ClassName
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Animal) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["className"] = o.ClassName
 	if !isNil(o.Color) {
 		toSerialize["color"] = o.Color
 	}
@@ -114,7 +123,7 @@ func (o Animal) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *Animal) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
index e49e2293080..0ceff9a111c 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the AppleReq type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &AppleReq{}
+
 // AppleReq struct for AppleReq
 type AppleReq struct {
 	Cultivar string `json:"cultivar"`
@@ -98,10 +101,16 @@ func (o *AppleReq) SetMealy(v bool) {
 }
 
 func (o AppleReq) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["cultivar"] = o.Cultivar
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o AppleReq) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["cultivar"] = o.Cultivar
 	if !isNil(o.Mealy) {
 		toSerialize["mealy"] = o.Mealy
 	}
@@ -110,7 +119,7 @@ func (o AppleReq) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *AppleReq) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
index 92b660dd30f..79948f5f7fe 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the BananaReq type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &BananaReq{}
+
 // BananaReq struct for BananaReq
 type BananaReq struct {
 	LengthCm float32 `json:"lengthCm"`
@@ -98,10 +101,16 @@ func (o *BananaReq) SetSweet(v bool) {
 }
 
 func (o BananaReq) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["lengthCm"] = o.LengthCm
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o BananaReq) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["lengthCm"] = o.LengthCm
 	if !isNil(o.Sweet) {
 		toSerialize["sweet"] = o.Sweet
 	}
@@ -110,7 +119,7 @@ func (o BananaReq) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *BananaReq) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_category.go b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
index 5900a618b9c..edc91739855 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_category.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_category.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Category type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Category{}
+
 // Category struct for Category
 type Category struct {
 	Id *int64 `json:"id,omitempty"`
@@ -100,19 +103,25 @@ func (o *Category) SetName(v string) {
 }
 
 func (o Category) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Category) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
 	}
-	if true {
-		toSerialize["name"] = o.Name
-	}
+	toSerialize["name"] = o.Name
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *Category) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
index 59f7f32eb7a..1c8ed0909f6 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the DuplicatedPropParent type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &DuplicatedPropParent{}
+
 // DuplicatedPropParent parent model with duplicated property
 type DuplicatedPropParent struct {
 	// A discriminator value
@@ -66,16 +69,22 @@ func (o *DuplicatedPropParent) SetDupProp(v string) {
 }
 
 func (o DuplicatedPropParent) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["dup-prop"] = o.DupProp
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o DuplicatedPropParent) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["dup-prop"] = o.DupProp
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *DuplicatedPropParent) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
index fb07b82d2f5..42941367b36 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the EnumTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &EnumTest{}
+
 // EnumTest struct for EnumTest
 type EnumTest struct {
 	EnumString *string `json:"enum_string,omitempty"`
@@ -314,13 +317,19 @@ func (o *EnumTest) SetOuterEnumIntegerDefaultValue(v OuterEnumIntegerDefaultValu
 }
 
 func (o EnumTest) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o EnumTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.EnumString) {
 		toSerialize["enum_string"] = o.EnumString
 	}
-	if true {
-		toSerialize["enum_string_required"] = o.EnumStringRequired
-	}
+	toSerialize["enum_string_required"] = o.EnumStringRequired
 	if !isNil(o.EnumInteger) {
 		toSerialize["enum_integer"] = o.EnumInteger
 	}
@@ -344,7 +353,7 @@ func (o EnumTest) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *EnumTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
index 3bbcbca7495..fe95d07ffaf 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go
@@ -16,6 +16,9 @@ import (
 	"time"
 )
 
+// checks if the FormatTest type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &FormatTest{}
+
 // FormatTest struct for FormatTest
 type FormatTest struct {
 	Integer *int32 `json:"integer,omitempty"`
@@ -510,6 +513,14 @@ func (o *FormatTest) SetPatternWithDigitsAndDelimiter(v string) {
 }
 
 func (o FormatTest) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o FormatTest) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Integer) {
 		toSerialize["integer"] = o.Integer
@@ -520,9 +531,7 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 	if !isNil(o.Int64) {
 		toSerialize["int64"] = o.Int64
 	}
-	if true {
-		toSerialize["number"] = o.Number
-	}
+	toSerialize["number"] = o.Number
 	if !isNil(o.Float) {
 		toSerialize["float"] = o.Float
 	}
@@ -532,24 +541,18 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 	if !isNil(o.String) {
 		toSerialize["string"] = o.String
 	}
-	if true {
-		toSerialize["byte"] = o.Byte
-	}
+	toSerialize["byte"] = o.Byte
 	if !isNil(o.Binary) {
 		toSerialize["binary"] = o.Binary
 	}
-	if true {
-		toSerialize["date"] = o.Date
-	}
+	toSerialize["date"] = o.Date
 	if !isNil(o.DateTime) {
 		toSerialize["dateTime"] = o.DateTime
 	}
 	if !isNil(o.Uuid) {
 		toSerialize["uuid"] = o.Uuid
 	}
-	if true {
-		toSerialize["password"] = o.Password
-	}
+	toSerialize["password"] = o.Password
 	if !isNil(o.PatternWithDigits) {
 		toSerialize["pattern_with_digits"] = o.PatternWithDigits
 	}
@@ -561,7 +564,7 @@ func (o FormatTest) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *FormatTest) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_name.go b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
index 167e669b2f4..22012a7d2cd 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_name.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_name.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Name type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Name{}
+
 // Name Model for testing model name same as property name
 type Name struct {
 	Name int32 `json:"name"`
@@ -164,10 +167,16 @@ func (o *Name) SetVar123Number(v int32) {
 }
 
 func (o Name) MarshalJSON() ([]byte, error) {
-	toSerialize := map[string]interface{}{}
-	if true {
-		toSerialize["name"] = o.Name
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
 	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Name) ToMap() (map[string]interface{}, error) {
+	toSerialize := map[string]interface{}{}
+	toSerialize["name"] = o.Name
 	if !isNil(o.SnakeCase) {
 		toSerialize["snake_case"] = o.SnakeCase
 	}
@@ -182,7 +191,7 @@ func (o Name) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *Name) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
index 3171045e49e..008200fcb55 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Pet type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Pet{}
+
 // Pet struct for Pet
 type Pet struct {
 	Id *int64 `json:"id,omitempty"`
@@ -228,6 +231,14 @@ func (o *Pet) SetStatus(v string) {
 }
 
 func (o Pet) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Pet) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Id) {
 		toSerialize["id"] = o.Id
@@ -235,12 +246,8 @@ func (o Pet) MarshalJSON() ([]byte, error) {
 	if !isNil(o.Category) {
 		toSerialize["category"] = o.Category
 	}
-	if true {
-		toSerialize["name"] = o.Name
-	}
-	if true {
-		toSerialize["photoUrls"] = o.PhotoUrls
-	}
+	toSerialize["name"] = o.Name
+	toSerialize["photoUrls"] = o.PhotoUrls
 	if !isNil(o.Tags) {
 		toSerialize["tags"] = o.Tags
 	}
@@ -252,7 +259,7 @@ func (o Pet) MarshalJSON() ([]byte, error) {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *Pet) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
index 8da3060406a..f90923f1046 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Whale type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Whale{}
+
 // Whale struct for Whale
 type Whale struct {
 	HasBaleen *bool `json:"hasBaleen,omitempty"`
@@ -131,6 +134,14 @@ func (o *Whale) SetClassName(v string) {
 }
 
 func (o Whale) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Whale) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.HasBaleen) {
 		toSerialize["hasBaleen"] = o.HasBaleen
@@ -138,15 +149,13 @@ func (o Whale) MarshalJSON() ([]byte, error) {
 	if !isNil(o.HasTeeth) {
 		toSerialize["hasTeeth"] = o.HasTeeth
 	}
-	if true {
-		toSerialize["className"] = o.ClassName
-	}
+	toSerialize["className"] = o.ClassName
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *Whale) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
index 70a1ee363c6..76106e1eb54 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go
@@ -14,6 +14,9 @@ import (
 	"encoding/json"
 )
 
+// checks if the Zebra type satisfies the MappedNullable interface at compile time
+var _ MappedNullable = &Zebra{}
+
 // Zebra struct for Zebra
 type Zebra struct {
 	Type *string `json:"type,omitempty"`
@@ -98,19 +101,25 @@ func (o *Zebra) SetClassName(v string) {
 }
 
 func (o Zebra) MarshalJSON() ([]byte, error) {
+	toSerialize,err := o.ToMap()
+	if err != nil {
+		return []byte{}, err
+	}
+	return json.Marshal(toSerialize)
+}
+
+func (o Zebra) ToMap() (map[string]interface{}, error) {
 	toSerialize := map[string]interface{}{}
 	if !isNil(o.Type) {
 		toSerialize["type"] = o.Type
 	}
-	if true {
-		toSerialize["className"] = o.ClassName
-	}
+	toSerialize["className"] = o.ClassName
 
 	for key, value := range o.AdditionalProperties {
 		toSerialize[key] = value
 	}
 
-	return json.Marshal(toSerialize)
+	return toSerialize, nil
 }
 
 func (o *Zebra) UnmarshalJSON(bytes []byte) (err error) {
diff --git a/samples/openapi3/client/petstore/go/go-petstore/utils.go b/samples/openapi3/client/petstore/go/go-petstore/utils.go
index f55144e1b47..9e3eb715da4 100644
--- a/samples/openapi3/client/petstore/go/go-petstore/utils.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/utils.go
@@ -341,3 +341,7 @@ func isNil(i interface{}) bool {
 	}
 	return false
 }
+
+type MappedNullable interface {
+	ToMap() (map[string]interface{}, error)
+}
-- 
GitLab


From 769ca5b91a8018d4ca1fccec606f8e1cd73ee41f Mon Sep 17 00:00:00 2001
From: "parvit (Vittorio Parrella)" <vittorioparrella+1@gmail.com>
Date: Sun, 20 Nov 2022 07:19:12 +0100
Subject: [PATCH 15/15] added api client test

---
 .../client/petstore/go/pet_api_test.go        | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/samples/openapi3/client/petstore/go/pet_api_test.go b/samples/openapi3/client/petstore/go/pet_api_test.go
index f92873d5d12..49896698b60 100644
--- a/samples/openapi3/client/petstore/go/pet_api_test.go
+++ b/samples/openapi3/client/petstore/go/pet_api_test.go
@@ -184,6 +184,26 @@ func TestDeletePet(t *testing.T) {
 	}
 }
 
+// test deep object query parameter and verify via tcpdump
+func TestDeepObjectQuery(t *testing.T) {
+	newPet := sw.Pet{
+		Id: sw.PtrInt64(12830), Name: "gopher",
+		PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
+		Tags: []sw.Tag{{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}},
+	}
+
+	newCategory := sw.Category{Id: sw.PtrInt64(12830), Name: "cat"}
+	configuration := sw.NewConfiguration()
+	apiClient := sw.NewAPIClient(configuration)
+	r, err := apiClient.FakeApi.TestQueryDeepObject(context.Background()).TestPet(newPet).InputOptions(newCategory).Execute()
+	if err != nil {
+		// for sure this will fail as the endpoint is fake
+	}
+	if r.StatusCode != 200 {
+		t.Log(r)
+	}
+}
+
 /*
 // Test we can concurrently create, retrieve, update, and delete.
 func TestConcurrency(t *testing.T) {
-- 
GitLab