Skip to content

Commit

Permalink
add oneof_parent parameter to fields
Browse files Browse the repository at this point in the history
  • Loading branch information
YaseenAlk committed Jul 1, 2021
1 parent f9341e7 commit 287eb47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 12 additions & 10 deletions parse.go
Expand Up @@ -79,11 +79,12 @@ type Map struct {
}

type Field struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
IsRepeated bool `json:"is_repeated,omitempty"`
Options []Option `json:"options,omitempty"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
IsRepeated bool `json:"is_repeated,omitempty"`
Options []Option `json:"options,omitempty"`
OneofParent string `json:"oneof_parent,omitempty"`
}

type Service struct {
Expand Down Expand Up @@ -314,11 +315,12 @@ func parseMessage(m *proto.Message) Message {
for _, el := range oo.Elements {
if f, ok := el.(*proto.OneOfField); ok {
fields = append(fields, Field{
ID: f.Sequence,
Name: f.Name,
Type: f.Type,
IsRepeated: false,
Options: parseOptions(f.Options),
ID: f.Sequence,
Name: f.Name,
Type: f.Type,
IsRepeated: false,
Options: parseOptions(f.Options),
OneofParent: oo.Name,
})
}
}
Expand Down
6 changes: 4 additions & 2 deletions proto.lock
Expand Up @@ -491,12 +491,14 @@
{
"id": 4,
"name": "name",
"type": "string"
"type": "string",
"oneof_parent": "test_oneof"
},
{
"id": 9,
"name": "is_active",
"type": "bool"
"type": "bool",
"oneof_parent": "test_oneof"
}
]
},
Expand Down

0 comments on commit 287eb47

Please sign in to comment.