From f443c03c2e495af25d3acab047151c30b2d8d7d5 Mon Sep 17 00:00:00 2001 From: Sachin Saxena Date: Fri, 22 Nov 2024 11:32:56 -0600 Subject: [PATCH] fix codegen --- .generator/templates/model_oneof.mustache | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.generator/templates/model_oneof.mustache b/.generator/templates/model_oneof.mustache index b4defc81a..6f0d2078c 100644 --- a/.generator/templates/model_oneof.mustache +++ b/.generator/templates/model_oneof.mustache @@ -1,3 +1,4 @@ + //model_oneof.mustache // {{classname}} - {{{description}}}{{^description}}struct for {{{classname}}}{{/description}} type {{classname}} struct { @@ -59,8 +60,8 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error { // try to unmarshal data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} err = json.Unmarshal(data, &dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) if err == nil { - json{{{.}}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) - if string(json{{{.}}}) == "{}" { // empty struct + json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + if string(json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) == "{}" { // empty struct dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil } else { match++ @@ -142,4 +143,4 @@ func (obj *{{classname}}) GetActualInstance() (interface{}) { return nil } -{{>nullable_model}} \ No newline at end of file +{{>nullable_model}}