Skip to content

Commit

Permalink
Adjust logic on handlebars to avoid 'if true' statement on models (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Sep 27, 2023
2 parents 21bc9fc + b1d82b1 commit 8f1fb87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/clients/go/template/model_simple.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,14 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
{{/isNullable}}
{{! if argument is not nullable, don't set it if it is nil}}
{{^isNullable}}
if {{#required}}true{{/required}}{{^required}}o.{{name}} != nil{{/required}} {
{{#required}}
toSerialize["{{baseName}}"] = o.{{name}}
{{/required}}
{{^required}}
if o.{{name}} != nil {
toSerialize["{{baseName}}"] = o.{{name}}
}
{{/required}}
{{/isNullable}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
Expand Down

0 comments on commit 8f1fb87

Please sign in to comment.