Skip to content

Commit 0e20cf8

Browse files
Fix generated JSON object types (#3329)
* Ensure that examples are typed as `map[string]interface{}` if schema contains an `object` with `additionalProperties: {}` * Trigger CI --------- Co-authored-by: jack-edmonds-dd <jack.edmonds@datadoghq.com>
1 parent 3794619 commit 0e20cf8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.generator/src/generator/formatter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,12 @@ def format_data_with_schema_list(
556556
else:
557557
nested_schema_name = "interface{}"
558558
else:
559-
nested_schema_name = f"{name_prefix}{nested_schema_name}" if nested_schema_name else "interface{}"
559+
if nested_schema_name:
560+
nested_schema_name = f"{name_prefix}{nested_schema_name}"
561+
elif list_schema.get("type") == "object" and list_schema.get("additionalProperties") == {}:
562+
nested_schema_name = "map[string]interface{}"
563+
else:
564+
nested_schema_name = "interface{}"
560565

561566
nested_type = simple_type(list_schema)
562567
schema_parts.append(

0 commit comments

Comments
 (0)