Skip to content

Commit 253f2e9

Browse files
committed
go: Emit null instead of {} for when struct enum config field is nil
1 parent e3313a4 commit 253f2e9

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

go/models/ingest_source_in.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var IngestSourceInTypeWithNoConfig = map[string]bool{
145145
func (i IngestSourceIn) MarshalJSON() ([]byte, error) {
146146
type Alias IngestSourceIn
147147
if _, found := IngestSourceInTypeWithNoConfig[string(i.Type)]; found {
148-
i.Config = emptyMap{}
148+
i.Config = nil
149149
}
150150
return json.Marshal(&struct{ Alias }{Alias: (Alias)(i)})
151151
}

go/models/ingest_source_out.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ var IngestSourceOutTypeWithNoConfig = map[string]bool{
150150
func (i IngestSourceOut) MarshalJSON() ([]byte, error) {
151151
type Alias IngestSourceOut
152152
if _, found := IngestSourceOutTypeWithNoConfig[string(i.Type)]; found {
153-
i.Config = emptyMap{}
153+
i.Config = nil
154154
}
155155
return json.Marshal(&struct{ Alias }{Alias: (Alias)(i)})
156156
}

openapi-templates/go/types/struct_enum.go.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (i {{ ty_name }}) MarshalJSON() ([]byte, error) {
9393
type Alias {{ ty_name }}
9494
{% if has_variant_with_no_schema_ref -%}
9595
if _, found := {{ ty_name }}{{ discriminator_field }}WithNo{{ content_field }}[string(i.{{ discriminator_field }})]; found {
96-
i.{{ content_field }} = emptyMap{}
96+
i.{{ content_field }} = nil
9797
}
9898
{% endif -%}
9999
return json.Marshal(&struct {Alias}{Alias: (Alias)(i)})

0 commit comments

Comments
 (0)