From 2a4eadc55901e866b8e33f0cdb38c6b341b3ca49 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Wed, 17 Jul 2024 13:35:28 +0200 Subject: [PATCH] Object metric (Swift): Set default empty array for array parameters This way it becomes optional --- glean_parser/templates/swift.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glean_parser/templates/swift.jinja2 b/glean_parser/templates/swift.jinja2 index eec825615..f8e332cb1 100644 --- a/glean_parser/templates/swift.jinja2 +++ b/glean_parser/templates/swift.jinja2 @@ -54,7 +54,7 @@ struct {{ obj.name|Camelize }}{{ suffix }}: EventExtras { struct {{ name }}: Codable, Equatable, ObjectSerialize { {% for itemname, val in struct.properties.items() %} {% if val.type == "array" %} - var {{itemname|camelize|variable_name}}: {{ name ~ itemname|Camelize }} + var {{itemname|camelize|variable_name}}: {{ name ~ itemname|Camelize }} = [] {% elif val.type == "object" %} var {{itemname|camelize|variable_name}}: {{ name ~ "Item" ~ itemname|Camelize ~ "Object" }}? {% else %}