From de8ed9d71c5f721302ddd0b33581c80ddd939588 Mon Sep 17 00:00:00 2001 From: sagar khot Date: Sat, 10 Feb 2024 18:41:42 +0530 Subject: [PATCH 1/2] #17835 changed to return !IsNil --- .../src/main/resources/go/model_simple.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 64952edcae64..f5a6b6c53ef4 100644 --- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache +++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache @@ -226,7 +226,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}}!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 } From 9a233d8db47b2064f41e37f2c8b37ada03ed2bb2 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 15 Feb 2024 13:42:25 +0800 Subject: [PATCH 2/2] update samples --- .../echo_api/go-external-refs/model_default_value.go | 4 ++-- samples/client/echo_api/go/model_default_value.go | 4 ++-- .../petstore/go/go-petstore/model_nullable_class.go | 8 ++++---- .../openapi3/client/petstore/go/go-petstore/model_user.go | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/samples/client/echo_api/go-external-refs/model_default_value.go b/samples/client/echo_api/go-external-refs/model_default_value.go index e40a4e5a1420..48d42bfe77b9 100644 --- a/samples/client/echo_api/go-external-refs/model_default_value.go +++ b/samples/client/echo_api/go-external-refs/model_default_value.go @@ -228,7 +228,7 @@ func (o *DefaultValue) GetArrayStringNullableOk() ([]string, bool) { // HasArrayStringNullable returns a boolean if a field has been set. func (o *DefaultValue) HasArrayStringNullable() bool { - if o != nil && IsNil(o.ArrayStringNullable) { + if o != nil && !IsNil(o.ArrayStringNullable) { return true } @@ -261,7 +261,7 @@ func (o *DefaultValue) GetArrayStringExtensionNullableOk() ([]string, bool) { // HasArrayStringExtensionNullable returns a boolean if a field has been set. func (o *DefaultValue) HasArrayStringExtensionNullable() bool { - if o != nil && IsNil(o.ArrayStringExtensionNullable) { + if o != nil && !IsNil(o.ArrayStringExtensionNullable) { return true } diff --git a/samples/client/echo_api/go/model_default_value.go b/samples/client/echo_api/go/model_default_value.go index e40a4e5a1420..48d42bfe77b9 100644 --- a/samples/client/echo_api/go/model_default_value.go +++ b/samples/client/echo_api/go/model_default_value.go @@ -228,7 +228,7 @@ func (o *DefaultValue) GetArrayStringNullableOk() ([]string, bool) { // HasArrayStringNullable returns a boolean if a field has been set. func (o *DefaultValue) HasArrayStringNullable() bool { - if o != nil && IsNil(o.ArrayStringNullable) { + if o != nil && !IsNil(o.ArrayStringNullable) { return true } @@ -261,7 +261,7 @@ func (o *DefaultValue) GetArrayStringExtensionNullableOk() ([]string, bool) { // HasArrayStringExtensionNullable returns a boolean if a field has been set. func (o *DefaultValue) HasArrayStringExtensionNullable() bool { - if o != nil && IsNil(o.ArrayStringExtensionNullable) { + if o != nil && !IsNil(o.ArrayStringExtensionNullable) { return true } 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 9754307946d4..074cff107147 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 @@ -331,7 +331,7 @@ func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool // HasArrayNullableProp returns a boolean if a field has been set. func (o *NullableClass) HasArrayNullableProp() bool { - if o != nil && IsNil(o.ArrayNullableProp) { + if o != nil && !IsNil(o.ArrayNullableProp) { return true } @@ -364,7 +364,7 @@ func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]*map[string]interfac // HasArrayAndItemsNullableProp returns a boolean if a field has been set. func (o *NullableClass) HasArrayAndItemsNullableProp() bool { - if o != nil && IsNil(o.ArrayAndItemsNullableProp) { + if o != nil && !IsNil(o.ArrayAndItemsNullableProp) { return true } @@ -429,7 +429,7 @@ func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interfa // HasObjectNullableProp returns a boolean if a field has been set. func (o *NullableClass) HasObjectNullableProp() bool { - if o != nil && IsNil(o.ObjectNullableProp) { + if o != nil && !IsNil(o.ObjectNullableProp) { return true } @@ -462,7 +462,7 @@ func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string // HasObjectAndItemsNullableProp returns a boolean if a field has been set. func (o *NullableClass) HasObjectAndItemsNullableProp() bool { - if o != nil && IsNil(o.ObjectAndItemsNullableProp) { + if o != nil && !IsNil(o.ObjectAndItemsNullableProp) { return true } 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 40bbc886acb1..7ea30adda0a9 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_user.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_user.go @@ -367,7 +367,7 @@ func (o *User) GetArbitraryNullableObjectOk() (map[string]interface{}, bool) { // HasArbitraryNullableObject returns a boolean if a field has been set. func (o *User) HasArbitraryNullableObject() bool { - if o != nil && IsNil(o.ArbitraryNullableObject) { + if o != nil && !IsNil(o.ArbitraryNullableObject) { return true } @@ -400,7 +400,7 @@ func (o *User) GetArbitraryTypeValueOk() (*interface{}, bool) { // HasArbitraryTypeValue returns a boolean if a field has been set. func (o *User) HasArbitraryTypeValue() bool { - if o != nil && IsNil(o.ArbitraryTypeValue) { + if o != nil && !IsNil(o.ArbitraryTypeValue) { return true } @@ -433,7 +433,7 @@ func (o *User) GetArbitraryNullableTypeValueOk() (*interface{}, bool) { // HasArbitraryNullableTypeValue returns a boolean if a field has been set. func (o *User) HasArbitraryNullableTypeValue() bool { - if o != nil && IsNil(o.ArbitraryNullableTypeValue) { + if o != nil && !IsNil(o.ArbitraryNullableTypeValue) { return true }