From 3298bb71841f0aa069e89af45ce2dc0c4ee6f316 Mon Sep 17 00:00:00 2001 From: Lucas Bremgartner Date: Mon, 16 Jan 2017 11:39:42 +0100 Subject: [PATCH] Support type "nested" with empty property list (#3360) --- libbeat/scripts/generate_template.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libbeat/scripts/generate_template.py b/libbeat/scripts/generate_template.py index e64b309d8db..5efcaf17cac 100644 --- a/libbeat/scripts/generate_template.py +++ b/libbeat/scripts/generate_template.py @@ -168,10 +168,11 @@ def fill_section_properties(args, section, defaults, path): properties = {} dynamic_templates = [] - for field in section["fields"]: - prop, dynamic = fill_field_properties(args, field, defaults, path) - properties.update(prop) - dynamic_templates.extend(dynamic) + if "fields" in section: + for field in section["fields"]: + prop, dynamic = fill_field_properties(args, field, defaults, path) + properties.update(prop) + dynamic_templates.extend(dynamic) return properties, dynamic_templates @@ -298,12 +299,12 @@ def fill_field_properties(args, field, defaults, path): path = field["name"] prop, dynamic = fill_section_properties(args, field, defaults, path) + properties[field.get("name")] = { + "type": "nested", + "properties": {} + } # Only add properties if they have a content if len(prop) is not 0: - properties[field.get("name")] = { - "type": "nested", - "properties": {} - } properties[field.get("name")]["properties"] = prop dynamic_templates.extend(dynamic)