From 0c0bdf812b326c337987d350da9c5eccf37b44db Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Fri, 24 Oct 2025 17:56:36 +0200 Subject: [PATCH 1/3] fix: generated unmarshalJSON in oneOf can not be complied --- templates/go/model_oneof.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/go/model_oneof.mustache b/templates/go/model_oneof.mustache index a3474f9..f179d14 100644 --- a/templates/go/model_oneof.mustache +++ b/templates/go/model_oneof.mustache @@ -65,7 +65,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error { dst{{classname}}{{-index}} := &{{classname}}{} err = json.Unmarshal(data, &dst{{classname}}{{-index}}.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) if err == nil { - json{{{.}}}, _ := json.Marshal(&dst{{classname}}{{-index}}.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, _ := json.Marshal(&dst{{classname}}{{-index}}.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) {{#pattern}} regex := `{{.}}` regex = regexp.MustCompile("^\\/|\\/$").ReplaceAllString(regex, "$1") // Remove beginning slash and ending slash @@ -73,7 +73,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error { rawString := regexp.MustCompile(`^"|"$`).ReplaceAllString(*dst{{classname}}{{-index}}.{{#lambda.type-to-name}}{{dataType}}{{/lambda.type-to-name}}, "$1") // Remove quotes isMatched, _ := regexp.MatchString(regex, rawString) {{/pattern}} - if string(json{{{.}}}) != "{}" {{#pattern}}&& isMatched {{/pattern}} { // empty struct + if string(json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) != "{}" {{#pattern}}&& isMatched {{/pattern}} { // empty struct dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = dst{{classname}}{{-index}}.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} match++ } From 0d99a96075fea6939ed8835ff13c8f5436effdb2 Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Mon, 10 Nov 2025 16:00:49 +0100 Subject: [PATCH 2/3] fix: generated unmarshalJSON tests in oneOf --- .../helper/array_json_example_value.mustache | 1 + .../helper/container_json_example_value.mustache | 1 + templates/go/custom/model_oneof_test.mustache | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 templates/go/custom/helper/array_json_example_value.mustache create mode 100644 templates/go/custom/helper/container_json_example_value.mustache diff --git a/templates/go/custom/helper/array_json_example_value.mustache b/templates/go/custom/helper/array_json_example_value.mustache new file mode 100644 index 0000000..00b75f8 --- /dev/null +++ b/templates/go/custom/helper/array_json_example_value.mustache @@ -0,0 +1 @@ +{{#isArray}}[{{#items}}{{#isString}}"example"{{/isString}}{{/items}}]{{/isArray}} \ No newline at end of file diff --git a/templates/go/custom/helper/container_json_example_value.mustache b/templates/go/custom/helper/container_json_example_value.mustache new file mode 100644 index 0000000..4643fa7 --- /dev/null +++ b/templates/go/custom/helper/container_json_example_value.mustache @@ -0,0 +1 @@ +{{#isContainer}}{{#isMap}}{"map":{{#items}}{{> custom/helper/array_json_example_value}}{{^isArray}}{{#isString}}"example"{{/isString}}{{/isArray}}{{/items}}}{{/isMap}}{{^isMap}}{{> custom/helper/array_json_example_value}}{{/isMap}}{{/isContainer}} \ No newline at end of file diff --git a/templates/go/custom/model_oneof_test.mustache b/templates/go/custom/model_oneof_test.mustache index 068d98e..cb2b712 100644 --- a/templates/go/custom/model_oneof_test.mustache +++ b/templates/go/custom/model_oneof_test.mustache @@ -27,15 +27,23 @@ func Test{{{classname}}}_UnmarshalJSON(t *testing.T) { wantErr: false, }, {{/allowableValues.values}} - {{^allowableValues.values}}{{^isModel}} + {{^allowableValues.values}}{{^isModel}}{{^isContainer}} { - name: "success - {{dataType}} {{example}}", + name: "success - {{dataType}} {{{example}}}", args: args{ - src: []byte(`"{{example}}"`), + src: []byte(`"{{{example}}}"`), }, wantErr: false, }, - {{/isModel}}{{/allowableValues.values}} + {{/isContainer}}{{#isContainer}} + { + name: "success - {{dataType}}", + args: args{ + src: []byte(`{{>custom/helper/container_json_example_value}}`), + }, + wantErr: false, + }, + {{/isContainer}}{{/isModel}}{{/allowableValues.values}} {{#-last}} } for _, tt := range tests { From 30a44faa802d07fce347c573d940c74390b45865 Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Mon, 10 Nov 2025 16:08:41 +0100 Subject: [PATCH 3/3] remove observability from blacklist --- blacklist.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/blacklist.txt b/blacklist.txt index 5b7d215..d48458c 100644 --- a/blacklist.txt +++ b/blacklist.txt @@ -4,5 +4,4 @@ featuretoggle workflows openstack notebooks -observability cost