diff --git a/examples/go-json-tags/__snapshots__/index.spec.ts.snap b/examples/go-json-tags/__snapshots__/index.spec.ts.snap index d0a0aaf1e9..3f1ddc2de8 100644 --- a/examples/go-json-tags/__snapshots__/index.spec.ts.snap +++ b/examples/go-json-tags/__snapshots__/index.spec.ts.snap @@ -4,8 +4,8 @@ exports[`Should be able to render json-tags in struct and should log expected ou Array [ "// Root represents a Root model. type Root struct { - Cities *Cities \`json:\\"cities\\"\` - Options *Options \`json:\\"options\\"\` + Cities *Cities \`json:\\"cities, omitempty\\"\` + Options *Options \`json:\\"options, omitempty\\"\` }", ] `; diff --git a/modelina-cli/package-lock.json b/modelina-cli/package-lock.json index 67a8370d69..1aa32ad4fc 100644 --- a/modelina-cli/package-lock.json +++ b/modelina-cli/package-lock.json @@ -185,9 +185,10 @@ } }, "node_modules/@asyncapi/modelina": { - "version": "4.0.0-next.38", + "version": "4.0.0-next.39", "resolved": "file:scripts/modelina-package/asyncapi-modelina.tgz", - "integrity": "sha512-Hv6M5/1ViR6EGGllwIqyblNlsLeW5qEQOHWc7F1+zk4DMmLT6cxiDPZKYyRbqWWhbjbKXY4A0bK0/pIDs8mdvg==", + "integrity": "sha512-Hkmdufj2ZJigzRvb2MQmfTxQpRj4Wp0A5n8o3vz9n9nhuMfehrzilYed8uIPaFJ9ML3wMckk0KrAYcpula7JFw==", + "license": "Apache-2.0", "dependencies": { "@apidevtools/json-schema-ref-parser": "^11.1.0", "@apidevtools/swagger-parser": "^10.1.0", diff --git a/src/generators/go/presets/CommonPreset.ts b/src/generators/go/presets/CommonPreset.ts index 8f1ae31643..248a7b5f6c 100644 --- a/src/generators/go/presets/CommonPreset.ts +++ b/src/generators/go/presets/CommonPreset.ts @@ -21,7 +21,7 @@ function renderJSONTag({ ) { return `json:"-"`; } - return `json:"${field.unconstrainedPropertyName}"`; + return `json:"${field.unconstrainedPropertyName}, omitempty"`; } function renderMarshallingFunctions({ diff --git a/test/generators/go/presets/CommonPreset.spec.ts b/test/generators/go/presets/CommonPreset.spec.ts index 9647bdfec6..5fe4213b9c 100644 --- a/test/generators/go/presets/CommonPreset.spec.ts +++ b/test/generators/go/presets/CommonPreset.spec.ts @@ -7,7 +7,9 @@ import { describe('GO_COMMON_PRESET', () => { let generator: GoGenerator; beforeEach(() => { - const options: GoCommonPresetOptions = { addJsonTag: true }; + const options: GoCommonPresetOptions = { + addJsonTag: true + }; generator = new GoGenerator({ presets: [{ preset: GO_COMMON_PRESET, options }] }); diff --git a/test/generators/go/presets/__snapshots__/CommonPreset.spec.ts.snap b/test/generators/go/presets/__snapshots__/CommonPreset.spec.ts.snap index 2b8d2f831c..6a1819d052 100644 --- a/test/generators/go/presets/__snapshots__/CommonPreset.spec.ts.snap +++ b/test/generators/go/presets/__snapshots__/CommonPreset.spec.ts.snap @@ -3,9 +3,9 @@ exports[`GO_COMMON_PRESET should render json tags for structs 1`] = ` "// Root represents a Root model. type Root struct { - StringProp string \`json:\\"stringProp\\"\` - NumberProp float64 \`json:\\"numberProp\\"\` - BooleanProp bool \`json:\\"booleanProp\\"\` + StringProp string \`json:\\"stringProp, omitempty\\"\` + NumberProp float64 \`json:\\"numberProp, omitempty\\"\` + BooleanProp bool \`json:\\"booleanProp, omitempty\\"\` }" `;