From 90c7f53a1ba88f5a1ab8e5cef5bac7a23ce4b51b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 21 Oct 2019 16:14:00 +0800 Subject: [PATCH] Allow retrieving the underlying configuration for APIClient (#4195) --- .../resources/go-experimental/client.mustache | 6 + .../go-experimental/go-petstore/client.go | 6 + .../go-experimental/go-petstore/client.go | 6 + .../go-petstore/docs/EnumTest.md | 10 +- .../go-petstore/docs/HealthCheckResult.md | 10 +- .../go-petstore/docs/NullableClass.md | 100 ++--- .../go-experimental/go-petstore/go.mod | 6 +- .../go-experimental/go-petstore/go.sum | 10 +- .../go-petstore/model_200_response.go | 44 +- .../go-petstore/model__special_model_name_.go | 36 +- .../model_additional_properties_class.go | 44 +- .../go-petstore/model_animal.go | 76 ++-- .../go-petstore/model_api_response.go | 52 +-- .../model_array_of_array_of_number_only.go | 36 +- .../go-petstore/model_array_of_number_only.go | 36 +- .../go-petstore/model_array_test_.go | 52 +-- .../go-petstore/model_capitalization.go | 76 ++-- .../go-experimental/go-petstore/model_cat.go | 84 ++-- .../go-petstore/model_cat_all_of.go | 36 +- .../go-petstore/model_category.go | 76 ++-- .../go-petstore/model_class_model.go | 36 +- .../go-petstore/model_client.go | 36 +- .../go-experimental/go-petstore/model_dog.go | 84 ++-- .../go-petstore/model_dog_all_of.go | 36 +- .../go-petstore/model_enum_arrays.go | 44 +- .../go-petstore/model_enum_class.go | 32 ++ .../go-petstore/model_enum_test_.go | 149 +++---- .../go-experimental/go-petstore/model_file.go | 36 +- .../model_file_schema_test_class.go | 44 +- .../go-experimental/go-petstore/model_foo.go | 36 +- .../go-petstore/model_format_test_.go | 275 ++++--------- .../go-petstore/model_has_only_read_only.go | 44 +- .../go-petstore/model_health_check_result.go | 57 +-- .../go-petstore/model_inline_object.go | 44 +- .../go-petstore/model_inline_object_1.go | 46 ++- .../go-petstore/model_inline_object_2.go | 44 +- .../go-petstore/model_inline_object_3.go | 267 ++++--------- .../go-petstore/model_inline_object_4.go | 107 ++--- .../go-petstore/model_inline_object_5.go | 78 ++-- .../model_inline_response_default.go | 36 +- .../go-experimental/go-petstore/model_list.go | 36 +- .../go-petstore/model_map_test_.go | 60 +-- ...perties_and_additional_properties_class.go | 54 +-- .../go-experimental/go-petstore/model_name.go | 92 ++--- .../go-petstore/model_nullable_class.go | 376 ++++++------------ .../go-petstore/model_number_only.go | 36 +- .../go-petstore/model_order.go | 78 ++-- .../go-petstore/model_outer_composite.go | 52 +-- .../go-petstore/model_outer_enum.go | 32 ++ .../model_outer_enum_default_value.go | 32 ++ .../go-petstore/model_outer_enum_integer.go | 32 ++ .../model_outer_enum_integer_default_value.go | 32 ++ .../go-experimental/go-petstore/model_pet.go | 139 +++---- .../go-petstore/model_read_only_first.go | 44 +- .../go-petstore/model_return.go | 36 +- .../go-experimental/go-petstore/model_tag.go | 44 +- .../go-experimental/go-petstore/model_user.go | 92 ++--- .../go-experimental/go-petstore/utils.go | 215 +++++++++- 58 files changed, 1941 insertions(+), 1874 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/go-experimental/client.mustache b/modules/openapi-generator/src/main/resources/go-experimental/client.mustache index c3af4534120..ec129d3d432 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/client.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/client.mustache @@ -169,6 +169,12 @@ func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, diff --git a/samples/client/petstore/go-experimental/go-petstore/client.go b/samples/client/petstore/go-experimental/go-petstore/client.go index 30377bdac64..c73a8db8d09 100644 --- a/samples/client/petstore/go-experimental/go-petstore/client.go +++ b/samples/client/petstore/go-experimental/go-petstore/client.go @@ -180,6 +180,12 @@ func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/client.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/client.go index db6225efebc..cdbf123bc1f 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/client.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/client.go @@ -183,6 +183,12 @@ func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/EnumTest.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/EnumTest.md index 45b1b7e5adb..ef2a67c39ff 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/EnumTest.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **EnumStringRequired** | Pointer to **string** | | **EnumInteger** | Pointer to **int32** | | [optional] **EnumNumber** | Pointer to **float64** | | [optional] -**OuterEnum** | Pointer to [**OuterEnum**](OuterEnum.md) | | [optional] +**OuterEnum** | Pointer to [**NullableOuterEnum**](OuterEnum.md) | | [optional] **OuterEnumInteger** | Pointer to [**OuterEnumInteger**](OuterEnumInteger.md) | | [optional] **OuterEnumDefaultValue** | Pointer to [**OuterEnumDefaultValue**](OuterEnumDefaultValue.md) | | [optional] **OuterEnumIntegerDefaultValue** | Pointer to [**OuterEnumIntegerDefaultValue**](OuterEnumIntegerDefaultValue.md) | | [optional] @@ -117,13 +117,13 @@ SetEnumNumber gets a reference to the given float64 and assigns it to the EnumNu ### GetOuterEnum -`func (o *EnumTest) GetOuterEnum() OuterEnum` +`func (o *EnumTest) GetOuterEnum() NullableOuterEnum` GetOuterEnum returns the OuterEnum field if non-nil, zero value otherwise. ### GetOuterEnumOk -`func (o *EnumTest) GetOuterEnumOk() (OuterEnum, bool)` +`func (o *EnumTest) GetOuterEnumOk() (NullableOuterEnum, bool)` GetOuterEnumOk returns a tuple with the OuterEnum field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -136,9 +136,9 @@ HasOuterEnum returns a boolean if a field has been set. ### SetOuterEnum -`func (o *EnumTest) SetOuterEnum(v OuterEnum)` +`func (o *EnumTest) SetOuterEnum(v NullableOuterEnum)` -SetOuterEnum gets a reference to the given OuterEnum and assigns it to the OuterEnum field. +SetOuterEnum gets a reference to the given NullableOuterEnum and assigns it to the OuterEnum field. ### SetOuterEnumExplicitNull diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/HealthCheckResult.md index 63f7a2fa846..15ad0d68cc4 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/HealthCheckResult.md @@ -4,19 +4,19 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**NullableMessage** | Pointer to **string** | | [optional] +**NullableMessage** | Pointer to **NullableString** | | [optional] ## Methods ### GetNullableMessage -`func (o *HealthCheckResult) GetNullableMessage() string` +`func (o *HealthCheckResult) GetNullableMessage() NullableString` GetNullableMessage returns the NullableMessage field if non-nil, zero value otherwise. ### GetNullableMessageOk -`func (o *HealthCheckResult) GetNullableMessageOk() (string, bool)` +`func (o *HealthCheckResult) GetNullableMessageOk() (NullableString, bool)` GetNullableMessageOk returns a tuple with the NullableMessage field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -29,9 +29,9 @@ HasNullableMessage returns a boolean if a field has been set. ### SetNullableMessage -`func (o *HealthCheckResult) SetNullableMessage(v string)` +`func (o *HealthCheckResult) SetNullableMessage(v NullableString)` -SetNullableMessage gets a reference to the given string and assigns it to the NullableMessage field. +SetNullableMessage gets a reference to the given NullableString and assigns it to the NullableMessage field. ### SetNullableMessageExplicitNull diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/NullableClass.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/NullableClass.md index 65067eda2ae..5b8efc3fd89 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/NullableClass.md +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/NullableClass.md @@ -4,30 +4,30 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**IntegerProp** | Pointer to **int32** | | [optional] -**NumberProp** | Pointer to **float32** | | [optional] -**BooleanProp** | Pointer to **bool** | | [optional] -**StringProp** | Pointer to **string** | | [optional] -**DateProp** | Pointer to **string** | | [optional] -**DatetimeProp** | Pointer to [**time.Time**](time.Time.md) | | [optional] -**ArrayNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional] -**ArrayAndItemsNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional] +**IntegerProp** | Pointer to **NullableInt32** | | [optional] +**NumberProp** | Pointer to **NullableFloat32** | | [optional] +**BooleanProp** | Pointer to **NullableBool** | | [optional] +**StringProp** | Pointer to **NullableString** | | [optional] +**DateProp** | Pointer to **NullableString** | | [optional] +**DatetimeProp** | Pointer to [**NullableTime.Time**](time.Time.md) | | [optional] +**ArrayNullableProp** | Pointer to [**Nullable[]map[string]interface{}**](map[string]interface{}.md) | | [optional] +**ArrayAndItemsNullableProp** | Pointer to [**Nullable[]map[string]interface{}**](map[string]interface{}.md) | | [optional] **ArrayItemsNullable** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional] -**ObjectNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional] -**ObjectAndItemsNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional] +**ObjectNullableProp** | Pointer to [**NullableMap[string]map[string]interface{}**](map[string]interface{}.md) | | [optional] +**ObjectAndItemsNullableProp** | Pointer to [**NullableMap[string]map[string]interface{}**](map[string]interface{}.md) | | [optional] **ObjectItemsNullable** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional] ## Methods ### GetIntegerProp -`func (o *NullableClass) GetIntegerProp() int32` +`func (o *NullableClass) GetIntegerProp() NullableInt32` GetIntegerProp returns the IntegerProp field if non-nil, zero value otherwise. ### GetIntegerPropOk -`func (o *NullableClass) GetIntegerPropOk() (int32, bool)` +`func (o *NullableClass) GetIntegerPropOk() (NullableInt32, bool)` GetIntegerPropOk returns a tuple with the IntegerProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -40,9 +40,9 @@ HasIntegerProp returns a boolean if a field has been set. ### SetIntegerProp -`func (o *NullableClass) SetIntegerProp(v int32)` +`func (o *NullableClass) SetIntegerProp(v NullableInt32)` -SetIntegerProp gets a reference to the given int32 and assigns it to the IntegerProp field. +SetIntegerProp gets a reference to the given NullableInt32 and assigns it to the IntegerProp field. ### SetIntegerPropExplicitNull @@ -53,13 +53,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The IntegerProp value is set to nil even if false is passed ### GetNumberProp -`func (o *NullableClass) GetNumberProp() float32` +`func (o *NullableClass) GetNumberProp() NullableFloat32` GetNumberProp returns the NumberProp field if non-nil, zero value otherwise. ### GetNumberPropOk -`func (o *NullableClass) GetNumberPropOk() (float32, bool)` +`func (o *NullableClass) GetNumberPropOk() (NullableFloat32, bool)` GetNumberPropOk returns a tuple with the NumberProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -72,9 +72,9 @@ HasNumberProp returns a boolean if a field has been set. ### SetNumberProp -`func (o *NullableClass) SetNumberProp(v float32)` +`func (o *NullableClass) SetNumberProp(v NullableFloat32)` -SetNumberProp gets a reference to the given float32 and assigns it to the NumberProp field. +SetNumberProp gets a reference to the given NullableFloat32 and assigns it to the NumberProp field. ### SetNumberPropExplicitNull @@ -85,13 +85,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The NumberProp value is set to nil even if false is passed ### GetBooleanProp -`func (o *NullableClass) GetBooleanProp() bool` +`func (o *NullableClass) GetBooleanProp() NullableBool` GetBooleanProp returns the BooleanProp field if non-nil, zero value otherwise. ### GetBooleanPropOk -`func (o *NullableClass) GetBooleanPropOk() (bool, bool)` +`func (o *NullableClass) GetBooleanPropOk() (NullableBool, bool)` GetBooleanPropOk returns a tuple with the BooleanProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -104,9 +104,9 @@ HasBooleanProp returns a boolean if a field has been set. ### SetBooleanProp -`func (o *NullableClass) SetBooleanProp(v bool)` +`func (o *NullableClass) SetBooleanProp(v NullableBool)` -SetBooleanProp gets a reference to the given bool and assigns it to the BooleanProp field. +SetBooleanProp gets a reference to the given NullableBool and assigns it to the BooleanProp field. ### SetBooleanPropExplicitNull @@ -117,13 +117,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The BooleanProp value is set to nil even if false is passed ### GetStringProp -`func (o *NullableClass) GetStringProp() string` +`func (o *NullableClass) GetStringProp() NullableString` GetStringProp returns the StringProp field if non-nil, zero value otherwise. ### GetStringPropOk -`func (o *NullableClass) GetStringPropOk() (string, bool)` +`func (o *NullableClass) GetStringPropOk() (NullableString, bool)` GetStringPropOk returns a tuple with the StringProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -136,9 +136,9 @@ HasStringProp returns a boolean if a field has been set. ### SetStringProp -`func (o *NullableClass) SetStringProp(v string)` +`func (o *NullableClass) SetStringProp(v NullableString)` -SetStringProp gets a reference to the given string and assigns it to the StringProp field. +SetStringProp gets a reference to the given NullableString and assigns it to the StringProp field. ### SetStringPropExplicitNull @@ -149,13 +149,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The StringProp value is set to nil even if false is passed ### GetDateProp -`func (o *NullableClass) GetDateProp() string` +`func (o *NullableClass) GetDateProp() NullableString` GetDateProp returns the DateProp field if non-nil, zero value otherwise. ### GetDatePropOk -`func (o *NullableClass) GetDatePropOk() (string, bool)` +`func (o *NullableClass) GetDatePropOk() (NullableString, bool)` GetDatePropOk returns a tuple with the DateProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -168,9 +168,9 @@ HasDateProp returns a boolean if a field has been set. ### SetDateProp -`func (o *NullableClass) SetDateProp(v string)` +`func (o *NullableClass) SetDateProp(v NullableString)` -SetDateProp gets a reference to the given string and assigns it to the DateProp field. +SetDateProp gets a reference to the given NullableString and assigns it to the DateProp field. ### SetDatePropExplicitNull @@ -181,13 +181,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The DateProp value is set to nil even if false is passed ### GetDatetimeProp -`func (o *NullableClass) GetDatetimeProp() time.Time` +`func (o *NullableClass) GetDatetimeProp() NullableTime.Time` GetDatetimeProp returns the DatetimeProp field if non-nil, zero value otherwise. ### GetDatetimePropOk -`func (o *NullableClass) GetDatetimePropOk() (time.Time, bool)` +`func (o *NullableClass) GetDatetimePropOk() (NullableTime.Time, bool)` GetDatetimePropOk returns a tuple with the DatetimeProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -200,9 +200,9 @@ HasDatetimeProp returns a boolean if a field has been set. ### SetDatetimeProp -`func (o *NullableClass) SetDatetimeProp(v time.Time)` +`func (o *NullableClass) SetDatetimeProp(v NullableTime.Time)` -SetDatetimeProp gets a reference to the given time.Time and assigns it to the DatetimeProp field. +SetDatetimeProp gets a reference to the given NullableTime.Time and assigns it to the DatetimeProp field. ### SetDatetimePropExplicitNull @@ -213,13 +213,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The DatetimeProp value is set to nil even if false is passed ### GetArrayNullableProp -`func (o *NullableClass) GetArrayNullableProp() []map[string]interface{}` +`func (o *NullableClass) GetArrayNullableProp() Nullable[]map[string]interface{}` GetArrayNullableProp returns the ArrayNullableProp field if non-nil, zero value otherwise. ### GetArrayNullablePropOk -`func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool)` +`func (o *NullableClass) GetArrayNullablePropOk() (Nullable[]map[string]interface{}, bool)` GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -232,9 +232,9 @@ HasArrayNullableProp returns a boolean if a field has been set. ### SetArrayNullableProp -`func (o *NullableClass) SetArrayNullableProp(v []map[string]interface{})` +`func (o *NullableClass) SetArrayNullableProp(v Nullable[]map[string]interface{})` -SetArrayNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayNullableProp field. +SetArrayNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayNullableProp field. ### SetArrayNullablePropExplicitNull @@ -245,13 +245,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The ArrayNullableProp value is set to nil even if false is passed ### GetArrayAndItemsNullableProp -`func (o *NullableClass) GetArrayAndItemsNullableProp() []map[string]interface{}` +`func (o *NullableClass) GetArrayAndItemsNullableProp() Nullable[]map[string]interface{}` GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field if non-nil, zero value otherwise. ### GetArrayAndItemsNullablePropOk -`func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]map[string]interface{}, bool)` +`func (o *NullableClass) GetArrayAndItemsNullablePropOk() (Nullable[]map[string]interface{}, bool)` GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -264,9 +264,9 @@ HasArrayAndItemsNullableProp returns a boolean if a field has been set. ### SetArrayAndItemsNullableProp -`func (o *NullableClass) SetArrayAndItemsNullableProp(v []map[string]interface{})` +`func (o *NullableClass) SetArrayAndItemsNullableProp(v Nullable[]map[string]interface{})` -SetArrayAndItemsNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field. +SetArrayAndItemsNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field. ### SetArrayAndItemsNullablePropExplicitNull @@ -302,13 +302,13 @@ SetArrayItemsNullable gets a reference to the given []map[string]interface{} and ### GetObjectNullableProp -`func (o *NullableClass) GetObjectNullableProp() map[string]map[string]interface{}` +`func (o *NullableClass) GetObjectNullableProp() NullableMap[string]map[string]interface{}` GetObjectNullableProp returns the ObjectNullableProp field if non-nil, zero value otherwise. ### GetObjectNullablePropOk -`func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interface{}, bool)` +`func (o *NullableClass) GetObjectNullablePropOk() (NullableMap[string]map[string]interface{}, bool)` GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -321,9 +321,9 @@ HasObjectNullableProp returns a boolean if a field has been set. ### SetObjectNullableProp -`func (o *NullableClass) SetObjectNullableProp(v map[string]map[string]interface{})` +`func (o *NullableClass) SetObjectNullableProp(v NullableMap[string]map[string]interface{})` -SetObjectNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectNullableProp field. +SetObjectNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectNullableProp field. ### SetObjectNullablePropExplicitNull @@ -334,13 +334,13 @@ when serializing to JSON (pass true as argument to set this, false to unset) The ObjectNullableProp value is set to nil even if false is passed ### GetObjectAndItemsNullableProp -`func (o *NullableClass) GetObjectAndItemsNullableProp() map[string]map[string]interface{}` +`func (o *NullableClass) GetObjectAndItemsNullableProp() NullableMap[string]map[string]interface{}` GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field if non-nil, zero value otherwise. ### GetObjectAndItemsNullablePropOk -`func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string]interface{}, bool)` +`func (o *NullableClass) GetObjectAndItemsNullablePropOk() (NullableMap[string]map[string]interface{}, bool)` GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. @@ -353,9 +353,9 @@ HasObjectAndItemsNullableProp returns a boolean if a field has been set. ### SetObjectAndItemsNullableProp -`func (o *NullableClass) SetObjectAndItemsNullableProp(v map[string]map[string]interface{})` +`func (o *NullableClass) SetObjectAndItemsNullableProp(v NullableMap[string]map[string]interface{})` -SetObjectAndItemsNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field. +SetObjectAndItemsNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field. ### SetObjectAndItemsNullablePropExplicitNull diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/go.mod b/samples/openapi3/client/petstore/go-experimental/go-petstore/go.mod index 199809ed706..b80383b722c 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/go.mod +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/go.mod @@ -1,6 +1,8 @@ module github.com/GIT_USER_ID/GIT_REPO_ID +go 1.13 + require ( - github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6 - golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a + github.com/antihax/optional v1.0.0 + golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 ) diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/go.sum b/samples/openapi3/client/petstore/go-experimental/go-petstore/go.sum index e3c16fef3ac..ce55b3c6a08 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/go.sum +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/go.sum @@ -1,11 +1,15 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= -golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_200_response.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_200_response.go index 236aca8ee39..f578c71ae1d 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_200_response.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_200_response.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // Model200Response Model for testing model name starting with number type Model200Response struct { Name *int32 `json:"name,omitempty"` - Class *string `json:"class,omitempty"` - } -// GetName returns the Name field if non-nil, zero value otherwise. +// GetName returns the Name field value if set, zero value otherwise. func (o *Model200Response) GetName() int32 { if o == nil || o.Name == nil { var ret int32 @@ -28,7 +29,7 @@ func (o *Model200Response) GetName() int32 { return *o.Name } -// GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +// GetNameOk returns a tuple with the Name field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Model200Response) GetNameOk() (int32, bool) { if o == nil || o.Name == nil { @@ -52,7 +53,7 @@ func (o *Model200Response) SetName(v int32) { o.Name = &v } -// GetClass returns the Class field if non-nil, zero value otherwise. +// GetClass returns the Class field value if set, zero value otherwise. func (o *Model200Response) GetClass() string { if o == nil || o.Class == nil { var ret string @@ -61,7 +62,7 @@ func (o *Model200Response) GetClass() string { return *o.Class } -// GetClassOk returns a tuple with the Class field if it's non-nil, zero value otherwise +// GetClassOk returns a tuple with the Class field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Model200Response) GetClassOk() (string, bool) { if o == nil || o.Class == nil { @@ -85,17 +86,26 @@ func (o *Model200Response) SetClass(v string) { o.Class = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Model200Response) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name - } - if o.Class != nil { - toSerialize["class"] = o.Class - } - return json.Marshal(toSerialize) +type NullableModel200Response struct { + Value Model200Response + ExplicitNull bool } +func (v NullableModel200Response) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableModel200Response) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model__special_model_name_.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model__special_model_name_.go index 9c2435fa146..e8e5786195d 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model__special_model_name_.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model__special_model_name_.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // SpecialModelName struct for SpecialModelName type SpecialModelName struct { SpecialPropertyName *int64 `json:"$special[property.name],omitempty"` - } -// GetSpecialPropertyName returns the SpecialPropertyName field if non-nil, zero value otherwise. +// GetSpecialPropertyName returns the SpecialPropertyName field value if set, zero value otherwise. func (o *SpecialModelName) GetSpecialPropertyName() int64 { if o == nil || o.SpecialPropertyName == nil { var ret int64 @@ -26,7 +28,7 @@ func (o *SpecialModelName) GetSpecialPropertyName() int64 { return *o.SpecialPropertyName } -// GetSpecialPropertyNameOk returns a tuple with the SpecialPropertyName field if it's non-nil, zero value otherwise +// GetSpecialPropertyNameOk returns a tuple with the SpecialPropertyName field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *SpecialModelName) GetSpecialPropertyNameOk() (int64, bool) { if o == nil || o.SpecialPropertyName == nil { @@ -50,14 +52,26 @@ func (o *SpecialModelName) SetSpecialPropertyName(v int64) { o.SpecialPropertyName = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o SpecialModelName) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.SpecialPropertyName != nil { - toSerialize["$special[property.name]"] = o.SpecialPropertyName - } - return json.Marshal(toSerialize) +type NullableSpecialModelName struct { + Value SpecialModelName + ExplicitNull bool } +func (v NullableSpecialModelName) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableSpecialModelName) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go index a4050e424c3..ea7b0eb7d77 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesClass struct for AdditionalPropertiesClass type AdditionalPropertiesClass struct { MapProperty *map[string]string `json:"map_property,omitempty"` - MapOfMapProperty *map[string]map[string]string `json:"map_of_map_property,omitempty"` - } -// GetMapProperty returns the MapProperty field if non-nil, zero value otherwise. +// GetMapProperty returns the MapProperty field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapProperty() map[string]string { if o == nil || o.MapProperty == nil { var ret map[string]string @@ -28,7 +29,7 @@ func (o *AdditionalPropertiesClass) GetMapProperty() map[string]string { return *o.MapProperty } -// GetMapPropertyOk returns a tuple with the MapProperty field if it's non-nil, zero value otherwise +// GetMapPropertyOk returns a tuple with the MapProperty field value if set, zero value 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 { @@ -52,7 +53,7 @@ func (o *AdditionalPropertiesClass) SetMapProperty(v map[string]string) { o.MapProperty = &v } -// GetMapOfMapProperty returns the MapOfMapProperty field if non-nil, zero value otherwise. +// 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 { var ret map[string]map[string]string @@ -61,7 +62,7 @@ func (o *AdditionalPropertiesClass) GetMapOfMapProperty() map[string]map[string] return *o.MapOfMapProperty } -// GetMapOfMapPropertyOk returns a tuple with the MapOfMapProperty field if it's non-nil, zero value otherwise +// GetMapOfMapPropertyOk returns a tuple with the MapOfMapProperty field value if set, zero value 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 { @@ -85,17 +86,26 @@ func (o *AdditionalPropertiesClass) SetMapOfMapProperty(v map[string]map[string] o.MapOfMapProperty = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.MapProperty != nil { - toSerialize["map_property"] = o.MapProperty - } - if o.MapOfMapProperty != nil { - toSerialize["map_of_map_property"] = o.MapOfMapProperty - } - return json.Marshal(toSerialize) +type NullableAdditionalPropertiesClass struct { + Value AdditionalPropertiesClass + ExplicitNull bool } +func (v NullableAdditionalPropertiesClass) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableAdditionalPropertiesClass) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_animal.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_animal.go index 472ed9a093e..1bca9d7f269 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_animal.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_animal.go @@ -8,52 +8,34 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // Animal struct for Animal type Animal struct { - ClassName *string `json:"className,omitempty"` - + ClassName string `json:"className"` Color *string `json:"color,omitempty"` - } -// GetClassName returns the ClassName field if non-nil, zero value otherwise. +// GetClassName returns the ClassName field value func (o *Animal) GetClassName() string { - if o == nil || o.ClassName == nil { + if o == nil { var ret string return ret } - return *o.ClassName + + return o.ClassName } -// GetClassNameOk returns a tuple with the ClassName field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Animal) GetClassNameOk() (string, bool) { - if o == nil || o.ClassName == nil { - var ret string - return ret, false - } - return *o.ClassName, true -} - -// HasClassName returns a boolean if a field has been set. -func (o *Animal) HasClassName() bool { - if o != nil && o.ClassName != nil { - return true - } - - return false -} - -// SetClassName gets a reference to the given string and assigns it to the ClassName field. +// SetClassName sets field value func (o *Animal) SetClassName(v string) { - o.ClassName = &v + o.ClassName = v } -// GetColor returns the Color field if non-nil, zero value otherwise. +// GetColor returns the Color field value if set, zero value otherwise. func (o *Animal) GetColor() string { if o == nil || o.Color == nil { var ret string @@ -62,7 +44,7 @@ func (o *Animal) GetColor() string { return *o.Color } -// GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise +// GetColorOk returns a tuple with the Color field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Animal) GetColorOk() (string, bool) { if o == nil || o.Color == nil { @@ -86,20 +68,26 @@ func (o *Animal) SetColor(v string) { o.Color = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Animal) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.ClassName == nil { - return nil, errors.New("ClassName is required and not nullable, but was not set on Animal") - } - if o.ClassName != nil { - toSerialize["className"] = o.ClassName - } - if o.Color != nil { - toSerialize["color"] = o.Color - } - return json.Marshal(toSerialize) +type NullableAnimal struct { + Value Animal + ExplicitNull bool } +func (v NullableAnimal) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableAnimal) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_api_response.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_api_response.go index 6ef9d8e9da9..24e67257987 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_api_response.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_api_response.go @@ -8,20 +8,20 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // ApiResponse struct for ApiResponse type ApiResponse struct { Code *int32 `json:"code,omitempty"` - Type *string `json:"type,omitempty"` - Message *string `json:"message,omitempty"` - } -// GetCode returns the Code field if non-nil, zero value otherwise. +// GetCode returns the Code field value if set, zero value otherwise. func (o *ApiResponse) GetCode() int32 { if o == nil || o.Code == nil { var ret int32 @@ -30,7 +30,7 @@ func (o *ApiResponse) GetCode() int32 { return *o.Code } -// GetCodeOk returns a tuple with the Code field if it's non-nil, zero value otherwise +// GetCodeOk returns a tuple with the Code field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ApiResponse) GetCodeOk() (int32, bool) { if o == nil || o.Code == nil { @@ -54,7 +54,7 @@ func (o *ApiResponse) SetCode(v int32) { o.Code = &v } -// GetType returns the Type field if non-nil, zero value otherwise. +// GetType returns the Type field value if set, zero value otherwise. func (o *ApiResponse) GetType() string { if o == nil || o.Type == nil { var ret string @@ -63,7 +63,7 @@ func (o *ApiResponse) GetType() string { return *o.Type } -// GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +// GetTypeOk returns a tuple with the Type field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ApiResponse) GetTypeOk() (string, bool) { if o == nil || o.Type == nil { @@ -87,7 +87,7 @@ func (o *ApiResponse) SetType(v string) { o.Type = &v } -// GetMessage returns the Message field if non-nil, zero value otherwise. +// GetMessage returns the Message field value if set, zero value otherwise. func (o *ApiResponse) GetMessage() string { if o == nil || o.Message == nil { var ret string @@ -96,7 +96,7 @@ func (o *ApiResponse) GetMessage() string { return *o.Message } -// GetMessageOk returns a tuple with the Message field if it's non-nil, zero value otherwise +// GetMessageOk returns a tuple with the Message field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ApiResponse) GetMessageOk() (string, bool) { if o == nil || o.Message == nil { @@ -120,20 +120,26 @@ func (o *ApiResponse) SetMessage(v string) { o.Message = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o ApiResponse) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Code != nil { - toSerialize["code"] = o.Code - } - if o.Type != nil { - toSerialize["type"] = o.Type - } - if o.Message != nil { - toSerialize["message"] = o.Message - } - return json.Marshal(toSerialize) +type NullableApiResponse struct { + Value ApiResponse + ExplicitNull bool } +func (v NullableApiResponse) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableApiResponse) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go index 72f26371671..d3a9679bf03 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // ArrayOfArrayOfNumberOnly struct for ArrayOfArrayOfNumberOnly type ArrayOfArrayOfNumberOnly struct { ArrayArrayNumber *[][]float32 `json:"ArrayArrayNumber,omitempty"` - } -// GetArrayArrayNumber returns the ArrayArrayNumber field if non-nil, zero value otherwise. +// GetArrayArrayNumber returns the ArrayArrayNumber field value if set, zero value otherwise. func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 { if o == nil || o.ArrayArrayNumber == nil { var ret [][]float32 @@ -26,7 +28,7 @@ func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumber() [][]float32 { return *o.ArrayArrayNumber } -// GetArrayArrayNumberOk returns a tuple with the ArrayArrayNumber field if it's non-nil, zero value otherwise +// GetArrayArrayNumberOk returns a tuple with the ArrayArrayNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ArrayOfArrayOfNumberOnly) GetArrayArrayNumberOk() ([][]float32, bool) { if o == nil || o.ArrayArrayNumber == nil { @@ -50,14 +52,26 @@ func (o *ArrayOfArrayOfNumberOnly) SetArrayArrayNumber(v [][]float32) { o.ArrayArrayNumber = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o ArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.ArrayArrayNumber != nil { - toSerialize["ArrayArrayNumber"] = o.ArrayArrayNumber - } - return json.Marshal(toSerialize) +type NullableArrayOfArrayOfNumberOnly struct { + Value ArrayOfArrayOfNumberOnly + ExplicitNull bool } +func (v NullableArrayOfArrayOfNumberOnly) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableArrayOfArrayOfNumberOnly) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go index 595caf5c351..34dfd56be88 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // ArrayOfNumberOnly struct for ArrayOfNumberOnly type ArrayOfNumberOnly struct { ArrayNumber *[]float32 `json:"ArrayNumber,omitempty"` - } -// GetArrayNumber returns the ArrayNumber field if non-nil, zero value otherwise. +// GetArrayNumber returns the ArrayNumber field value if set, zero value otherwise. func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 { if o == nil || o.ArrayNumber == nil { var ret []float32 @@ -26,7 +28,7 @@ func (o *ArrayOfNumberOnly) GetArrayNumber() []float32 { return *o.ArrayNumber } -// GetArrayNumberOk returns a tuple with the ArrayNumber field if it's non-nil, zero value otherwise +// GetArrayNumberOk returns a tuple with the ArrayNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ArrayOfNumberOnly) GetArrayNumberOk() ([]float32, bool) { if o == nil || o.ArrayNumber == nil { @@ -50,14 +52,26 @@ func (o *ArrayOfNumberOnly) SetArrayNumber(v []float32) { o.ArrayNumber = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o ArrayOfNumberOnly) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.ArrayNumber != nil { - toSerialize["ArrayNumber"] = o.ArrayNumber - } - return json.Marshal(toSerialize) +type NullableArrayOfNumberOnly struct { + Value ArrayOfNumberOnly + ExplicitNull bool } +func (v NullableArrayOfNumberOnly) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableArrayOfNumberOnly) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_test_.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_test_.go index fe8729cc1de..959ec1702db 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_test_.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_array_test_.go @@ -8,20 +8,20 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // ArrayTest struct for ArrayTest type ArrayTest struct { ArrayOfString *[]string `json:"array_of_string,omitempty"` - ArrayArrayOfInteger *[][]int64 `json:"array_array_of_integer,omitempty"` - ArrayArrayOfModel *[][]ReadOnlyFirst `json:"array_array_of_model,omitempty"` - } -// GetArrayOfString returns the ArrayOfString field if non-nil, zero value otherwise. +// GetArrayOfString returns the ArrayOfString field value if set, zero value otherwise. func (o *ArrayTest) GetArrayOfString() []string { if o == nil || o.ArrayOfString == nil { var ret []string @@ -30,7 +30,7 @@ func (o *ArrayTest) GetArrayOfString() []string { return *o.ArrayOfString } -// GetArrayOfStringOk returns a tuple with the ArrayOfString field if it's non-nil, zero value otherwise +// GetArrayOfStringOk returns a tuple with the ArrayOfString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ArrayTest) GetArrayOfStringOk() ([]string, bool) { if o == nil || o.ArrayOfString == nil { @@ -54,7 +54,7 @@ func (o *ArrayTest) SetArrayOfString(v []string) { o.ArrayOfString = &v } -// GetArrayArrayOfInteger returns the ArrayArrayOfInteger field if non-nil, zero value otherwise. +// GetArrayArrayOfInteger returns the ArrayArrayOfInteger field value if set, zero value otherwise. func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 { if o == nil || o.ArrayArrayOfInteger == nil { var ret [][]int64 @@ -63,7 +63,7 @@ func (o *ArrayTest) GetArrayArrayOfInteger() [][]int64 { return *o.ArrayArrayOfInteger } -// GetArrayArrayOfIntegerOk returns a tuple with the ArrayArrayOfInteger field if it's non-nil, zero value otherwise +// GetArrayArrayOfIntegerOk returns a tuple with the ArrayArrayOfInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ArrayTest) GetArrayArrayOfIntegerOk() ([][]int64, bool) { if o == nil || o.ArrayArrayOfInteger == nil { @@ -87,7 +87,7 @@ func (o *ArrayTest) SetArrayArrayOfInteger(v [][]int64) { o.ArrayArrayOfInteger = &v } -// GetArrayArrayOfModel returns the ArrayArrayOfModel field if non-nil, zero value otherwise. +// GetArrayArrayOfModel returns the ArrayArrayOfModel field value if set, zero value otherwise. func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst { if o == nil || o.ArrayArrayOfModel == nil { var ret [][]ReadOnlyFirst @@ -96,7 +96,7 @@ func (o *ArrayTest) GetArrayArrayOfModel() [][]ReadOnlyFirst { return *o.ArrayArrayOfModel } -// GetArrayArrayOfModelOk returns a tuple with the ArrayArrayOfModel field if it's non-nil, zero value otherwise +// GetArrayArrayOfModelOk returns a tuple with the ArrayArrayOfModel field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ArrayTest) GetArrayArrayOfModelOk() ([][]ReadOnlyFirst, bool) { if o == nil || o.ArrayArrayOfModel == nil { @@ -120,20 +120,26 @@ func (o *ArrayTest) SetArrayArrayOfModel(v [][]ReadOnlyFirst) { o.ArrayArrayOfModel = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o ArrayTest) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.ArrayOfString != nil { - toSerialize["array_of_string"] = o.ArrayOfString - } - if o.ArrayArrayOfInteger != nil { - toSerialize["array_array_of_integer"] = o.ArrayArrayOfInteger - } - if o.ArrayArrayOfModel != nil { - toSerialize["array_array_of_model"] = o.ArrayArrayOfModel - } - return json.Marshal(toSerialize) +type NullableArrayTest struct { + Value ArrayTest + ExplicitNull bool } +func (v NullableArrayTest) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableArrayTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_capitalization.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_capitalization.go index 152069cde94..9fa45b1b216 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_capitalization.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_capitalization.go @@ -8,27 +8,24 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // Capitalization struct for Capitalization type Capitalization struct { SmallCamel *string `json:"smallCamel,omitempty"` - CapitalCamel *string `json:"CapitalCamel,omitempty"` - SmallSnake *string `json:"small_Snake,omitempty"` - CapitalSnake *string `json:"Capital_Snake,omitempty"` - SCAETHFlowPoints *string `json:"SCA_ETH_Flow_Points,omitempty"` - // Name of the pet ATT_NAME *string `json:"ATT_NAME,omitempty"` - } -// GetSmallCamel returns the SmallCamel field if non-nil, zero value otherwise. +// GetSmallCamel returns the SmallCamel field value if set, zero value otherwise. func (o *Capitalization) GetSmallCamel() string { if o == nil || o.SmallCamel == nil { var ret string @@ -37,7 +34,7 @@ func (o *Capitalization) GetSmallCamel() string { return *o.SmallCamel } -// GetSmallCamelOk returns a tuple with the SmallCamel field if it's non-nil, zero value otherwise +// GetSmallCamelOk returns a tuple with the SmallCamel field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Capitalization) GetSmallCamelOk() (string, bool) { if o == nil || o.SmallCamel == nil { @@ -61,7 +58,7 @@ func (o *Capitalization) SetSmallCamel(v string) { o.SmallCamel = &v } -// GetCapitalCamel returns the CapitalCamel field if non-nil, zero value otherwise. +// GetCapitalCamel returns the CapitalCamel field value if set, zero value otherwise. func (o *Capitalization) GetCapitalCamel() string { if o == nil || o.CapitalCamel == nil { var ret string @@ -70,7 +67,7 @@ func (o *Capitalization) GetCapitalCamel() string { return *o.CapitalCamel } -// GetCapitalCamelOk returns a tuple with the CapitalCamel field if it's non-nil, zero value otherwise +// GetCapitalCamelOk returns a tuple with the CapitalCamel field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Capitalization) GetCapitalCamelOk() (string, bool) { if o == nil || o.CapitalCamel == nil { @@ -94,7 +91,7 @@ func (o *Capitalization) SetCapitalCamel(v string) { o.CapitalCamel = &v } -// GetSmallSnake returns the SmallSnake field if non-nil, zero value otherwise. +// GetSmallSnake returns the SmallSnake field value if set, zero value otherwise. func (o *Capitalization) GetSmallSnake() string { if o == nil || o.SmallSnake == nil { var ret string @@ -103,7 +100,7 @@ func (o *Capitalization) GetSmallSnake() string { return *o.SmallSnake } -// GetSmallSnakeOk returns a tuple with the SmallSnake field if it's non-nil, zero value otherwise +// GetSmallSnakeOk returns a tuple with the SmallSnake field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Capitalization) GetSmallSnakeOk() (string, bool) { if o == nil || o.SmallSnake == nil { @@ -127,7 +124,7 @@ func (o *Capitalization) SetSmallSnake(v string) { o.SmallSnake = &v } -// GetCapitalSnake returns the CapitalSnake field if non-nil, zero value otherwise. +// GetCapitalSnake returns the CapitalSnake field value if set, zero value otherwise. func (o *Capitalization) GetCapitalSnake() string { if o == nil || o.CapitalSnake == nil { var ret string @@ -136,7 +133,7 @@ func (o *Capitalization) GetCapitalSnake() string { return *o.CapitalSnake } -// GetCapitalSnakeOk returns a tuple with the CapitalSnake field if it's non-nil, zero value otherwise +// GetCapitalSnakeOk returns a tuple with the CapitalSnake field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Capitalization) GetCapitalSnakeOk() (string, bool) { if o == nil || o.CapitalSnake == nil { @@ -160,7 +157,7 @@ func (o *Capitalization) SetCapitalSnake(v string) { o.CapitalSnake = &v } -// GetSCAETHFlowPoints returns the SCAETHFlowPoints field if non-nil, zero value otherwise. +// GetSCAETHFlowPoints returns the SCAETHFlowPoints field value if set, zero value otherwise. func (o *Capitalization) GetSCAETHFlowPoints() string { if o == nil || o.SCAETHFlowPoints == nil { var ret string @@ -169,7 +166,7 @@ func (o *Capitalization) GetSCAETHFlowPoints() string { return *o.SCAETHFlowPoints } -// GetSCAETHFlowPointsOk returns a tuple with the SCAETHFlowPoints field if it's non-nil, zero value otherwise +// GetSCAETHFlowPointsOk returns a tuple with the SCAETHFlowPoints field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Capitalization) GetSCAETHFlowPointsOk() (string, bool) { if o == nil || o.SCAETHFlowPoints == nil { @@ -193,7 +190,7 @@ func (o *Capitalization) SetSCAETHFlowPoints(v string) { o.SCAETHFlowPoints = &v } -// GetATT_NAME returns the ATT_NAME field if non-nil, zero value otherwise. +// 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 { var ret string @@ -202,7 +199,7 @@ func (o *Capitalization) GetATT_NAME() string { return *o.ATT_NAME } -// GetATT_NAMEOk returns a tuple with the ATT_NAME field if it's non-nil, zero value otherwise +// GetATT_NAMEOk returns a tuple with the ATT_NAME field value if set, zero value 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 { @@ -226,29 +223,26 @@ func (o *Capitalization) SetATT_NAME(v string) { o.ATT_NAME = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Capitalization) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.SmallCamel != nil { - toSerialize["smallCamel"] = o.SmallCamel - } - if o.CapitalCamel != nil { - toSerialize["CapitalCamel"] = o.CapitalCamel - } - if o.SmallSnake != nil { - toSerialize["small_Snake"] = o.SmallSnake - } - if o.CapitalSnake != nil { - toSerialize["Capital_Snake"] = o.CapitalSnake - } - if o.SCAETHFlowPoints != nil { - toSerialize["SCA_ETH_Flow_Points"] = o.SCAETHFlowPoints - } - if o.ATT_NAME != nil { - toSerialize["ATT_NAME"] = o.ATT_NAME - } - return json.Marshal(toSerialize) +type NullableCapitalization struct { + Value Capitalization + ExplicitNull bool } +func (v NullableCapitalization) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableCapitalization) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat.go index 68740a9cc9d..8c79d36766a 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat.go @@ -8,54 +8,35 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // Cat struct for Cat type Cat struct { - ClassName *string `json:"className,omitempty"` - + ClassName string `json:"className"` Color *string `json:"color,omitempty"` - Declawed *bool `json:"declawed,omitempty"` - } -// GetClassName returns the ClassName field if non-nil, zero value otherwise. +// GetClassName returns the ClassName field value func (o *Cat) GetClassName() string { - if o == nil || o.ClassName == nil { + if o == nil { var ret string return ret } - return *o.ClassName + + return o.ClassName } -// GetClassNameOk returns a tuple with the ClassName field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Cat) GetClassNameOk() (string, bool) { - if o == nil || o.ClassName == nil { - var ret string - return ret, false - } - return *o.ClassName, true -} - -// HasClassName returns a boolean if a field has been set. -func (o *Cat) HasClassName() bool { - if o != nil && o.ClassName != nil { - return true - } - - return false -} - -// SetClassName gets a reference to the given string and assigns it to the ClassName field. +// SetClassName sets field value func (o *Cat) SetClassName(v string) { - o.ClassName = &v + o.ClassName = v } -// GetColor returns the Color field if non-nil, zero value otherwise. +// GetColor returns the Color field value if set, zero value otherwise. func (o *Cat) GetColor() string { if o == nil || o.Color == nil { var ret string @@ -64,7 +45,7 @@ func (o *Cat) GetColor() string { return *o.Color } -// GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise +// GetColorOk returns a tuple with the Color field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Cat) GetColorOk() (string, bool) { if o == nil || o.Color == nil { @@ -88,7 +69,7 @@ func (o *Cat) SetColor(v string) { o.Color = &v } -// GetDeclawed returns the Declawed field if non-nil, zero value otherwise. +// GetDeclawed returns the Declawed field value if set, zero value otherwise. func (o *Cat) GetDeclawed() bool { if o == nil || o.Declawed == nil { var ret bool @@ -97,7 +78,7 @@ func (o *Cat) GetDeclawed() bool { return *o.Declawed } -// GetDeclawedOk returns a tuple with the Declawed field if it's non-nil, zero value otherwise +// GetDeclawedOk returns a tuple with the Declawed field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Cat) GetDeclawedOk() (bool, bool) { if o == nil || o.Declawed == nil { @@ -121,23 +102,26 @@ func (o *Cat) SetDeclawed(v bool) { o.Declawed = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Cat) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.ClassName == nil { - return nil, errors.New("ClassName is required and not nullable, but was not set on Cat") - } - if o.ClassName != nil { - toSerialize["className"] = o.ClassName - } - if o.Color != nil { - toSerialize["color"] = o.Color - } - if o.Declawed != nil { - toSerialize["declawed"] = o.Declawed - } - return json.Marshal(toSerialize) +type NullableCat struct { + Value Cat + ExplicitNull bool } +func (v NullableCat) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableCat) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat_all_of.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat_all_of.go index 0ae64baf61a..af2e351aa80 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat_all_of.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_cat_all_of.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // CatAllOf struct for CatAllOf type CatAllOf struct { Declawed *bool `json:"declawed,omitempty"` - } -// GetDeclawed returns the Declawed field if non-nil, zero value otherwise. +// GetDeclawed returns the Declawed field value if set, zero value otherwise. func (o *CatAllOf) GetDeclawed() bool { if o == nil || o.Declawed == nil { var ret bool @@ -26,7 +28,7 @@ func (o *CatAllOf) GetDeclawed() bool { return *o.Declawed } -// GetDeclawedOk returns a tuple with the Declawed field if it's non-nil, zero value otherwise +// GetDeclawedOk returns a tuple with the Declawed field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *CatAllOf) GetDeclawedOk() (bool, bool) { if o == nil || o.Declawed == nil { @@ -50,14 +52,26 @@ func (o *CatAllOf) SetDeclawed(v bool) { o.Declawed = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o CatAllOf) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Declawed != nil { - toSerialize["declawed"] = o.Declawed - } - return json.Marshal(toSerialize) +type NullableCatAllOf struct { + Value CatAllOf + ExplicitNull bool } +func (v NullableCatAllOf) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableCatAllOf) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_category.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_category.go index 40f16e0f205..b4e6f0fecd8 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_category.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_category.go @@ -8,19 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // Category struct for Category type Category struct { Id *int64 `json:"id,omitempty"` - - Name *string `json:"name,omitempty"` - + Name string `json:"name"` } -// GetId returns the Id field if non-nil, zero value otherwise. +// GetId returns the Id field value if set, zero value otherwise. func (o *Category) GetId() int64 { if o == nil || o.Id == nil { var ret int64 @@ -29,7 +29,7 @@ func (o *Category) GetId() int64 { return *o.Id } -// GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +// GetIdOk returns a tuple with the Id field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Category) GetIdOk() (int64, bool) { if o == nil || o.Id == nil { @@ -53,53 +53,41 @@ func (o *Category) SetId(v int64) { o.Id = &v } -// GetName returns the Name field if non-nil, zero value otherwise. +// GetName returns the Name field value func (o *Category) GetName() string { - if o == nil || o.Name == nil { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Category) GetNameOk() (string, bool) { - if o == nil || o.Name == nil { - var ret string - return ret, false - } - return *o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *Category) HasName() bool { - if o != nil && o.Name != nil { - return true - } - - return false -} - -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *Category) SetName(v string) { - o.Name = &v + o.Name = v } - -// MarshalJSON returns the JSON representation of the model. -func (o Category) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Id != nil { - toSerialize["id"] = o.Id - } - if o.Name == nil { - return nil, errors.New("Name is required and not nullable, but was not set on Category") - } - if o.Name != nil { - toSerialize["name"] = o.Name - } - return json.Marshal(toSerialize) +type NullableCategory struct { + Value Category + ExplicitNull bool } +func (v NullableCategory) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableCategory) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_class_model.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_class_model.go index 942013150ed..a4d8428053a 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_class_model.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_class_model.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // ClassModel Model for testing model with \"_class\" property type ClassModel struct { Class *string `json:"_class,omitempty"` - } -// GetClass returns the Class field if non-nil, zero value otherwise. +// GetClass returns the Class field value if set, zero value otherwise. func (o *ClassModel) GetClass() string { if o == nil || o.Class == nil { var ret string @@ -26,7 +28,7 @@ func (o *ClassModel) GetClass() string { return *o.Class } -// GetClassOk returns a tuple with the Class field if it's non-nil, zero value otherwise +// GetClassOk returns a tuple with the Class field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ClassModel) GetClassOk() (string, bool) { if o == nil || o.Class == nil { @@ -50,14 +52,26 @@ func (o *ClassModel) SetClass(v string) { o.Class = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o ClassModel) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Class != nil { - toSerialize["_class"] = o.Class - } - return json.Marshal(toSerialize) +type NullableClassModel struct { + Value ClassModel + ExplicitNull bool } +func (v NullableClassModel) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableClassModel) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_client.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_client.go index 926e0f9b155..b564954b90e 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_client.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_client.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // Client struct for Client type Client struct { Client *string `json:"client,omitempty"` - } -// GetClient returns the Client field if non-nil, zero value otherwise. +// GetClient returns the Client field value if set, zero value otherwise. func (o *Client) GetClient() string { if o == nil || o.Client == nil { var ret string @@ -26,7 +28,7 @@ func (o *Client) GetClient() string { return *o.Client } -// GetClientOk returns a tuple with the Client field if it's non-nil, zero value otherwise +// GetClientOk returns a tuple with the Client field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Client) GetClientOk() (string, bool) { if o == nil || o.Client == nil { @@ -50,14 +52,26 @@ func (o *Client) SetClient(v string) { o.Client = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Client) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Client != nil { - toSerialize["client"] = o.Client - } - return json.Marshal(toSerialize) +type NullableClient struct { + Value Client + ExplicitNull bool } +func (v NullableClient) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableClient) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog.go index d5e743b75af..71c6cf17e2c 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog.go @@ -8,54 +8,35 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // Dog struct for Dog type Dog struct { - ClassName *string `json:"className,omitempty"` - + ClassName string `json:"className"` Color *string `json:"color,omitempty"` - Breed *string `json:"breed,omitempty"` - } -// GetClassName returns the ClassName field if non-nil, zero value otherwise. +// GetClassName returns the ClassName field value func (o *Dog) GetClassName() string { - if o == nil || o.ClassName == nil { + if o == nil { var ret string return ret } - return *o.ClassName + + return o.ClassName } -// GetClassNameOk returns a tuple with the ClassName field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Dog) GetClassNameOk() (string, bool) { - if o == nil || o.ClassName == nil { - var ret string - return ret, false - } - return *o.ClassName, true -} - -// HasClassName returns a boolean if a field has been set. -func (o *Dog) HasClassName() bool { - if o != nil && o.ClassName != nil { - return true - } - - return false -} - -// SetClassName gets a reference to the given string and assigns it to the ClassName field. +// SetClassName sets field value func (o *Dog) SetClassName(v string) { - o.ClassName = &v + o.ClassName = v } -// GetColor returns the Color field if non-nil, zero value otherwise. +// GetColor returns the Color field value if set, zero value otherwise. func (o *Dog) GetColor() string { if o == nil || o.Color == nil { var ret string @@ -64,7 +45,7 @@ func (o *Dog) GetColor() string { return *o.Color } -// GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise +// GetColorOk returns a tuple with the Color field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Dog) GetColorOk() (string, bool) { if o == nil || o.Color == nil { @@ -88,7 +69,7 @@ func (o *Dog) SetColor(v string) { o.Color = &v } -// GetBreed returns the Breed field if non-nil, zero value otherwise. +// GetBreed returns the Breed field value if set, zero value otherwise. func (o *Dog) GetBreed() string { if o == nil || o.Breed == nil { var ret string @@ -97,7 +78,7 @@ func (o *Dog) GetBreed() string { return *o.Breed } -// GetBreedOk returns a tuple with the Breed field if it's non-nil, zero value otherwise +// GetBreedOk returns a tuple with the Breed field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Dog) GetBreedOk() (string, bool) { if o == nil || o.Breed == nil { @@ -121,23 +102,26 @@ func (o *Dog) SetBreed(v string) { o.Breed = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Dog) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.ClassName == nil { - return nil, errors.New("ClassName is required and not nullable, but was not set on Dog") - } - if o.ClassName != nil { - toSerialize["className"] = o.ClassName - } - if o.Color != nil { - toSerialize["color"] = o.Color - } - if o.Breed != nil { - toSerialize["breed"] = o.Breed - } - return json.Marshal(toSerialize) +type NullableDog struct { + Value Dog + ExplicitNull bool } +func (v NullableDog) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableDog) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog_all_of.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog_all_of.go index 239229308c7..e7df31a2e4d 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog_all_of.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_dog_all_of.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // DogAllOf struct for DogAllOf type DogAllOf struct { Breed *string `json:"breed,omitempty"` - } -// GetBreed returns the Breed field if non-nil, zero value otherwise. +// GetBreed returns the Breed field value if set, zero value otherwise. func (o *DogAllOf) GetBreed() string { if o == nil || o.Breed == nil { var ret string @@ -26,7 +28,7 @@ func (o *DogAllOf) GetBreed() string { return *o.Breed } -// GetBreedOk returns a tuple with the Breed field if it's non-nil, zero value otherwise +// GetBreedOk returns a tuple with the Breed field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *DogAllOf) GetBreedOk() (string, bool) { if o == nil || o.Breed == nil { @@ -50,14 +52,26 @@ func (o *DogAllOf) SetBreed(v string) { o.Breed = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o DogAllOf) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Breed != nil { - toSerialize["breed"] = o.Breed - } - return json.Marshal(toSerialize) +type NullableDogAllOf struct { + Value DogAllOf + ExplicitNull bool } +func (v NullableDogAllOf) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableDogAllOf) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_arrays.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_arrays.go index 4a06504b56e..5944a22e035 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_arrays.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_arrays.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // EnumArrays struct for EnumArrays type EnumArrays struct { JustSymbol *string `json:"just_symbol,omitempty"` - ArrayEnum *[]string `json:"array_enum,omitempty"` - } -// GetJustSymbol returns the JustSymbol field if non-nil, zero value otherwise. +// GetJustSymbol returns the JustSymbol field value if set, zero value otherwise. func (o *EnumArrays) GetJustSymbol() string { if o == nil || o.JustSymbol == nil { var ret string @@ -28,7 +29,7 @@ func (o *EnumArrays) GetJustSymbol() string { return *o.JustSymbol } -// GetJustSymbolOk returns a tuple with the JustSymbol field if it's non-nil, zero value otherwise +// GetJustSymbolOk returns a tuple with the JustSymbol field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumArrays) GetJustSymbolOk() (string, bool) { if o == nil || o.JustSymbol == nil { @@ -52,7 +53,7 @@ func (o *EnumArrays) SetJustSymbol(v string) { o.JustSymbol = &v } -// GetArrayEnum returns the ArrayEnum field if non-nil, zero value otherwise. +// GetArrayEnum returns the ArrayEnum field value if set, zero value otherwise. func (o *EnumArrays) GetArrayEnum() []string { if o == nil || o.ArrayEnum == nil { var ret []string @@ -61,7 +62,7 @@ func (o *EnumArrays) GetArrayEnum() []string { return *o.ArrayEnum } -// GetArrayEnumOk returns a tuple with the ArrayEnum field if it's non-nil, zero value otherwise +// GetArrayEnumOk returns a tuple with the ArrayEnum field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumArrays) GetArrayEnumOk() ([]string, bool) { if o == nil || o.ArrayEnum == nil { @@ -85,17 +86,26 @@ func (o *EnumArrays) SetArrayEnum(v []string) { o.ArrayEnum = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o EnumArrays) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.JustSymbol != nil { - toSerialize["just_symbol"] = o.JustSymbol - } - if o.ArrayEnum != nil { - toSerialize["array_enum"] = o.ArrayEnum - } - return json.Marshal(toSerialize) +type NullableEnumArrays struct { + Value EnumArrays + ExplicitNull bool } +func (v NullableEnumArrays) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableEnumArrays) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_class.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_class.go index 6f7e93a9864..8271d1de643 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_class.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_class.go @@ -8,6 +8,12 @@ */ package openapi + +import ( + "bytes" + "encoding/json" +) + // EnumClass the model 'EnumClass' type EnumClass string @@ -18,4 +24,30 @@ const ( XYZ EnumClass = "(xyz)" ) +type NullableEnumClass struct { + Value EnumClass + ExplicitNull bool +} + +func (v NullableEnumClass) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != "": + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableEnumClass) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_test_.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_test_.go index 5ed8bba1b74..1dc3c855a55 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_test_.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_enum_test_.go @@ -8,31 +8,25 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // EnumTest struct for EnumTest type EnumTest struct { EnumString *string `json:"enum_string,omitempty"` - - EnumStringRequired *string `json:"enum_string_required,omitempty"` - + EnumStringRequired string `json:"enum_string_required"` EnumInteger *int32 `json:"enum_integer,omitempty"` - EnumNumber *float64 `json:"enum_number,omitempty"` - - OuterEnum *OuterEnum `json:"outerEnum,omitempty"` - isExplicitNullOuterEnum bool `json:"-"` + OuterEnum *NullableOuterEnum `json:"outerEnum,omitempty"` OuterEnumInteger *OuterEnumInteger `json:"outerEnumInteger,omitempty"` - OuterEnumDefaultValue *OuterEnumDefaultValue `json:"outerEnumDefaultValue,omitempty"` - OuterEnumIntegerDefaultValue *OuterEnumIntegerDefaultValue `json:"outerEnumIntegerDefaultValue,omitempty"` - } -// GetEnumString returns the EnumString field if non-nil, zero value otherwise. +// GetEnumString returns the EnumString field value if set, zero value otherwise. func (o *EnumTest) GetEnumString() string { if o == nil || o.EnumString == nil { var ret string @@ -41,7 +35,7 @@ func (o *EnumTest) GetEnumString() string { return *o.EnumString } -// GetEnumStringOk returns a tuple with the EnumString field if it's non-nil, zero value otherwise +// GetEnumStringOk returns a tuple with the EnumString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumTest) GetEnumStringOk() (string, bool) { if o == nil || o.EnumString == nil { @@ -65,40 +59,22 @@ func (o *EnumTest) SetEnumString(v string) { o.EnumString = &v } -// GetEnumStringRequired returns the EnumStringRequired field if non-nil, zero value otherwise. +// GetEnumStringRequired returns the EnumStringRequired field value func (o *EnumTest) GetEnumStringRequired() string { - if o == nil || o.EnumStringRequired == nil { + if o == nil { var ret string return ret } - return *o.EnumStringRequired + + return o.EnumStringRequired } -// GetEnumStringRequiredOk returns a tuple with the EnumStringRequired field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *EnumTest) GetEnumStringRequiredOk() (string, bool) { - if o == nil || o.EnumStringRequired == nil { - var ret string - return ret, false - } - return *o.EnumStringRequired, true -} - -// HasEnumStringRequired returns a boolean if a field has been set. -func (o *EnumTest) HasEnumStringRequired() bool { - if o != nil && o.EnumStringRequired != nil { - return true - } - - return false -} - -// SetEnumStringRequired gets a reference to the given string and assigns it to the EnumStringRequired field. +// SetEnumStringRequired sets field value func (o *EnumTest) SetEnumStringRequired(v string) { - o.EnumStringRequired = &v + o.EnumStringRequired = v } -// GetEnumInteger returns the EnumInteger field if non-nil, zero value otherwise. +// GetEnumInteger returns the EnumInteger field value if set, zero value otherwise. func (o *EnumTest) GetEnumInteger() int32 { if o == nil || o.EnumInteger == nil { var ret int32 @@ -107,7 +83,7 @@ func (o *EnumTest) GetEnumInteger() int32 { return *o.EnumInteger } -// GetEnumIntegerOk returns a tuple with the EnumInteger field if it's non-nil, zero value otherwise +// GetEnumIntegerOk returns a tuple with the EnumInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumTest) GetEnumIntegerOk() (int32, bool) { if o == nil || o.EnumInteger == nil { @@ -131,7 +107,7 @@ func (o *EnumTest) SetEnumInteger(v int32) { o.EnumInteger = &v } -// GetEnumNumber returns the EnumNumber field if non-nil, zero value otherwise. +// GetEnumNumber returns the EnumNumber field value if set, zero value otherwise. func (o *EnumTest) GetEnumNumber() float64 { if o == nil || o.EnumNumber == nil { var ret float64 @@ -140,7 +116,7 @@ func (o *EnumTest) GetEnumNumber() float64 { return *o.EnumNumber } -// GetEnumNumberOk returns a tuple with the EnumNumber field if it's non-nil, zero value otherwise +// GetEnumNumberOk returns a tuple with the EnumNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumTest) GetEnumNumberOk() (float64, bool) { if o == nil || o.EnumNumber == nil { @@ -164,20 +140,20 @@ func (o *EnumTest) SetEnumNumber(v float64) { o.EnumNumber = &v } -// GetOuterEnum returns the OuterEnum field if non-nil, zero value otherwise. -func (o *EnumTest) GetOuterEnum() OuterEnum { +// GetOuterEnum returns the OuterEnum field value if set, zero value otherwise. +func (o *EnumTest) GetOuterEnum() NullableOuterEnum { if o == nil || o.OuterEnum == nil { - var ret OuterEnum + var ret NullableOuterEnum return ret } return *o.OuterEnum } -// GetOuterEnumOk returns a tuple with the OuterEnum field if it's non-nil, zero value otherwise +// GetOuterEnumOk returns a tuple with the OuterEnum field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *EnumTest) GetOuterEnumOk() (OuterEnum, bool) { +func (o *EnumTest) GetOuterEnumOk() (NullableOuterEnum, bool) { if o == nil || o.OuterEnum == nil { - var ret OuterEnum + var ret NullableOuterEnum return ret, false } return *o.OuterEnum, true @@ -192,19 +168,12 @@ func (o *EnumTest) HasOuterEnum() bool { return false } -// SetOuterEnum gets a reference to the given OuterEnum and assigns it to the OuterEnum field. -func (o *EnumTest) SetOuterEnum(v OuterEnum) { +// SetOuterEnum gets a reference to the given NullableOuterEnum and assigns it to the OuterEnum field. +func (o *EnumTest) SetOuterEnum(v NullableOuterEnum) { o.OuterEnum = &v } -// SetOuterEnumExplicitNull (un)sets OuterEnum to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The OuterEnum value is set to nil even if false is passed -func (o *EnumTest) SetOuterEnumExplicitNull(b bool) { - o.OuterEnum = nil - o.isExplicitNullOuterEnum = b -} -// GetOuterEnumInteger returns the OuterEnumInteger field if non-nil, zero value otherwise. +// GetOuterEnumInteger returns the OuterEnumInteger field value if set, zero value otherwise. func (o *EnumTest) GetOuterEnumInteger() OuterEnumInteger { if o == nil || o.OuterEnumInteger == nil { var ret OuterEnumInteger @@ -213,7 +182,7 @@ func (o *EnumTest) GetOuterEnumInteger() OuterEnumInteger { return *o.OuterEnumInteger } -// GetOuterEnumIntegerOk returns a tuple with the OuterEnumInteger field if it's non-nil, zero value otherwise +// GetOuterEnumIntegerOk returns a tuple with the OuterEnumInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumTest) GetOuterEnumIntegerOk() (OuterEnumInteger, bool) { if o == nil || o.OuterEnumInteger == nil { @@ -237,7 +206,7 @@ func (o *EnumTest) SetOuterEnumInteger(v OuterEnumInteger) { o.OuterEnumInteger = &v } -// GetOuterEnumDefaultValue returns the OuterEnumDefaultValue field if non-nil, zero value otherwise. +// GetOuterEnumDefaultValue returns the OuterEnumDefaultValue field value if set, zero value otherwise. func (o *EnumTest) GetOuterEnumDefaultValue() OuterEnumDefaultValue { if o == nil || o.OuterEnumDefaultValue == nil { var ret OuterEnumDefaultValue @@ -246,7 +215,7 @@ func (o *EnumTest) GetOuterEnumDefaultValue() OuterEnumDefaultValue { return *o.OuterEnumDefaultValue } -// GetOuterEnumDefaultValueOk returns a tuple with the OuterEnumDefaultValue field if it's non-nil, zero value otherwise +// GetOuterEnumDefaultValueOk returns a tuple with the OuterEnumDefaultValue field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumTest) GetOuterEnumDefaultValueOk() (OuterEnumDefaultValue, bool) { if o == nil || o.OuterEnumDefaultValue == nil { @@ -270,7 +239,7 @@ func (o *EnumTest) SetOuterEnumDefaultValue(v OuterEnumDefaultValue) { o.OuterEnumDefaultValue = &v } -// GetOuterEnumIntegerDefaultValue returns the OuterEnumIntegerDefaultValue field if non-nil, zero value otherwise. +// GetOuterEnumIntegerDefaultValue returns the OuterEnumIntegerDefaultValue field value if set, zero value otherwise. func (o *EnumTest) GetOuterEnumIntegerDefaultValue() OuterEnumIntegerDefaultValue { if o == nil || o.OuterEnumIntegerDefaultValue == nil { var ret OuterEnumIntegerDefaultValue @@ -279,7 +248,7 @@ func (o *EnumTest) GetOuterEnumIntegerDefaultValue() OuterEnumIntegerDefaultValu return *o.OuterEnumIntegerDefaultValue } -// GetOuterEnumIntegerDefaultValueOk returns a tuple with the OuterEnumIntegerDefaultValue field if it's non-nil, zero value otherwise +// GetOuterEnumIntegerDefaultValueOk returns a tuple with the OuterEnumIntegerDefaultValue field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *EnumTest) GetOuterEnumIntegerDefaultValueOk() (OuterEnumIntegerDefaultValue, bool) { if o == nil || o.OuterEnumIntegerDefaultValue == nil { @@ -303,42 +272,26 @@ func (o *EnumTest) SetOuterEnumIntegerDefaultValue(v OuterEnumIntegerDefaultValu o.OuterEnumIntegerDefaultValue = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o EnumTest) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.EnumString != nil { - toSerialize["enum_string"] = o.EnumString - } - if o.EnumStringRequired == nil { - return nil, errors.New("EnumStringRequired is required and not nullable, but was not set on EnumTest") - } - if o.EnumStringRequired != nil { - toSerialize["enum_string_required"] = o.EnumStringRequired - } - if o.EnumInteger != nil { - toSerialize["enum_integer"] = o.EnumInteger - } - if o.EnumNumber != nil { - toSerialize["enum_number"] = o.EnumNumber - } - if o.OuterEnum == nil { - if o.isExplicitNullOuterEnum { - toSerialize["outerEnum"] = o.OuterEnum - } - } else { - toSerialize["outerEnum"] = o.OuterEnum - } - if o.OuterEnumInteger != nil { - toSerialize["outerEnumInteger"] = o.OuterEnumInteger - } - if o.OuterEnumDefaultValue != nil { - toSerialize["outerEnumDefaultValue"] = o.OuterEnumDefaultValue - } - if o.OuterEnumIntegerDefaultValue != nil { - toSerialize["outerEnumIntegerDefaultValue"] = o.OuterEnumIntegerDefaultValue - } - return json.Marshal(toSerialize) +type NullableEnumTest struct { + Value EnumTest + ExplicitNull bool } +func (v NullableEnumTest) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableEnumTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file.go index a39a447e2b6..bff1e6aab19 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file.go @@ -8,17 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // File Must be named `File` for test. type File struct { // Test capitalization SourceURI *string `json:"sourceURI,omitempty"` - } -// GetSourceURI returns the SourceURI field if non-nil, zero value otherwise. +// GetSourceURI returns the SourceURI field value if set, zero value otherwise. func (o *File) GetSourceURI() string { if o == nil || o.SourceURI == nil { var ret string @@ -27,7 +29,7 @@ func (o *File) GetSourceURI() string { return *o.SourceURI } -// GetSourceURIOk returns a tuple with the SourceURI field if it's non-nil, zero value otherwise +// GetSourceURIOk returns a tuple with the SourceURI field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *File) GetSourceURIOk() (string, bool) { if o == nil || o.SourceURI == nil { @@ -51,14 +53,26 @@ func (o *File) SetSourceURI(v string) { o.SourceURI = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o File) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.SourceURI != nil { - toSerialize["sourceURI"] = o.SourceURI - } - return json.Marshal(toSerialize) +type NullableFile struct { + Value File + ExplicitNull bool } +func (v NullableFile) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFile) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go index ce392ac89d3..9a4c8d2293f 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // FileSchemaTestClass struct for FileSchemaTestClass type FileSchemaTestClass struct { File *File `json:"file,omitempty"` - Files *[]File `json:"files,omitempty"` - } -// GetFile returns the File field if non-nil, zero value otherwise. +// GetFile returns the File field value if set, zero value otherwise. func (o *FileSchemaTestClass) GetFile() File { if o == nil || o.File == nil { var ret File @@ -28,7 +29,7 @@ func (o *FileSchemaTestClass) GetFile() File { return *o.File } -// GetFileOk returns a tuple with the File field if it's non-nil, zero value otherwise +// GetFileOk returns a tuple with the File field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FileSchemaTestClass) GetFileOk() (File, bool) { if o == nil || o.File == nil { @@ -52,7 +53,7 @@ func (o *FileSchemaTestClass) SetFile(v File) { o.File = &v } -// GetFiles returns the Files field if non-nil, zero value otherwise. +// GetFiles returns the Files field value if set, zero value otherwise. func (o *FileSchemaTestClass) GetFiles() []File { if o == nil || o.Files == nil { var ret []File @@ -61,7 +62,7 @@ func (o *FileSchemaTestClass) GetFiles() []File { return *o.Files } -// GetFilesOk returns a tuple with the Files field if it's non-nil, zero value otherwise +// GetFilesOk returns a tuple with the Files field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FileSchemaTestClass) GetFilesOk() ([]File, bool) { if o == nil || o.Files == nil { @@ -85,17 +86,26 @@ func (o *FileSchemaTestClass) SetFiles(v []File) { o.Files = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o FileSchemaTestClass) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.File != nil { - toSerialize["file"] = o.File - } - if o.Files != nil { - toSerialize["files"] = o.Files - } - return json.Marshal(toSerialize) +type NullableFileSchemaTestClass struct { + Value FileSchemaTestClass + ExplicitNull bool } +func (v NullableFileSchemaTestClass) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFileSchemaTestClass) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_foo.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_foo.go index ae61f7394bf..4f8c45e3318 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_foo.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_foo.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // Foo struct for Foo type Foo struct { Bar *string `json:"bar,omitempty"` - } -// GetBar returns the Bar field if non-nil, zero value otherwise. +// GetBar returns the Bar field value if set, zero value otherwise. func (o *Foo) GetBar() string { if o == nil || o.Bar == nil { var ret string @@ -26,7 +28,7 @@ func (o *Foo) GetBar() string { return *o.Bar } -// GetBarOk returns a tuple with the Bar field if it's non-nil, zero value otherwise +// GetBarOk returns a tuple with the Bar field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Foo) GetBarOk() (string, bool) { if o == nil || o.Bar == nil { @@ -50,14 +52,26 @@ func (o *Foo) SetBar(v string) { o.Bar = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Foo) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Bar != nil { - toSerialize["bar"] = o.Bar - } - return json.Marshal(toSerialize) +type NullableFoo struct { + Value Foo + ExplicitNull bool } +func (v NullableFoo) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFoo) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_format_test_.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_format_test_.go index a544db31360..48639a972f3 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_format_test_.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_format_test_.go @@ -8,49 +8,36 @@ */ package openapi + import ( + "bytes" + "encoding/json" "os" "time" - "encoding/json" - "errors" ) + // FormatTest struct for FormatTest type FormatTest struct { Integer *int32 `json:"integer,omitempty"` - Int32 *int32 `json:"int32,omitempty"` - Int64 *int64 `json:"int64,omitempty"` - - Number *float32 `json:"number,omitempty"` - + Number float32 `json:"number"` Float *float32 `json:"float,omitempty"` - Double *float64 `json:"double,omitempty"` - String *string `json:"string,omitempty"` - - Byte *string `json:"byte,omitempty"` - + Byte string `json:"byte"` Binary **os.File `json:"binary,omitempty"` - - Date *string `json:"date,omitempty"` - + Date string `json:"date"` DateTime *time.Time `json:"dateTime,omitempty"` - Uuid *string `json:"uuid,omitempty"` - - Password *string `json:"password,omitempty"` - + Password string `json:"password"` // A string that is a 10 digit number. Can have leading zeros. PatternWithDigits *string `json:"pattern_with_digits,omitempty"` - // A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. PatternWithDigitsAndDelimiter *string `json:"pattern_with_digits_and_delimiter,omitempty"` - } -// GetInteger returns the Integer field if non-nil, zero value otherwise. +// GetInteger returns the Integer field value if set, zero value otherwise. func (o *FormatTest) GetInteger() int32 { if o == nil || o.Integer == nil { var ret int32 @@ -59,7 +46,7 @@ func (o *FormatTest) GetInteger() int32 { return *o.Integer } -// GetIntegerOk returns a tuple with the Integer field if it's non-nil, zero value otherwise +// GetIntegerOk returns a tuple with the Integer field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetIntegerOk() (int32, bool) { if o == nil || o.Integer == nil { @@ -83,7 +70,7 @@ func (o *FormatTest) SetInteger(v int32) { o.Integer = &v } -// GetInt32 returns the Int32 field if non-nil, zero value otherwise. +// GetInt32 returns the Int32 field value if set, zero value otherwise. func (o *FormatTest) GetInt32() int32 { if o == nil || o.Int32 == nil { var ret int32 @@ -92,7 +79,7 @@ func (o *FormatTest) GetInt32() int32 { return *o.Int32 } -// GetInt32Ok returns a tuple with the Int32 field if it's non-nil, zero value otherwise +// GetInt32Ok returns a tuple with the Int32 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetInt32Ok() (int32, bool) { if o == nil || o.Int32 == nil { @@ -116,7 +103,7 @@ func (o *FormatTest) SetInt32(v int32) { o.Int32 = &v } -// GetInt64 returns the Int64 field if non-nil, zero value otherwise. +// GetInt64 returns the Int64 field value if set, zero value otherwise. func (o *FormatTest) GetInt64() int64 { if o == nil || o.Int64 == nil { var ret int64 @@ -125,7 +112,7 @@ func (o *FormatTest) GetInt64() int64 { return *o.Int64 } -// GetInt64Ok returns a tuple with the Int64 field if it's non-nil, zero value otherwise +// GetInt64Ok returns a tuple with the Int64 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetInt64Ok() (int64, bool) { if o == nil || o.Int64 == nil { @@ -149,40 +136,22 @@ func (o *FormatTest) SetInt64(v int64) { o.Int64 = &v } -// GetNumber returns the Number field if non-nil, zero value otherwise. +// GetNumber returns the Number field value func (o *FormatTest) GetNumber() float32 { - if o == nil || o.Number == nil { + if o == nil { var ret float32 return ret } - return *o.Number + + return o.Number } -// GetNumberOk returns a tuple with the Number field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *FormatTest) GetNumberOk() (float32, bool) { - if o == nil || o.Number == nil { - var ret float32 - return ret, false - } - return *o.Number, true -} - -// HasNumber returns a boolean if a field has been set. -func (o *FormatTest) HasNumber() bool { - if o != nil && o.Number != nil { - return true - } - - return false -} - -// SetNumber gets a reference to the given float32 and assigns it to the Number field. +// SetNumber sets field value func (o *FormatTest) SetNumber(v float32) { - o.Number = &v + o.Number = v } -// GetFloat returns the Float field if non-nil, zero value otherwise. +// GetFloat returns the Float field value if set, zero value otherwise. func (o *FormatTest) GetFloat() float32 { if o == nil || o.Float == nil { var ret float32 @@ -191,7 +160,7 @@ func (o *FormatTest) GetFloat() float32 { return *o.Float } -// GetFloatOk returns a tuple with the Float field if it's non-nil, zero value otherwise +// GetFloatOk returns a tuple with the Float field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetFloatOk() (float32, bool) { if o == nil || o.Float == nil { @@ -215,7 +184,7 @@ func (o *FormatTest) SetFloat(v float32) { o.Float = &v } -// GetDouble returns the Double field if non-nil, zero value otherwise. +// GetDouble returns the Double field value if set, zero value otherwise. func (o *FormatTest) GetDouble() float64 { if o == nil || o.Double == nil { var ret float64 @@ -224,7 +193,7 @@ func (o *FormatTest) GetDouble() float64 { return *o.Double } -// GetDoubleOk returns a tuple with the Double field if it's non-nil, zero value otherwise +// GetDoubleOk returns a tuple with the Double field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetDoubleOk() (float64, bool) { if o == nil || o.Double == nil { @@ -248,7 +217,7 @@ func (o *FormatTest) SetDouble(v float64) { o.Double = &v } -// GetString returns the String field if non-nil, zero value otherwise. +// GetString returns the String field value if set, zero value otherwise. func (o *FormatTest) GetString() string { if o == nil || o.String == nil { var ret string @@ -257,7 +226,7 @@ func (o *FormatTest) GetString() string { return *o.String } -// GetStringOk returns a tuple with the String field if it's non-nil, zero value otherwise +// GetStringOk returns a tuple with the String field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetStringOk() (string, bool) { if o == nil || o.String == nil { @@ -281,40 +250,22 @@ func (o *FormatTest) SetString(v string) { o.String = &v } -// GetByte returns the Byte field if non-nil, zero value otherwise. +// GetByte returns the Byte field value func (o *FormatTest) GetByte() string { - if o == nil || o.Byte == nil { + if o == nil { var ret string return ret } - return *o.Byte + + return o.Byte } -// GetByteOk returns a tuple with the Byte field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *FormatTest) GetByteOk() (string, bool) { - if o == nil || o.Byte == nil { - var ret string - return ret, false - } - return *o.Byte, true -} - -// HasByte returns a boolean if a field has been set. -func (o *FormatTest) HasByte() bool { - if o != nil && o.Byte != nil { - return true - } - - return false -} - -// SetByte gets a reference to the given string and assigns it to the Byte field. +// SetByte sets field value func (o *FormatTest) SetByte(v string) { - o.Byte = &v + o.Byte = v } -// GetBinary returns the Binary field if non-nil, zero value otherwise. +// GetBinary returns the Binary field value if set, zero value otherwise. func (o *FormatTest) GetBinary() *os.File { if o == nil || o.Binary == nil { var ret *os.File @@ -323,7 +274,7 @@ func (o *FormatTest) GetBinary() *os.File { return *o.Binary } -// GetBinaryOk returns a tuple with the Binary field if it's non-nil, zero value otherwise +// GetBinaryOk returns a tuple with the Binary field value if set, zero value 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 { @@ -347,40 +298,22 @@ func (o *FormatTest) SetBinary(v *os.File) { o.Binary = &v } -// GetDate returns the Date field if non-nil, zero value otherwise. +// GetDate returns the Date field value func (o *FormatTest) GetDate() string { - if o == nil || o.Date == nil { + if o == nil { var ret string return ret } - return *o.Date + + return o.Date } -// GetDateOk returns a tuple with the Date field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *FormatTest) GetDateOk() (string, bool) { - if o == nil || o.Date == nil { - var ret string - return ret, false - } - return *o.Date, true -} - -// HasDate returns a boolean if a field has been set. -func (o *FormatTest) HasDate() bool { - if o != nil && o.Date != nil { - return true - } - - return false -} - -// SetDate gets a reference to the given string and assigns it to the Date field. +// SetDate sets field value func (o *FormatTest) SetDate(v string) { - o.Date = &v + o.Date = v } -// GetDateTime returns the DateTime field if non-nil, zero value otherwise. +// GetDateTime returns the DateTime field value if set, zero value otherwise. func (o *FormatTest) GetDateTime() time.Time { if o == nil || o.DateTime == nil { var ret time.Time @@ -389,7 +322,7 @@ func (o *FormatTest) GetDateTime() time.Time { return *o.DateTime } -// GetDateTimeOk returns a tuple with the DateTime field if it's non-nil, zero value otherwise +// GetDateTimeOk returns a tuple with the DateTime field value if set, zero value 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 { @@ -413,7 +346,7 @@ func (o *FormatTest) SetDateTime(v time.Time) { o.DateTime = &v } -// GetUuid returns the Uuid field if non-nil, zero value otherwise. +// GetUuid returns the Uuid field value if set, zero value otherwise. func (o *FormatTest) GetUuid() string { if o == nil || o.Uuid == nil { var ret string @@ -422,7 +355,7 @@ func (o *FormatTest) GetUuid() string { return *o.Uuid } -// GetUuidOk returns a tuple with the Uuid field if it's non-nil, zero value otherwise +// GetUuidOk returns a tuple with the Uuid field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetUuidOk() (string, bool) { if o == nil || o.Uuid == nil { @@ -446,40 +379,22 @@ func (o *FormatTest) SetUuid(v string) { o.Uuid = &v } -// GetPassword returns the Password field if non-nil, zero value otherwise. +// GetPassword returns the Password field value func (o *FormatTest) GetPassword() string { - if o == nil || o.Password == nil { + if o == nil { var ret string return ret } - return *o.Password + + return o.Password } -// GetPasswordOk returns a tuple with the Password field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *FormatTest) GetPasswordOk() (string, bool) { - if o == nil || o.Password == nil { - var ret string - return ret, false - } - return *o.Password, true -} - -// HasPassword returns a boolean if a field has been set. -func (o *FormatTest) HasPassword() bool { - if o != nil && o.Password != nil { - return true - } - - return false -} - -// SetPassword gets a reference to the given string and assigns it to the Password field. +// SetPassword sets field value func (o *FormatTest) SetPassword(v string) { - o.Password = &v + o.Password = v } -// GetPatternWithDigits returns the PatternWithDigits field if non-nil, zero value otherwise. +// GetPatternWithDigits returns the PatternWithDigits field value if set, zero value otherwise. func (o *FormatTest) GetPatternWithDigits() string { if o == nil || o.PatternWithDigits == nil { var ret string @@ -488,7 +403,7 @@ func (o *FormatTest) GetPatternWithDigits() string { return *o.PatternWithDigits } -// GetPatternWithDigitsOk returns a tuple with the PatternWithDigits field if it's non-nil, zero value otherwise +// GetPatternWithDigitsOk returns a tuple with the PatternWithDigits field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetPatternWithDigitsOk() (string, bool) { if o == nil || o.PatternWithDigits == nil { @@ -512,7 +427,7 @@ func (o *FormatTest) SetPatternWithDigits(v string) { o.PatternWithDigits = &v } -// GetPatternWithDigitsAndDelimiter returns the PatternWithDigitsAndDelimiter field if non-nil, zero value otherwise. +// GetPatternWithDigitsAndDelimiter returns the PatternWithDigitsAndDelimiter field value if set, zero value otherwise. func (o *FormatTest) GetPatternWithDigitsAndDelimiter() string { if o == nil || o.PatternWithDigitsAndDelimiter == nil { var ret string @@ -521,7 +436,7 @@ func (o *FormatTest) GetPatternWithDigitsAndDelimiter() string { return *o.PatternWithDigitsAndDelimiter } -// GetPatternWithDigitsAndDelimiterOk returns a tuple with the PatternWithDigitsAndDelimiter field if it's non-nil, zero value otherwise +// GetPatternWithDigitsAndDelimiterOk returns a tuple with the PatternWithDigitsAndDelimiter field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetPatternWithDigitsAndDelimiterOk() (string, bool) { if o == nil || o.PatternWithDigitsAndDelimiter == nil { @@ -545,68 +460,26 @@ func (o *FormatTest) SetPatternWithDigitsAndDelimiter(v string) { o.PatternWithDigitsAndDelimiter = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o FormatTest) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Integer != nil { - toSerialize["integer"] = o.Integer - } - if o.Int32 != nil { - toSerialize["int32"] = o.Int32 - } - if o.Int64 != nil { - toSerialize["int64"] = o.Int64 - } - if o.Number == nil { - return nil, errors.New("Number is required and not nullable, but was not set on FormatTest") - } - if o.Number != nil { - toSerialize["number"] = o.Number - } - if o.Float != nil { - toSerialize["float"] = o.Float - } - if o.Double != nil { - toSerialize["double"] = o.Double - } - if o.String != nil { - toSerialize["string"] = o.String - } - if o.Byte == nil { - return nil, errors.New("Byte is required and not nullable, but was not set on FormatTest") - } - if o.Byte != nil { - toSerialize["byte"] = o.Byte - } - if o.Binary != nil { - toSerialize["binary"] = o.Binary - } - if o.Date == nil { - return nil, errors.New("Date is required and not nullable, but was not set on FormatTest") - } - if o.Date != nil { - toSerialize["date"] = o.Date - } - if o.DateTime != nil { - toSerialize["dateTime"] = o.DateTime - } - if o.Uuid != nil { - toSerialize["uuid"] = o.Uuid - } - if o.Password == nil { - return nil, errors.New("Password is required and not nullable, but was not set on FormatTest") - } - if o.Password != nil { - toSerialize["password"] = o.Password - } - if o.PatternWithDigits != nil { - toSerialize["pattern_with_digits"] = o.PatternWithDigits - } - if o.PatternWithDigitsAndDelimiter != nil { - toSerialize["pattern_with_digits_and_delimiter"] = o.PatternWithDigitsAndDelimiter - } - return json.Marshal(toSerialize) +type NullableFormatTest struct { + Value FormatTest + ExplicitNull bool } +func (v NullableFormatTest) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFormatTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go index 708df847837..6ff753d0744 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // HasOnlyReadOnly struct for HasOnlyReadOnly type HasOnlyReadOnly struct { Bar *string `json:"bar,omitempty"` - Foo *string `json:"foo,omitempty"` - } -// GetBar returns the Bar field if non-nil, zero value otherwise. +// GetBar returns the Bar field value if set, zero value otherwise. func (o *HasOnlyReadOnly) GetBar() string { if o == nil || o.Bar == nil { var ret string @@ -28,7 +29,7 @@ func (o *HasOnlyReadOnly) GetBar() string { return *o.Bar } -// GetBarOk returns a tuple with the Bar field if it's non-nil, zero value otherwise +// GetBarOk returns a tuple with the Bar field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *HasOnlyReadOnly) GetBarOk() (string, bool) { if o == nil || o.Bar == nil { @@ -52,7 +53,7 @@ func (o *HasOnlyReadOnly) SetBar(v string) { o.Bar = &v } -// GetFoo returns the Foo field if non-nil, zero value otherwise. +// GetFoo returns the Foo field value if set, zero value otherwise. func (o *HasOnlyReadOnly) GetFoo() string { if o == nil || o.Foo == nil { var ret string @@ -61,7 +62,7 @@ func (o *HasOnlyReadOnly) GetFoo() string { return *o.Foo } -// GetFooOk returns a tuple with the Foo field if it's non-nil, zero value otherwise +// GetFooOk returns a tuple with the Foo field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *HasOnlyReadOnly) GetFooOk() (string, bool) { if o == nil || o.Foo == nil { @@ -85,17 +86,26 @@ func (o *HasOnlyReadOnly) SetFoo(v string) { o.Foo = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o HasOnlyReadOnly) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Bar != nil { - toSerialize["bar"] = o.Bar - } - if o.Foo != nil { - toSerialize["foo"] = o.Foo - } - return json.Marshal(toSerialize) +type NullableHasOnlyReadOnly struct { + Value HasOnlyReadOnly + ExplicitNull bool } +func (v NullableHasOnlyReadOnly) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableHasOnlyReadOnly) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_health_check_result.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_health_check_result.go index 6a83bf79144..936c1fc8880 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_health_check_result.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_health_check_result.go @@ -8,29 +8,31 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // 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 *string `json:"NullableMessage,omitempty"` - isExplicitNullNullableMessage bool `json:"-"` + NullableMessage *NullableString `json:"NullableMessage,omitempty"` } -// GetNullableMessage returns the NullableMessage field if non-nil, zero value otherwise. -func (o *HealthCheckResult) GetNullableMessage() string { +// GetNullableMessage returns the NullableMessage field value if set, zero value otherwise. +func (o *HealthCheckResult) GetNullableMessage() NullableString { if o == nil || o.NullableMessage == nil { - var ret string + var ret NullableString return ret } return *o.NullableMessage } -// GetNullableMessageOk returns a tuple with the NullableMessage field if it's non-nil, zero value otherwise +// GetNullableMessageOk returns a tuple with the NullableMessage field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *HealthCheckResult) GetNullableMessageOk() (string, bool) { +func (o *HealthCheckResult) GetNullableMessageOk() (NullableString, bool) { if o == nil || o.NullableMessage == nil { - var ret string + var ret NullableString return ret, false } return *o.NullableMessage, true @@ -45,30 +47,31 @@ func (o *HealthCheckResult) HasNullableMessage() bool { return false } -// SetNullableMessage gets a reference to the given string and assigns it to the NullableMessage field. -func (o *HealthCheckResult) SetNullableMessage(v string) { +// SetNullableMessage gets a reference to the given NullableString and assigns it to the NullableMessage field. +func (o *HealthCheckResult) SetNullableMessage(v NullableString) { o.NullableMessage = &v } -// SetNullableMessageExplicitNull (un)sets NullableMessage to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The NullableMessage value is set to nil even if false is passed -func (o *HealthCheckResult) SetNullableMessageExplicitNull(b bool) { - o.NullableMessage = nil - o.isExplicitNullNullableMessage = b +type NullableHealthCheckResult struct { + Value HealthCheckResult + ExplicitNull bool } -// MarshalJSON returns the JSON representation of the model. -func (o HealthCheckResult) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.NullableMessage == nil { - if o.isExplicitNullNullableMessage { - toSerialize["NullableMessage"] = o.NullableMessage - } - } else { - toSerialize["NullableMessage"] = o.NullableMessage +func (v NullableHealthCheckResult) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableHealthCheckResult) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - return json.Marshal(toSerialize) + + return json.Unmarshal(src, &v.Value) } - diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object.go index 830295fd4b9..1dd06726eb5 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object.go @@ -8,20 +8,21 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // InlineObject struct for InlineObject type InlineObject struct { // Updated name of the pet Name *string `json:"name,omitempty"` - // Updated status of the pet Status *string `json:"status,omitempty"` - } -// GetName returns the Name field if non-nil, zero value otherwise. +// GetName returns the Name field value if set, zero value otherwise. func (o *InlineObject) GetName() string { if o == nil || o.Name == nil { var ret string @@ -30,7 +31,7 @@ func (o *InlineObject) GetName() string { return *o.Name } -// GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +// GetNameOk returns a tuple with the Name field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -54,7 +55,7 @@ func (o *InlineObject) SetName(v string) { o.Name = &v } -// GetStatus returns the Status field if non-nil, zero value otherwise. +// GetStatus returns the Status field value if set, zero value otherwise. func (o *InlineObject) GetStatus() string { if o == nil || o.Status == nil { var ret string @@ -63,7 +64,7 @@ func (o *InlineObject) GetStatus() string { return *o.Status } -// GetStatusOk returns a tuple with the Status field if it's non-nil, zero value otherwise +// GetStatusOk returns a tuple with the Status field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject) GetStatusOk() (string, bool) { if o == nil || o.Status == nil { @@ -87,17 +88,26 @@ func (o *InlineObject) SetStatus(v string) { o.Status = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineObject) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name - } - if o.Status != nil { - toSerialize["status"] = o.Status - } - return json.Marshal(toSerialize) +type NullableInlineObject struct { + Value InlineObject + ExplicitNull bool } +func (v NullableInlineObject) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineObject) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_1.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_1.go index 0dc45833a76..9deaf79e09f 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_1.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_1.go @@ -8,21 +8,22 @@ */ package openapi + import ( - "os" + "bytes" "encoding/json" + "os" ) + // InlineObject1 struct for InlineObject1 type InlineObject1 struct { // Additional data to pass to server AdditionalMetadata *string `json:"additionalMetadata,omitempty"` - // file to upload File **os.File `json:"file,omitempty"` - } -// GetAdditionalMetadata returns the AdditionalMetadata field if non-nil, zero value otherwise. +// GetAdditionalMetadata returns the AdditionalMetadata field value if set, zero value otherwise. func (o *InlineObject1) GetAdditionalMetadata() string { if o == nil || o.AdditionalMetadata == nil { var ret string @@ -31,7 +32,7 @@ func (o *InlineObject1) GetAdditionalMetadata() string { return *o.AdditionalMetadata } -// GetAdditionalMetadataOk returns a tuple with the AdditionalMetadata field if it's non-nil, zero value otherwise +// GetAdditionalMetadataOk returns a tuple with the AdditionalMetadata field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject1) GetAdditionalMetadataOk() (string, bool) { if o == nil || o.AdditionalMetadata == nil { @@ -55,7 +56,7 @@ func (o *InlineObject1) SetAdditionalMetadata(v string) { o.AdditionalMetadata = &v } -// GetFile returns the File field if non-nil, zero value otherwise. +// GetFile returns the File field value if set, zero value otherwise. func (o *InlineObject1) GetFile() *os.File { if o == nil || o.File == nil { var ret *os.File @@ -64,7 +65,7 @@ func (o *InlineObject1) GetFile() *os.File { return *o.File } -// GetFileOk returns a tuple with the File field if it's non-nil, zero value otherwise +// GetFileOk returns a tuple with the File field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject1) GetFileOk() (*os.File, bool) { if o == nil || o.File == nil { @@ -88,17 +89,26 @@ func (o *InlineObject1) SetFile(v *os.File) { o.File = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineObject1) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.AdditionalMetadata != nil { - toSerialize["additionalMetadata"] = o.AdditionalMetadata - } - if o.File != nil { - toSerialize["file"] = o.File - } - return json.Marshal(toSerialize) +type NullableInlineObject1 struct { + Value InlineObject1 + ExplicitNull bool } +func (v NullableInlineObject1) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineObject1) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_2.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_2.go index 4b1bf9ec3a2..9db10a658bb 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_2.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_2.go @@ -8,20 +8,21 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // InlineObject2 struct for InlineObject2 type InlineObject2 struct { // Form parameter enum test (string array) EnumFormStringArray *[]string `json:"enum_form_string_array,omitempty"` - // Form parameter enum test (string) EnumFormString *string `json:"enum_form_string,omitempty"` - } -// GetEnumFormStringArray returns the EnumFormStringArray field if non-nil, zero value otherwise. +// GetEnumFormStringArray returns the EnumFormStringArray field value if set, zero value otherwise. func (o *InlineObject2) GetEnumFormStringArray() []string { if o == nil || o.EnumFormStringArray == nil { var ret []string @@ -30,7 +31,7 @@ func (o *InlineObject2) GetEnumFormStringArray() []string { return *o.EnumFormStringArray } -// GetEnumFormStringArrayOk returns a tuple with the EnumFormStringArray field if it's non-nil, zero value otherwise +// GetEnumFormStringArrayOk returns a tuple with the EnumFormStringArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject2) GetEnumFormStringArrayOk() ([]string, bool) { if o == nil || o.EnumFormStringArray == nil { @@ -54,7 +55,7 @@ func (o *InlineObject2) SetEnumFormStringArray(v []string) { o.EnumFormStringArray = &v } -// GetEnumFormString returns the EnumFormString field if non-nil, zero value otherwise. +// GetEnumFormString returns the EnumFormString field value if set, zero value otherwise. func (o *InlineObject2) GetEnumFormString() string { if o == nil || o.EnumFormString == nil { var ret string @@ -63,7 +64,7 @@ func (o *InlineObject2) GetEnumFormString() string { return *o.EnumFormString } -// GetEnumFormStringOk returns a tuple with the EnumFormString field if it's non-nil, zero value otherwise +// GetEnumFormStringOk returns a tuple with the EnumFormString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject2) GetEnumFormStringOk() (string, bool) { if o == nil || o.EnumFormString == nil { @@ -87,17 +88,26 @@ func (o *InlineObject2) SetEnumFormString(v string) { o.EnumFormString = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineObject2) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.EnumFormStringArray != nil { - toSerialize["enum_form_string_array"] = o.EnumFormStringArray - } - if o.EnumFormString != nil { - toSerialize["enum_form_string"] = o.EnumFormString - } - return json.Marshal(toSerialize) +type NullableInlineObject2 struct { + Value InlineObject2 + ExplicitNull bool } +func (v NullableInlineObject2) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineObject2) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_3.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_3.go index 54dd573d90c..17c1a53b2fc 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_3.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_3.go @@ -8,59 +8,47 @@ */ package openapi + import ( + "bytes" + "encoding/json" "os" "time" - "encoding/json" - "errors" ) + // InlineObject3 struct for InlineObject3 type InlineObject3 struct { // None Integer *int32 `json:"integer,omitempty"` - // None Int32 *int32 `json:"int32,omitempty"` - // None Int64 *int64 `json:"int64,omitempty"` - // None - Number *float32 `json:"number,omitempty"` - + Number float32 `json:"number"` // None Float *float32 `json:"float,omitempty"` - // None - Double *float64 `json:"double,omitempty"` - + Double float64 `json:"double"` // None String *string `json:"string,omitempty"` - // None - PatternWithoutDelimiter *string `json:"pattern_without_delimiter,omitempty"` - + PatternWithoutDelimiter string `json:"pattern_without_delimiter"` // None - Byte *string `json:"byte,omitempty"` - + Byte string `json:"byte"` // None Binary **os.File `json:"binary,omitempty"` - // None Date *string `json:"date,omitempty"` - // None DateTime *time.Time `json:"dateTime,omitempty"` - // None Password *string `json:"password,omitempty"` - // None Callback *string `json:"callback,omitempty"` - } -// GetInteger returns the Integer field if non-nil, zero value otherwise. +// GetInteger returns the Integer field value if set, zero value otherwise. func (o *InlineObject3) GetInteger() int32 { if o == nil || o.Integer == nil { var ret int32 @@ -69,7 +57,7 @@ func (o *InlineObject3) GetInteger() int32 { return *o.Integer } -// GetIntegerOk returns a tuple with the Integer field if it's non-nil, zero value otherwise +// GetIntegerOk returns a tuple with the Integer field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetIntegerOk() (int32, bool) { if o == nil || o.Integer == nil { @@ -93,7 +81,7 @@ func (o *InlineObject3) SetInteger(v int32) { o.Integer = &v } -// GetInt32 returns the Int32 field if non-nil, zero value otherwise. +// GetInt32 returns the Int32 field value if set, zero value otherwise. func (o *InlineObject3) GetInt32() int32 { if o == nil || o.Int32 == nil { var ret int32 @@ -102,7 +90,7 @@ func (o *InlineObject3) GetInt32() int32 { return *o.Int32 } -// GetInt32Ok returns a tuple with the Int32 field if it's non-nil, zero value otherwise +// GetInt32Ok returns a tuple with the Int32 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetInt32Ok() (int32, bool) { if o == nil || o.Int32 == nil { @@ -126,7 +114,7 @@ func (o *InlineObject3) SetInt32(v int32) { o.Int32 = &v } -// GetInt64 returns the Int64 field if non-nil, zero value otherwise. +// GetInt64 returns the Int64 field value if set, zero value otherwise. func (o *InlineObject3) GetInt64() int64 { if o == nil || o.Int64 == nil { var ret int64 @@ -135,7 +123,7 @@ func (o *InlineObject3) GetInt64() int64 { return *o.Int64 } -// GetInt64Ok returns a tuple with the Int64 field if it's non-nil, zero value otherwise +// GetInt64Ok returns a tuple with the Int64 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetInt64Ok() (int64, bool) { if o == nil || o.Int64 == nil { @@ -159,40 +147,22 @@ func (o *InlineObject3) SetInt64(v int64) { o.Int64 = &v } -// GetNumber returns the Number field if non-nil, zero value otherwise. +// GetNumber returns the Number field value func (o *InlineObject3) GetNumber() float32 { - if o == nil || o.Number == nil { + if o == nil { var ret float32 return ret } - return *o.Number + + return o.Number } -// GetNumberOk returns a tuple with the Number field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject3) GetNumberOk() (float32, bool) { - if o == nil || o.Number == nil { - var ret float32 - return ret, false - } - return *o.Number, true -} - -// HasNumber returns a boolean if a field has been set. -func (o *InlineObject3) HasNumber() bool { - if o != nil && o.Number != nil { - return true - } - - return false -} - -// SetNumber gets a reference to the given float32 and assigns it to the Number field. +// SetNumber sets field value func (o *InlineObject3) SetNumber(v float32) { - o.Number = &v + o.Number = v } -// GetFloat returns the Float field if non-nil, zero value otherwise. +// GetFloat returns the Float field value if set, zero value otherwise. func (o *InlineObject3) GetFloat() float32 { if o == nil || o.Float == nil { var ret float32 @@ -201,7 +171,7 @@ func (o *InlineObject3) GetFloat() float32 { return *o.Float } -// GetFloatOk returns a tuple with the Float field if it's non-nil, zero value otherwise +// GetFloatOk returns a tuple with the Float field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetFloatOk() (float32, bool) { if o == nil || o.Float == nil { @@ -225,40 +195,22 @@ func (o *InlineObject3) SetFloat(v float32) { o.Float = &v } -// GetDouble returns the Double field if non-nil, zero value otherwise. +// GetDouble returns the Double field value func (o *InlineObject3) GetDouble() float64 { - if o == nil || o.Double == nil { + if o == nil { var ret float64 return ret } - return *o.Double + + return o.Double } -// GetDoubleOk returns a tuple with the Double field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject3) GetDoubleOk() (float64, bool) { - if o == nil || o.Double == nil { - var ret float64 - return ret, false - } - return *o.Double, true -} - -// HasDouble returns a boolean if a field has been set. -func (o *InlineObject3) HasDouble() bool { - if o != nil && o.Double != nil { - return true - } - - return false -} - -// SetDouble gets a reference to the given float64 and assigns it to the Double field. +// SetDouble sets field value func (o *InlineObject3) SetDouble(v float64) { - o.Double = &v + o.Double = v } -// GetString returns the String field if non-nil, zero value otherwise. +// GetString returns the String field value if set, zero value otherwise. func (o *InlineObject3) GetString() string { if o == nil || o.String == nil { var ret string @@ -267,7 +219,7 @@ func (o *InlineObject3) GetString() string { return *o.String } -// GetStringOk returns a tuple with the String field if it's non-nil, zero value otherwise +// GetStringOk returns a tuple with the String field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetStringOk() (string, bool) { if o == nil || o.String == nil { @@ -291,73 +243,37 @@ func (o *InlineObject3) SetString(v string) { o.String = &v } -// GetPatternWithoutDelimiter returns the PatternWithoutDelimiter field if non-nil, zero value otherwise. +// GetPatternWithoutDelimiter returns the PatternWithoutDelimiter field value func (o *InlineObject3) GetPatternWithoutDelimiter() string { - if o == nil || o.PatternWithoutDelimiter == nil { + if o == nil { var ret string return ret } - return *o.PatternWithoutDelimiter + + return o.PatternWithoutDelimiter } -// GetPatternWithoutDelimiterOk returns a tuple with the PatternWithoutDelimiter field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject3) GetPatternWithoutDelimiterOk() (string, bool) { - if o == nil || o.PatternWithoutDelimiter == nil { - var ret string - return ret, false - } - return *o.PatternWithoutDelimiter, true -} - -// HasPatternWithoutDelimiter returns a boolean if a field has been set. -func (o *InlineObject3) HasPatternWithoutDelimiter() bool { - if o != nil && o.PatternWithoutDelimiter != nil { - return true - } - - return false -} - -// SetPatternWithoutDelimiter gets a reference to the given string and assigns it to the PatternWithoutDelimiter field. +// SetPatternWithoutDelimiter sets field value func (o *InlineObject3) SetPatternWithoutDelimiter(v string) { - o.PatternWithoutDelimiter = &v + o.PatternWithoutDelimiter = v } -// GetByte returns the Byte field if non-nil, zero value otherwise. +// GetByte returns the Byte field value func (o *InlineObject3) GetByte() string { - if o == nil || o.Byte == nil { + if o == nil { var ret string return ret } - return *o.Byte + + return o.Byte } -// GetByteOk returns a tuple with the Byte field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject3) GetByteOk() (string, bool) { - if o == nil || o.Byte == nil { - var ret string - return ret, false - } - return *o.Byte, true -} - -// HasByte returns a boolean if a field has been set. -func (o *InlineObject3) HasByte() bool { - if o != nil && o.Byte != nil { - return true - } - - return false -} - -// SetByte gets a reference to the given string and assigns it to the Byte field. +// SetByte sets field value func (o *InlineObject3) SetByte(v string) { - o.Byte = &v + o.Byte = v } -// GetBinary returns the Binary field if non-nil, zero value otherwise. +// GetBinary returns the Binary field value if set, zero value otherwise. func (o *InlineObject3) GetBinary() *os.File { if o == nil || o.Binary == nil { var ret *os.File @@ -366,7 +282,7 @@ func (o *InlineObject3) GetBinary() *os.File { return *o.Binary } -// GetBinaryOk returns a tuple with the Binary field if it's non-nil, zero value otherwise +// GetBinaryOk returns a tuple with the Binary field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetBinaryOk() (*os.File, bool) { if o == nil || o.Binary == nil { @@ -390,7 +306,7 @@ func (o *InlineObject3) SetBinary(v *os.File) { o.Binary = &v } -// GetDate returns the Date field if non-nil, zero value otherwise. +// GetDate returns the Date field value if set, zero value otherwise. func (o *InlineObject3) GetDate() string { if o == nil || o.Date == nil { var ret string @@ -399,7 +315,7 @@ func (o *InlineObject3) GetDate() string { return *o.Date } -// GetDateOk returns a tuple with the Date field if it's non-nil, zero value otherwise +// GetDateOk returns a tuple with the Date field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetDateOk() (string, bool) { if o == nil || o.Date == nil { @@ -423,7 +339,7 @@ func (o *InlineObject3) SetDate(v string) { o.Date = &v } -// GetDateTime returns the DateTime field if non-nil, zero value otherwise. +// GetDateTime returns the DateTime field value if set, zero value otherwise. func (o *InlineObject3) GetDateTime() time.Time { if o == nil || o.DateTime == nil { var ret time.Time @@ -432,7 +348,7 @@ func (o *InlineObject3) GetDateTime() time.Time { return *o.DateTime } -// GetDateTimeOk returns a tuple with the DateTime field if it's non-nil, zero value otherwise +// GetDateTimeOk returns a tuple with the DateTime field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetDateTimeOk() (time.Time, bool) { if o == nil || o.DateTime == nil { @@ -456,7 +372,7 @@ func (o *InlineObject3) SetDateTime(v time.Time) { o.DateTime = &v } -// GetPassword returns the Password field if non-nil, zero value otherwise. +// GetPassword returns the Password field value if set, zero value otherwise. func (o *InlineObject3) GetPassword() string { if o == nil || o.Password == nil { var ret string @@ -465,7 +381,7 @@ func (o *InlineObject3) GetPassword() string { return *o.Password } -// GetPasswordOk returns a tuple with the Password field if it's non-nil, zero value otherwise +// GetPasswordOk returns a tuple with the Password field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetPasswordOk() (string, bool) { if o == nil || o.Password == nil { @@ -489,7 +405,7 @@ func (o *InlineObject3) SetPassword(v string) { o.Password = &v } -// GetCallback returns the Callback field if non-nil, zero value otherwise. +// GetCallback returns the Callback field value if set, zero value otherwise. func (o *InlineObject3) GetCallback() string { if o == nil || o.Callback == nil { var ret string @@ -498,7 +414,7 @@ func (o *InlineObject3) GetCallback() string { return *o.Callback } -// GetCallbackOk returns a tuple with the Callback field if it's non-nil, zero value otherwise +// GetCallbackOk returns a tuple with the Callback field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject3) GetCallbackOk() (string, bool) { if o == nil || o.Callback == nil { @@ -522,65 +438,26 @@ func (o *InlineObject3) SetCallback(v string) { o.Callback = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineObject3) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Integer != nil { - toSerialize["integer"] = o.Integer - } - if o.Int32 != nil { - toSerialize["int32"] = o.Int32 - } - if o.Int64 != nil { - toSerialize["int64"] = o.Int64 - } - if o.Number == nil { - return nil, errors.New("Number is required and not nullable, but was not set on InlineObject3") - } - if o.Number != nil { - toSerialize["number"] = o.Number - } - if o.Float != nil { - toSerialize["float"] = o.Float - } - if o.Double == nil { - return nil, errors.New("Double is required and not nullable, but was not set on InlineObject3") - } - if o.Double != nil { - toSerialize["double"] = o.Double - } - if o.String != nil { - toSerialize["string"] = o.String - } - if o.PatternWithoutDelimiter == nil { - return nil, errors.New("PatternWithoutDelimiter is required and not nullable, but was not set on InlineObject3") - } - if o.PatternWithoutDelimiter != nil { - toSerialize["pattern_without_delimiter"] = o.PatternWithoutDelimiter - } - if o.Byte == nil { - return nil, errors.New("Byte is required and not nullable, but was not set on InlineObject3") - } - if o.Byte != nil { - toSerialize["byte"] = o.Byte - } - if o.Binary != nil { - toSerialize["binary"] = o.Binary - } - if o.Date != nil { - toSerialize["date"] = o.Date - } - if o.DateTime != nil { - toSerialize["dateTime"] = o.DateTime - } - if o.Password != nil { - toSerialize["password"] = o.Password - } - if o.Callback != nil { - toSerialize["callback"] = o.Callback - } - return json.Marshal(toSerialize) +type NullableInlineObject3 struct { + Value InlineObject3 + ExplicitNull bool } +func (v NullableInlineObject3) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineObject3) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_4.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_4.go index 761f535d074..ec72ab8d1f1 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_4.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_4.go @@ -8,103 +8,70 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // InlineObject4 struct for InlineObject4 type InlineObject4 struct { // field1 - Param *string `json:"param,omitempty"` - + Param string `json:"param"` // field2 - Param2 *string `json:"param2,omitempty"` - + Param2 string `json:"param2"` } -// GetParam returns the Param field if non-nil, zero value otherwise. +// GetParam returns the Param field value func (o *InlineObject4) GetParam() string { - if o == nil || o.Param == nil { + if o == nil { var ret string return ret } - return *o.Param + + return o.Param } -// GetParamOk returns a tuple with the Param field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject4) GetParamOk() (string, bool) { - if o == nil || o.Param == nil { - var ret string - return ret, false - } - return *o.Param, true -} - -// HasParam returns a boolean if a field has been set. -func (o *InlineObject4) HasParam() bool { - if o != nil && o.Param != nil { - return true - } - - return false -} - -// SetParam gets a reference to the given string and assigns it to the Param field. +// SetParam sets field value func (o *InlineObject4) SetParam(v string) { - o.Param = &v + o.Param = v } -// GetParam2 returns the Param2 field if non-nil, zero value otherwise. +// GetParam2 returns the Param2 field value func (o *InlineObject4) GetParam2() string { - if o == nil || o.Param2 == nil { + if o == nil { var ret string return ret } - return *o.Param2 + + return o.Param2 } -// GetParam2Ok returns a tuple with the Param2 field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject4) GetParam2Ok() (string, bool) { - if o == nil || o.Param2 == nil { - var ret string - return ret, false - } - return *o.Param2, true -} - -// HasParam2 returns a boolean if a field has been set. -func (o *InlineObject4) HasParam2() bool { - if o != nil && o.Param2 != nil { - return true - } - - return false -} - -// SetParam2 gets a reference to the given string and assigns it to the Param2 field. +// SetParam2 sets field value func (o *InlineObject4) SetParam2(v string) { - o.Param2 = &v + o.Param2 = v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineObject4) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Param == nil { - return nil, errors.New("Param is required and not nullable, but was not set on InlineObject4") - } - if o.Param != nil { - toSerialize["param"] = o.Param - } - if o.Param2 == nil { - return nil, errors.New("Param2 is required and not nullable, but was not set on InlineObject4") - } - if o.Param2 != nil { - toSerialize["param2"] = o.Param2 - } - return json.Marshal(toSerialize) +type NullableInlineObject4 struct { + Value InlineObject4 + ExplicitNull bool } +func (v NullableInlineObject4) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineObject4) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_5.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_5.go index 3699a33df46..c65df83e7af 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_5.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_object_5.go @@ -8,22 +8,22 @@ */ package openapi + import ( - "os" + "bytes" "encoding/json" - "errors" + "os" ) + // InlineObject5 struct for InlineObject5 type InlineObject5 struct { // Additional data to pass to server AdditionalMetadata *string `json:"additionalMetadata,omitempty"` - // file to upload - RequiredFile **os.File `json:"requiredFile,omitempty"` - + RequiredFile *os.File `json:"requiredFile"` } -// GetAdditionalMetadata returns the AdditionalMetadata field if non-nil, zero value otherwise. +// GetAdditionalMetadata returns the AdditionalMetadata field value if set, zero value otherwise. func (o *InlineObject5) GetAdditionalMetadata() string { if o == nil || o.AdditionalMetadata == nil { var ret string @@ -32,7 +32,7 @@ func (o *InlineObject5) GetAdditionalMetadata() string { return *o.AdditionalMetadata } -// GetAdditionalMetadataOk returns a tuple with the AdditionalMetadata field if it's non-nil, zero value otherwise +// GetAdditionalMetadataOk returns a tuple with the AdditionalMetadata field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineObject5) GetAdditionalMetadataOk() (string, bool) { if o == nil || o.AdditionalMetadata == nil { @@ -56,53 +56,41 @@ func (o *InlineObject5) SetAdditionalMetadata(v string) { o.AdditionalMetadata = &v } -// GetRequiredFile returns the RequiredFile field if non-nil, zero value otherwise. +// GetRequiredFile returns the RequiredFile field value func (o *InlineObject5) GetRequiredFile() *os.File { - if o == nil || o.RequiredFile == nil { + if o == nil { var ret *os.File return ret } - return *o.RequiredFile + + return o.RequiredFile } -// GetRequiredFileOk returns a tuple with the RequiredFile field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *InlineObject5) GetRequiredFileOk() (*os.File, bool) { - if o == nil || o.RequiredFile == nil { - var ret *os.File - return ret, false - } - return *o.RequiredFile, true -} - -// HasRequiredFile returns a boolean if a field has been set. -func (o *InlineObject5) HasRequiredFile() bool { - if o != nil && o.RequiredFile != nil { - return true - } - - return false -} - -// SetRequiredFile gets a reference to the given *os.File and assigns it to the RequiredFile field. +// SetRequiredFile sets field value func (o *InlineObject5) SetRequiredFile(v *os.File) { - o.RequiredFile = &v + o.RequiredFile = v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineObject5) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.AdditionalMetadata != nil { - toSerialize["additionalMetadata"] = o.AdditionalMetadata - } - if o.RequiredFile == nil { - return nil, errors.New("RequiredFile is required and not nullable, but was not set on InlineObject5") - } - if o.RequiredFile != nil { - toSerialize["requiredFile"] = o.RequiredFile - } - return json.Marshal(toSerialize) +type NullableInlineObject5 struct { + Value InlineObject5 + ExplicitNull bool } +func (v NullableInlineObject5) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineObject5) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_response_default.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_response_default.go index 024ad4f84ea..5d974dfc4c6 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_response_default.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_inline_response_default.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // InlineResponseDefault struct for InlineResponseDefault type InlineResponseDefault struct { String *Foo `json:"string,omitempty"` - } -// GetString returns the String field if non-nil, zero value otherwise. +// GetString returns the String field value if set, zero value otherwise. func (o *InlineResponseDefault) GetString() Foo { if o == nil || o.String == nil { var ret Foo @@ -26,7 +28,7 @@ func (o *InlineResponseDefault) GetString() Foo { return *o.String } -// GetStringOk returns a tuple with the String field if it's non-nil, zero value otherwise +// GetStringOk returns a tuple with the String field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *InlineResponseDefault) GetStringOk() (Foo, bool) { if o == nil || o.String == nil { @@ -50,14 +52,26 @@ func (o *InlineResponseDefault) SetString(v Foo) { o.String = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o InlineResponseDefault) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.String != nil { - toSerialize["string"] = o.String - } - return json.Marshal(toSerialize) +type NullableInlineResponseDefault struct { + Value InlineResponseDefault + ExplicitNull bool } +func (v NullableInlineResponseDefault) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInlineResponseDefault) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_list.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_list.go index efa6dfd86a1..70b77ab6642 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_list.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_list.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // List struct for List type List struct { Var123List *string `json:"123-list,omitempty"` - } -// GetVar123List returns the Var123List field if non-nil, zero value otherwise. +// GetVar123List returns the Var123List field value if set, zero value otherwise. func (o *List) GetVar123List() string { if o == nil || o.Var123List == nil { var ret string @@ -26,7 +28,7 @@ func (o *List) GetVar123List() string { return *o.Var123List } -// GetVar123ListOk returns a tuple with the Var123List field if it's non-nil, zero value otherwise +// GetVar123ListOk returns a tuple with the Var123List field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *List) GetVar123ListOk() (string, bool) { if o == nil || o.Var123List == nil { @@ -50,14 +52,26 @@ func (o *List) SetVar123List(v string) { o.Var123List = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o List) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Var123List != nil { - toSerialize["123-list"] = o.Var123List - } - return json.Marshal(toSerialize) +type NullableList struct { + Value List + ExplicitNull bool } +func (v NullableList) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableList) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_map_test_.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_map_test_.go index d934df451ae..a0731be7850 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_map_test_.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_map_test_.go @@ -8,22 +8,21 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // MapTest struct for MapTest type MapTest struct { MapMapOfString *map[string]map[string]string `json:"map_map_of_string,omitempty"` - MapOfEnumString *map[string]string `json:"map_of_enum_string,omitempty"` - DirectMap *map[string]bool `json:"direct_map,omitempty"` - IndirectMap *map[string]bool `json:"indirect_map,omitempty"` - } -// GetMapMapOfString returns the MapMapOfString field if non-nil, zero value otherwise. +// 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 { var ret map[string]map[string]string @@ -32,7 +31,7 @@ func (o *MapTest) GetMapMapOfString() map[string]map[string]string { return *o.MapMapOfString } -// GetMapMapOfStringOk returns a tuple with the MapMapOfString field if it's non-nil, zero value otherwise +// GetMapMapOfStringOk returns a tuple with the MapMapOfString field value if set, zero value 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 { @@ -56,7 +55,7 @@ func (o *MapTest) SetMapMapOfString(v map[string]map[string]string) { o.MapMapOfString = &v } -// GetMapOfEnumString returns the MapOfEnumString field if non-nil, zero value otherwise. +// GetMapOfEnumString returns the MapOfEnumString field value if set, zero value otherwise. func (o *MapTest) GetMapOfEnumString() map[string]string { if o == nil || o.MapOfEnumString == nil { var ret map[string]string @@ -65,7 +64,7 @@ func (o *MapTest) GetMapOfEnumString() map[string]string { return *o.MapOfEnumString } -// GetMapOfEnumStringOk returns a tuple with the MapOfEnumString field if it's non-nil, zero value otherwise +// GetMapOfEnumStringOk returns a tuple with the MapOfEnumString field value if set, zero value 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 { @@ -89,7 +88,7 @@ func (o *MapTest) SetMapOfEnumString(v map[string]string) { o.MapOfEnumString = &v } -// GetDirectMap returns the DirectMap field if non-nil, zero value otherwise. +// GetDirectMap returns the DirectMap field value if set, zero value otherwise. func (o *MapTest) GetDirectMap() map[string]bool { if o == nil || o.DirectMap == nil { var ret map[string]bool @@ -98,7 +97,7 @@ func (o *MapTest) GetDirectMap() map[string]bool { return *o.DirectMap } -// GetDirectMapOk returns a tuple with the DirectMap field if it's non-nil, zero value otherwise +// GetDirectMapOk returns a tuple with the DirectMap field value if set, zero value 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 { @@ -122,7 +121,7 @@ func (o *MapTest) SetDirectMap(v map[string]bool) { o.DirectMap = &v } -// GetIndirectMap returns the IndirectMap field if non-nil, zero value otherwise. +// GetIndirectMap returns the IndirectMap field value if set, zero value otherwise. func (o *MapTest) GetIndirectMap() map[string]bool { if o == nil || o.IndirectMap == nil { var ret map[string]bool @@ -131,7 +130,7 @@ func (o *MapTest) GetIndirectMap() map[string]bool { return *o.IndirectMap } -// GetIndirectMapOk returns a tuple with the IndirectMap field if it's non-nil, zero value otherwise +// GetIndirectMapOk returns a tuple with the IndirectMap field value if set, zero value 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 { @@ -155,23 +154,26 @@ func (o *MapTest) SetIndirectMap(v map[string]bool) { o.IndirectMap = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o MapTest) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.MapMapOfString != nil { - toSerialize["map_map_of_string"] = o.MapMapOfString - } - if o.MapOfEnumString != nil { - toSerialize["map_of_enum_string"] = o.MapOfEnumString - } - if o.DirectMap != nil { - toSerialize["direct_map"] = o.DirectMap - } - if o.IndirectMap != nil { - toSerialize["indirect_map"] = o.IndirectMap - } - return json.Marshal(toSerialize) +type NullableMapTest struct { + Value MapTest + ExplicitNull bool } +func (v NullableMapTest) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableMapTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go index d4756b2da4f..4ccc42689a3 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go @@ -8,21 +8,21 @@ */ package openapi + import ( - "time" + "bytes" "encoding/json" + "time" ) + // MixedPropertiesAndAdditionalPropertiesClass struct for MixedPropertiesAndAdditionalPropertiesClass type MixedPropertiesAndAdditionalPropertiesClass struct { Uuid *string `json:"uuid,omitempty"` - DateTime *time.Time `json:"dateTime,omitempty"` - Map *map[string]Animal `json:"map,omitempty"` - } -// GetUuid returns the Uuid field if non-nil, zero value otherwise. +// GetUuid returns the Uuid field value if set, zero value otherwise. func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string { if o == nil || o.Uuid == nil { var ret string @@ -31,7 +31,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuid() string { return *o.Uuid } -// GetUuidOk returns a tuple with the Uuid field if it's non-nil, zero value otherwise +// GetUuidOk returns a tuple with the Uuid field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *MixedPropertiesAndAdditionalPropertiesClass) GetUuidOk() (string, bool) { if o == nil || o.Uuid == nil { @@ -55,7 +55,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetUuid(v string) { o.Uuid = &v } -// GetDateTime returns the DateTime field if non-nil, zero value otherwise. +// GetDateTime returns the DateTime field value if set, zero value otherwise. func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time { if o == nil || o.DateTime == nil { var ret time.Time @@ -64,7 +64,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetDateTime() time.Time { return *o.DateTime } -// GetDateTimeOk returns a tuple with the DateTime field if it's non-nil, zero value otherwise +// GetDateTimeOk returns a tuple with the DateTime field value if set, zero value 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 { @@ -88,7 +88,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetDateTime(v time.Time) { o.DateTime = &v } -// GetMap returns the Map field if non-nil, zero value otherwise. +// GetMap returns the Map field value if set, zero value otherwise. func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal { if o == nil || o.Map == nil { var ret map[string]Animal @@ -97,7 +97,7 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) GetMap() map[string]Animal return *o.Map } -// GetMapOk returns a tuple with the Map field if it's non-nil, zero value otherwise +// GetMapOk returns a tuple with the Map field value if set, zero value 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 { @@ -121,20 +121,26 @@ func (o *MixedPropertiesAndAdditionalPropertiesClass) SetMap(v map[string]Animal o.Map = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o MixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Uuid != nil { - toSerialize["uuid"] = o.Uuid - } - if o.DateTime != nil { - toSerialize["dateTime"] = o.DateTime - } - if o.Map != nil { - toSerialize["map"] = o.Map - } - return json.Marshal(toSerialize) +type NullableMixedPropertiesAndAdditionalPropertiesClass struct { + Value MixedPropertiesAndAdditionalPropertiesClass + ExplicitNull bool } +func (v NullableMixedPropertiesAndAdditionalPropertiesClass) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableMixedPropertiesAndAdditionalPropertiesClass) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_name.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_name.go index 78990e5e97a..b37ee67d233 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_name.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_name.go @@ -8,56 +8,36 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // Name Model for testing model name same as property name type Name struct { - Name *int32 `json:"name,omitempty"` - + Name int32 `json:"name"` SnakeCase *int32 `json:"snake_case,omitempty"` - Property *string `json:"property,omitempty"` - Var123Number *int32 `json:"123Number,omitempty"` - } -// GetName returns the Name field if non-nil, zero value otherwise. +// GetName returns the Name field value func (o *Name) GetName() int32 { - if o == nil || o.Name == nil { + if o == nil { var ret int32 return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Name) GetNameOk() (int32, bool) { - if o == nil || o.Name == nil { - var ret int32 - return ret, false - } - return *o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *Name) HasName() bool { - if o != nil && o.Name != nil { - return true - } - - return false -} - -// SetName gets a reference to the given int32 and assigns it to the Name field. +// SetName sets field value func (o *Name) SetName(v int32) { - o.Name = &v + o.Name = v } -// GetSnakeCase returns the SnakeCase field if non-nil, zero value otherwise. +// GetSnakeCase returns the SnakeCase field value if set, zero value otherwise. func (o *Name) GetSnakeCase() int32 { if o == nil || o.SnakeCase == nil { var ret int32 @@ -66,7 +46,7 @@ func (o *Name) GetSnakeCase() int32 { return *o.SnakeCase } -// GetSnakeCaseOk returns a tuple with the SnakeCase field if it's non-nil, zero value otherwise +// GetSnakeCaseOk returns a tuple with the SnakeCase field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Name) GetSnakeCaseOk() (int32, bool) { if o == nil || o.SnakeCase == nil { @@ -90,7 +70,7 @@ func (o *Name) SetSnakeCase(v int32) { o.SnakeCase = &v } -// GetProperty returns the Property field if non-nil, zero value otherwise. +// GetProperty returns the Property field value if set, zero value otherwise. func (o *Name) GetProperty() string { if o == nil || o.Property == nil { var ret string @@ -99,7 +79,7 @@ func (o *Name) GetProperty() string { return *o.Property } -// GetPropertyOk returns a tuple with the Property field if it's non-nil, zero value otherwise +// GetPropertyOk returns a tuple with the Property field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Name) GetPropertyOk() (string, bool) { if o == nil || o.Property == nil { @@ -123,7 +103,7 @@ func (o *Name) SetProperty(v string) { o.Property = &v } -// GetVar123Number returns the Var123Number field if non-nil, zero value otherwise. +// GetVar123Number returns the Var123Number field value if set, zero value otherwise. func (o *Name) GetVar123Number() int32 { if o == nil || o.Var123Number == nil { var ret int32 @@ -132,7 +112,7 @@ func (o *Name) GetVar123Number() int32 { return *o.Var123Number } -// GetVar123NumberOk returns a tuple with the Var123Number field if it's non-nil, zero value otherwise +// GetVar123NumberOk returns a tuple with the Var123Number field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Name) GetVar123NumberOk() (int32, bool) { if o == nil || o.Var123Number == nil { @@ -156,26 +136,26 @@ func (o *Name) SetVar123Number(v int32) { o.Var123Number = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Name) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name == nil { - return nil, errors.New("Name is required and not nullable, but was not set on Name") - } - if o.Name != nil { - toSerialize["name"] = o.Name - } - if o.SnakeCase != nil { - toSerialize["snake_case"] = o.SnakeCase - } - if o.Property != nil { - toSerialize["property"] = o.Property - } - if o.Var123Number != nil { - toSerialize["123Number"] = o.Var123Number - } - return json.Marshal(toSerialize) +type NullableName struct { + Value Name + ExplicitNull bool } +func (v NullableName) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableName) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go index 88b3d27a7db..4ab8dfc1c2a 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go @@ -8,52 +8,43 @@ */ package openapi + import ( - "time" + "bytes" "encoding/json" + "time" ) + // NullableClass struct for NullableClass type NullableClass struct { - IntegerProp *int32 `json:"integer_prop,omitempty"` - isExplicitNullIntegerProp bool `json:"-"` - NumberProp *float32 `json:"number_prop,omitempty"` - isExplicitNullNumberProp bool `json:"-"` - BooleanProp *bool `json:"boolean_prop,omitempty"` - isExplicitNullBooleanProp bool `json:"-"` - StringProp *string `json:"string_prop,omitempty"` - isExplicitNullStringProp bool `json:"-"` - DateProp *string `json:"date_prop,omitempty"` - isExplicitNullDateProp bool `json:"-"` - DatetimeProp *time.Time `json:"datetime_prop,omitempty"` - isExplicitNullDatetimeProp bool `json:"-"` - ArrayNullableProp *[]map[string]interface{} `json:"array_nullable_prop,omitempty"` - isExplicitNullArrayNullableProp bool `json:"-"` - ArrayAndItemsNullableProp *[]map[string]interface{} `json:"array_and_items_nullable_prop,omitempty"` - isExplicitNullArrayAndItemsNullableProp bool `json:"-"` + IntegerProp *NullableInt32 `json:"integer_prop,omitempty"` + NumberProp *NullableFloat32 `json:"number_prop,omitempty"` + BooleanProp *NullableBool `json:"boolean_prop,omitempty"` + StringProp *NullableString `json:"string_prop,omitempty"` + DateProp *NullableString `json:"date_prop,omitempty"` + DatetimeProp *NullableTime.Time `json:"datetime_prop,omitempty"` + ArrayNullableProp *Nullable[]map[string]interface{} `json:"array_nullable_prop,omitempty"` + ArrayAndItemsNullableProp *Nullable[]map[string]interface{} `json:"array_and_items_nullable_prop,omitempty"` ArrayItemsNullable *[]map[string]interface{} `json:"array_items_nullable,omitempty"` - - ObjectNullableProp *map[string]map[string]interface{} `json:"object_nullable_prop,omitempty"` - isExplicitNullObjectNullableProp bool `json:"-"` - ObjectAndItemsNullableProp *map[string]map[string]interface{} `json:"object_and_items_nullable_prop,omitempty"` - isExplicitNullObjectAndItemsNullableProp bool `json:"-"` + ObjectNullableProp *NullableMap[string]map[string]interface{} `json:"object_nullable_prop,omitempty"` + ObjectAndItemsNullableProp *NullableMap[string]map[string]interface{} `json:"object_and_items_nullable_prop,omitempty"` ObjectItemsNullable *map[string]map[string]interface{} `json:"object_items_nullable,omitempty"` - } -// GetIntegerProp returns the IntegerProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetIntegerProp() int32 { +// GetIntegerProp returns the IntegerProp field value if set, zero value otherwise. +func (o *NullableClass) GetIntegerProp() NullableInt32 { if o == nil || o.IntegerProp == nil { - var ret int32 + var ret NullableInt32 return ret } return *o.IntegerProp } -// GetIntegerPropOk returns a tuple with the IntegerProp field if it's non-nil, zero value otherwise +// GetIntegerPropOk returns a tuple with the IntegerProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetIntegerPropOk() (int32, bool) { +func (o *NullableClass) GetIntegerPropOk() (NullableInt32, bool) { if o == nil || o.IntegerProp == nil { - var ret int32 + var ret NullableInt32 return ret, false } return *o.IntegerProp, true @@ -68,32 +59,25 @@ func (o *NullableClass) HasIntegerProp() bool { return false } -// SetIntegerProp gets a reference to the given int32 and assigns it to the IntegerProp field. -func (o *NullableClass) SetIntegerProp(v int32) { +// SetIntegerProp gets a reference to the given NullableInt32 and assigns it to the IntegerProp field. +func (o *NullableClass) SetIntegerProp(v NullableInt32) { o.IntegerProp = &v } -// SetIntegerPropExplicitNull (un)sets IntegerProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The IntegerProp value is set to nil even if false is passed -func (o *NullableClass) SetIntegerPropExplicitNull(b bool) { - o.IntegerProp = nil - o.isExplicitNullIntegerProp = b -} -// GetNumberProp returns the NumberProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetNumberProp() float32 { +// GetNumberProp returns the NumberProp field value if set, zero value otherwise. +func (o *NullableClass) GetNumberProp() NullableFloat32 { if o == nil || o.NumberProp == nil { - var ret float32 + var ret NullableFloat32 return ret } return *o.NumberProp } -// GetNumberPropOk returns a tuple with the NumberProp field if it's non-nil, zero value otherwise +// GetNumberPropOk returns a tuple with the NumberProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetNumberPropOk() (float32, bool) { +func (o *NullableClass) GetNumberPropOk() (NullableFloat32, bool) { if o == nil || o.NumberProp == nil { - var ret float32 + var ret NullableFloat32 return ret, false } return *o.NumberProp, true @@ -108,32 +92,25 @@ func (o *NullableClass) HasNumberProp() bool { return false } -// SetNumberProp gets a reference to the given float32 and assigns it to the NumberProp field. -func (o *NullableClass) SetNumberProp(v float32) { +// SetNumberProp gets a reference to the given NullableFloat32 and assigns it to the NumberProp field. +func (o *NullableClass) SetNumberProp(v NullableFloat32) { o.NumberProp = &v } -// SetNumberPropExplicitNull (un)sets NumberProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The NumberProp value is set to nil even if false is passed -func (o *NullableClass) SetNumberPropExplicitNull(b bool) { - o.NumberProp = nil - o.isExplicitNullNumberProp = b -} -// GetBooleanProp returns the BooleanProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetBooleanProp() bool { +// GetBooleanProp returns the BooleanProp field value if set, zero value otherwise. +func (o *NullableClass) GetBooleanProp() NullableBool { if o == nil || o.BooleanProp == nil { - var ret bool + var ret NullableBool return ret } return *o.BooleanProp } -// GetBooleanPropOk returns a tuple with the BooleanProp field if it's non-nil, zero value otherwise +// GetBooleanPropOk returns a tuple with the BooleanProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetBooleanPropOk() (bool, bool) { +func (o *NullableClass) GetBooleanPropOk() (NullableBool, bool) { if o == nil || o.BooleanProp == nil { - var ret bool + var ret NullableBool return ret, false } return *o.BooleanProp, true @@ -148,32 +125,25 @@ func (o *NullableClass) HasBooleanProp() bool { return false } -// SetBooleanProp gets a reference to the given bool and assigns it to the BooleanProp field. -func (o *NullableClass) SetBooleanProp(v bool) { +// SetBooleanProp gets a reference to the given NullableBool and assigns it to the BooleanProp field. +func (o *NullableClass) SetBooleanProp(v NullableBool) { o.BooleanProp = &v } -// SetBooleanPropExplicitNull (un)sets BooleanProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The BooleanProp value is set to nil even if false is passed -func (o *NullableClass) SetBooleanPropExplicitNull(b bool) { - o.BooleanProp = nil - o.isExplicitNullBooleanProp = b -} -// GetStringProp returns the StringProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetStringProp() string { +// GetStringProp returns the StringProp field value if set, zero value otherwise. +func (o *NullableClass) GetStringProp() NullableString { if o == nil || o.StringProp == nil { - var ret string + var ret NullableString return ret } return *o.StringProp } -// GetStringPropOk returns a tuple with the StringProp field if it's non-nil, zero value otherwise +// GetStringPropOk returns a tuple with the StringProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetStringPropOk() (string, bool) { +func (o *NullableClass) GetStringPropOk() (NullableString, bool) { if o == nil || o.StringProp == nil { - var ret string + var ret NullableString return ret, false } return *o.StringProp, true @@ -188,32 +158,25 @@ func (o *NullableClass) HasStringProp() bool { return false } -// SetStringProp gets a reference to the given string and assigns it to the StringProp field. -func (o *NullableClass) SetStringProp(v string) { +// SetStringProp gets a reference to the given NullableString and assigns it to the StringProp field. +func (o *NullableClass) SetStringProp(v NullableString) { o.StringProp = &v } -// SetStringPropExplicitNull (un)sets StringProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The StringProp value is set to nil even if false is passed -func (o *NullableClass) SetStringPropExplicitNull(b bool) { - o.StringProp = nil - o.isExplicitNullStringProp = b -} -// GetDateProp returns the DateProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetDateProp() string { +// GetDateProp returns the DateProp field value if set, zero value otherwise. +func (o *NullableClass) GetDateProp() NullableString { if o == nil || o.DateProp == nil { - var ret string + var ret NullableString return ret } return *o.DateProp } -// GetDatePropOk returns a tuple with the DateProp field if it's non-nil, zero value otherwise +// GetDatePropOk returns a tuple with the DateProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetDatePropOk() (string, bool) { +func (o *NullableClass) GetDatePropOk() (NullableString, bool) { if o == nil || o.DateProp == nil { - var ret string + var ret NullableString return ret, false } return *o.DateProp, true @@ -228,32 +191,25 @@ func (o *NullableClass) HasDateProp() bool { return false } -// SetDateProp gets a reference to the given string and assigns it to the DateProp field. -func (o *NullableClass) SetDateProp(v string) { +// SetDateProp gets a reference to the given NullableString and assigns it to the DateProp field. +func (o *NullableClass) SetDateProp(v NullableString) { o.DateProp = &v } -// SetDatePropExplicitNull (un)sets DateProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The DateProp value is set to nil even if false is passed -func (o *NullableClass) SetDatePropExplicitNull(b bool) { - o.DateProp = nil - o.isExplicitNullDateProp = b -} -// GetDatetimeProp returns the DatetimeProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetDatetimeProp() time.Time { +// GetDatetimeProp returns the DatetimeProp field value if set, zero value otherwise. +func (o *NullableClass) GetDatetimeProp() NullableTime.Time { if o == nil || o.DatetimeProp == nil { - var ret time.Time + var ret NullableTime.Time return ret } return *o.DatetimeProp } -// GetDatetimePropOk returns a tuple with the DatetimeProp field if it's non-nil, zero value otherwise +// GetDatetimePropOk returns a tuple with the DatetimeProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetDatetimePropOk() (time.Time, bool) { +func (o *NullableClass) GetDatetimePropOk() (NullableTime.Time, bool) { if o == nil || o.DatetimeProp == nil { - var ret time.Time + var ret NullableTime.Time return ret, false } return *o.DatetimeProp, true @@ -268,32 +224,25 @@ func (o *NullableClass) HasDatetimeProp() bool { return false } -// SetDatetimeProp gets a reference to the given time.Time and assigns it to the DatetimeProp field. -func (o *NullableClass) SetDatetimeProp(v time.Time) { +// SetDatetimeProp gets a reference to the given NullableTime.Time and assigns it to the DatetimeProp field. +func (o *NullableClass) SetDatetimeProp(v NullableTime.Time) { o.DatetimeProp = &v } -// SetDatetimePropExplicitNull (un)sets DatetimeProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The DatetimeProp value is set to nil even if false is passed -func (o *NullableClass) SetDatetimePropExplicitNull(b bool) { - o.DatetimeProp = nil - o.isExplicitNullDatetimeProp = b -} -// GetArrayNullableProp returns the ArrayNullableProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetArrayNullableProp() []map[string]interface{} { +// GetArrayNullableProp returns the ArrayNullableProp field value if set, zero value otherwise. +func (o *NullableClass) GetArrayNullableProp() Nullable[]map[string]interface{} { if o == nil || o.ArrayNullableProp == nil { - var ret []map[string]interface{} + var ret Nullable[]map[string]interface{} return ret } return *o.ArrayNullableProp } -// GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field if it's non-nil, zero value otherwise +// GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool) { +func (o *NullableClass) GetArrayNullablePropOk() (Nullable[]map[string]interface{}, bool) { if o == nil || o.ArrayNullableProp == nil { - var ret []map[string]interface{} + var ret Nullable[]map[string]interface{} return ret, false } return *o.ArrayNullableProp, true @@ -308,32 +257,25 @@ func (o *NullableClass) HasArrayNullableProp() bool { return false } -// SetArrayNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayNullableProp field. -func (o *NullableClass) SetArrayNullableProp(v []map[string]interface{}) { +// SetArrayNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayNullableProp field. +func (o *NullableClass) SetArrayNullableProp(v Nullable[]map[string]interface{}) { o.ArrayNullableProp = &v } -// SetArrayNullablePropExplicitNull (un)sets ArrayNullableProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The ArrayNullableProp value is set to nil even if false is passed -func (o *NullableClass) SetArrayNullablePropExplicitNull(b bool) { - o.ArrayNullableProp = nil - o.isExplicitNullArrayNullableProp = b -} -// GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetArrayAndItemsNullableProp() []map[string]interface{} { +// GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field value if set, zero value otherwise. +func (o *NullableClass) GetArrayAndItemsNullableProp() Nullable[]map[string]interface{} { if o == nil || o.ArrayAndItemsNullableProp == nil { - var ret []map[string]interface{} + var ret Nullable[]map[string]interface{} return ret } return *o.ArrayAndItemsNullableProp } -// GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field if it's non-nil, zero value otherwise +// GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]map[string]interface{}, bool) { +func (o *NullableClass) GetArrayAndItemsNullablePropOk() (Nullable[]map[string]interface{}, bool) { if o == nil || o.ArrayAndItemsNullableProp == nil { - var ret []map[string]interface{} + var ret Nullable[]map[string]interface{} return ret, false } return *o.ArrayAndItemsNullableProp, true @@ -348,19 +290,12 @@ func (o *NullableClass) HasArrayAndItemsNullableProp() bool { return false } -// SetArrayAndItemsNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field. -func (o *NullableClass) SetArrayAndItemsNullableProp(v []map[string]interface{}) { +// SetArrayAndItemsNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field. +func (o *NullableClass) SetArrayAndItemsNullableProp(v Nullable[]map[string]interface{}) { o.ArrayAndItemsNullableProp = &v } -// SetArrayAndItemsNullablePropExplicitNull (un)sets ArrayAndItemsNullableProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The ArrayAndItemsNullableProp value is set to nil even if false is passed -func (o *NullableClass) SetArrayAndItemsNullablePropExplicitNull(b bool) { - o.ArrayAndItemsNullableProp = nil - o.isExplicitNullArrayAndItemsNullableProp = b -} -// GetArrayItemsNullable returns the ArrayItemsNullable field if non-nil, zero value otherwise. +// GetArrayItemsNullable returns the ArrayItemsNullable field value if set, zero value otherwise. func (o *NullableClass) GetArrayItemsNullable() []map[string]interface{} { if o == nil || o.ArrayItemsNullable == nil { var ret []map[string]interface{} @@ -369,7 +304,7 @@ func (o *NullableClass) GetArrayItemsNullable() []map[string]interface{} { return *o.ArrayItemsNullable } -// GetArrayItemsNullableOk returns a tuple with the ArrayItemsNullable field if it's non-nil, zero value otherwise +// GetArrayItemsNullableOk returns a tuple with the ArrayItemsNullable field value if set, zero value 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 { @@ -393,20 +328,20 @@ func (o *NullableClass) SetArrayItemsNullable(v []map[string]interface{}) { o.ArrayItemsNullable = &v } -// GetObjectNullableProp returns the ObjectNullableProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetObjectNullableProp() map[string]map[string]interface{} { +// GetObjectNullableProp returns the ObjectNullableProp field value if set, zero value otherwise. +func (o *NullableClass) GetObjectNullableProp() NullableMap[string]map[string]interface{} { if o == nil || o.ObjectNullableProp == nil { - var ret map[string]map[string]interface{} + var ret NullableMap[string]map[string]interface{} return ret } return *o.ObjectNullableProp } -// GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field if it's non-nil, zero value otherwise +// GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interface{}, bool) { +func (o *NullableClass) GetObjectNullablePropOk() (NullableMap[string]map[string]interface{}, bool) { if o == nil || o.ObjectNullableProp == nil { - var ret map[string]map[string]interface{} + var ret NullableMap[string]map[string]interface{} return ret, false } return *o.ObjectNullableProp, true @@ -421,32 +356,25 @@ func (o *NullableClass) HasObjectNullableProp() bool { return false } -// SetObjectNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectNullableProp field. -func (o *NullableClass) SetObjectNullableProp(v map[string]map[string]interface{}) { +// SetObjectNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectNullableProp field. +func (o *NullableClass) SetObjectNullableProp(v NullableMap[string]map[string]interface{}) { o.ObjectNullableProp = &v } -// SetObjectNullablePropExplicitNull (un)sets ObjectNullableProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The ObjectNullableProp value is set to nil even if false is passed -func (o *NullableClass) SetObjectNullablePropExplicitNull(b bool) { - o.ObjectNullableProp = nil - o.isExplicitNullObjectNullableProp = b -} -// GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field if non-nil, zero value otherwise. -func (o *NullableClass) GetObjectAndItemsNullableProp() map[string]map[string]interface{} { +// GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field value if set, zero value otherwise. +func (o *NullableClass) GetObjectAndItemsNullableProp() NullableMap[string]map[string]interface{} { if o == nil || o.ObjectAndItemsNullableProp == nil { - var ret map[string]map[string]interface{} + var ret NullableMap[string]map[string]interface{} return ret } return *o.ObjectAndItemsNullableProp } -// GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field if it's non-nil, zero value otherwise +// GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field value if set, zero value otherwise // and a boolean to check if the value has been set. -func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string]interface{}, bool) { +func (o *NullableClass) GetObjectAndItemsNullablePropOk() (NullableMap[string]map[string]interface{}, bool) { if o == nil || o.ObjectAndItemsNullableProp == nil { - var ret map[string]map[string]interface{} + var ret NullableMap[string]map[string]interface{} return ret, false } return *o.ObjectAndItemsNullableProp, true @@ -461,19 +389,12 @@ func (o *NullableClass) HasObjectAndItemsNullableProp() bool { return false } -// SetObjectAndItemsNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field. -func (o *NullableClass) SetObjectAndItemsNullableProp(v map[string]map[string]interface{}) { +// SetObjectAndItemsNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field. +func (o *NullableClass) SetObjectAndItemsNullableProp(v NullableMap[string]map[string]interface{}) { o.ObjectAndItemsNullableProp = &v } -// SetObjectAndItemsNullablePropExplicitNull (un)sets ObjectAndItemsNullableProp to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The ObjectAndItemsNullableProp value is set to nil even if false is passed -func (o *NullableClass) SetObjectAndItemsNullablePropExplicitNull(b bool) { - o.ObjectAndItemsNullableProp = nil - o.isExplicitNullObjectAndItemsNullableProp = b -} -// GetObjectItemsNullable returns the ObjectItemsNullable field if non-nil, zero value otherwise. +// 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 { var ret map[string]map[string]interface{} @@ -482,7 +403,7 @@ func (o *NullableClass) GetObjectItemsNullable() map[string]map[string]interface return *o.ObjectItemsNullable } -// GetObjectItemsNullableOk returns a tuple with the ObjectItemsNullable field if it's non-nil, zero value otherwise +// GetObjectItemsNullableOk returns a tuple with the ObjectItemsNullable field value if set, zero value 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 { @@ -506,87 +427,26 @@ func (o *NullableClass) SetObjectItemsNullable(v map[string]map[string]interface o.ObjectItemsNullable = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o NullableClass) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.IntegerProp == nil { - if o.isExplicitNullIntegerProp { - toSerialize["integer_prop"] = o.IntegerProp - } - } else { - toSerialize["integer_prop"] = o.IntegerProp - } - if o.NumberProp == nil { - if o.isExplicitNullNumberProp { - toSerialize["number_prop"] = o.NumberProp - } - } else { - toSerialize["number_prop"] = o.NumberProp - } - if o.BooleanProp == nil { - if o.isExplicitNullBooleanProp { - toSerialize["boolean_prop"] = o.BooleanProp - } - } else { - toSerialize["boolean_prop"] = o.BooleanProp - } - if o.StringProp == nil { - if o.isExplicitNullStringProp { - toSerialize["string_prop"] = o.StringProp - } - } else { - toSerialize["string_prop"] = o.StringProp - } - if o.DateProp == nil { - if o.isExplicitNullDateProp { - toSerialize["date_prop"] = o.DateProp - } - } else { - toSerialize["date_prop"] = o.DateProp - } - if o.DatetimeProp == nil { - if o.isExplicitNullDatetimeProp { - toSerialize["datetime_prop"] = o.DatetimeProp - } - } else { - toSerialize["datetime_prop"] = o.DatetimeProp - } - if o.ArrayNullableProp == nil { - if o.isExplicitNullArrayNullableProp { - toSerialize["array_nullable_prop"] = o.ArrayNullableProp - } - } else { - toSerialize["array_nullable_prop"] = o.ArrayNullableProp - } - if o.ArrayAndItemsNullableProp == nil { - if o.isExplicitNullArrayAndItemsNullableProp { - toSerialize["array_and_items_nullable_prop"] = o.ArrayAndItemsNullableProp - } - } else { - toSerialize["array_and_items_nullable_prop"] = o.ArrayAndItemsNullableProp - } - if o.ArrayItemsNullable != nil { - toSerialize["array_items_nullable"] = o.ArrayItemsNullable - } - if o.ObjectNullableProp == nil { - if o.isExplicitNullObjectNullableProp { - toSerialize["object_nullable_prop"] = o.ObjectNullableProp - } - } else { - toSerialize["object_nullable_prop"] = o.ObjectNullableProp - } - if o.ObjectAndItemsNullableProp == nil { - if o.isExplicitNullObjectAndItemsNullableProp { - toSerialize["object_and_items_nullable_prop"] = o.ObjectAndItemsNullableProp - } - } else { - toSerialize["object_and_items_nullable_prop"] = o.ObjectAndItemsNullableProp - } - if o.ObjectItemsNullable != nil { - toSerialize["object_items_nullable"] = o.ObjectItemsNullable - } - return json.Marshal(toSerialize) +type NullableNullableClass struct { + Value NullableClass + ExplicitNull bool } +func (v NullableNullableClass) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableNullableClass) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_number_only.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_number_only.go index 5e6f7c74d99..f7b79fd08aa 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_number_only.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_number_only.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // NumberOnly struct for NumberOnly type NumberOnly struct { JustNumber *float32 `json:"JustNumber,omitempty"` - } -// GetJustNumber returns the JustNumber field if non-nil, zero value otherwise. +// GetJustNumber returns the JustNumber field value if set, zero value otherwise. func (o *NumberOnly) GetJustNumber() float32 { if o == nil || o.JustNumber == nil { var ret float32 @@ -26,7 +28,7 @@ func (o *NumberOnly) GetJustNumber() float32 { return *o.JustNumber } -// GetJustNumberOk returns a tuple with the JustNumber field if it's non-nil, zero value otherwise +// GetJustNumberOk returns a tuple with the JustNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *NumberOnly) GetJustNumberOk() (float32, bool) { if o == nil || o.JustNumber == nil { @@ -50,14 +52,26 @@ func (o *NumberOnly) SetJustNumber(v float32) { o.JustNumber = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o NumberOnly) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.JustNumber != nil { - toSerialize["JustNumber"] = o.JustNumber - } - return json.Marshal(toSerialize) +type NullableNumberOnly struct { + Value NumberOnly + ExplicitNull bool } +func (v NullableNumberOnly) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableNumberOnly) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_order.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_order.go index a05ac01a884..20c5d9c1384 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_order.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_order.go @@ -8,28 +8,25 @@ */ package openapi + import ( - "time" + "bytes" "encoding/json" + "time" ) + // Order struct for Order type Order struct { Id *int64 `json:"id,omitempty"` - PetId *int64 `json:"petId,omitempty"` - Quantity *int32 `json:"quantity,omitempty"` - ShipDate *time.Time `json:"shipDate,omitempty"` - // Order Status Status *string `json:"status,omitempty"` - Complete *bool `json:"complete,omitempty"` - } -// GetId returns the Id field if non-nil, zero value otherwise. +// GetId returns the Id field value if set, zero value otherwise. func (o *Order) GetId() int64 { if o == nil || o.Id == nil { var ret int64 @@ -38,7 +35,7 @@ func (o *Order) GetId() int64 { return *o.Id } -// GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +// GetIdOk returns a tuple with the Id field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Order) GetIdOk() (int64, bool) { if o == nil || o.Id == nil { @@ -62,7 +59,7 @@ func (o *Order) SetId(v int64) { o.Id = &v } -// GetPetId returns the PetId field if non-nil, zero value otherwise. +// GetPetId returns the PetId field value if set, zero value otherwise. func (o *Order) GetPetId() int64 { if o == nil || o.PetId == nil { var ret int64 @@ -71,7 +68,7 @@ func (o *Order) GetPetId() int64 { return *o.PetId } -// GetPetIdOk returns a tuple with the PetId field if it's non-nil, zero value otherwise +// GetPetIdOk returns a tuple with the PetId field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Order) GetPetIdOk() (int64, bool) { if o == nil || o.PetId == nil { @@ -95,7 +92,7 @@ func (o *Order) SetPetId(v int64) { o.PetId = &v } -// GetQuantity returns the Quantity field if non-nil, zero value otherwise. +// GetQuantity returns the Quantity field value if set, zero value otherwise. func (o *Order) GetQuantity() int32 { if o == nil || o.Quantity == nil { var ret int32 @@ -104,7 +101,7 @@ func (o *Order) GetQuantity() int32 { return *o.Quantity } -// GetQuantityOk returns a tuple with the Quantity field if it's non-nil, zero value otherwise +// GetQuantityOk returns a tuple with the Quantity field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Order) GetQuantityOk() (int32, bool) { if o == nil || o.Quantity == nil { @@ -128,7 +125,7 @@ func (o *Order) SetQuantity(v int32) { o.Quantity = &v } -// GetShipDate returns the ShipDate field if non-nil, zero value otherwise. +// GetShipDate returns the ShipDate field value if set, zero value otherwise. func (o *Order) GetShipDate() time.Time { if o == nil || o.ShipDate == nil { var ret time.Time @@ -137,7 +134,7 @@ func (o *Order) GetShipDate() time.Time { return *o.ShipDate } -// GetShipDateOk returns a tuple with the ShipDate field if it's non-nil, zero value otherwise +// GetShipDateOk returns a tuple with the ShipDate field value if set, zero value 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 { @@ -161,7 +158,7 @@ func (o *Order) SetShipDate(v time.Time) { o.ShipDate = &v } -// GetStatus returns the Status field if non-nil, zero value otherwise. +// GetStatus returns the Status field value if set, zero value otherwise. func (o *Order) GetStatus() string { if o == nil || o.Status == nil { var ret string @@ -170,7 +167,7 @@ func (o *Order) GetStatus() string { return *o.Status } -// GetStatusOk returns a tuple with the Status field if it's non-nil, zero value otherwise +// GetStatusOk returns a tuple with the Status field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Order) GetStatusOk() (string, bool) { if o == nil || o.Status == nil { @@ -194,7 +191,7 @@ func (o *Order) SetStatus(v string) { o.Status = &v } -// GetComplete returns the Complete field if non-nil, zero value otherwise. +// GetComplete returns the Complete field value if set, zero value otherwise. func (o *Order) GetComplete() bool { if o == nil || o.Complete == nil { var ret bool @@ -203,7 +200,7 @@ func (o *Order) GetComplete() bool { return *o.Complete } -// GetCompleteOk returns a tuple with the Complete field if it's non-nil, zero value otherwise +// GetCompleteOk returns a tuple with the Complete field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Order) GetCompleteOk() (bool, bool) { if o == nil || o.Complete == nil { @@ -227,29 +224,26 @@ func (o *Order) SetComplete(v bool) { o.Complete = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Order) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Id != nil { - toSerialize["id"] = o.Id - } - if o.PetId != nil { - toSerialize["petId"] = o.PetId - } - if o.Quantity != nil { - toSerialize["quantity"] = o.Quantity - } - if o.ShipDate != nil { - toSerialize["shipDate"] = o.ShipDate - } - if o.Status != nil { - toSerialize["status"] = o.Status - } - if o.Complete != nil { - toSerialize["complete"] = o.Complete - } - return json.Marshal(toSerialize) +type NullableOrder struct { + Value Order + ExplicitNull bool } +func (v NullableOrder) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableOrder) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_composite.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_composite.go index 83c5d661eb2..1943fda269f 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_composite.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_composite.go @@ -8,20 +8,20 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // OuterComposite struct for OuterComposite type OuterComposite struct { MyNumber *float32 `json:"my_number,omitempty"` - MyString *string `json:"my_string,omitempty"` - MyBoolean *bool `json:"my_boolean,omitempty"` - } -// GetMyNumber returns the MyNumber field if non-nil, zero value otherwise. +// GetMyNumber returns the MyNumber field value if set, zero value otherwise. func (o *OuterComposite) GetMyNumber() float32 { if o == nil || o.MyNumber == nil { var ret float32 @@ -30,7 +30,7 @@ func (o *OuterComposite) GetMyNumber() float32 { return *o.MyNumber } -// GetMyNumberOk returns a tuple with the MyNumber field if it's non-nil, zero value otherwise +// GetMyNumberOk returns a tuple with the MyNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *OuterComposite) GetMyNumberOk() (float32, bool) { if o == nil || o.MyNumber == nil { @@ -54,7 +54,7 @@ func (o *OuterComposite) SetMyNumber(v float32) { o.MyNumber = &v } -// GetMyString returns the MyString field if non-nil, zero value otherwise. +// GetMyString returns the MyString field value if set, zero value otherwise. func (o *OuterComposite) GetMyString() string { if o == nil || o.MyString == nil { var ret string @@ -63,7 +63,7 @@ func (o *OuterComposite) GetMyString() string { return *o.MyString } -// GetMyStringOk returns a tuple with the MyString field if it's non-nil, zero value otherwise +// GetMyStringOk returns a tuple with the MyString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *OuterComposite) GetMyStringOk() (string, bool) { if o == nil || o.MyString == nil { @@ -87,7 +87,7 @@ func (o *OuterComposite) SetMyString(v string) { o.MyString = &v } -// GetMyBoolean returns the MyBoolean field if non-nil, zero value otherwise. +// GetMyBoolean returns the MyBoolean field value if set, zero value otherwise. func (o *OuterComposite) GetMyBoolean() bool { if o == nil || o.MyBoolean == nil { var ret bool @@ -96,7 +96,7 @@ func (o *OuterComposite) GetMyBoolean() bool { return *o.MyBoolean } -// GetMyBooleanOk returns a tuple with the MyBoolean field if it's non-nil, zero value otherwise +// GetMyBooleanOk returns a tuple with the MyBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *OuterComposite) GetMyBooleanOk() (bool, bool) { if o == nil || o.MyBoolean == nil { @@ -120,20 +120,26 @@ func (o *OuterComposite) SetMyBoolean(v bool) { o.MyBoolean = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o OuterComposite) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.MyNumber != nil { - toSerialize["my_number"] = o.MyNumber - } - if o.MyString != nil { - toSerialize["my_string"] = o.MyString - } - if o.MyBoolean != nil { - toSerialize["my_boolean"] = o.MyBoolean - } - return json.Marshal(toSerialize) +type NullableOuterComposite struct { + Value OuterComposite + ExplicitNull bool } +func (v NullableOuterComposite) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableOuterComposite) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum.go index e8299a160ec..c1763b7bd2f 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum.go @@ -8,6 +8,12 @@ */ package openapi + +import ( + "bytes" + "encoding/json" +) + // OuterEnum the model 'OuterEnum' type OuterEnum string @@ -18,4 +24,30 @@ const ( DELIVERED OuterEnum = "delivered" ) +type NullableOuterEnum struct { + Value OuterEnum + ExplicitNull bool +} + +func (v NullableOuterEnum) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != "": + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableOuterEnum) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_default_value.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_default_value.go index d5f8a9a76fc..e19de0cdc50 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_default_value.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_default_value.go @@ -8,6 +8,12 @@ */ package openapi + +import ( + "bytes" + "encoding/json" +) + // OuterEnumDefaultValue the model 'OuterEnumDefaultValue' type OuterEnumDefaultValue string @@ -18,4 +24,30 @@ const ( DELIVERED OuterEnumDefaultValue = "delivered" ) +type NullableOuterEnumDefaultValue struct { + Value OuterEnumDefaultValue + ExplicitNull bool +} + +func (v NullableOuterEnumDefaultValue) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != "": + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableOuterEnumDefaultValue) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer.go index 2bdaee50144..e80a8e2522e 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer.go @@ -8,6 +8,12 @@ */ package openapi + +import ( + "bytes" + "encoding/json" +) + // OuterEnumInteger the model 'OuterEnumInteger' type OuterEnumInteger int32 @@ -18,4 +24,30 @@ const ( _2 OuterEnumInteger = 2 ) +type NullableOuterEnumInteger struct { + Value OuterEnumInteger + ExplicitNull bool +} + +func (v NullableOuterEnumInteger) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != "": + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableOuterEnumInteger) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer_default_value.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer_default_value.go index 492dcc08bda..5d1811ef9d7 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer_default_value.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_outer_enum_integer_default_value.go @@ -8,6 +8,12 @@ */ package openapi + +import ( + "bytes" + "encoding/json" +) + // OuterEnumIntegerDefaultValue the model 'OuterEnumIntegerDefaultValue' type OuterEnumIntegerDefaultValue int32 @@ -18,4 +24,30 @@ const ( _2 OuterEnumIntegerDefaultValue = 2 ) +type NullableOuterEnumIntegerDefaultValue struct { + Value OuterEnumIntegerDefaultValue + ExplicitNull bool +} + +func (v NullableOuterEnumIntegerDefaultValue) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != "": + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableOuterEnumIntegerDefaultValue) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_pet.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_pet.go index 1c7cde3b15d..bbd29397b4c 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_pet.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_pet.go @@ -8,28 +8,24 @@ */ package openapi + import ( + "bytes" "encoding/json" - "errors" ) + // Pet struct for Pet type Pet struct { Id *int64 `json:"id,omitempty"` - Category *Category `json:"category,omitempty"` - - Name *string `json:"name,omitempty"` - - PhotoUrls *[]string `json:"photoUrls,omitempty"` - + Name string `json:"name"` + PhotoUrls []string `json:"photoUrls"` Tags *[]Tag `json:"tags,omitempty"` - // pet status in the store Status *string `json:"status,omitempty"` - } -// GetId returns the Id field if non-nil, zero value otherwise. +// GetId returns the Id field value if set, zero value otherwise. func (o *Pet) GetId() int64 { if o == nil || o.Id == nil { var ret int64 @@ -38,7 +34,7 @@ func (o *Pet) GetId() int64 { return *o.Id } -// GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +// GetIdOk returns a tuple with the Id field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Pet) GetIdOk() (int64, bool) { if o == nil || o.Id == nil { @@ -62,7 +58,7 @@ func (o *Pet) SetId(v int64) { o.Id = &v } -// GetCategory returns the Category field if non-nil, zero value otherwise. +// GetCategory returns the Category field value if set, zero value otherwise. func (o *Pet) GetCategory() Category { if o == nil || o.Category == nil { var ret Category @@ -71,7 +67,7 @@ func (o *Pet) GetCategory() Category { return *o.Category } -// GetCategoryOk returns a tuple with the Category field if it's non-nil, zero value otherwise +// GetCategoryOk returns a tuple with the Category field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Pet) GetCategoryOk() (Category, bool) { if o == nil || o.Category == nil { @@ -95,73 +91,37 @@ func (o *Pet) SetCategory(v Category) { o.Category = &v } -// GetName returns the Name field if non-nil, zero value otherwise. +// GetName returns the Name field value func (o *Pet) GetName() string { - if o == nil || o.Name == nil { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Pet) GetNameOk() (string, bool) { - if o == nil || o.Name == nil { - var ret string - return ret, false - } - return *o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *Pet) HasName() bool { - if o != nil && o.Name != nil { - return true - } - - return false -} - -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *Pet) SetName(v string) { - o.Name = &v + o.Name = v } -// GetPhotoUrls returns the PhotoUrls field if non-nil, zero value otherwise. +// GetPhotoUrls returns the PhotoUrls field value func (o *Pet) GetPhotoUrls() []string { - if o == nil || o.PhotoUrls == nil { + if o == nil { var ret []string return ret } - return *o.PhotoUrls + + return o.PhotoUrls } -// GetPhotoUrlsOk returns a tuple with the PhotoUrls field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *Pet) GetPhotoUrlsOk() ([]string, bool) { - if o == nil || o.PhotoUrls == nil { - var ret []string - return ret, false - } - return *o.PhotoUrls, true -} - -// HasPhotoUrls returns a boolean if a field has been set. -func (o *Pet) HasPhotoUrls() bool { - if o != nil && o.PhotoUrls != nil { - return true - } - - return false -} - -// SetPhotoUrls gets a reference to the given []string and assigns it to the PhotoUrls field. +// SetPhotoUrls sets field value func (o *Pet) SetPhotoUrls(v []string) { - o.PhotoUrls = &v + o.PhotoUrls = v } -// GetTags returns the Tags field if non-nil, zero value otherwise. +// GetTags returns the Tags field value if set, zero value otherwise. func (o *Pet) GetTags() []Tag { if o == nil || o.Tags == nil { var ret []Tag @@ -170,7 +130,7 @@ func (o *Pet) GetTags() []Tag { return *o.Tags } -// GetTagsOk returns a tuple with the Tags field if it's non-nil, zero value otherwise +// GetTagsOk returns a tuple with the Tags field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Pet) GetTagsOk() ([]Tag, bool) { if o == nil || o.Tags == nil { @@ -194,7 +154,7 @@ func (o *Pet) SetTags(v []Tag) { o.Tags = &v } -// GetStatus returns the Status field if non-nil, zero value otherwise. +// GetStatus returns the Status field value if set, zero value otherwise. func (o *Pet) GetStatus() string { if o == nil || o.Status == nil { var ret string @@ -203,7 +163,7 @@ func (o *Pet) GetStatus() string { return *o.Status } -// GetStatusOk returns a tuple with the Status field if it's non-nil, zero value otherwise +// GetStatusOk returns a tuple with the Status field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Pet) GetStatusOk() (string, bool) { if o == nil || o.Status == nil { @@ -227,35 +187,26 @@ func (o *Pet) SetStatus(v string) { o.Status = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Pet) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Id != nil { - toSerialize["id"] = o.Id - } - if o.Category != nil { - toSerialize["category"] = o.Category - } - if o.Name == nil { - return nil, errors.New("Name is required and not nullable, but was not set on Pet") - } - if o.Name != nil { - toSerialize["name"] = o.Name - } - if o.PhotoUrls == nil { - return nil, errors.New("PhotoUrls is required and not nullable, but was not set on Pet") - } - if o.PhotoUrls != nil { - toSerialize["photoUrls"] = o.PhotoUrls - } - if o.Tags != nil { - toSerialize["tags"] = o.Tags - } - if o.Status != nil { - toSerialize["status"] = o.Status - } - return json.Marshal(toSerialize) +type NullablePet struct { + Value Pet + ExplicitNull bool } +func (v NullablePet) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullablePet) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_read_only_first.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_read_only_first.go index 3035cc15e51..3b9b68414c0 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_read_only_first.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_read_only_first.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // ReadOnlyFirst struct for ReadOnlyFirst type ReadOnlyFirst struct { Bar *string `json:"bar,omitempty"` - Baz *string `json:"baz,omitempty"` - } -// GetBar returns the Bar field if non-nil, zero value otherwise. +// GetBar returns the Bar field value if set, zero value otherwise. func (o *ReadOnlyFirst) GetBar() string { if o == nil || o.Bar == nil { var ret string @@ -28,7 +29,7 @@ func (o *ReadOnlyFirst) GetBar() string { return *o.Bar } -// GetBarOk returns a tuple with the Bar field if it's non-nil, zero value otherwise +// GetBarOk returns a tuple with the Bar field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ReadOnlyFirst) GetBarOk() (string, bool) { if o == nil || o.Bar == nil { @@ -52,7 +53,7 @@ func (o *ReadOnlyFirst) SetBar(v string) { o.Bar = &v } -// GetBaz returns the Baz field if non-nil, zero value otherwise. +// GetBaz returns the Baz field value if set, zero value otherwise. func (o *ReadOnlyFirst) GetBaz() string { if o == nil || o.Baz == nil { var ret string @@ -61,7 +62,7 @@ func (o *ReadOnlyFirst) GetBaz() string { return *o.Baz } -// GetBazOk returns a tuple with the Baz field if it's non-nil, zero value otherwise +// GetBazOk returns a tuple with the Baz field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *ReadOnlyFirst) GetBazOk() (string, bool) { if o == nil || o.Baz == nil { @@ -85,17 +86,26 @@ func (o *ReadOnlyFirst) SetBaz(v string) { o.Baz = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o ReadOnlyFirst) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Bar != nil { - toSerialize["bar"] = o.Bar - } - if o.Baz != nil { - toSerialize["baz"] = o.Baz - } - return json.Marshal(toSerialize) +type NullableReadOnlyFirst struct { + Value ReadOnlyFirst + ExplicitNull bool } +func (v NullableReadOnlyFirst) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableReadOnlyFirst) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_return.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_return.go index fcf674e31ca..4d5af7cda2b 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_return.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_return.go @@ -8,16 +8,18 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // Return Model for testing reserved words type Return struct { Return *int32 `json:"return,omitempty"` - } -// GetReturn returns the Return field if non-nil, zero value otherwise. +// GetReturn returns the Return field value if set, zero value otherwise. func (o *Return) GetReturn() int32 { if o == nil || o.Return == nil { var ret int32 @@ -26,7 +28,7 @@ func (o *Return) GetReturn() int32 { return *o.Return } -// GetReturnOk returns a tuple with the Return field if it's non-nil, zero value otherwise +// GetReturnOk returns a tuple with the Return field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Return) GetReturnOk() (int32, bool) { if o == nil || o.Return == nil { @@ -50,14 +52,26 @@ func (o *Return) SetReturn(v int32) { o.Return = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Return) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Return != nil { - toSerialize["return"] = o.Return - } - return json.Marshal(toSerialize) +type NullableReturn struct { + Value Return + ExplicitNull bool } +func (v NullableReturn) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableReturn) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_tag.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_tag.go index c75f4762e87..885ba363bd2 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_tag.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_tag.go @@ -8,18 +8,19 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // Tag struct for Tag type Tag struct { Id *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - } -// GetId returns the Id field if non-nil, zero value otherwise. +// GetId returns the Id field value if set, zero value otherwise. func (o *Tag) GetId() int64 { if o == nil || o.Id == nil { var ret int64 @@ -28,7 +29,7 @@ func (o *Tag) GetId() int64 { return *o.Id } -// GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +// GetIdOk returns a tuple with the Id field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Tag) GetIdOk() (int64, bool) { if o == nil || o.Id == nil { @@ -52,7 +53,7 @@ func (o *Tag) SetId(v int64) { o.Id = &v } -// GetName returns the Name field if non-nil, zero value otherwise. +// GetName returns the Name field value if set, zero value otherwise. func (o *Tag) GetName() string { if o == nil || o.Name == nil { var ret string @@ -61,7 +62,7 @@ func (o *Tag) GetName() string { return *o.Name } -// GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +// GetNameOk returns a tuple with the Name field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *Tag) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -85,17 +86,26 @@ func (o *Tag) SetName(v string) { o.Name = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o Tag) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Id != nil { - toSerialize["id"] = o.Id - } - if o.Name != nil { - toSerialize["name"] = o.Name - } - return json.Marshal(toSerialize) +type NullableTag struct { + Value Tag + ExplicitNull bool } +func (v NullableTag) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableTag) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_user.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_user.go index b07841354bf..1b280a841ce 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_user.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_user.go @@ -8,31 +8,26 @@ */ package openapi + import ( + "bytes" "encoding/json" ) + // User struct for User type User struct { Id *int64 `json:"id,omitempty"` - Username *string `json:"username,omitempty"` - FirstName *string `json:"firstName,omitempty"` - LastName *string `json:"lastName,omitempty"` - Email *string `json:"email,omitempty"` - Password *string `json:"password,omitempty"` - Phone *string `json:"phone,omitempty"` - // User Status UserStatus *int32 `json:"userStatus,omitempty"` - } -// GetId returns the Id field if non-nil, zero value otherwise. +// GetId returns the Id field value if set, zero value otherwise. func (o *User) GetId() int64 { if o == nil || o.Id == nil { var ret int64 @@ -41,7 +36,7 @@ func (o *User) GetId() int64 { return *o.Id } -// GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +// GetIdOk returns a tuple with the Id field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetIdOk() (int64, bool) { if o == nil || o.Id == nil { @@ -65,7 +60,7 @@ func (o *User) SetId(v int64) { o.Id = &v } -// GetUsername returns the Username field if non-nil, zero value otherwise. +// GetUsername returns the Username field value if set, zero value otherwise. func (o *User) GetUsername() string { if o == nil || o.Username == nil { var ret string @@ -74,7 +69,7 @@ func (o *User) GetUsername() string { return *o.Username } -// GetUsernameOk returns a tuple with the Username field if it's non-nil, zero value otherwise +// GetUsernameOk returns a tuple with the Username field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetUsernameOk() (string, bool) { if o == nil || o.Username == nil { @@ -98,7 +93,7 @@ func (o *User) SetUsername(v string) { o.Username = &v } -// GetFirstName returns the FirstName field if non-nil, zero value otherwise. +// GetFirstName returns the FirstName field value if set, zero value otherwise. func (o *User) GetFirstName() string { if o == nil || o.FirstName == nil { var ret string @@ -107,7 +102,7 @@ func (o *User) GetFirstName() string { return *o.FirstName } -// GetFirstNameOk returns a tuple with the FirstName field if it's non-nil, zero value otherwise +// GetFirstNameOk returns a tuple with the FirstName field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetFirstNameOk() (string, bool) { if o == nil || o.FirstName == nil { @@ -131,7 +126,7 @@ func (o *User) SetFirstName(v string) { o.FirstName = &v } -// GetLastName returns the LastName field if non-nil, zero value otherwise. +// GetLastName returns the LastName field value if set, zero value otherwise. func (o *User) GetLastName() string { if o == nil || o.LastName == nil { var ret string @@ -140,7 +135,7 @@ func (o *User) GetLastName() string { return *o.LastName } -// GetLastNameOk returns a tuple with the LastName field if it's non-nil, zero value otherwise +// GetLastNameOk returns a tuple with the LastName field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetLastNameOk() (string, bool) { if o == nil || o.LastName == nil { @@ -164,7 +159,7 @@ func (o *User) SetLastName(v string) { o.LastName = &v } -// GetEmail returns the Email field if non-nil, zero value otherwise. +// GetEmail returns the Email field value if set, zero value otherwise. func (o *User) GetEmail() string { if o == nil || o.Email == nil { var ret string @@ -173,7 +168,7 @@ func (o *User) GetEmail() string { return *o.Email } -// GetEmailOk returns a tuple with the Email field if it's non-nil, zero value otherwise +// GetEmailOk returns a tuple with the Email field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetEmailOk() (string, bool) { if o == nil || o.Email == nil { @@ -197,7 +192,7 @@ func (o *User) SetEmail(v string) { o.Email = &v } -// GetPassword returns the Password field if non-nil, zero value otherwise. +// GetPassword returns the Password field value if set, zero value otherwise. func (o *User) GetPassword() string { if o == nil || o.Password == nil { var ret string @@ -206,7 +201,7 @@ func (o *User) GetPassword() string { return *o.Password } -// GetPasswordOk returns a tuple with the Password field if it's non-nil, zero value otherwise +// GetPasswordOk returns a tuple with the Password field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetPasswordOk() (string, bool) { if o == nil || o.Password == nil { @@ -230,7 +225,7 @@ func (o *User) SetPassword(v string) { o.Password = &v } -// GetPhone returns the Phone field if non-nil, zero value otherwise. +// GetPhone returns the Phone field value if set, zero value otherwise. func (o *User) GetPhone() string { if o == nil || o.Phone == nil { var ret string @@ -239,7 +234,7 @@ func (o *User) GetPhone() string { return *o.Phone } -// GetPhoneOk returns a tuple with the Phone field if it's non-nil, zero value otherwise +// GetPhoneOk returns a tuple with the Phone field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetPhoneOk() (string, bool) { if o == nil || o.Phone == nil { @@ -263,7 +258,7 @@ func (o *User) SetPhone(v string) { o.Phone = &v } -// GetUserStatus returns the UserStatus field if non-nil, zero value otherwise. +// GetUserStatus returns the UserStatus field value if set, zero value otherwise. func (o *User) GetUserStatus() int32 { if o == nil || o.UserStatus == nil { var ret int32 @@ -272,7 +267,7 @@ func (o *User) GetUserStatus() int32 { return *o.UserStatus } -// GetUserStatusOk returns a tuple with the UserStatus field if it's non-nil, zero value otherwise +// GetUserStatusOk returns a tuple with the UserStatus field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *User) GetUserStatusOk() (int32, bool) { if o == nil || o.UserStatus == nil { @@ -296,35 +291,26 @@ func (o *User) SetUserStatus(v int32) { o.UserStatus = &v } - -// MarshalJSON returns the JSON representation of the model. -func (o User) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Id != nil { - toSerialize["id"] = o.Id - } - if o.Username != nil { - toSerialize["username"] = o.Username - } - if o.FirstName != nil { - toSerialize["firstName"] = o.FirstName - } - if o.LastName != nil { - toSerialize["lastName"] = o.LastName - } - if o.Email != nil { - toSerialize["email"] = o.Email - } - if o.Password != nil { - toSerialize["password"] = o.Password - } - if o.Phone != nil { - toSerialize["phone"] = o.Phone - } - if o.UserStatus != nil { - toSerialize["userStatus"] = o.UserStatus - } - return json.Marshal(toSerialize) +type NullableUser struct { + Value User + ExplicitNull bool } +func (v NullableUser) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableUser) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/utils.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/utils.go index f5916b755a2..2bfa04d4e48 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/utils.go +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/utils.go @@ -9,7 +9,14 @@ package openapi -import "time" +import ( + "bytes" + "encoding/json" + "errors" + "time" +) + +var ErrInvalidNullable = errors.New("nullable cannot have non-zero Value and ExplicitNull simultaneously") // PtrBool is a helper routine that returns a pointer to given integer value. func PtrBool(v bool) *bool { return &v } @@ -23,9 +30,6 @@ func PtrInt32(v int32) *int32 { return &v } // PtrInt64 is a helper routine that returns a pointer to given integer value. func PtrInt64(v int64) *int64 { return &v } -// PtrFloat is a helper routine that returns a pointer to given float value. -func PtrFloat(v float32) *float32 { return &v } - // PtrFloat32 is a helper routine that returns a pointer to given float value. func PtrFloat32(v float32) *float32 { return &v } @@ -36,4 +40,205 @@ func PtrFloat64(v float64) *float64 { return &v } func PtrString(v string) *string { return &v } // PtrTime is helper routine that returns a pointer to given Time value. -func PtrTime(v time.Time) *time.Time { return &v } \ No newline at end of file +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + Value bool + ExplicitNull bool +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value: + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableInt struct { + Value int + ExplicitNull bool +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != 0: + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableInt32 struct { + Value int32 + ExplicitNull bool +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != 0: + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableInt64 struct { + Value int64 + ExplicitNull bool +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != 0: + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableFloat32 struct { + Value float32 + ExplicitNull bool +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != 0.0: + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableFloat64 struct { + Value float64 + ExplicitNull bool +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != 0.0: + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableString struct { + Value string + ExplicitNull bool +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && v.Value != "": + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + +type NullableTime struct { + Value time.Time + ExplicitNull bool +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull && !v.Value.IsZero(): + return nil, ErrInvalidNullable + case v.ExplicitNull: + return []byte("null"), nil + default: + return v.Value.MarshalJSON() + } +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} \ No newline at end of file