Skip to content

Commit 3edd80d

Browse files
Rakothantonmedv
authored andcommitted
fix docgen for ambiguous fields on nested structs
1 parent ec30886 commit 3edd80d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

docgen/docgen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ appendix:
193193
}
194194

195195
for name, field := range conf.FieldsFromStruct(t) {
196-
if isPrivate(name) || isProtobuf(name) {
196+
if isPrivate(name) || isProtobuf(name) || field.Ambiguous {
197197
continue
198198
}
199199
a.Fields[Identifier(name)] = c.use(field.Type)

docgen/docgen_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,15 @@ type A struct {
139139
type B struct {
140140
AmbiguousField string
141141
}
142+
143+
type C struct {
144+
A
145+
B
146+
}
142147
type EnvAmbiguous struct {
143148
A
144149
B
150+
C C
145151
}
146152

147153
func TestCreateDoc_Ambiguous(t *testing.T) {
@@ -159,6 +165,10 @@ func TestCreateDoc_Ambiguous(t *testing.T) {
159165
"OkField": {
160166
Kind: "int",
161167
},
168+
"C": {
169+
Kind: "struct",
170+
Name: "C",
171+
},
162172
},
163173
Types: map[TypeName]*Type{
164174
"A": {
@@ -174,6 +184,14 @@ func TestCreateDoc_Ambiguous(t *testing.T) {
174184
"AmbiguousField": {Kind: "string"},
175185
},
176186
},
187+
"C": {
188+
Kind: "struct",
189+
Fields: map[Identifier]*Type{
190+
"A": {Kind: "struct", Name: "A"},
191+
"B": {Kind: "struct", Name: "B"},
192+
"OkField": {Kind: "int"},
193+
},
194+
},
177195
},
178196
}
179197

0 commit comments

Comments
 (0)