diff --git a/go/models/empty_map.go b/go/models/empty_map.go deleted file mode 100644 index 277e746f6..000000000 --- a/go/models/empty_map.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package svix this file was hand written -package models - -// Used to denote an empty map -type emptyMap struct{} diff --git a/go/models/ingest_source_in.go b/go/models/ingest_source_in.go index d5dadb4d3..72607bdde 100644 --- a/go/models/ingest_source_in.go +++ b/go/models/ingest_source_in.go @@ -60,7 +60,6 @@ type IngestSourceInConfig interface { isIngestSourceInConfig() } -func (emptyMap) isIngestSourceInConfig() {} func (CronConfig) isIngestSourceInConfig() {} func (AdobeSignConfig) isIngestSourceInConfig() {} func (SvixConfig) isIngestSourceInConfig() {} @@ -145,7 +144,7 @@ var IngestSourceInTypeWithNoConfig = map[string]bool{ func (i IngestSourceIn) MarshalJSON() ([]byte, error) { type Alias IngestSourceIn if _, found := IngestSourceInTypeWithNoConfig[string(i.Type)]; found { - i.Config = emptyMap{} + i.Config = nil } return json.Marshal(&struct{ Alias }{Alias: (Alias)(i)}) } diff --git a/go/models/ingest_source_out.go b/go/models/ingest_source_out.go index fad68b6b4..7c55b3d1e 100644 --- a/go/models/ingest_source_out.go +++ b/go/models/ingest_source_out.go @@ -65,7 +65,6 @@ type IngestSourceOutConfig interface { isIngestSourceOutConfig() } -func (emptyMap) isIngestSourceOutConfig() {} func (CronConfig) isIngestSourceOutConfig() {} func (AdobeSignConfigOut) isIngestSourceOutConfig() {} func (SvixConfigOut) isIngestSourceOutConfig() {} @@ -150,7 +149,7 @@ var IngestSourceOutTypeWithNoConfig = map[string]bool{ func (i IngestSourceOut) MarshalJSON() ([]byte, error) { type Alias IngestSourceOut if _, found := IngestSourceOutTypeWithNoConfig[string(i.Type)]; found { - i.Config = emptyMap{} + i.Config = nil } return json.Marshal(&struct{ Alias }{Alias: (Alias)(i)}) } diff --git a/go/svix_test.go b/go/svix_test.go index 849884425..2627e57ae 100644 --- a/go/svix_test.go +++ b/go/svix_test.go @@ -685,7 +685,7 @@ func TestStructEnumWithFields(t *testing.T) { } func TestStructEnumWithNoFields(t *testing.T) { - expectedJson := `{"name":"Mendy","uid":"very unique","type":"generic-webhook","config":{}}` + expectedJson := `{"name":"Mendy","uid":"very unique","type":"generic-webhook","config":null}` uid := "very unique" sourceIn := models.IngestSourceIn{ Name: "Mendy", @@ -702,7 +702,7 @@ func TestStructEnumWithNoFields(t *testing.T) { } func TestStructEnumWithNoFieldsNilConfig(t *testing.T) { - expectedJson := `{"name":"Mendy","uid":"very unique","type":"generic-webhook","config":{}}` + expectedJson := `{"name":"Mendy","uid":"very unique","type":"generic-webhook","config":null}` uid := "very unique" sourceIn := models.IngestSourceIn{ Name: "Mendy", diff --git a/openapi-templates/go/types/struct_enum.go.jinja b/openapi-templates/go/types/struct_enum.go.jinja index 4d44d2ea6..3db4933df 100644 --- a/openapi-templates/go/types/struct_enum.go.jinja +++ b/openapi-templates/go/types/struct_enum.go.jinja @@ -46,8 +46,6 @@ type {{ ty_name }}{{ content_field }} interface { {% for schema_ref in type.variants| map(attribute="schema_ref") | unique -%} {% if schema_ref is defined -%} func ({{ schema_ref | to_upper_camel_case }}) is{{ ty_name }}{{ content_field }}(){} - {% else -%} -func (emptyMap) is{{ ty_name }}{{ content_field }}(){} {% endif -%} {% endfor %} @@ -93,7 +91,7 @@ func (i {{ ty_name }}) MarshalJSON() ([]byte, error) { type Alias {{ ty_name }} {% if has_variant_with_no_schema_ref -%} if _, found := {{ ty_name }}{{ discriminator_field }}WithNo{{ content_field }}[string(i.{{ discriminator_field }})]; found { - i.{{ content_field }} = emptyMap{} + i.{{ content_field }} = nil } {% endif -%} return json.Marshal(&struct {Alias}{Alias: (Alias)(i)})