diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache index d634c704a34b..84c8b3a9e7ca 100644 --- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache +++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache @@ -404,10 +404,14 @@ func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) { {{#isMap}} var{{{classname}}} := _{{{classname}}}{} - if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil { - *o = {{{classname}}}(var{{{classname}}}) + err = json.Unmarshal(bytes, &var{{{classname}}}) + + if err != nil { + return err } + *o = {{{classname}}}(var{{{classname}}}) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { @@ -423,10 +427,14 @@ func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) { {{^parent}} var{{{classname}}} := _{{{classname}}}{} - if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil { - *o = {{{classname}}}(var{{{classname}}}) + err = json.Unmarshal(bytes, &var{{{classname}}}) + + if err != nil { + return err } + *o = {{{classname}}}(var{{{classname}}}) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go index eadf2a95994a..880f95e954ab 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesAnyType) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesAnyType) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesAnyType := _AdditionalPropertiesAnyType{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesAnyType); err == nil { - *o = AdditionalPropertiesAnyType(varAdditionalPropertiesAnyType) + err = json.Unmarshal(bytes, &varAdditionalPropertiesAnyType) + + if err != nil { + return err } + *o = AdditionalPropertiesAnyType(varAdditionalPropertiesAnyType) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go index f2527113454e..22c59ee9a613 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesArray) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesArray) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesArray := _AdditionalPropertiesArray{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesArray); err == nil { - *o = AdditionalPropertiesArray(varAdditionalPropertiesArray) + err = json.Unmarshal(bytes, &varAdditionalPropertiesArray) + + if err != nil { + return err } + *o = AdditionalPropertiesArray(varAdditionalPropertiesArray) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go index c1401d929123..e898485760ab 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesBoolean) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesBoolean) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesBoolean := _AdditionalPropertiesBoolean{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesBoolean); err == nil { - *o = AdditionalPropertiesBoolean(varAdditionalPropertiesBoolean) + err = json.Unmarshal(bytes, &varAdditionalPropertiesBoolean) + + if err != nil { + return err } + *o = AdditionalPropertiesBoolean(varAdditionalPropertiesBoolean) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go index 0147d6eaf856..af609f1474c0 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesInteger) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesInteger) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesInteger := _AdditionalPropertiesInteger{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesInteger); err == nil { - *o = AdditionalPropertiesInteger(varAdditionalPropertiesInteger) + err = json.Unmarshal(bytes, &varAdditionalPropertiesInteger) + + if err != nil { + return err } + *o = AdditionalPropertiesInteger(varAdditionalPropertiesInteger) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go index 85b3663bf4cf..f3eb23fc4560 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesNumber) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesNumber) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesNumber := _AdditionalPropertiesNumber{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesNumber); err == nil { - *o = AdditionalPropertiesNumber(varAdditionalPropertiesNumber) + err = json.Unmarshal(bytes, &varAdditionalPropertiesNumber) + + if err != nil { + return err } + *o = AdditionalPropertiesNumber(varAdditionalPropertiesNumber) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go index 7132cbe61bc4..d0730dc7f53d 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesObject) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesObject) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesObject := _AdditionalPropertiesObject{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesObject); err == nil { - *o = AdditionalPropertiesObject(varAdditionalPropertiesObject) + err = json.Unmarshal(bytes, &varAdditionalPropertiesObject) + + if err != nil { + return err } + *o = AdditionalPropertiesObject(varAdditionalPropertiesObject) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go index 70882312adfe..acfc3440092f 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go @@ -98,10 +98,14 @@ func (o AdditionalPropertiesString) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesString) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesString := _AdditionalPropertiesString{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesString); err == nil { - *o = AdditionalPropertiesString(varAdditionalPropertiesString) + err = json.Unmarshal(bytes, &varAdditionalPropertiesString) + + if err != nil { + return err } + *o = AdditionalPropertiesString(varAdditionalPropertiesString) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go index 68a402cba163..2bf31c269bb4 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_200_response.go @@ -134,10 +134,14 @@ func (o Model200Response) ToMap() (map[string]interface{}, error) { func (o *Model200Response) UnmarshalJSON(bytes []byte) (err error) { varModel200Response := _Model200Response{} - if err = json.Unmarshal(bytes, &varModel200Response); err == nil { - *o = Model200Response(varModel200Response) + err = json.Unmarshal(bytes, &varModel200Response) + + if err != nil { + return err } + *o = Model200Response(varModel200Response) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go index 131bc4726e50..3e64a6b310ca 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model__foo_get_default_response.go @@ -98,10 +98,14 @@ func (o FooGetDefaultResponse) ToMap() (map[string]interface{}, error) { func (o *FooGetDefaultResponse) UnmarshalJSON(bytes []byte) (err error) { varFooGetDefaultResponse := _FooGetDefaultResponse{} - if err = json.Unmarshal(bytes, &varFooGetDefaultResponse); err == nil { - *o = FooGetDefaultResponse(varFooGetDefaultResponse) + err = json.Unmarshal(bytes, &varFooGetDefaultResponse) + + if err != nil { + return err } + *o = FooGetDefaultResponse(varFooGetDefaultResponse) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go index 55f423140575..0509ff5da5d8 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model__special_model_name_.go @@ -98,10 +98,14 @@ func (o SpecialModelName) ToMap() (map[string]interface{}, error) { func (o *SpecialModelName) UnmarshalJSON(bytes []byte) (err error) { varSpecialModelName := _SpecialModelName{} - if err = json.Unmarshal(bytes, &varSpecialModelName); err == nil { - *o = SpecialModelName(varSpecialModelName) + err = json.Unmarshal(bytes, &varSpecialModelName) + + if err != nil { + return err } + *o = SpecialModelName(varSpecialModelName) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go index bf906f2224ba..d9210014d80d 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_additional_properties_class.go @@ -134,10 +134,14 @@ func (o AdditionalPropertiesClass) ToMap() (map[string]interface{}, error) { func (o *AdditionalPropertiesClass) UnmarshalJSON(bytes []byte) (err error) { varAdditionalPropertiesClass := _AdditionalPropertiesClass{} - if err = json.Unmarshal(bytes, &varAdditionalPropertiesClass); err == nil { - *o = AdditionalPropertiesClass(varAdditionalPropertiesClass) + err = json.Unmarshal(bytes, &varAdditionalPropertiesClass) + + if err != nil { + return err } + *o = AdditionalPropertiesClass(varAdditionalPropertiesClass) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_all_of_primitive_types.go b/samples/openapi3/client/petstore/go/go-petstore/model_all_of_primitive_types.go index 825944aeadc2..8c6f26889502 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_all_of_primitive_types.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_all_of_primitive_types.go @@ -99,10 +99,14 @@ func (o AllOfPrimitiveTypes) ToMap() (map[string]interface{}, error) { func (o *AllOfPrimitiveTypes) UnmarshalJSON(bytes []byte) (err error) { varAllOfPrimitiveTypes := _AllOfPrimitiveTypes{} - if err = json.Unmarshal(bytes, &varAllOfPrimitiveTypes); err == nil { - *o = AllOfPrimitiveTypes(varAllOfPrimitiveTypes) + err = json.Unmarshal(bytes, &varAllOfPrimitiveTypes) + + if err != nil { + return err } + *o = AllOfPrimitiveTypes(varAllOfPrimitiveTypes) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go index 5b8b9b9f0420..c01aa9aeadc2 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_animal.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_animal.go @@ -129,10 +129,14 @@ func (o Animal) ToMap() (map[string]interface{}, error) { func (o *Animal) UnmarshalJSON(bytes []byte) (err error) { varAnimal := _Animal{} - if err = json.Unmarshal(bytes, &varAnimal); err == nil { - *o = Animal(varAnimal) + err = json.Unmarshal(bytes, &varAnimal) + + if err != nil { + return err } + *o = Animal(varAnimal) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go index 699ca7d52f63..c8d0d91baabe 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_api_response.go @@ -170,10 +170,14 @@ func (o ApiResponse) ToMap() (map[string]interface{}, error) { func (o *ApiResponse) UnmarshalJSON(bytes []byte) (err error) { varApiResponse := _ApiResponse{} - if err = json.Unmarshal(bytes, &varApiResponse); err == nil { - *o = ApiResponse(varApiResponse) + err = json.Unmarshal(bytes, &varApiResponse) + + if err != nil { + return err } + *o = ApiResponse(varApiResponse) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go index 43082aa35b6f..19df0b7b57b1 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_apple.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple.go @@ -98,10 +98,14 @@ func (o Apple) ToMap() (map[string]interface{}, error) { func (o *Apple) UnmarshalJSON(bytes []byte) (err error) { varApple := _Apple{} - if err = json.Unmarshal(bytes, &varApple); err == nil { - *o = Apple(varApple) + err = json.Unmarshal(bytes, &varApple) + + if err != nil { + return err } + *o = Apple(varApple) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go index 6e58309aa40b..23fa5ed2867b 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go @@ -125,10 +125,14 @@ func (o AppleReq) ToMap() (map[string]interface{}, error) { func (o *AppleReq) UnmarshalJSON(bytes []byte) (err error) { varAppleReq := _AppleReq{} - if err = json.Unmarshal(bytes, &varAppleReq); err == nil { - *o = AppleReq(varAppleReq) + err = json.Unmarshal(bytes, &varAppleReq) + + if err != nil { + return err } + *o = AppleReq(varAppleReq) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go index 9f84133a4ae1..6d4c67f246e2 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_array_of_number_only.go @@ -98,10 +98,14 @@ func (o ArrayOfArrayOfNumberOnly) ToMap() (map[string]interface{}, error) { func (o *ArrayOfArrayOfNumberOnly) UnmarshalJSON(bytes []byte) (err error) { varArrayOfArrayOfNumberOnly := _ArrayOfArrayOfNumberOnly{} - if err = json.Unmarshal(bytes, &varArrayOfArrayOfNumberOnly); err == nil { - *o = ArrayOfArrayOfNumberOnly(varArrayOfArrayOfNumberOnly) + err = json.Unmarshal(bytes, &varArrayOfArrayOfNumberOnly) + + if err != nil { + return err } + *o = ArrayOfArrayOfNumberOnly(varArrayOfArrayOfNumberOnly) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go index e3ff1e6c56b8..d45cec963658 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_of_number_only.go @@ -98,10 +98,14 @@ func (o ArrayOfNumberOnly) ToMap() (map[string]interface{}, error) { func (o *ArrayOfNumberOnly) UnmarshalJSON(bytes []byte) (err error) { varArrayOfNumberOnly := _ArrayOfNumberOnly{} - if err = json.Unmarshal(bytes, &varArrayOfNumberOnly); err == nil { - *o = ArrayOfNumberOnly(varArrayOfNumberOnly) + err = json.Unmarshal(bytes, &varArrayOfNumberOnly) + + if err != nil { + return err } + *o = ArrayOfNumberOnly(varArrayOfNumberOnly) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go index 5d97f8623397..2851c2f46843 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_array_test_.go @@ -170,10 +170,14 @@ func (o ArrayTest) ToMap() (map[string]interface{}, error) { func (o *ArrayTest) UnmarshalJSON(bytes []byte) (err error) { varArrayTest := _ArrayTest{} - if err = json.Unmarshal(bytes, &varArrayTest); err == nil { - *o = ArrayTest(varArrayTest) + err = json.Unmarshal(bytes, &varArrayTest) + + if err != nil { + return err } + *o = ArrayTest(varArrayTest) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go index 2a6f5d4d2624..4d757fbf9925 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_banana.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana.go @@ -98,10 +98,14 @@ func (o Banana) ToMap() (map[string]interface{}, error) { func (o *Banana) UnmarshalJSON(bytes []byte) (err error) { varBanana := _Banana{} - if err = json.Unmarshal(bytes, &varBanana); err == nil { - *o = Banana(varBanana) + err = json.Unmarshal(bytes, &varBanana) + + if err != nil { + return err } + *o = Banana(varBanana) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go index cb1045513e7b..5d5923fc5a7c 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go @@ -125,10 +125,14 @@ func (o BananaReq) ToMap() (map[string]interface{}, error) { func (o *BananaReq) UnmarshalJSON(bytes []byte) (err error) { varBananaReq := _BananaReq{} - if err = json.Unmarshal(bytes, &varBananaReq); err == nil { - *o = BananaReq(varBananaReq) + err = json.Unmarshal(bytes, &varBananaReq) + + if err != nil { + return err } + *o = BananaReq(varBananaReq) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go index 06a8833a2fbf..8b09f0d813e4 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_capitalization.go @@ -279,10 +279,14 @@ func (o Capitalization) ToMap() (map[string]interface{}, error) { func (o *Capitalization) UnmarshalJSON(bytes []byte) (err error) { varCapitalization := _Capitalization{} - if err = json.Unmarshal(bytes, &varCapitalization); err == nil { - *o = Capitalization(varCapitalization) + err = json.Unmarshal(bytes, &varCapitalization) + + if err != nil { + return err } + *o = Capitalization(varCapitalization) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_category.go b/samples/openapi3/client/petstore/go/go-petstore/model_category.go index 6275a2967e93..bd4d6815e72e 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_category.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_category.go @@ -127,10 +127,14 @@ func (o Category) ToMap() (map[string]interface{}, error) { func (o *Category) UnmarshalJSON(bytes []byte) (err error) { varCategory := _Category{} - if err = json.Unmarshal(bytes, &varCategory); err == nil { - *o = Category(varCategory) + err = json.Unmarshal(bytes, &varCategory) + + if err != nil { + return err } + *o = Category(varCategory) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go index 0f01c8201721..72fe2596231c 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_class_model.go @@ -98,10 +98,14 @@ func (o ClassModel) ToMap() (map[string]interface{}, error) { func (o *ClassModel) UnmarshalJSON(bytes []byte) (err error) { varClassModel := _ClassModel{} - if err = json.Unmarshal(bytes, &varClassModel); err == nil { - *o = ClassModel(varClassModel) + err = json.Unmarshal(bytes, &varClassModel) + + if err != nil { + return err } + *o = ClassModel(varClassModel) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_client.go b/samples/openapi3/client/petstore/go/go-petstore/model_client.go index f034a9f91f22..e635b0546e07 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_client.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_client.go @@ -98,10 +98,14 @@ func (o Client) ToMap() (map[string]interface{}, error) { func (o *Client) UnmarshalJSON(bytes []byte) (err error) { varClient := _Client{} - if err = json.Unmarshal(bytes, &varClient); err == nil { - *o = Client(varClient) + err = json.Unmarshal(bytes, &varClient) + + if err != nil { + return err } + *o = Client(varClient) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go index 1c8ed0909f66..bb2e2132e122 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go @@ -90,10 +90,14 @@ func (o DuplicatedPropParent) ToMap() (map[string]interface{}, error) { func (o *DuplicatedPropParent) UnmarshalJSON(bytes []byte) (err error) { varDuplicatedPropParent := _DuplicatedPropParent{} - if err = json.Unmarshal(bytes, &varDuplicatedPropParent); err == nil { - *o = DuplicatedPropParent(varDuplicatedPropParent) + err = json.Unmarshal(bytes, &varDuplicatedPropParent) + + if err != nil { + return err } + *o = DuplicatedPropParent(varDuplicatedPropParent) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go index 9a16611ca047..cbb59df3be01 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_arrays.go @@ -134,10 +134,14 @@ func (o EnumArrays) ToMap() (map[string]interface{}, error) { func (o *EnumArrays) UnmarshalJSON(bytes []byte) (err error) { varEnumArrays := _EnumArrays{} - if err = json.Unmarshal(bytes, &varEnumArrays); err == nil { - *o = EnumArrays(varEnumArrays) + err = json.Unmarshal(bytes, &varEnumArrays) + + if err != nil { + return err } + *o = EnumArrays(varEnumArrays) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go index 14202318657c..eb00c70e14f6 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go @@ -359,10 +359,14 @@ func (o EnumTest) ToMap() (map[string]interface{}, error) { func (o *EnumTest) UnmarshalJSON(bytes []byte) (err error) { varEnumTest := _EnumTest{} - if err = json.Unmarshal(bytes, &varEnumTest); err == nil { - *o = EnumTest(varEnumTest) + err = json.Unmarshal(bytes, &varEnumTest) + + if err != nil { + return err } + *o = EnumTest(varEnumTest) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file.go b/samples/openapi3/client/petstore/go/go-petstore/model_file.go index 631cd8ee96b2..bf26cb96bf35 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_file.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_file.go @@ -99,10 +99,14 @@ func (o File) ToMap() (map[string]interface{}, error) { func (o *File) UnmarshalJSON(bytes []byte) (err error) { varFile := _File{} - if err = json.Unmarshal(bytes, &varFile); err == nil { - *o = File(varFile) + err = json.Unmarshal(bytes, &varFile) + + if err != nil { + return err } + *o = File(varFile) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go index d35771316bbf..ab98b53cba46 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_file_schema_test_class.go @@ -134,10 +134,14 @@ func (o FileSchemaTestClass) ToMap() (map[string]interface{}, error) { func (o *FileSchemaTestClass) UnmarshalJSON(bytes []byte) (err error) { varFileSchemaTestClass := _FileSchemaTestClass{} - if err = json.Unmarshal(bytes, &varFileSchemaTestClass); err == nil { - *o = FileSchemaTestClass(varFileSchemaTestClass) + err = json.Unmarshal(bytes, &varFileSchemaTestClass) + + if err != nil { + return err } + *o = FileSchemaTestClass(varFileSchemaTestClass) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go index 930080a69eb4..76e88bfaa2e2 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_foo.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_foo.go @@ -102,10 +102,14 @@ func (o Foo) ToMap() (map[string]interface{}, error) { func (o *Foo) UnmarshalJSON(bytes []byte) (err error) { varFoo := _Foo{} - if err = json.Unmarshal(bytes, &varFoo); err == nil { - *o = Foo(varFoo) + err = json.Unmarshal(bytes, &varFoo) + + if err != nil { + return err } + *o = Foo(varFoo) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go index b887e12ec737..499ceba4acb0 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go @@ -570,10 +570,14 @@ func (o FormatTest) ToMap() (map[string]interface{}, error) { func (o *FormatTest) UnmarshalJSON(bytes []byte) (err error) { varFormatTest := _FormatTest{} - if err = json.Unmarshal(bytes, &varFormatTest); err == nil { - *o = FormatTest(varFormatTest) + err = json.Unmarshal(bytes, &varFormatTest) + + if err != nil { + return err } + *o = FormatTest(varFormatTest) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go index 7f37585fa2e0..c7f8236ee236 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_has_only_read_only.go @@ -134,10 +134,14 @@ func (o HasOnlyReadOnly) ToMap() (map[string]interface{}, error) { func (o *HasOnlyReadOnly) UnmarshalJSON(bytes []byte) (err error) { varHasOnlyReadOnly := _HasOnlyReadOnly{} - if err = json.Unmarshal(bytes, &varHasOnlyReadOnly); err == nil { - *o = HasOnlyReadOnly(varHasOnlyReadOnly) + err = json.Unmarshal(bytes, &varHasOnlyReadOnly) + + if err != nil { + return err } + *o = HasOnlyReadOnly(varHasOnlyReadOnly) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go b/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go index c3498f9e9f8a..3617d9b3f8b7 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_health_check_result.go @@ -108,10 +108,14 @@ func (o HealthCheckResult) ToMap() (map[string]interface{}, error) { func (o *HealthCheckResult) UnmarshalJSON(bytes []byte) (err error) { varHealthCheckResult := _HealthCheckResult{} - if err = json.Unmarshal(bytes, &varHealthCheckResult); err == nil { - *o = HealthCheckResult(varHealthCheckResult) + err = json.Unmarshal(bytes, &varHealthCheckResult) + + if err != nil { + return err } + *o = HealthCheckResult(varHealthCheckResult) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_list.go b/samples/openapi3/client/petstore/go/go-petstore/model_list.go index 77017d73bc0c..8af38e91ef3b 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_list.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_list.go @@ -98,10 +98,14 @@ func (o List) ToMap() (map[string]interface{}, error) { func (o *List) UnmarshalJSON(bytes []byte) (err error) { varList := _List{} - if err = json.Unmarshal(bytes, &varList); err == nil { - *o = List(varList) + err = json.Unmarshal(bytes, &varList) + + if err != nil { + return err } + *o = List(varList) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go index e14eaaafe243..c86070564546 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_of_file_test_.go @@ -100,10 +100,14 @@ func (o MapOfFileTest) ToMap() (map[string]interface{}, error) { func (o *MapOfFileTest) UnmarshalJSON(bytes []byte) (err error) { varMapOfFileTest := _MapOfFileTest{} - if err = json.Unmarshal(bytes, &varMapOfFileTest); err == nil { - *o = MapOfFileTest(varMapOfFileTest) + err = json.Unmarshal(bytes, &varMapOfFileTest) + + if err != nil { + return err } + *o = MapOfFileTest(varMapOfFileTest) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go index bd512760a45f..f7fefb0c1036 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_map_test_.go @@ -206,10 +206,14 @@ func (o MapTest) ToMap() (map[string]interface{}, error) { func (o *MapTest) UnmarshalJSON(bytes []byte) (err error) { varMapTest := _MapTest{} - if err = json.Unmarshal(bytes, &varMapTest); err == nil { - *o = MapTest(varMapTest) + err = json.Unmarshal(bytes, &varMapTest) + + if err != nil { + return err } + *o = MapTest(varMapTest) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go index 4a65bb995733..8470ccb66320 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go @@ -171,10 +171,14 @@ func (o MixedPropertiesAndAdditionalPropertiesClass) ToMap() (map[string]interfa func (o *MixedPropertiesAndAdditionalPropertiesClass) UnmarshalJSON(bytes []byte) (err error) { varMixedPropertiesAndAdditionalPropertiesClass := _MixedPropertiesAndAdditionalPropertiesClass{} - if err = json.Unmarshal(bytes, &varMixedPropertiesAndAdditionalPropertiesClass); err == nil { - *o = MixedPropertiesAndAdditionalPropertiesClass(varMixedPropertiesAndAdditionalPropertiesClass) + err = json.Unmarshal(bytes, &varMixedPropertiesAndAdditionalPropertiesClass) + + if err != nil { + return err } + *o = MixedPropertiesAndAdditionalPropertiesClass(varMixedPropertiesAndAdditionalPropertiesClass) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_name.go b/samples/openapi3/client/petstore/go/go-petstore/model_name.go index 74b7b5deda0b..84a92878766a 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_name.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_name.go @@ -197,10 +197,14 @@ func (o Name) ToMap() (map[string]interface{}, error) { func (o *Name) UnmarshalJSON(bytes []byte) (err error) { varName := _Name{} - if err = json.Unmarshal(bytes, &varName); err == nil { - *o = Name(varName) + err = json.Unmarshal(bytes, &varName) + + if err != nil { + return err } + *o = Name(varName) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go index f9f10c7e5ff4..3f7029b787da 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of.go @@ -108,10 +108,14 @@ func (o NullableAllOf) ToMap() (map[string]interface{}, error) { func (o *NullableAllOf) UnmarshalJSON(bytes []byte) (err error) { varNullableAllOf := _NullableAllOf{} - if err = json.Unmarshal(bytes, &varNullableAllOf); err == nil { - *o = NullableAllOf(varNullableAllOf) + err = json.Unmarshal(bytes, &varNullableAllOf) + + if err != nil { + return err } + *o = NullableAllOf(varNullableAllOf) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go index 7b28b820f332..0aec0ac62550 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_all_of_child.go @@ -98,10 +98,14 @@ func (o NullableAllOfChild) ToMap() (map[string]interface{}, error) { func (o *NullableAllOfChild) UnmarshalJSON(bytes []byte) (err error) { varNullableAllOfChild := _NullableAllOfChild{} - if err = json.Unmarshal(bytes, &varNullableAllOfChild); err == nil { - *o = NullableAllOfChild(varNullableAllOfChild) + err = json.Unmarshal(bytes, &varNullableAllOfChild) + + if err != nil { + return err } + *o = NullableAllOfChild(varNullableAllOfChild) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go index 580936cff216..a323a2e59524 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go @@ -563,10 +563,14 @@ func (o NullableClass) ToMap() (map[string]interface{}, error) { func (o *NullableClass) UnmarshalJSON(bytes []byte) (err error) { varNullableClass := _NullableClass{} - if err = json.Unmarshal(bytes, &varNullableClass); err == nil { - *o = NullableClass(varNullableClass) + err = json.Unmarshal(bytes, &varNullableClass) + + if err != nil { + return err } + *o = NullableClass(varNullableClass) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go index 36bd0c4b7a2b..95b416db196f 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_number_only.go @@ -98,10 +98,14 @@ func (o NumberOnly) ToMap() (map[string]interface{}, error) { func (o *NumberOnly) UnmarshalJSON(bytes []byte) (err error) { varNumberOnly := _NumberOnly{} - if err = json.Unmarshal(bytes, &varNumberOnly); err == nil { - *o = NumberOnly(varNumberOnly) + err = json.Unmarshal(bytes, &varNumberOnly) + + if err != nil { + return err } + *o = NumberOnly(varNumberOnly) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go index 1c719015646d..1fa6693b43b3 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_one_of_primitive_type_child.go @@ -98,10 +98,14 @@ func (o OneOfPrimitiveTypeChild) ToMap() (map[string]interface{}, error) { func (o *OneOfPrimitiveTypeChild) UnmarshalJSON(bytes []byte) (err error) { varOneOfPrimitiveTypeChild := _OneOfPrimitiveTypeChild{} - if err = json.Unmarshal(bytes, &varOneOfPrimitiveTypeChild); err == nil { - *o = OneOfPrimitiveTypeChild(varOneOfPrimitiveTypeChild) + err = json.Unmarshal(bytes, &varOneOfPrimitiveTypeChild) + + if err != nil { + return err } + *o = OneOfPrimitiveTypeChild(varOneOfPrimitiveTypeChild) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_order.go b/samples/openapi3/client/petstore/go/go-petstore/model_order.go index a4be8a04ee2a..15f139933399 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_order.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_order.go @@ -284,10 +284,14 @@ func (o Order) ToMap() (map[string]interface{}, error) { func (o *Order) UnmarshalJSON(bytes []byte) (err error) { varOrder := _Order{} - if err = json.Unmarshal(bytes, &varOrder); err == nil { - *o = Order(varOrder) + err = json.Unmarshal(bytes, &varOrder) + + if err != nil { + return err } + *o = Order(varOrder) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go index 74c5518557bb..279f46eeac46 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_outer_composite.go @@ -170,10 +170,14 @@ func (o OuterComposite) ToMap() (map[string]interface{}, error) { func (o *OuterComposite) UnmarshalJSON(bytes []byte) (err error) { varOuterComposite := _OuterComposite{} - if err = json.Unmarshal(bytes, &varOuterComposite); err == nil { - *o = OuterComposite(varOuterComposite) + err = json.Unmarshal(bytes, &varOuterComposite) + + if err != nil { + return err } + *o = OuterComposite(varOuterComposite) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go index 156f6be2f76b..0f1ffe373e5b 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go @@ -265,10 +265,14 @@ func (o Pet) ToMap() (map[string]interface{}, error) { func (o *Pet) UnmarshalJSON(bytes []byte) (err error) { varPet := _Pet{} - if err = json.Unmarshal(bytes, &varPet); err == nil { - *o = Pet(varPet) + err = json.Unmarshal(bytes, &varPet) + + if err != nil { + return err } + *o = Pet(varPet) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_property_name_mapping.go b/samples/openapi3/client/petstore/go/go-petstore/model_property_name_mapping.go index 058a55bd0b26..c621f708467d 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_property_name_mapping.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_property_name_mapping.go @@ -206,10 +206,14 @@ func (o PropertyNameMapping) ToMap() (map[string]interface{}, error) { func (o *PropertyNameMapping) UnmarshalJSON(bytes []byte) (err error) { varPropertyNameMapping := _PropertyNameMapping{} - if err = json.Unmarshal(bytes, &varPropertyNameMapping); err == nil { - *o = PropertyNameMapping(varPropertyNameMapping) + err = json.Unmarshal(bytes, &varPropertyNameMapping) + + if err != nil { + return err } + *o = PropertyNameMapping(varPropertyNameMapping) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go index 6aa66a79f202..3b240abf82b7 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_first.go @@ -134,10 +134,14 @@ func (o ReadOnlyFirst) ToMap() (map[string]interface{}, error) { func (o *ReadOnlyFirst) UnmarshalJSON(bytes []byte) (err error) { varReadOnlyFirst := _ReadOnlyFirst{} - if err = json.Unmarshal(bytes, &varReadOnlyFirst); err == nil { - *o = ReadOnlyFirst(varReadOnlyFirst) + err = json.Unmarshal(bytes, &varReadOnlyFirst) + + if err != nil { + return err } + *o = ReadOnlyFirst(varReadOnlyFirst) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go index 146b94ebc147..5bf6817a9c9b 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_read_only_with_default.go @@ -326,10 +326,14 @@ func (o ReadOnlyWithDefault) ToMap() (map[string]interface{}, error) { func (o *ReadOnlyWithDefault) UnmarshalJSON(bytes []byte) (err error) { varReadOnlyWithDefault := _ReadOnlyWithDefault{} - if err = json.Unmarshal(bytes, &varReadOnlyWithDefault); err == nil { - *o = ReadOnlyWithDefault(varReadOnlyWithDefault) + err = json.Unmarshal(bytes, &varReadOnlyWithDefault) + + if err != nil { + return err } + *o = ReadOnlyWithDefault(varReadOnlyWithDefault) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_return.go b/samples/openapi3/client/petstore/go/go-petstore/model_return.go index e77f7e007925..991ccc4bd796 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_return.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_return.go @@ -98,10 +98,14 @@ func (o Return) ToMap() (map[string]interface{}, error) { func (o *Return) UnmarshalJSON(bytes []byte) (err error) { varReturn := _Return{} - if err = json.Unmarshal(bytes, &varReturn); err == nil { - *o = Return(varReturn) + err = json.Unmarshal(bytes, &varReturn) + + if err != nil { + return err } + *o = Return(varReturn) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go index f77bf7206b0c..822a5a12c015 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_tag.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_tag.go @@ -134,10 +134,14 @@ func (o Tag) ToMap() (map[string]interface{}, error) { func (o *Tag) UnmarshalJSON(bytes []byte) (err error) { varTag := _Tag{} - if err = json.Unmarshal(bytes, &varTag); err == nil { - *o = Tag(varTag) + err = json.Unmarshal(bytes, &varTag) + + if err != nil { + return err } + *o = Tag(varTag) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_user.go b/samples/openapi3/client/petstore/go/go-petstore/model_user.go index b884647d1be0..08a1961af341 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_user.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_user.go @@ -502,10 +502,14 @@ func (o User) ToMap() (map[string]interface{}, error) { func (o *User) UnmarshalJSON(bytes []byte) (err error) { varUser := _User{} - if err = json.Unmarshal(bytes, &varUser); err == nil { - *o = User(varUser) + err = json.Unmarshal(bytes, &varUser) + + if err != nil { + return err } + *o = User(varUser) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go index 8ee96e3aea32..7e450a046cd9 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_whale.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_whale.go @@ -161,10 +161,14 @@ func (o Whale) ToMap() (map[string]interface{}, error) { func (o *Whale) UnmarshalJSON(bytes []byte) (err error) { varWhale := _Whale{} - if err = json.Unmarshal(bytes, &varWhale); err == nil { - *o = Whale(varWhale) + err = json.Unmarshal(bytes, &varWhale) + + if err != nil { + return err } + *o = Whale(varWhale) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go index 3349c9470cfc..01a0ae804d41 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_zebra.go @@ -125,10 +125,14 @@ func (o Zebra) ToMap() (map[string]interface{}, error) { func (o *Zebra) UnmarshalJSON(bytes []byte) (err error) { varZebra := _Zebra{} - if err = json.Unmarshal(bytes, &varZebra); err == nil { - *o = Zebra(varZebra) + err = json.Unmarshal(bytes, &varZebra) + + if err != nil { + return err } + *o = Zebra(varZebra) + additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { diff --git a/samples/openapi3/client/petstore/go/store_api_test.go b/samples/openapi3/client/petstore/go/store_api_test.go index d8d5834452bf..564117a2bf84 100644 --- a/samples/openapi3/client/petstore/go/store_api_test.go +++ b/samples/openapi3/client/petstore/go/store_api_test.go @@ -24,7 +24,7 @@ func TestPlaceOrder(t *testing.T) { // Skip parsing time error due to error in Petstore Test Server // https://github.com/OpenAPITools/openapi-generator/issues/1292 if regexp. - MustCompile(`^parsing time.+cannot parse "\+0000"" as "Z07:00"$`). + MustCompile(`as "Z07:00"$`). MatchString(err.Error()) { t.Log("Skipping error for parsing time with `+0000` UTC offset as Petstore Test Server does not return valid RFC 3339 datetime") } else {