Skip to content

Commit

Permalink
fix: bug with omitempty tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Souvikns committed May 23, 2024
1 parent 1c83912 commit 89cb8e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/go-json-tags/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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, omitempty\\"\`
Options *Options \`json:\\"options, omitempty\\"\`
Cities *Cities \`json:\\"cities,omitempty\\"\`
Options *Options \`json:\\"options,omitempty\\"\`
}",
]
`;
Expand Down
4 changes: 2 additions & 2 deletions src/generators/go/presets/CommonPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function renderJSONTag({
field.property instanceof ConstrainedDictionaryModel &&
field.property.serializationType === 'unwrap'
) {
return `json:"-"`;
return `json:"-",omitempty`;
}
return `json:"${field.unconstrainedPropertyName}, omitempty"`;
return `json:"${field.unconstrainedPropertyName},omitempty"`;
}

function renderMarshallingFunctions({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, omitempty\\"\`
NumberProp float64 \`json:\\"numberProp, omitempty\\"\`
BooleanProp bool \`json:\\"booleanProp, omitempty\\"\`
StringProp string \`json:\\"stringProp,omitempty\\"\`
NumberProp float64 \`json:\\"numberProp,omitempty\\"\`
BooleanProp bool \`json:\\"booleanProp,omitempty\\"\`
}"
`;
Expand Down

0 comments on commit 89cb8e2

Please sign in to comment.