Skip to content

Commit 964f066

Browse files
Merge pull request #494 from okta/ssaxena/fix-code-gen
Fix codegen process to avoid manual intervention
2 parents 370527b + f443c03 commit 964f066

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

.generator/templates/model_oneof.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
//model_oneof.mustache
23
// {{classname}} - {{{description}}}{{^description}}struct for {{{classname}}}{{/description}}
34
type {{classname}} struct {
@@ -59,8 +60,8 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
5960
// try to unmarshal data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}
6061
err = json.Unmarshal(data, &dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}})
6162
if err == nil {
62-
json{{{.}}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}})
63-
if string(json{{{.}}}) == "{}" { // empty struct
63+
json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}})
64+
if string(json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) == "{}" { // empty struct
6465
dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil
6566
} else {
6667
match++
@@ -142,4 +143,4 @@ func (obj *{{classname}}) GetActualInstance() (interface{}) {
142143
return nil
143144
}
144145

145-
{{>nullable_model}}
146+
{{>nullable_model}}

0 commit comments

Comments
 (0)