Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug with omitempty tag #2016

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading