File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,14 @@ iteration:
35
35
36
36
// See whether this is an embedded field
37
37
if f .Anonymous {
38
- if f .Tag .Get ("json" ) == "-" {
38
+ jsonTag := f .Tag .Get ("json" )
39
+ if jsonTag == "-" {
39
40
continue
40
41
}
41
- fields = AppendFields (fields , index , f .Type )
42
- continue iteration
42
+ if jsonTag == "" {
43
+ fields = AppendFields (fields , index , f .Type )
44
+ continue iteration
45
+ }
43
46
}
44
47
45
48
// Ignore certain types
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ import (
18
18
19
19
func ExampleGenerator_SchemaRefs () {
20
20
type SomeOtherType string
21
+ type Embedded struct {
22
+ Z string `json:"z"`
23
+ }
24
+ type Embedded2 struct {
25
+ A string `json:"a"`
26
+ }
21
27
type SomeStruct struct {
22
28
Bool bool `json:"bool"`
23
29
Int int `json:"int"`
@@ -38,6 +44,10 @@ func ExampleGenerator_SchemaRefs() {
38
44
Y string
39
45
} `json:"structWithoutFields"`
40
46
47
+ Embedded `json:"embedded"`
48
+
49
+ Embedded2
50
+
41
51
Ptr * SomeOtherType `json:"ptr"`
42
52
}
43
53
@@ -54,16 +64,27 @@ func ExampleGenerator_SchemaRefs() {
54
64
}
55
65
fmt .Printf ("schemaRef: %s\n " , data )
56
66
// Output:
57
- // g.SchemaRefs: 15
67
+ // g.SchemaRefs: 16
58
68
// schemaRef: {
59
69
// "properties": {
70
+ // "a": {
71
+ // "type": "string"
72
+ // },
60
73
// "bool": {
61
74
// "type": "boolean"
62
75
// },
63
76
// "bytes": {
64
77
// "format": "byte",
65
78
// "type": "string"
66
79
// },
80
+ // "embedded": {
81
+ // "properties": {
82
+ // "z": {
83
+ // "type": "string"
84
+ // }
85
+ // },
86
+ // "type": "object"
87
+ // },
67
88
// "float64": {
68
89
// "format": "double",
69
90
// "type": "number"
You can’t perform that action at this time.
0 commit comments