Skip to content

Commit 284d7db

Browse files
committed
ApiStruct fixups: accept any non-array with fields
1 parent 20ae626 commit 284d7db

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

kafka/protocol/new/api_struct.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
class ApiStruct(Field):
1010
@classmethod
1111
def parse_json(cls, json):
12-
if json['type'] in ('request', 'response', 'header') or json['type'][0].isupper():
13-
if 'fields' in json:
14-
return cls(json)
12+
if 'type' not in json or json['type'].startswith('[]'):
13+
return
14+
if 'fields' in json:
15+
return cls(json)
1516

1617
# Cases
1718
# oldschool - standard types, no tagged fields
1819
# newschool - compact types, tagged fields
1920
# nested tag - compact types, no (nested) tagged fields
2021
def __init__(self, json):
2122
super().__init__(json)
22-
self._field_map = {field.name: field for field in self._fields if field is not None}
23+
self._field_map = {field.name: field for field in self._fields}
2324
self._data_class = None
2425

2526
@property

0 commit comments

Comments
 (0)