diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java index e541998cddc2..76d265049693 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java @@ -36,14 +36,12 @@ public GoClientExperimentalCodegen() { outputFolder = "generated-code/go-experimental"; embeddedTemplateDir = templateDir = "go-experimental"; - generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) - .stability(Stability.EXPERIMENTAL) - .build(); + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata).stability(Stability.EXPERIMENTAL).build(); } /** - * Configures a friendly name for the generator. This will be used by the generator - * to select the library with the -g flag. + * Configures a friendly name for the generator. This will be used by the + * generator to select the library with the -g flag. * * @return the friendly name for the generator */ @@ -53,7 +51,7 @@ public String getName() { } /** - * Returns human-friendly help for the generator. Provide the consumer with help + * Returns human-friendly help for the generator. Provide the consumer with help * tips, parameters here * * @return A string value for the help message @@ -70,24 +68,25 @@ public void processOpts() { } @Override - public Map postProcessModels(Map objs) { + public Map postProcessModels(Map objs) { objs = super.postProcessModels(objs); - List> imports = (List>) objs.get("imports"); - boolean addedErrorsImport = false; List> models = (List>) objs.get("models"); for (Map m : models) { Object v = m.get("model"); if (v instanceof CodegenModel) { CodegenModel model = (CodegenModel) v; - if (!model.isEnum) { - imports.add(createMapping("import", "encoding/json")); + if (model.isEnum) { + continue; } + for (CodegenProperty param : model.vars) { - if (!addedErrorsImport && param.required) { - imports.add(createMapping("import", "errors")); - addedErrorsImport = true; + if (!param.isNullable) { + continue; } + + param.dataType = "Nullable" + Character.toUpperCase(param.dataType.charAt(0)) + + param.dataType.substring(1); } } } diff --git a/modules/openapi-generator/src/main/resources/go-experimental/model.mustache b/modules/openapi-generator/src/main/resources/go-experimental/model.mustache index 2b97b31b3cfa..f1f3dd8c1250 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/model.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/model.mustache @@ -1,15 +1,15 @@ {{>partial_header}} package {{packageName}} + {{#models}} -{{#imports}} -{{#-first}} import ( -{{/-first}} + "bytes" + "encoding/json" +{{#imports}} "{{import}}" -{{#-last}} -) -{{/-last}} {{/imports}} +) + {{#model}} {{#isEnum}} // {{{classname}}} {{#description}}{{{.}}}{{/description}}{{^description}}the model '{{{classname}}}'{{/description}} @@ -25,6 +25,32 @@ const ( {{/enumVars}} {{/allowableValues}} ) + +type Nullable{{{classname}}} struct { + Value {{{classname}}} + ExplicitNull bool +} + +func (v Nullable{{{classname}}}) 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 *Nullable{{{classname}}}) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} + {{/isEnum}} {{^isEnum}} // {{classname}}{{#description}} {{{description}}}{{/description}}{{^description}} struct for {{{classname}}}{{/description}} @@ -35,15 +61,32 @@ type {{classname}} struct { {{#description}} // {{{description}}} {{/description}} - {{name}} *{{{dataType}}} `json:"{{baseName}},omitempty"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` -{{#isNullable}} isExplicitNull{{name}} bool `json:"-"{{#withXml}} xml:"-"{{/withXml}}`{{/isNullable}} + {{name}} {{^required}}*{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` {{/vars}} } {{/isEnum}} {{^isEnum}} {{#vars}} -// Get{{name}} returns the {{name}} field if non-nil, zero value otherwise. +{{#required}} +// Get{{name}} returns the {{name}} field value +func (o *{{classname}}) Get{{name}}() {{dataType}} { + if o == nil { + var ret {{dataType}} + return ret + } + + return o.{{name}} +} + +// Set{{name}} sets field value +func (o *{{classname}}) Set{{name}}(v {{dataType}}) { + o.{{name}} = v +} + +{{/required}} +{{^required}} +// Get{{name}} returns the {{name}} field value if set, zero value otherwise. func (o *{{classname}}) Get{{name}}() {{dataType}} { if o == nil || o.{{name}} == nil { var ret {{dataType}} @@ -52,7 +95,7 @@ func (o *{{classname}}) Get{{name}}() {{dataType}} { return *o.{{name}} } -// Get{{name}}Ok returns a tuple with the {{name}} field if it's non-nil, zero value otherwise +// Get{{name}}Ok 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 *{{classname}}) Get{{name}}Ok() ({{dataType}}, bool) { if o == nil || o.{{name}} == nil { @@ -76,54 +119,30 @@ func (o *{{classname}}) Set{{name}}(v {{dataType}}) { o.{{name}} = &v } -{{#isNullable}} -// Set{{name}}ExplicitNull (un)sets {{name}} to be considered as explicit "null" value -// when serializing to JSON (pass true as argument to set this, false to unset) -// The {{name}} value is set to nil even if false is passed -func (o *{{classname}}) Set{{name}}ExplicitNull(b bool) { - o.{{name}} = nil - o.isExplicitNull{{name}} = b -} -{{/isNullable}} +{{/required}} {{/vars}} +type Nullable{{{classname}}} struct { + Value {{{classname}}} + ExplicitNull bool +} -// MarshalJSON returns the JSON representation of the model. -func (o {{classname}}) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - {{#vars}} - {{#required}} - {{! if argument is required and not nullable, it can't be nil}} - {{^isNullable}} - if o.{{name}} == nil { - return nil, errors.New("{{name}} is required and not nullable, but was not set on {{classname}}") - }{{/isNullable}} - {{! if argument is required and nullable, it *must* have isExplicitNull set to true when it's nil}} - {{#isNullable}} - if o.{{name}} == nil && !o.isExplicitNull{{name}} { - return nil, errors.New("{{name}} is required and nullable, but it wasn't set to be explicit null") - } - {{/isNullable}} - {{/required}} - {{! if argument is nullable, only serialize it if it is nil *and* was explicitly set to nil}} - {{#isNullable}} - if o.{{name}} == nil { - if o.isExplicitNull{{name}} { - toSerialize["{{baseName}}"] = o.{{name}} - } - } else { - toSerialize["{{baseName}}"] = o.{{name}} - } - {{/isNullable}} - {{! if argument is not nullable, don't set it if it is nil}} - {{^isNullable}} - if o.{{name}} != nil { - toSerialize["{{baseName}}"] = o.{{name}} - } - {{/isNullable}} - {{/vars}} - return json.Marshal(toSerialize) +func (v Nullable{{{classname}}}) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } } +func (v *Nullable{{{classname}}}) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} {{/isEnum}} {{/model}} diff --git a/modules/openapi-generator/src/main/resources/go-experimental/utils.mustache b/modules/openapi-generator/src/main/resources/go-experimental/utils.mustache index e3598373cb4a..4502401b6ea4 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/utils.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/utils.mustache @@ -1,7 +1,14 @@ {{>partial_header}} package {{packageName}} -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 } @@ -15,9 +22,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 } @@ -28,4 +32,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 diff --git a/samples/client/petstore/go-experimental/auth_test.go b/samples/client/petstore/go-experimental/auth_test.go index 1bb5d8175635..b788cc1199e3 100644 --- a/samples/client/petstore/go-experimental/auth_test.go +++ b/samples/client/petstore/go-experimental/auth_test.go @@ -37,8 +37,8 @@ func TestOAuth2(t *testing.T) { tokenSource := cfg.TokenSource(createContext(nil), &tok) auth := context.WithValue(context.Background(), sw.ContextOAuth2, tokenSource) - newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(context.Background(), newPet) @@ -72,8 +72,8 @@ func TestBasicAuth(t *testing.T) { Password: "f4k3p455", }) - newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(auth, newPet) @@ -102,8 +102,8 @@ func TestBasicAuth(t *testing.T) { func TestAccessToken(t *testing.T) { auth := context.WithValue(context.Background(), sw.ContextAccessToken, "TESTFAKEACCESSTOKENISFAKE") - newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(nil, newPet) @@ -132,8 +132,8 @@ func TestAccessToken(t *testing.T) { func TestAPIKeyNoPrefix(t *testing.T) { auth := context.WithValue(context.Background(), sw.ContextAPIKeys, map[string]sw.APIKey{"api_key": sw.APIKey{Key: "TEST123"}}) - newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(context.Background(), newPet) @@ -167,8 +167,8 @@ func TestAPIKeyNoPrefix(t *testing.T) { func TestAPIKeyWithPrefix(t *testing.T) { auth := context.WithValue(context.Background(), sw.ContextAPIKeys, map[string]sw.APIKey{"api_key": sw.APIKey{Key: "TEST123", Prefix: "Bearer"}}) - newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(nil, newPet) @@ -200,9 +200,8 @@ func TestAPIKeyWithPrefix(t *testing.T) { } func TestDefaultHeader(t *testing.T) { - - newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(context.Background(), newPet) diff --git a/samples/client/petstore/go-experimental/go-petstore/model_200_response.go b/samples/client/petstore/go-experimental/go-petstore/model_200_response.go index cebe724d060e..6aa7f9b6a79e 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_200_response.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_200_response.go @@ -8,18 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableModel200Response) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_any_type.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_any_type.go index 586b84f029b6..c6fbcc703b3c 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_any_type.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_any_type.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType type AdditionalPropertiesAnyType struct { Name *string `json:"name,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 *AdditionalPropertiesAnyType) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesAnyType) 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 *AdditionalPropertiesAnyType) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesAnyType) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesAnyType struct { + Value AdditionalPropertiesAnyType + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesAnyType) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesAnyType) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesAnyType) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_array.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_array.go index 8cda0b7d08da..b1bf7f332828 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_array.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_array.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesArray struct for AdditionalPropertiesArray type AdditionalPropertiesArray struct { Name *string `json:"name,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 *AdditionalPropertiesArray) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesArray) 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 *AdditionalPropertiesArray) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesArray) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesArray struct { + Value AdditionalPropertiesArray + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesArray) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesArray) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesArray) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_boolean.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_boolean.go index 0148cce9ab42..c1aacbc1eb51 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_boolean.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_boolean.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesBoolean struct for AdditionalPropertiesBoolean type AdditionalPropertiesBoolean struct { Name *string `json:"name,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 *AdditionalPropertiesBoolean) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesBoolean) 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 *AdditionalPropertiesBoolean) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesBoolean) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesBoolean struct { + Value AdditionalPropertiesBoolean + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesBoolean) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesBoolean) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesBoolean) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go index 6d9025a8965b..3c1e8db6244f 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_class.go @@ -8,36 +8,28 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesClass struct for AdditionalPropertiesClass type AdditionalPropertiesClass struct { MapString *map[string]string `json:"map_string,omitempty"` - MapNumber *map[string]float32 `json:"map_number,omitempty"` - MapInteger *map[string]int32 `json:"map_integer,omitempty"` - MapBoolean *map[string]bool `json:"map_boolean,omitempty"` - MapArrayInteger *map[string][]int32 `json:"map_array_integer,omitempty"` - MapArrayAnytype *map[string][]map[string]interface{} `json:"map_array_anytype,omitempty"` - MapMapString *map[string]map[string]string `json:"map_map_string,omitempty"` - MapMapAnytype *map[string]map[string]map[string]interface{} `json:"map_map_anytype,omitempty"` - Anytype1 *map[string]interface{} `json:"anytype_1,omitempty"` - Anytype2 *map[string]interface{} `json:"anytype_2,omitempty"` - Anytype3 *map[string]interface{} `json:"anytype_3,omitempty"` - } -// GetMapString returns the MapString field if non-nil, zero value otherwise. +// GetMapString returns the MapString field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapString() map[string]string { if o == nil || o.MapString == nil { var ret map[string]string @@ -46,7 +38,7 @@ func (o *AdditionalPropertiesClass) GetMapString() map[string]string { return *o.MapString } -// GetMapStringOk returns a tuple with the MapString field if it's non-nil, zero value otherwise +// GetMapStringOk returns a tuple with the MapString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapStringOk() (map[string]string, bool) { if o == nil || o.MapString == nil { @@ -70,7 +62,7 @@ func (o *AdditionalPropertiesClass) SetMapString(v map[string]string) { o.MapString = &v } -// GetMapNumber returns the MapNumber field if non-nil, zero value otherwise. +// GetMapNumber returns the MapNumber field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapNumber() map[string]float32 { if o == nil || o.MapNumber == nil { var ret map[string]float32 @@ -79,7 +71,7 @@ func (o *AdditionalPropertiesClass) GetMapNumber() map[string]float32 { return *o.MapNumber } -// GetMapNumberOk returns a tuple with the MapNumber field if it's non-nil, zero value otherwise +// GetMapNumberOk returns a tuple with the MapNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapNumberOk() (map[string]float32, bool) { if o == nil || o.MapNumber == nil { @@ -103,7 +95,7 @@ func (o *AdditionalPropertiesClass) SetMapNumber(v map[string]float32) { o.MapNumber = &v } -// GetMapInteger returns the MapInteger field if non-nil, zero value otherwise. +// GetMapInteger returns the MapInteger field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapInteger() map[string]int32 { if o == nil || o.MapInteger == nil { var ret map[string]int32 @@ -112,7 +104,7 @@ func (o *AdditionalPropertiesClass) GetMapInteger() map[string]int32 { return *o.MapInteger } -// GetMapIntegerOk returns a tuple with the MapInteger field if it's non-nil, zero value otherwise +// GetMapIntegerOk returns a tuple with the MapInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapIntegerOk() (map[string]int32, bool) { if o == nil || o.MapInteger == nil { @@ -136,7 +128,7 @@ func (o *AdditionalPropertiesClass) SetMapInteger(v map[string]int32) { o.MapInteger = &v } -// GetMapBoolean returns the MapBoolean field if non-nil, zero value otherwise. +// GetMapBoolean returns the MapBoolean field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapBoolean() map[string]bool { if o == nil || o.MapBoolean == nil { var ret map[string]bool @@ -145,7 +137,7 @@ func (o *AdditionalPropertiesClass) GetMapBoolean() map[string]bool { return *o.MapBoolean } -// GetMapBooleanOk returns a tuple with the MapBoolean field if it's non-nil, zero value otherwise +// GetMapBooleanOk returns a tuple with the MapBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapBooleanOk() (map[string]bool, bool) { if o == nil || o.MapBoolean == nil { @@ -169,7 +161,7 @@ func (o *AdditionalPropertiesClass) SetMapBoolean(v map[string]bool) { o.MapBoolean = &v } -// GetMapArrayInteger returns the MapArrayInteger field if non-nil, zero value otherwise. +// GetMapArrayInteger returns the MapArrayInteger field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapArrayInteger() map[string][]int32 { if o == nil || o.MapArrayInteger == nil { var ret map[string][]int32 @@ -178,7 +170,7 @@ func (o *AdditionalPropertiesClass) GetMapArrayInteger() map[string][]int32 { return *o.MapArrayInteger } -// GetMapArrayIntegerOk returns a tuple with the MapArrayInteger field if it's non-nil, zero value otherwise +// GetMapArrayIntegerOk returns a tuple with the MapArrayInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapArrayIntegerOk() (map[string][]int32, bool) { if o == nil || o.MapArrayInteger == nil { @@ -202,7 +194,7 @@ func (o *AdditionalPropertiesClass) SetMapArrayInteger(v map[string][]int32) { o.MapArrayInteger = &v } -// GetMapArrayAnytype returns the MapArrayAnytype field if non-nil, zero value otherwise. +// GetMapArrayAnytype returns the MapArrayAnytype field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapArrayAnytype() map[string][]map[string]interface{} { if o == nil || o.MapArrayAnytype == nil { var ret map[string][]map[string]interface{} @@ -211,7 +203,7 @@ func (o *AdditionalPropertiesClass) GetMapArrayAnytype() map[string][]map[string return *o.MapArrayAnytype } -// GetMapArrayAnytypeOk returns a tuple with the MapArrayAnytype field if it's non-nil, zero value otherwise +// GetMapArrayAnytypeOk returns a tuple with the MapArrayAnytype field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapArrayAnytypeOk() (map[string][]map[string]interface{}, bool) { if o == nil || o.MapArrayAnytype == nil { @@ -235,7 +227,7 @@ func (o *AdditionalPropertiesClass) SetMapArrayAnytype(v map[string][]map[string o.MapArrayAnytype = &v } -// GetMapMapString returns the MapMapString field if non-nil, zero value otherwise. +// GetMapMapString returns the MapMapString field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapMapString() map[string]map[string]string { if o == nil || o.MapMapString == nil { var ret map[string]map[string]string @@ -244,7 +236,7 @@ func (o *AdditionalPropertiesClass) GetMapMapString() map[string]map[string]stri return *o.MapMapString } -// GetMapMapStringOk returns a tuple with the MapMapString field if it's non-nil, zero value otherwise +// GetMapMapStringOk returns a tuple with the MapMapString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapMapStringOk() (map[string]map[string]string, bool) { if o == nil || o.MapMapString == nil { @@ -268,7 +260,7 @@ func (o *AdditionalPropertiesClass) SetMapMapString(v map[string]map[string]stri o.MapMapString = &v } -// GetMapMapAnytype returns the MapMapAnytype field if non-nil, zero value otherwise. +// GetMapMapAnytype returns the MapMapAnytype field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetMapMapAnytype() map[string]map[string]map[string]interface{} { if o == nil || o.MapMapAnytype == nil { var ret map[string]map[string]map[string]interface{} @@ -277,7 +269,7 @@ func (o *AdditionalPropertiesClass) GetMapMapAnytype() map[string]map[string]map return *o.MapMapAnytype } -// GetMapMapAnytypeOk returns a tuple with the MapMapAnytype field if it's non-nil, zero value otherwise +// GetMapMapAnytypeOk returns a tuple with the MapMapAnytype field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetMapMapAnytypeOk() (map[string]map[string]map[string]interface{}, bool) { if o == nil || o.MapMapAnytype == nil { @@ -301,7 +293,7 @@ func (o *AdditionalPropertiesClass) SetMapMapAnytype(v map[string]map[string]map o.MapMapAnytype = &v } -// GetAnytype1 returns the Anytype1 field if non-nil, zero value otherwise. +// GetAnytype1 returns the Anytype1 field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetAnytype1() map[string]interface{} { if o == nil || o.Anytype1 == nil { var ret map[string]interface{} @@ -310,7 +302,7 @@ func (o *AdditionalPropertiesClass) GetAnytype1() map[string]interface{} { return *o.Anytype1 } -// GetAnytype1Ok returns a tuple with the Anytype1 field if it's non-nil, zero value otherwise +// GetAnytype1Ok returns a tuple with the Anytype1 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetAnytype1Ok() (map[string]interface{}, bool) { if o == nil || o.Anytype1 == nil { @@ -334,7 +326,7 @@ func (o *AdditionalPropertiesClass) SetAnytype1(v map[string]interface{}) { o.Anytype1 = &v } -// GetAnytype2 returns the Anytype2 field if non-nil, zero value otherwise. +// GetAnytype2 returns the Anytype2 field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetAnytype2() map[string]interface{} { if o == nil || o.Anytype2 == nil { var ret map[string]interface{} @@ -343,7 +335,7 @@ func (o *AdditionalPropertiesClass) GetAnytype2() map[string]interface{} { return *o.Anytype2 } -// GetAnytype2Ok returns a tuple with the Anytype2 field if it's non-nil, zero value otherwise +// GetAnytype2Ok returns a tuple with the Anytype2 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetAnytype2Ok() (map[string]interface{}, bool) { if o == nil || o.Anytype2 == nil { @@ -367,7 +359,7 @@ func (o *AdditionalPropertiesClass) SetAnytype2(v map[string]interface{}) { o.Anytype2 = &v } -// GetAnytype3 returns the Anytype3 field if non-nil, zero value otherwise. +// GetAnytype3 returns the Anytype3 field value if set, zero value otherwise. func (o *AdditionalPropertiesClass) GetAnytype3() map[string]interface{} { if o == nil || o.Anytype3 == nil { var ret map[string]interface{} @@ -376,7 +368,7 @@ func (o *AdditionalPropertiesClass) GetAnytype3() map[string]interface{} { return *o.Anytype3 } -// GetAnytype3Ok returns a tuple with the Anytype3 field if it's non-nil, zero value otherwise +// GetAnytype3Ok returns a tuple with the Anytype3 field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *AdditionalPropertiesClass) GetAnytype3Ok() (map[string]interface{}, bool) { if o == nil || o.Anytype3 == nil { @@ -400,44 +392,26 @@ func (o *AdditionalPropertiesClass) SetAnytype3(v map[string]interface{}) { o.Anytype3 = &v } +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) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesClass) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.MapString != nil { - toSerialize["map_string"] = o.MapString - } - if o.MapNumber != nil { - toSerialize["map_number"] = o.MapNumber - } - if o.MapInteger != nil { - toSerialize["map_integer"] = o.MapInteger - } - if o.MapBoolean != nil { - toSerialize["map_boolean"] = o.MapBoolean - } - if o.MapArrayInteger != nil { - toSerialize["map_array_integer"] = o.MapArrayInteger - } - if o.MapArrayAnytype != nil { - toSerialize["map_array_anytype"] = o.MapArrayAnytype +func (v *NullableAdditionalPropertiesClass) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.MapMapString != nil { - toSerialize["map_map_string"] = o.MapMapString - } - if o.MapMapAnytype != nil { - toSerialize["map_map_anytype"] = o.MapMapAnytype - } - if o.Anytype1 != nil { - toSerialize["anytype_1"] = o.Anytype1 - } - if o.Anytype2 != nil { - toSerialize["anytype_2"] = o.Anytype2 - } - if o.Anytype3 != nil { - toSerialize["anytype_3"] = o.Anytype3 - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_integer.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_integer.go index c779aa63676c..07c11d9cdcd0 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_integer.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_integer.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesInteger struct for AdditionalPropertiesInteger type AdditionalPropertiesInteger struct { Name *string `json:"name,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 *AdditionalPropertiesInteger) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesInteger) 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 *AdditionalPropertiesInteger) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesInteger) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesInteger struct { + Value AdditionalPropertiesInteger + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesInteger) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesInteger) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesInteger) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_number.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_number.go index c14902300c67..59759fb409ee 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_number.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_number.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesNumber struct for AdditionalPropertiesNumber type AdditionalPropertiesNumber struct { Name *string `json:"name,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 *AdditionalPropertiesNumber) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesNumber) 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 *AdditionalPropertiesNumber) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesNumber) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesNumber struct { + Value AdditionalPropertiesNumber + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesNumber) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesNumber) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesNumber) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_object.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_object.go index 3fafb78aec03..df2b0305a4d5 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_object.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_object.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesObject struct for AdditionalPropertiesObject type AdditionalPropertiesObject struct { Name *string `json:"name,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 *AdditionalPropertiesObject) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesObject) 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 *AdditionalPropertiesObject) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesObject) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesObject struct { + Value AdditionalPropertiesObject + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesObject) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesObject) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesObject) 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/client/petstore/go-experimental/go-petstore/model_additional_properties_string.go b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_string.go index bc75e98add3a..47eb4dd0de5e 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_string.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_additional_properties_string.go @@ -8,16 +8,18 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // AdditionalPropertiesString struct for AdditionalPropertiesString type AdditionalPropertiesString struct { Name *string `json:"name,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 *AdditionalPropertiesString) GetName() string { if o == nil || o.Name == nil { var ret string @@ -26,7 +28,7 @@ func (o *AdditionalPropertiesString) 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 *AdditionalPropertiesString) GetNameOk() (string, bool) { if o == nil || o.Name == nil { @@ -50,14 +52,26 @@ func (o *AdditionalPropertiesString) SetName(v string) { o.Name = &v } +type NullableAdditionalPropertiesString struct { + Value AdditionalPropertiesString + ExplicitNull bool +} + +func (v NullableAdditionalPropertiesString) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o AdditionalPropertiesString) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.Name != nil { - toSerialize["name"] = o.Name +func (v *NullableAdditionalPropertiesString) 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/client/petstore/go-experimental/go-petstore/model_animal.go b/samples/client/petstore/go-experimental/go-petstore/model_animal.go index 877476882ed5..dfae59606ed3 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_animal.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_animal.go @@ -8,52 +8,34 @@ */ package petstore + 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 -} - -// 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 + return o.ClassName } -// 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 } +type NullableAnimal struct { + Value Animal + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_api_response.go b/samples/client/petstore/go-experimental/go-petstore/model_api_response.go index 358d4d4e569b..e2d80e220741 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_api_response.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_api_response.go @@ -8,20 +8,20 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableApiResponse) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.Message != nil { - toSerialize["message"] = o.Message - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go b/samples/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go index de619c3fa055..cf5e59622f39 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_array_of_array_of_number_only.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableArrayOfArrayOfNumberOnly) 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/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go b/samples/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go index 4efd5be06039..7495577a4ce5 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_array_of_number_only.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableArrayOfNumberOnly) 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/client/petstore/go-experimental/go-petstore/model_array_test_.go b/samples/client/petstore/go-experimental/go-petstore/model_array_test_.go index 2e1b18949dc2..01d310fd480a 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_array_test_.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_array_test_.go @@ -8,20 +8,20 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableArrayTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.ArrayArrayOfModel != nil { - toSerialize["array_array_of_model"] = o.ArrayArrayOfModel - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_capitalization.go b/samples/client/petstore/go-experimental/go-petstore/model_capitalization.go index 9cd486a70ca6..281f380508c3 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_capitalization.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_capitalization.go @@ -8,27 +8,24 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableCapitalization) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - 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) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_cat.go b/samples/client/petstore/go-experimental/go-petstore/model_cat.go index 07dfafae8b65..a4390348e393 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_cat.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_cat.go @@ -8,54 +8,35 @@ */ package petstore + 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 -} - -// 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 + return o.ClassName } -// 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 } +type NullableCat struct { + Value Cat + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_cat_all_of.go b/samples/client/petstore/go-experimental/go-petstore/model_cat_all_of.go index db53c7dbbd6b..5fe06820a255 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_cat_all_of.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_cat_all_of.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableCatAllOf) 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/client/petstore/go-experimental/go-petstore/model_category.go b/samples/client/petstore/go-experimental/go-petstore/model_category.go index eef9caf28f1f..1a4d80c25abf 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_category.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_category.go @@ -8,19 +8,19 @@ */ package petstore + 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 -} -// 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 + return o.Name } -// 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 sets field value +func (o *Category) SetName(v string) { + o.Name = v } -// SetName gets a reference to the given string and assigns it to the Name field. -func (o *Category) SetName(v string) { - o.Name = &v +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) + } +} -// 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 +func (v *NullableCategory) 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/client/petstore/go-experimental/go-petstore/model_class_model.go b/samples/client/petstore/go-experimental/go-petstore/model_class_model.go index 8a83ac5698bd..cb217ea0b938 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_class_model.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_class_model.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableClassModel) 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/client/petstore/go-experimental/go-petstore/model_client.go b/samples/client/petstore/go-experimental/go-petstore/model_client.go index abead359c737..1c2d82dbaa25 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_client.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_client.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableClient) 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/client/petstore/go-experimental/go-petstore/model_dog.go b/samples/client/petstore/go-experimental/go-petstore/model_dog.go index 2c09989cca72..1e12cf2030e2 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_dog.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_dog.go @@ -8,54 +8,35 @@ */ package petstore + 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 -} - -// 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 + return o.ClassName } -// 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 } +type NullableDog struct { + Value Dog + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_dog_all_of.go b/samples/client/petstore/go-experimental/go-petstore/model_dog_all_of.go index abd645b6e72d..0572953d4691 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_dog_all_of.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_dog_all_of.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableDogAllOf) 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/client/petstore/go-experimental/go-petstore/model_enum_arrays.go b/samples/client/petstore/go-experimental/go-petstore/model_enum_arrays.go index 453848096d14..68b520550b3a 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_enum_arrays.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_enum_arrays.go @@ -8,18 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableEnumArrays) 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/client/petstore/go-experimental/go-petstore/model_enum_class.go b/samples/client/petstore/go-experimental/go-petstore/model_enum_class.go index 06f7d5535ded..8864dc38698e 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_enum_class.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_enum_class.go @@ -8,6 +8,12 @@ */ package petstore + +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/client/petstore/go-experimental/go-petstore/model_enum_test_.go b/samples/client/petstore/go-experimental/go-petstore/model_enum_test_.go index 17a5fc44fd34..8594082a56ae 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_enum_test_.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_enum_test_.go @@ -8,25 +8,22 @@ */ package petstore + 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"` - } -// 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 @@ -35,7 +32,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 { @@ -59,40 +56,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 -} - -// 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 + return o.EnumStringRequired } -// 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 @@ -101,7 +80,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 { @@ -125,7 +104,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 @@ -134,7 +113,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 { @@ -158,7 +137,7 @@ func (o *EnumTest) SetEnumNumber(v float64) { o.EnumNumber = &v } -// GetOuterEnum returns the OuterEnum field if non-nil, zero value otherwise. +// GetOuterEnum returns the OuterEnum field value if set, zero value otherwise. func (o *EnumTest) GetOuterEnum() OuterEnum { if o == nil || o.OuterEnum == nil { var ret OuterEnum @@ -167,7 +146,7 @@ func (o *EnumTest) GetOuterEnum() OuterEnum { 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) { if o == nil || o.OuterEnum == nil { @@ -191,29 +170,26 @@ func (o *EnumTest) SetOuterEnum(v OuterEnum) { o.OuterEnum = &v } +type NullableEnumTest struct { + Value EnumTest + ExplicitNull bool +} -// 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 { - toSerialize["outerEnum"] = o.OuterEnum - } - return json.Marshal(toSerialize) +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/client/petstore/go-experimental/go-petstore/model_file.go b/samples/client/petstore/go-experimental/go-petstore/model_file.go index 872952cc14ea..d35f12c08879 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_file.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_file.go @@ -8,17 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableFile) 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/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go b/samples/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go index 3926d06b2398..5c6a45436bea 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_file_schema_test_class.go @@ -8,18 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableFileSchemaTestClass) 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/client/petstore/go-experimental/go-petstore/model_format_test_.go b/samples/client/petstore/go-experimental/go-petstore/model_format_test_.go index c6de468fbfb4..6676cf826fbf 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_format_test_.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_format_test_.go @@ -8,45 +8,33 @@ */ package petstore + 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"` BigDecimal *float64 `json:"BigDecimal,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 @@ -55,7 +43,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 { @@ -79,7 +67,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 @@ -88,7 +76,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 { @@ -112,7 +100,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 @@ -121,7 +109,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 { @@ -145,40 +133,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 -} - -// 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 + return o.Number } -// 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 @@ -187,7 +157,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 { @@ -211,7 +181,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 @@ -220,7 +190,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 { @@ -244,7 +214,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 @@ -253,7 +223,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 { @@ -277,40 +247,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 -} -// 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 + return o.Byte } -// 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 @@ -319,7 +271,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 { @@ -343,40 +295,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 -} - -// 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 + return o.Date } -// 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 @@ -385,7 +319,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 { @@ -409,7 +343,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 @@ -418,7 +352,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 { @@ -442,40 +376,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 -} -// 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 + return o.Password } -// 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 } -// GetBigDecimal returns the BigDecimal field if non-nil, zero value otherwise. +// GetBigDecimal returns the BigDecimal field value if set, zero value otherwise. func (o *FormatTest) GetBigDecimal() float64 { if o == nil || o.BigDecimal == nil { var ret float64 @@ -484,7 +400,7 @@ func (o *FormatTest) GetBigDecimal() float64 { return *o.BigDecimal } -// GetBigDecimalOk returns a tuple with the BigDecimal field if it's non-nil, zero value otherwise +// GetBigDecimalOk returns a tuple with the BigDecimal field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *FormatTest) GetBigDecimalOk() (float64, bool) { if o == nil || o.BigDecimal == nil { @@ -508,65 +424,26 @@ func (o *FormatTest) SetBigDecimal(v float64) { o.BigDecimal = &v } +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) + } +} -// 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 +func (v *NullableFormatTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - 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.BigDecimal != nil { - toSerialize["BigDecimal"] = o.BigDecimal - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go b/samples/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go index a36344fdf8ea..4d6a4ade3bab 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_has_only_read_only.go @@ -8,18 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableHasOnlyReadOnly) 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/client/petstore/go-experimental/go-petstore/model_list.go b/samples/client/petstore/go-experimental/go-petstore/model_list.go index 2d1e013e6840..2e341b13fe21 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_list.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_list.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableList) 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/client/petstore/go-experimental/go-petstore/model_map_test_.go b/samples/client/petstore/go-experimental/go-petstore/model_map_test_.go index 1f5db78738cc..482e2dcaa546 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_map_test_.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_map_test_.go @@ -8,22 +8,21 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableMapTest) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.IndirectMap != nil { - toSerialize["indirect_map"] = o.IndirectMap - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go index 8f8d81b2c586..29a15dd4b9bb 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_mixed_properties_and_additional_properties_class.go @@ -8,21 +8,21 @@ */ package petstore + 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 } +type NullableMixedPropertiesAndAdditionalPropertiesClass struct { + Value MixedPropertiesAndAdditionalPropertiesClass + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_name.go b/samples/client/petstore/go-experimental/go-petstore/model_name.go index ce720badba43..15cb31cf79f0 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_name.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_name.go @@ -8,56 +8,36 @@ */ package petstore + 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 -} - -// 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 + return o.Name } -// 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 } +type NullableName struct { + Value Name + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_number_only.go b/samples/client/petstore/go-experimental/go-petstore/model_number_only.go index 0cc88037cdd4..a844fb8128ab 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_number_only.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_number_only.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableNumberOnly) 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/client/petstore/go-experimental/go-petstore/model_order.go b/samples/client/petstore/go-experimental/go-petstore/model_order.go index c0aefd904826..d138fa95cbae 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_order.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_order.go @@ -8,28 +8,25 @@ */ package petstore + 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 } +type NullableOrder struct { + Value Order + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_outer_composite.go b/samples/client/petstore/go-experimental/go-petstore/model_outer_composite.go index 1fe5d4103461..b22599eb6722 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_outer_composite.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_outer_composite.go @@ -8,20 +8,20 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableOuterComposite) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.MyBoolean != nil { - toSerialize["my_boolean"] = o.MyBoolean - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_outer_enum.go b/samples/client/petstore/go-experimental/go-petstore/model_outer_enum.go index f133b6fc890c..b6385fcb5630 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_outer_enum.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_outer_enum.go @@ -8,6 +8,12 @@ */ package petstore + +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/client/petstore/go-experimental/go-petstore/model_pet.go b/samples/client/petstore/go-experimental/go-petstore/model_pet.go index 110a21e094e4..405a179218b7 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_pet.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_pet.go @@ -8,28 +8,24 @@ */ package petstore + 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 -} -// 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 + return o.Name } -// 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 -} - -// 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 + return o.PhotoUrls } -// 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 } +type NullablePet struct { + Value Pet + ExplicitNull bool +} -// 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) +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/client/petstore/go-experimental/go-petstore/model_read_only_first.go b/samples/client/petstore/go-experimental/go-petstore/model_read_only_first.go index 4ed8a2571764..bdd9807ca899 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_read_only_first.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_read_only_first.go @@ -8,18 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableReadOnlyFirst) 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/client/petstore/go-experimental/go-petstore/model_return.go b/samples/client/petstore/go-experimental/go-petstore/model_return.go index c694495fdac8..14821a5ca747 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_return.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_return.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableReturn) 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/client/petstore/go-experimental/go-petstore/model_special_model_name.go b/samples/client/petstore/go-experimental/go-petstore/model_special_model_name.go index 5568361e1d5f..abafacb4e4dd 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_special_model_name.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_special_model_name.go @@ -8,16 +8,18 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableSpecialModelName) 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/client/petstore/go-experimental/go-petstore/model_tag.go b/samples/client/petstore/go-experimental/go-petstore/model_tag.go index 063283820e92..a702f37f0939 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_tag.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_tag.go @@ -8,18 +8,19 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableTag) 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/client/petstore/go-experimental/go-petstore/model_type_holder_default.go b/samples/client/petstore/go-experimental/go-petstore/model_type_holder_default.go index 7022b082547d..173bd1c1b98e 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_type_holder_default.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_type_holder_default.go @@ -8,224 +8,116 @@ */ package petstore + import ( + "bytes" "encoding/json" - "errors" ) + // TypeHolderDefault struct for TypeHolderDefault type TypeHolderDefault struct { - StringItem *string `json:"string_item,omitempty"` - - NumberItem *float32 `json:"number_item,omitempty"` - - IntegerItem *int32 `json:"integer_item,omitempty"` - - BoolItem *bool `json:"bool_item,omitempty"` - - ArrayItem *[]int32 `json:"array_item,omitempty"` - + StringItem string `json:"string_item"` + NumberItem float32 `json:"number_item"` + IntegerItem int32 `json:"integer_item"` + BoolItem bool `json:"bool_item"` + ArrayItem []int32 `json:"array_item"` } -// GetStringItem returns the StringItem field if non-nil, zero value otherwise. +// GetStringItem returns the StringItem field value func (o *TypeHolderDefault) GetStringItem() string { - if o == nil || o.StringItem == nil { + if o == nil { var ret string return ret } - return *o.StringItem -} - -// GetStringItemOk returns a tuple with the StringItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderDefault) GetStringItemOk() (string, bool) { - if o == nil || o.StringItem == nil { - var ret string - return ret, false - } - return *o.StringItem, true -} - -// HasStringItem returns a boolean if a field has been set. -func (o *TypeHolderDefault) HasStringItem() bool { - if o != nil && o.StringItem != nil { - return true - } - return false + return o.StringItem } -// SetStringItem gets a reference to the given string and assigns it to the StringItem field. +// SetStringItem sets field value func (o *TypeHolderDefault) SetStringItem(v string) { - o.StringItem = &v + o.StringItem = v } -// GetNumberItem returns the NumberItem field if non-nil, zero value otherwise. +// GetNumberItem returns the NumberItem field value func (o *TypeHolderDefault) GetNumberItem() float32 { - if o == nil || o.NumberItem == nil { + if o == nil { var ret float32 return ret } - return *o.NumberItem -} - -// GetNumberItemOk returns a tuple with the NumberItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderDefault) GetNumberItemOk() (float32, bool) { - if o == nil || o.NumberItem == nil { - var ret float32 - return ret, false - } - return *o.NumberItem, true -} - -// HasNumberItem returns a boolean if a field has been set. -func (o *TypeHolderDefault) HasNumberItem() bool { - if o != nil && o.NumberItem != nil { - return true - } - return false + return o.NumberItem } -// SetNumberItem gets a reference to the given float32 and assigns it to the NumberItem field. +// SetNumberItem sets field value func (o *TypeHolderDefault) SetNumberItem(v float32) { - o.NumberItem = &v + o.NumberItem = v } -// GetIntegerItem returns the IntegerItem field if non-nil, zero value otherwise. +// GetIntegerItem returns the IntegerItem field value func (o *TypeHolderDefault) GetIntegerItem() int32 { - if o == nil || o.IntegerItem == nil { + if o == nil { var ret int32 return ret } - return *o.IntegerItem -} - -// GetIntegerItemOk returns a tuple with the IntegerItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderDefault) GetIntegerItemOk() (int32, bool) { - if o == nil || o.IntegerItem == nil { - var ret int32 - return ret, false - } - return *o.IntegerItem, true -} - -// HasIntegerItem returns a boolean if a field has been set. -func (o *TypeHolderDefault) HasIntegerItem() bool { - if o != nil && o.IntegerItem != nil { - return true - } - return false + return o.IntegerItem } -// SetIntegerItem gets a reference to the given int32 and assigns it to the IntegerItem field. +// SetIntegerItem sets field value func (o *TypeHolderDefault) SetIntegerItem(v int32) { - o.IntegerItem = &v + o.IntegerItem = v } -// GetBoolItem returns the BoolItem field if non-nil, zero value otherwise. +// GetBoolItem returns the BoolItem field value func (o *TypeHolderDefault) GetBoolItem() bool { - if o == nil || o.BoolItem == nil { + if o == nil { var ret bool return ret } - return *o.BoolItem -} - -// GetBoolItemOk returns a tuple with the BoolItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderDefault) GetBoolItemOk() (bool, bool) { - if o == nil || o.BoolItem == nil { - var ret bool - return ret, false - } - return *o.BoolItem, true -} - -// HasBoolItem returns a boolean if a field has been set. -func (o *TypeHolderDefault) HasBoolItem() bool { - if o != nil && o.BoolItem != nil { - return true - } - return false + return o.BoolItem } -// SetBoolItem gets a reference to the given bool and assigns it to the BoolItem field. +// SetBoolItem sets field value func (o *TypeHolderDefault) SetBoolItem(v bool) { - o.BoolItem = &v + o.BoolItem = v } -// GetArrayItem returns the ArrayItem field if non-nil, zero value otherwise. +// GetArrayItem returns the ArrayItem field value func (o *TypeHolderDefault) GetArrayItem() []int32 { - if o == nil || o.ArrayItem == nil { + if o == nil { var ret []int32 return ret } - return *o.ArrayItem -} -// GetArrayItemOk returns a tuple with the ArrayItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderDefault) GetArrayItemOk() ([]int32, bool) { - if o == nil || o.ArrayItem == nil { - var ret []int32 - return ret, false - } - return *o.ArrayItem, true + return o.ArrayItem } -// HasArrayItem returns a boolean if a field has been set. -func (o *TypeHolderDefault) HasArrayItem() bool { - if o != nil && o.ArrayItem != nil { - return true - } - - return false +// SetArrayItem sets field value +func (o *TypeHolderDefault) SetArrayItem(v []int32) { + o.ArrayItem = v } -// SetArrayItem gets a reference to the given []int32 and assigns it to the ArrayItem field. -func (o *TypeHolderDefault) SetArrayItem(v []int32) { - o.ArrayItem = &v +type NullableTypeHolderDefault struct { + Value TypeHolderDefault + ExplicitNull bool } +func (v NullableTypeHolderDefault) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o TypeHolderDefault) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.StringItem == nil { - return nil, errors.New("StringItem is required and not nullable, but was not set on TypeHolderDefault") - } - if o.StringItem != nil { - toSerialize["string_item"] = o.StringItem - } - if o.NumberItem == nil { - return nil, errors.New("NumberItem is required and not nullable, but was not set on TypeHolderDefault") - } - if o.NumberItem != nil { - toSerialize["number_item"] = o.NumberItem - } - if o.IntegerItem == nil { - return nil, errors.New("IntegerItem is required and not nullable, but was not set on TypeHolderDefault") - } - if o.IntegerItem != nil { - toSerialize["integer_item"] = o.IntegerItem +func (v *NullableTypeHolderDefault) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.BoolItem == nil { - return nil, errors.New("BoolItem is required and not nullable, but was not set on TypeHolderDefault") - } - if o.BoolItem != nil { - toSerialize["bool_item"] = o.BoolItem - } - if o.ArrayItem == nil { - return nil, errors.New("ArrayItem is required and not nullable, but was not set on TypeHolderDefault") - } - if o.ArrayItem != nil { - toSerialize["array_item"] = o.ArrayItem - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_type_holder_example.go b/samples/client/petstore/go-experimental/go-petstore/model_type_holder_example.go index e51025fcb74b..6cd9a0867caf 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_type_holder_example.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_type_holder_example.go @@ -8,265 +8,132 @@ */ package petstore + import ( + "bytes" "encoding/json" - "errors" ) + // TypeHolderExample struct for TypeHolderExample type TypeHolderExample struct { - StringItem *string `json:"string_item,omitempty"` - - NumberItem *float32 `json:"number_item,omitempty"` - - FloatItem *float32 `json:"float_item,omitempty"` - - IntegerItem *int32 `json:"integer_item,omitempty"` - - BoolItem *bool `json:"bool_item,omitempty"` - - ArrayItem *[]int32 `json:"array_item,omitempty"` - + StringItem string `json:"string_item"` + NumberItem float32 `json:"number_item"` + FloatItem float32 `json:"float_item"` + IntegerItem int32 `json:"integer_item"` + BoolItem bool `json:"bool_item"` + ArrayItem []int32 `json:"array_item"` } -// GetStringItem returns the StringItem field if non-nil, zero value otherwise. +// GetStringItem returns the StringItem field value func (o *TypeHolderExample) GetStringItem() string { - if o == nil || o.StringItem == nil { + if o == nil { var ret string return ret } - return *o.StringItem -} - -// GetStringItemOk returns a tuple with the StringItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderExample) GetStringItemOk() (string, bool) { - if o == nil || o.StringItem == nil { - var ret string - return ret, false - } - return *o.StringItem, true -} - -// HasStringItem returns a boolean if a field has been set. -func (o *TypeHolderExample) HasStringItem() bool { - if o != nil && o.StringItem != nil { - return true - } - return false + return o.StringItem } -// SetStringItem gets a reference to the given string and assigns it to the StringItem field. +// SetStringItem sets field value func (o *TypeHolderExample) SetStringItem(v string) { - o.StringItem = &v + o.StringItem = v } -// GetNumberItem returns the NumberItem field if non-nil, zero value otherwise. +// GetNumberItem returns the NumberItem field value func (o *TypeHolderExample) GetNumberItem() float32 { - if o == nil || o.NumberItem == nil { + if o == nil { var ret float32 return ret } - return *o.NumberItem -} - -// GetNumberItemOk returns a tuple with the NumberItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderExample) GetNumberItemOk() (float32, bool) { - if o == nil || o.NumberItem == nil { - var ret float32 - return ret, false - } - return *o.NumberItem, true -} - -// HasNumberItem returns a boolean if a field has been set. -func (o *TypeHolderExample) HasNumberItem() bool { - if o != nil && o.NumberItem != nil { - return true - } - return false + return o.NumberItem } -// SetNumberItem gets a reference to the given float32 and assigns it to the NumberItem field. +// SetNumberItem sets field value func (o *TypeHolderExample) SetNumberItem(v float32) { - o.NumberItem = &v + o.NumberItem = v } -// GetFloatItem returns the FloatItem field if non-nil, zero value otherwise. +// GetFloatItem returns the FloatItem field value func (o *TypeHolderExample) GetFloatItem() float32 { - if o == nil || o.FloatItem == nil { + if o == nil { var ret float32 return ret } - return *o.FloatItem -} - -// GetFloatItemOk returns a tuple with the FloatItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderExample) GetFloatItemOk() (float32, bool) { - if o == nil || o.FloatItem == nil { - var ret float32 - return ret, false - } - return *o.FloatItem, true -} - -// HasFloatItem returns a boolean if a field has been set. -func (o *TypeHolderExample) HasFloatItem() bool { - if o != nil && o.FloatItem != nil { - return true - } - return false + return o.FloatItem } -// SetFloatItem gets a reference to the given float32 and assigns it to the FloatItem field. +// SetFloatItem sets field value func (o *TypeHolderExample) SetFloatItem(v float32) { - o.FloatItem = &v + o.FloatItem = v } -// GetIntegerItem returns the IntegerItem field if non-nil, zero value otherwise. +// GetIntegerItem returns the IntegerItem field value func (o *TypeHolderExample) GetIntegerItem() int32 { - if o == nil || o.IntegerItem == nil { + if o == nil { var ret int32 return ret } - return *o.IntegerItem -} - -// GetIntegerItemOk returns a tuple with the IntegerItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderExample) GetIntegerItemOk() (int32, bool) { - if o == nil || o.IntegerItem == nil { - var ret int32 - return ret, false - } - return *o.IntegerItem, true -} - -// HasIntegerItem returns a boolean if a field has been set. -func (o *TypeHolderExample) HasIntegerItem() bool { - if o != nil && o.IntegerItem != nil { - return true - } - return false + return o.IntegerItem } -// SetIntegerItem gets a reference to the given int32 and assigns it to the IntegerItem field. +// SetIntegerItem sets field value func (o *TypeHolderExample) SetIntegerItem(v int32) { - o.IntegerItem = &v + o.IntegerItem = v } -// GetBoolItem returns the BoolItem field if non-nil, zero value otherwise. +// GetBoolItem returns the BoolItem field value func (o *TypeHolderExample) GetBoolItem() bool { - if o == nil || o.BoolItem == nil { + if o == nil { var ret bool return ret } - return *o.BoolItem -} - -// GetBoolItemOk returns a tuple with the BoolItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderExample) GetBoolItemOk() (bool, bool) { - if o == nil || o.BoolItem == nil { - var ret bool - return ret, false - } - return *o.BoolItem, true -} - -// HasBoolItem returns a boolean if a field has been set. -func (o *TypeHolderExample) HasBoolItem() bool { - if o != nil && o.BoolItem != nil { - return true - } - return false + return o.BoolItem } -// SetBoolItem gets a reference to the given bool and assigns it to the BoolItem field. +// SetBoolItem sets field value func (o *TypeHolderExample) SetBoolItem(v bool) { - o.BoolItem = &v + o.BoolItem = v } -// GetArrayItem returns the ArrayItem field if non-nil, zero value otherwise. +// GetArrayItem returns the ArrayItem field value func (o *TypeHolderExample) GetArrayItem() []int32 { - if o == nil || o.ArrayItem == nil { + if o == nil { var ret []int32 return ret } - return *o.ArrayItem -} -// GetArrayItemOk returns a tuple with the ArrayItem field if it's non-nil, zero value otherwise -// and a boolean to check if the value has been set. -func (o *TypeHolderExample) GetArrayItemOk() ([]int32, bool) { - if o == nil || o.ArrayItem == nil { - var ret []int32 - return ret, false - } - return *o.ArrayItem, true + return o.ArrayItem } -// HasArrayItem returns a boolean if a field has been set. -func (o *TypeHolderExample) HasArrayItem() bool { - if o != nil && o.ArrayItem != nil { - return true - } - - return false +// SetArrayItem sets field value +func (o *TypeHolderExample) SetArrayItem(v []int32) { + o.ArrayItem = v } -// SetArrayItem gets a reference to the given []int32 and assigns it to the ArrayItem field. -func (o *TypeHolderExample) SetArrayItem(v []int32) { - o.ArrayItem = &v +type NullableTypeHolderExample struct { + Value TypeHolderExample + ExplicitNull bool } +func (v NullableTypeHolderExample) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o TypeHolderExample) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.StringItem == nil { - return nil, errors.New("StringItem is required and not nullable, but was not set on TypeHolderExample") - } - if o.StringItem != nil { - toSerialize["string_item"] = o.StringItem - } - if o.NumberItem == nil { - return nil, errors.New("NumberItem is required and not nullable, but was not set on TypeHolderExample") - } - if o.NumberItem != nil { - toSerialize["number_item"] = o.NumberItem - } - if o.FloatItem == nil { - return nil, errors.New("FloatItem is required and not nullable, but was not set on TypeHolderExample") - } - if o.FloatItem != nil { - toSerialize["float_item"] = o.FloatItem +func (v *NullableTypeHolderExample) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.IntegerItem == nil { - return nil, errors.New("IntegerItem is required and not nullable, but was not set on TypeHolderExample") - } - if o.IntegerItem != nil { - toSerialize["integer_item"] = o.IntegerItem - } - if o.BoolItem == nil { - return nil, errors.New("BoolItem is required and not nullable, but was not set on TypeHolderExample") - } - if o.BoolItem != nil { - toSerialize["bool_item"] = o.BoolItem - } - if o.ArrayItem == nil { - return nil, errors.New("ArrayItem is required and not nullable, but was not set on TypeHolderExample") - } - if o.ArrayItem != nil { - toSerialize["array_item"] = o.ArrayItem - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_user.go b/samples/client/petstore/go-experimental/go-petstore/model_user.go index 174a791aa728..4411c284794d 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_user.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_user.go @@ -8,31 +8,26 @@ */ package petstore + 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 } +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) + } +} -// 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 +func (v *NullableUser) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - 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) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/model_xml_item.go b/samples/client/petstore/go-experimental/go-petstore/model_xml_item.go index e1b9efa8e0b9..ddf16b84247f 100644 --- a/samples/client/petstore/go-experimental/go-petstore/model_xml_item.go +++ b/samples/client/petstore/go-experimental/go-petstore/model_xml_item.go @@ -8,72 +8,46 @@ */ package petstore + import ( + "bytes" "encoding/json" ) + // XmlItem struct for XmlItem type XmlItem struct { AttributeString *string `json:"attribute_string,omitempty"` - AttributeNumber *float32 `json:"attribute_number,omitempty"` - AttributeInteger *int32 `json:"attribute_integer,omitempty"` - AttributeBoolean *bool `json:"attribute_boolean,omitempty"` - WrappedArray *[]int32 `json:"wrapped_array,omitempty"` - NameString *string `json:"name_string,omitempty"` - NameNumber *float32 `json:"name_number,omitempty"` - NameInteger *int32 `json:"name_integer,omitempty"` - NameBoolean *bool `json:"name_boolean,omitempty"` - NameArray *[]int32 `json:"name_array,omitempty"` - NameWrappedArray *[]int32 `json:"name_wrapped_array,omitempty"` - PrefixString *string `json:"prefix_string,omitempty"` - PrefixNumber *float32 `json:"prefix_number,omitempty"` - PrefixInteger *int32 `json:"prefix_integer,omitempty"` - PrefixBoolean *bool `json:"prefix_boolean,omitempty"` - PrefixArray *[]int32 `json:"prefix_array,omitempty"` - PrefixWrappedArray *[]int32 `json:"prefix_wrapped_array,omitempty"` - NamespaceString *string `json:"namespace_string,omitempty"` - NamespaceNumber *float32 `json:"namespace_number,omitempty"` - NamespaceInteger *int32 `json:"namespace_integer,omitempty"` - NamespaceBoolean *bool `json:"namespace_boolean,omitempty"` - NamespaceArray *[]int32 `json:"namespace_array,omitempty"` - NamespaceWrappedArray *[]int32 `json:"namespace_wrapped_array,omitempty"` - PrefixNsString *string `json:"prefix_ns_string,omitempty"` - PrefixNsNumber *float32 `json:"prefix_ns_number,omitempty"` - PrefixNsInteger *int32 `json:"prefix_ns_integer,omitempty"` - PrefixNsBoolean *bool `json:"prefix_ns_boolean,omitempty"` - PrefixNsArray *[]int32 `json:"prefix_ns_array,omitempty"` - PrefixNsWrappedArray *[]int32 `json:"prefix_ns_wrapped_array,omitempty"` - } -// GetAttributeString returns the AttributeString field if non-nil, zero value otherwise. +// GetAttributeString returns the AttributeString field value if set, zero value otherwise. func (o *XmlItem) GetAttributeString() string { if o == nil || o.AttributeString == nil { var ret string @@ -82,7 +56,7 @@ func (o *XmlItem) GetAttributeString() string { return *o.AttributeString } -// GetAttributeStringOk returns a tuple with the AttributeString field if it's non-nil, zero value otherwise +// GetAttributeStringOk returns a tuple with the AttributeString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetAttributeStringOk() (string, bool) { if o == nil || o.AttributeString == nil { @@ -106,7 +80,7 @@ func (o *XmlItem) SetAttributeString(v string) { o.AttributeString = &v } -// GetAttributeNumber returns the AttributeNumber field if non-nil, zero value otherwise. +// GetAttributeNumber returns the AttributeNumber field value if set, zero value otherwise. func (o *XmlItem) GetAttributeNumber() float32 { if o == nil || o.AttributeNumber == nil { var ret float32 @@ -115,7 +89,7 @@ func (o *XmlItem) GetAttributeNumber() float32 { return *o.AttributeNumber } -// GetAttributeNumberOk returns a tuple with the AttributeNumber field if it's non-nil, zero value otherwise +// GetAttributeNumberOk returns a tuple with the AttributeNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetAttributeNumberOk() (float32, bool) { if o == nil || o.AttributeNumber == nil { @@ -139,7 +113,7 @@ func (o *XmlItem) SetAttributeNumber(v float32) { o.AttributeNumber = &v } -// GetAttributeInteger returns the AttributeInteger field if non-nil, zero value otherwise. +// GetAttributeInteger returns the AttributeInteger field value if set, zero value otherwise. func (o *XmlItem) GetAttributeInteger() int32 { if o == nil || o.AttributeInteger == nil { var ret int32 @@ -148,7 +122,7 @@ func (o *XmlItem) GetAttributeInteger() int32 { return *o.AttributeInteger } -// GetAttributeIntegerOk returns a tuple with the AttributeInteger field if it's non-nil, zero value otherwise +// GetAttributeIntegerOk returns a tuple with the AttributeInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetAttributeIntegerOk() (int32, bool) { if o == nil || o.AttributeInteger == nil { @@ -172,7 +146,7 @@ func (o *XmlItem) SetAttributeInteger(v int32) { o.AttributeInteger = &v } -// GetAttributeBoolean returns the AttributeBoolean field if non-nil, zero value otherwise. +// GetAttributeBoolean returns the AttributeBoolean field value if set, zero value otherwise. func (o *XmlItem) GetAttributeBoolean() bool { if o == nil || o.AttributeBoolean == nil { var ret bool @@ -181,7 +155,7 @@ func (o *XmlItem) GetAttributeBoolean() bool { return *o.AttributeBoolean } -// GetAttributeBooleanOk returns a tuple with the AttributeBoolean field if it's non-nil, zero value otherwise +// GetAttributeBooleanOk returns a tuple with the AttributeBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetAttributeBooleanOk() (bool, bool) { if o == nil || o.AttributeBoolean == nil { @@ -205,7 +179,7 @@ func (o *XmlItem) SetAttributeBoolean(v bool) { o.AttributeBoolean = &v } -// GetWrappedArray returns the WrappedArray field if non-nil, zero value otherwise. +// GetWrappedArray returns the WrappedArray field value if set, zero value otherwise. func (o *XmlItem) GetWrappedArray() []int32 { if o == nil || o.WrappedArray == nil { var ret []int32 @@ -214,7 +188,7 @@ func (o *XmlItem) GetWrappedArray() []int32 { return *o.WrappedArray } -// GetWrappedArrayOk returns a tuple with the WrappedArray field if it's non-nil, zero value otherwise +// GetWrappedArrayOk returns a tuple with the WrappedArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetWrappedArrayOk() ([]int32, bool) { if o == nil || o.WrappedArray == nil { @@ -238,7 +212,7 @@ func (o *XmlItem) SetWrappedArray(v []int32) { o.WrappedArray = &v } -// GetNameString returns the NameString field if non-nil, zero value otherwise. +// GetNameString returns the NameString field value if set, zero value otherwise. func (o *XmlItem) GetNameString() string { if o == nil || o.NameString == nil { var ret string @@ -247,7 +221,7 @@ func (o *XmlItem) GetNameString() string { return *o.NameString } -// GetNameStringOk returns a tuple with the NameString field if it's non-nil, zero value otherwise +// GetNameStringOk returns a tuple with the NameString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNameStringOk() (string, bool) { if o == nil || o.NameString == nil { @@ -271,7 +245,7 @@ func (o *XmlItem) SetNameString(v string) { o.NameString = &v } -// GetNameNumber returns the NameNumber field if non-nil, zero value otherwise. +// GetNameNumber returns the NameNumber field value if set, zero value otherwise. func (o *XmlItem) GetNameNumber() float32 { if o == nil || o.NameNumber == nil { var ret float32 @@ -280,7 +254,7 @@ func (o *XmlItem) GetNameNumber() float32 { return *o.NameNumber } -// GetNameNumberOk returns a tuple with the NameNumber field if it's non-nil, zero value otherwise +// GetNameNumberOk returns a tuple with the NameNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNameNumberOk() (float32, bool) { if o == nil || o.NameNumber == nil { @@ -304,7 +278,7 @@ func (o *XmlItem) SetNameNumber(v float32) { o.NameNumber = &v } -// GetNameInteger returns the NameInteger field if non-nil, zero value otherwise. +// GetNameInteger returns the NameInteger field value if set, zero value otherwise. func (o *XmlItem) GetNameInteger() int32 { if o == nil || o.NameInteger == nil { var ret int32 @@ -313,7 +287,7 @@ func (o *XmlItem) GetNameInteger() int32 { return *o.NameInteger } -// GetNameIntegerOk returns a tuple with the NameInteger field if it's non-nil, zero value otherwise +// GetNameIntegerOk returns a tuple with the NameInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNameIntegerOk() (int32, bool) { if o == nil || o.NameInteger == nil { @@ -337,7 +311,7 @@ func (o *XmlItem) SetNameInteger(v int32) { o.NameInteger = &v } -// GetNameBoolean returns the NameBoolean field if non-nil, zero value otherwise. +// GetNameBoolean returns the NameBoolean field value if set, zero value otherwise. func (o *XmlItem) GetNameBoolean() bool { if o == nil || o.NameBoolean == nil { var ret bool @@ -346,7 +320,7 @@ func (o *XmlItem) GetNameBoolean() bool { return *o.NameBoolean } -// GetNameBooleanOk returns a tuple with the NameBoolean field if it's non-nil, zero value otherwise +// GetNameBooleanOk returns a tuple with the NameBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNameBooleanOk() (bool, bool) { if o == nil || o.NameBoolean == nil { @@ -370,7 +344,7 @@ func (o *XmlItem) SetNameBoolean(v bool) { o.NameBoolean = &v } -// GetNameArray returns the NameArray field if non-nil, zero value otherwise. +// GetNameArray returns the NameArray field value if set, zero value otherwise. func (o *XmlItem) GetNameArray() []int32 { if o == nil || o.NameArray == nil { var ret []int32 @@ -379,7 +353,7 @@ func (o *XmlItem) GetNameArray() []int32 { return *o.NameArray } -// GetNameArrayOk returns a tuple with the NameArray field if it's non-nil, zero value otherwise +// GetNameArrayOk returns a tuple with the NameArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNameArrayOk() ([]int32, bool) { if o == nil || o.NameArray == nil { @@ -403,7 +377,7 @@ func (o *XmlItem) SetNameArray(v []int32) { o.NameArray = &v } -// GetNameWrappedArray returns the NameWrappedArray field if non-nil, zero value otherwise. +// GetNameWrappedArray returns the NameWrappedArray field value if set, zero value otherwise. func (o *XmlItem) GetNameWrappedArray() []int32 { if o == nil || o.NameWrappedArray == nil { var ret []int32 @@ -412,7 +386,7 @@ func (o *XmlItem) GetNameWrappedArray() []int32 { return *o.NameWrappedArray } -// GetNameWrappedArrayOk returns a tuple with the NameWrappedArray field if it's non-nil, zero value otherwise +// GetNameWrappedArrayOk returns a tuple with the NameWrappedArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNameWrappedArrayOk() ([]int32, bool) { if o == nil || o.NameWrappedArray == nil { @@ -436,7 +410,7 @@ func (o *XmlItem) SetNameWrappedArray(v []int32) { o.NameWrappedArray = &v } -// GetPrefixString returns the PrefixString field if non-nil, zero value otherwise. +// GetPrefixString returns the PrefixString field value if set, zero value otherwise. func (o *XmlItem) GetPrefixString() string { if o == nil || o.PrefixString == nil { var ret string @@ -445,7 +419,7 @@ func (o *XmlItem) GetPrefixString() string { return *o.PrefixString } -// GetPrefixStringOk returns a tuple with the PrefixString field if it's non-nil, zero value otherwise +// GetPrefixStringOk returns a tuple with the PrefixString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixStringOk() (string, bool) { if o == nil || o.PrefixString == nil { @@ -469,7 +443,7 @@ func (o *XmlItem) SetPrefixString(v string) { o.PrefixString = &v } -// GetPrefixNumber returns the PrefixNumber field if non-nil, zero value otherwise. +// GetPrefixNumber returns the PrefixNumber field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNumber() float32 { if o == nil || o.PrefixNumber == nil { var ret float32 @@ -478,7 +452,7 @@ func (o *XmlItem) GetPrefixNumber() float32 { return *o.PrefixNumber } -// GetPrefixNumberOk returns a tuple with the PrefixNumber field if it's non-nil, zero value otherwise +// GetPrefixNumberOk returns a tuple with the PrefixNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNumberOk() (float32, bool) { if o == nil || o.PrefixNumber == nil { @@ -502,7 +476,7 @@ func (o *XmlItem) SetPrefixNumber(v float32) { o.PrefixNumber = &v } -// GetPrefixInteger returns the PrefixInteger field if non-nil, zero value otherwise. +// GetPrefixInteger returns the PrefixInteger field value if set, zero value otherwise. func (o *XmlItem) GetPrefixInteger() int32 { if o == nil || o.PrefixInteger == nil { var ret int32 @@ -511,7 +485,7 @@ func (o *XmlItem) GetPrefixInteger() int32 { return *o.PrefixInteger } -// GetPrefixIntegerOk returns a tuple with the PrefixInteger field if it's non-nil, zero value otherwise +// GetPrefixIntegerOk returns a tuple with the PrefixInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixIntegerOk() (int32, bool) { if o == nil || o.PrefixInteger == nil { @@ -535,7 +509,7 @@ func (o *XmlItem) SetPrefixInteger(v int32) { o.PrefixInteger = &v } -// GetPrefixBoolean returns the PrefixBoolean field if non-nil, zero value otherwise. +// GetPrefixBoolean returns the PrefixBoolean field value if set, zero value otherwise. func (o *XmlItem) GetPrefixBoolean() bool { if o == nil || o.PrefixBoolean == nil { var ret bool @@ -544,7 +518,7 @@ func (o *XmlItem) GetPrefixBoolean() bool { return *o.PrefixBoolean } -// GetPrefixBooleanOk returns a tuple with the PrefixBoolean field if it's non-nil, zero value otherwise +// GetPrefixBooleanOk returns a tuple with the PrefixBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixBooleanOk() (bool, bool) { if o == nil || o.PrefixBoolean == nil { @@ -568,7 +542,7 @@ func (o *XmlItem) SetPrefixBoolean(v bool) { o.PrefixBoolean = &v } -// GetPrefixArray returns the PrefixArray field if non-nil, zero value otherwise. +// GetPrefixArray returns the PrefixArray field value if set, zero value otherwise. func (o *XmlItem) GetPrefixArray() []int32 { if o == nil || o.PrefixArray == nil { var ret []int32 @@ -577,7 +551,7 @@ func (o *XmlItem) GetPrefixArray() []int32 { return *o.PrefixArray } -// GetPrefixArrayOk returns a tuple with the PrefixArray field if it's non-nil, zero value otherwise +// GetPrefixArrayOk returns a tuple with the PrefixArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixArrayOk() ([]int32, bool) { if o == nil || o.PrefixArray == nil { @@ -601,7 +575,7 @@ func (o *XmlItem) SetPrefixArray(v []int32) { o.PrefixArray = &v } -// GetPrefixWrappedArray returns the PrefixWrappedArray field if non-nil, zero value otherwise. +// GetPrefixWrappedArray returns the PrefixWrappedArray field value if set, zero value otherwise. func (o *XmlItem) GetPrefixWrappedArray() []int32 { if o == nil || o.PrefixWrappedArray == nil { var ret []int32 @@ -610,7 +584,7 @@ func (o *XmlItem) GetPrefixWrappedArray() []int32 { return *o.PrefixWrappedArray } -// GetPrefixWrappedArrayOk returns a tuple with the PrefixWrappedArray field if it's non-nil, zero value otherwise +// GetPrefixWrappedArrayOk returns a tuple with the PrefixWrappedArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixWrappedArrayOk() ([]int32, bool) { if o == nil || o.PrefixWrappedArray == nil { @@ -634,7 +608,7 @@ func (o *XmlItem) SetPrefixWrappedArray(v []int32) { o.PrefixWrappedArray = &v } -// GetNamespaceString returns the NamespaceString field if non-nil, zero value otherwise. +// GetNamespaceString returns the NamespaceString field value if set, zero value otherwise. func (o *XmlItem) GetNamespaceString() string { if o == nil || o.NamespaceString == nil { var ret string @@ -643,7 +617,7 @@ func (o *XmlItem) GetNamespaceString() string { return *o.NamespaceString } -// GetNamespaceStringOk returns a tuple with the NamespaceString field if it's non-nil, zero value otherwise +// GetNamespaceStringOk returns a tuple with the NamespaceString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNamespaceStringOk() (string, bool) { if o == nil || o.NamespaceString == nil { @@ -667,7 +641,7 @@ func (o *XmlItem) SetNamespaceString(v string) { o.NamespaceString = &v } -// GetNamespaceNumber returns the NamespaceNumber field if non-nil, zero value otherwise. +// GetNamespaceNumber returns the NamespaceNumber field value if set, zero value otherwise. func (o *XmlItem) GetNamespaceNumber() float32 { if o == nil || o.NamespaceNumber == nil { var ret float32 @@ -676,7 +650,7 @@ func (o *XmlItem) GetNamespaceNumber() float32 { return *o.NamespaceNumber } -// GetNamespaceNumberOk returns a tuple with the NamespaceNumber field if it's non-nil, zero value otherwise +// GetNamespaceNumberOk returns a tuple with the NamespaceNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNamespaceNumberOk() (float32, bool) { if o == nil || o.NamespaceNumber == nil { @@ -700,7 +674,7 @@ func (o *XmlItem) SetNamespaceNumber(v float32) { o.NamespaceNumber = &v } -// GetNamespaceInteger returns the NamespaceInteger field if non-nil, zero value otherwise. +// GetNamespaceInteger returns the NamespaceInteger field value if set, zero value otherwise. func (o *XmlItem) GetNamespaceInteger() int32 { if o == nil || o.NamespaceInteger == nil { var ret int32 @@ -709,7 +683,7 @@ func (o *XmlItem) GetNamespaceInteger() int32 { return *o.NamespaceInteger } -// GetNamespaceIntegerOk returns a tuple with the NamespaceInteger field if it's non-nil, zero value otherwise +// GetNamespaceIntegerOk returns a tuple with the NamespaceInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNamespaceIntegerOk() (int32, bool) { if o == nil || o.NamespaceInteger == nil { @@ -733,7 +707,7 @@ func (o *XmlItem) SetNamespaceInteger(v int32) { o.NamespaceInteger = &v } -// GetNamespaceBoolean returns the NamespaceBoolean field if non-nil, zero value otherwise. +// GetNamespaceBoolean returns the NamespaceBoolean field value if set, zero value otherwise. func (o *XmlItem) GetNamespaceBoolean() bool { if o == nil || o.NamespaceBoolean == nil { var ret bool @@ -742,7 +716,7 @@ func (o *XmlItem) GetNamespaceBoolean() bool { return *o.NamespaceBoolean } -// GetNamespaceBooleanOk returns a tuple with the NamespaceBoolean field if it's non-nil, zero value otherwise +// GetNamespaceBooleanOk returns a tuple with the NamespaceBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNamespaceBooleanOk() (bool, bool) { if o == nil || o.NamespaceBoolean == nil { @@ -766,7 +740,7 @@ func (o *XmlItem) SetNamespaceBoolean(v bool) { o.NamespaceBoolean = &v } -// GetNamespaceArray returns the NamespaceArray field if non-nil, zero value otherwise. +// GetNamespaceArray returns the NamespaceArray field value if set, zero value otherwise. func (o *XmlItem) GetNamespaceArray() []int32 { if o == nil || o.NamespaceArray == nil { var ret []int32 @@ -775,7 +749,7 @@ func (o *XmlItem) GetNamespaceArray() []int32 { return *o.NamespaceArray } -// GetNamespaceArrayOk returns a tuple with the NamespaceArray field if it's non-nil, zero value otherwise +// GetNamespaceArrayOk returns a tuple with the NamespaceArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNamespaceArrayOk() ([]int32, bool) { if o == nil || o.NamespaceArray == nil { @@ -799,7 +773,7 @@ func (o *XmlItem) SetNamespaceArray(v []int32) { o.NamespaceArray = &v } -// GetNamespaceWrappedArray returns the NamespaceWrappedArray field if non-nil, zero value otherwise. +// GetNamespaceWrappedArray returns the NamespaceWrappedArray field value if set, zero value otherwise. func (o *XmlItem) GetNamespaceWrappedArray() []int32 { if o == nil || o.NamespaceWrappedArray == nil { var ret []int32 @@ -808,7 +782,7 @@ func (o *XmlItem) GetNamespaceWrappedArray() []int32 { return *o.NamespaceWrappedArray } -// GetNamespaceWrappedArrayOk returns a tuple with the NamespaceWrappedArray field if it's non-nil, zero value otherwise +// GetNamespaceWrappedArrayOk returns a tuple with the NamespaceWrappedArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetNamespaceWrappedArrayOk() ([]int32, bool) { if o == nil || o.NamespaceWrappedArray == nil { @@ -832,7 +806,7 @@ func (o *XmlItem) SetNamespaceWrappedArray(v []int32) { o.NamespaceWrappedArray = &v } -// GetPrefixNsString returns the PrefixNsString field if non-nil, zero value otherwise. +// GetPrefixNsString returns the PrefixNsString field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNsString() string { if o == nil || o.PrefixNsString == nil { var ret string @@ -841,7 +815,7 @@ func (o *XmlItem) GetPrefixNsString() string { return *o.PrefixNsString } -// GetPrefixNsStringOk returns a tuple with the PrefixNsString field if it's non-nil, zero value otherwise +// GetPrefixNsStringOk returns a tuple with the PrefixNsString field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNsStringOk() (string, bool) { if o == nil || o.PrefixNsString == nil { @@ -865,7 +839,7 @@ func (o *XmlItem) SetPrefixNsString(v string) { o.PrefixNsString = &v } -// GetPrefixNsNumber returns the PrefixNsNumber field if non-nil, zero value otherwise. +// GetPrefixNsNumber returns the PrefixNsNumber field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNsNumber() float32 { if o == nil || o.PrefixNsNumber == nil { var ret float32 @@ -874,7 +848,7 @@ func (o *XmlItem) GetPrefixNsNumber() float32 { return *o.PrefixNsNumber } -// GetPrefixNsNumberOk returns a tuple with the PrefixNsNumber field if it's non-nil, zero value otherwise +// GetPrefixNsNumberOk returns a tuple with the PrefixNsNumber field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNsNumberOk() (float32, bool) { if o == nil || o.PrefixNsNumber == nil { @@ -898,7 +872,7 @@ func (o *XmlItem) SetPrefixNsNumber(v float32) { o.PrefixNsNumber = &v } -// GetPrefixNsInteger returns the PrefixNsInteger field if non-nil, zero value otherwise. +// GetPrefixNsInteger returns the PrefixNsInteger field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNsInteger() int32 { if o == nil || o.PrefixNsInteger == nil { var ret int32 @@ -907,7 +881,7 @@ func (o *XmlItem) GetPrefixNsInteger() int32 { return *o.PrefixNsInteger } -// GetPrefixNsIntegerOk returns a tuple with the PrefixNsInteger field if it's non-nil, zero value otherwise +// GetPrefixNsIntegerOk returns a tuple with the PrefixNsInteger field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNsIntegerOk() (int32, bool) { if o == nil || o.PrefixNsInteger == nil { @@ -931,7 +905,7 @@ func (o *XmlItem) SetPrefixNsInteger(v int32) { o.PrefixNsInteger = &v } -// GetPrefixNsBoolean returns the PrefixNsBoolean field if non-nil, zero value otherwise. +// GetPrefixNsBoolean returns the PrefixNsBoolean field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNsBoolean() bool { if o == nil || o.PrefixNsBoolean == nil { var ret bool @@ -940,7 +914,7 @@ func (o *XmlItem) GetPrefixNsBoolean() bool { return *o.PrefixNsBoolean } -// GetPrefixNsBooleanOk returns a tuple with the PrefixNsBoolean field if it's non-nil, zero value otherwise +// GetPrefixNsBooleanOk returns a tuple with the PrefixNsBoolean field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNsBooleanOk() (bool, bool) { if o == nil || o.PrefixNsBoolean == nil { @@ -964,7 +938,7 @@ func (o *XmlItem) SetPrefixNsBoolean(v bool) { o.PrefixNsBoolean = &v } -// GetPrefixNsArray returns the PrefixNsArray field if non-nil, zero value otherwise. +// GetPrefixNsArray returns the PrefixNsArray field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNsArray() []int32 { if o == nil || o.PrefixNsArray == nil { var ret []int32 @@ -973,7 +947,7 @@ func (o *XmlItem) GetPrefixNsArray() []int32 { return *o.PrefixNsArray } -// GetPrefixNsArrayOk returns a tuple with the PrefixNsArray field if it's non-nil, zero value otherwise +// GetPrefixNsArrayOk returns a tuple with the PrefixNsArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNsArrayOk() ([]int32, bool) { if o == nil || o.PrefixNsArray == nil { @@ -997,7 +971,7 @@ func (o *XmlItem) SetPrefixNsArray(v []int32) { o.PrefixNsArray = &v } -// GetPrefixNsWrappedArray returns the PrefixNsWrappedArray field if non-nil, zero value otherwise. +// GetPrefixNsWrappedArray returns the PrefixNsWrappedArray field value if set, zero value otherwise. func (o *XmlItem) GetPrefixNsWrappedArray() []int32 { if o == nil || o.PrefixNsWrappedArray == nil { var ret []int32 @@ -1006,7 +980,7 @@ func (o *XmlItem) GetPrefixNsWrappedArray() []int32 { return *o.PrefixNsWrappedArray } -// GetPrefixNsWrappedArrayOk returns a tuple with the PrefixNsWrappedArray field if it's non-nil, zero value otherwise +// GetPrefixNsWrappedArrayOk returns a tuple with the PrefixNsWrappedArray field value if set, zero value otherwise // and a boolean to check if the value has been set. func (o *XmlItem) GetPrefixNsWrappedArrayOk() ([]int32, bool) { if o == nil || o.PrefixNsWrappedArray == nil { @@ -1030,98 +1004,26 @@ func (o *XmlItem) SetPrefixNsWrappedArray(v []int32) { o.PrefixNsWrappedArray = &v } +type NullableXmlItem struct { + Value XmlItem + ExplicitNull bool +} + +func (v NullableXmlItem) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} -// MarshalJSON returns the JSON representation of the model. -func (o XmlItem) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.AttributeString != nil { - toSerialize["attribute_string"] = o.AttributeString - } - if o.AttributeNumber != nil { - toSerialize["attribute_number"] = o.AttributeNumber - } - if o.AttributeInteger != nil { - toSerialize["attribute_integer"] = o.AttributeInteger - } - if o.AttributeBoolean != nil { - toSerialize["attribute_boolean"] = o.AttributeBoolean - } - if o.WrappedArray != nil { - toSerialize["wrapped_array"] = o.WrappedArray - } - if o.NameString != nil { - toSerialize["name_string"] = o.NameString - } - if o.NameNumber != nil { - toSerialize["name_number"] = o.NameNumber - } - if o.NameInteger != nil { - toSerialize["name_integer"] = o.NameInteger - } - if o.NameBoolean != nil { - toSerialize["name_boolean"] = o.NameBoolean - } - if o.NameArray != nil { - toSerialize["name_array"] = o.NameArray - } - if o.NameWrappedArray != nil { - toSerialize["name_wrapped_array"] = o.NameWrappedArray - } - if o.PrefixString != nil { - toSerialize["prefix_string"] = o.PrefixString - } - if o.PrefixNumber != nil { - toSerialize["prefix_number"] = o.PrefixNumber - } - if o.PrefixInteger != nil { - toSerialize["prefix_integer"] = o.PrefixInteger - } - if o.PrefixBoolean != nil { - toSerialize["prefix_boolean"] = o.PrefixBoolean +func (v *NullableXmlItem) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil } - if o.PrefixArray != nil { - toSerialize["prefix_array"] = o.PrefixArray - } - if o.PrefixWrappedArray != nil { - toSerialize["prefix_wrapped_array"] = o.PrefixWrappedArray - } - if o.NamespaceString != nil { - toSerialize["namespace_string"] = o.NamespaceString - } - if o.NamespaceNumber != nil { - toSerialize["namespace_number"] = o.NamespaceNumber - } - if o.NamespaceInteger != nil { - toSerialize["namespace_integer"] = o.NamespaceInteger - } - if o.NamespaceBoolean != nil { - toSerialize["namespace_boolean"] = o.NamespaceBoolean - } - if o.NamespaceArray != nil { - toSerialize["namespace_array"] = o.NamespaceArray - } - if o.NamespaceWrappedArray != nil { - toSerialize["namespace_wrapped_array"] = o.NamespaceWrappedArray - } - if o.PrefixNsString != nil { - toSerialize["prefix_ns_string"] = o.PrefixNsString - } - if o.PrefixNsNumber != nil { - toSerialize["prefix_ns_number"] = o.PrefixNsNumber - } - if o.PrefixNsInteger != nil { - toSerialize["prefix_ns_integer"] = o.PrefixNsInteger - } - if o.PrefixNsBoolean != nil { - toSerialize["prefix_ns_boolean"] = o.PrefixNsBoolean - } - if o.PrefixNsArray != nil { - toSerialize["prefix_ns_array"] = o.PrefixNsArray - } - if o.PrefixNsWrappedArray != nil { - toSerialize["prefix_ns_wrapped_array"] = o.PrefixNsWrappedArray - } - return json.Marshal(toSerialize) -} + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/client/petstore/go-experimental/go-petstore/utils.go b/samples/client/petstore/go-experimental/go-petstore/utils.go index 8d2130be3f47..3a3303b24451 100644 --- a/samples/client/petstore/go-experimental/go-petstore/utils.go +++ b/samples/client/petstore/go-experimental/go-petstore/utils.go @@ -9,7 +9,14 @@ package petstore -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 diff --git a/samples/client/petstore/go-experimental/pet_api_test.go b/samples/client/petstore/go-experimental/pet_api_test.go index c1e8006bb0cf..847aa517af19 100644 --- a/samples/client/petstore/go-experimental/pet_api_test.go +++ b/samples/client/petstore/go-experimental/pet_api_test.go @@ -28,8 +28,8 @@ func TestMain(m *testing.M) { } func TestAddPet(t *testing.T) { - newPet := (sw.Pet{Id: sw.PtrInt64(12830), Name: sw.PtrString("gopher"), - PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), + newPet := (sw.Pet{Id: sw.PtrInt64(12830), Name: "gopher", + PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"), Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}}) r, err := client.PetApi.AddPet(context.Background(), newPet) @@ -286,7 +286,7 @@ func isPetCorrect(t *testing.T, id int64, name string, status string) { t.Fatalf("Error while getting pet by id: %v", err) } else { assert.Equal(*resp.Id, int64(id), "Pet id should be equal") - assert.Equal(*resp.Name, name, fmt.Sprintf("Pet name should be %s", name)) + assert.Equal(resp.Name, name, fmt.Sprintf("Pet name should be %s", name)) assert.Equal(*resp.Status, status, fmt.Sprintf("Pet status should be %s", status)) //t.Log(resp) diff --git a/samples/client/petstore/go-experimental/user_api_test.go b/samples/client/petstore/go-experimental/user_api_test.go index 07b82ebb9757..882608702097 100644 --- a/samples/client/petstore/go-experimental/user_api_test.go +++ b/samples/client/petstore/go-experimental/user_api_test.go @@ -14,7 +14,7 @@ func TestCreateUser(t *testing.T) { Id: sw.PtrInt64(1000), FirstName: sw.PtrString("gopher"), LastName: sw.PtrString("lang"), - Username: sw.PtrString("gopher"), + Username: sw.PtrString("gopher"), Password: sw.PtrString("lang"), Email: sw.PtrString("lang@test.com"), Phone: sw.PtrString("5101112222"),