Description
Move the logic from the long function that generates the go type into a helper with good function and inline comments. Possible names: shouldEmitField(), skipField()
Some fields are redefined in hierarchical types, but to ensure consistent translation between JSON & Go, we must limit each field to appear only once. We need skip two types of duplicate fields:
- Parent definition defines field : type, child definition assigns a single value to that type => skip field in child
- Parent definition defines field : "any", child definitions refines the type to something concrete => skip field in parent
NOTE: in case non-message types define the same
Programatic detection of these is tricky since we process one type at a time, so for now we just hardcode known fields/type pairs that fall into the above categories. Comments to document these cases will help.
"type" - use in ProtocolMessage, skip assignments in children (1)
"command" - use in Request and Response, skip assignments in children (1)
"event" - use in Event, skip assignments in all children (1)
"arguments" - skip any type in Request, use specific types in children (2)
"body" - skip any type in Response and Event, use specific types in children (2)