Skip to content

Commit fecc7b4

Browse files
committed
fix: add exceptions for float32 and int32 to keep bug-compatibility with previous generated code
1 parent dc1aa47 commit fecc7b4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

templates/go/model_simple.mustache

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type {{classname}} struct {
3737
{{/isWriteOnly}}
3838
{{/isReadOnly}}
3939
{{/required}}
40-
{{name}} *{{#isNullable}}{{#isInteger}}NullableInt64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNullable}}{{^isNullable}}{{^isPrimitiveType}}{{dataType}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isPrimitiveType}}{{/isNullable}} `json:"{{baseName}}{{#required}}{{#isReadOnly}},omitempty{{/isReadOnly}}{{/required}}{{#required}}{{#isWriteOnly}},omitempty{{/isWriteOnly}}{{/required}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
40+
{{name}} *{{#isNullable}}{{#isInteger}}NullableInt64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNullable}}{{^isNullable}}{{^isPrimitiveType}}{{dataType}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}}{{/isPrimitiveType}}{{/isNullable}} `json:"{{baseName}}{{#required}}{{#isReadOnly}},omitempty{{/isReadOnly}}{{/required}}{{#required}}{{#isWriteOnly}},omitempty{{/isWriteOnly}}{{/required}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
4141
{{#isAdditionalPropertiesTrue}}
4242
AdditionalProperties map[string]interface{}
4343
{{/isAdditionalPropertiesTrue}}
@@ -59,7 +59,7 @@ type _{{{classname}}} {{{classname}}}
5959
// This constructor will assign default values to properties that have it defined,
6060
// and makes sure properties required by API are set, but the set of arguments
6161
// will change when the set of required properties is changed
62-
func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} *{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{datatype}}{{/isInteger}}{{^-last}}, {{/-last}}{{/requiredVars}}) *{{classname}} {
62+
func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} *{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{datatype}}{{/isInteger}}{{/isNumber}}{{^-last}}, {{/-last}}{{/requiredVars}}) *{{classname}} {
6363
this := {{classname}}{}
6464
{{#allVars}}
6565
{{#required}}
@@ -69,7 +69,7 @@ func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} *{{#isInteger}}int64{
6969
{{#defaultValue}}
7070
{{^vendorExtensions.x-golang-is-container}}
7171
{{^isReadOnly}}
72-
var {{nameInCamelCase}} {{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}} = {{{.}}}
72+
var {{nameInCamelCase}} {{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}} = {{{.}}}
7373
{{#isNullable}}
7474
this.{{name}} = *New{{dataType}}(&{{nameInCamelCase}})
7575
{{/isNullable}}
@@ -94,7 +94,7 @@ func New{{classname}}WithDefaults() *{{classname}} {
9494
{{^vendorExtensions.x-golang-is-container}}
9595
{{^isReadOnly}}
9696
{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}}
97-
var {{nameInCamelCase}} {{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}} = {{{.}}}
97+
var {{nameInCamelCase}} {{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}} = {{{.}}}
9898
{{#isNullable}}
9999
this.{{name}} = *New{{dataType}}(&{{nameInCamelCase}})
100100
{{/isNullable}}
@@ -117,9 +117,9 @@ func New{{classname}}WithDefaults() *{{classname}} {
117117
{{#deprecated}}
118118
// Deprecated
119119
{{/deprecated}}
120-
func (o *{{classname}}) Get{{name}}() *{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}} {
120+
func (o *{{classname}}) Get{{name}}() *{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}} {
121121
if o == nil|| IsNil(o.{{name}}) {{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
122-
var ret *{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}}
122+
var ret *{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}}
123123
return ret
124124
}
125125

@@ -144,7 +144,7 @@ func (o *{{classname}}) Get{{name}}() *{{#isInteger}}int64{{/isInteger}}{{^isInt
144144
{{#deprecated}}
145145
// Deprecated
146146
{{/deprecated}}
147-
func (o *{{classname}}) Get{{name}}Ok() (*{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}}, bool) {
147+
func (o *{{classname}}) Get{{name}}Ok() (*{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}}, bool) {
148148
if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
149149
{{^isFreeFormObject}}
150150
return nil, false
@@ -170,7 +170,7 @@ func (o *{{classname}}) Get{{name}}Ok() (*{{#isInteger}}int64{{/isInteger}}{{^is
170170
{{#deprecated}}
171171
// Deprecated
172172
{{/deprecated}}
173-
func (o *{{classname}}) Set{{name}}(v *{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{dataType}}{{/isInteger}}) {
173+
func (o *{{classname}}) Set{{name}}(v *{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{dataType}}{{/isInteger}}{{/isNumber}}) {
174174
{{#isNullable}}
175175
{{#vendorExtensions.x-golang-is-container}}
176176
o.{{name}} = v
@@ -193,9 +193,9 @@ func (o *{{classname}}) Set{{name}}(v *{{#isInteger}}int64{{/isInteger}}{{^isInt
193193
{{#deprecated}}
194194
// Deprecated
195195
{{/deprecated}}
196-
func (o *{{classname}}) Get{{name}}() *{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isContainer}} {
196+
func (o *{{classname}}) Get{{name}}() *{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isNumber}}{{/isContainer}} {
197197
if o == nil || IsNil(o.{{name}}) {{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
198-
var ret *{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isContainer}}
198+
var ret *{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isNumber}}{{/isContainer}}
199199
return ret
200200
}
201201
{{#isNullable}}
@@ -219,7 +219,7 @@ func (o *{{classname}}) Get{{name}}() *{{#isContainer}}{{dataType}}{{/isContaine
219219
{{#deprecated}}
220220
// Deprecated
221221
{{/deprecated}}
222-
func (o *{{classname}}) Get{{name}}Ok() (*{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isContainer}}, bool) {
222+
func (o *{{classname}}) Get{{name}}Ok() (*{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isNumber}}{{/isContainer}}, bool) {
223223
if o == nil || IsNil(o.{{name}}) {
224224
{{^isFreeFormObject}}
225225
return nil, false
@@ -254,7 +254,7 @@ func (o *{{classname}}) Has{{name}}() bool {
254254
{{#deprecated}}
255255
// Deprecated
256256
{{/deprecated}}
257-
func (o *{{classname}}) Set{{name}}(v *{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isContainer}}) {
257+
func (o *{{classname}}) Set{{name}}(v *{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}{{#isInteger}}int64{{/isInteger}}{{#isNumber}}float64{{/isNumber}}{{^isNumber}}{{^isInteger}}{{baseType}}{{/isInteger}}{{/isNumber}}{{/isContainer}}) {
258258
{{#isNullable}}
259259
{{#vendorExtensions.x-golang-is-container}}
260260
o.{{name}} = v

0 commit comments

Comments
 (0)