Skip to content

Commit 986ee44

Browse files
authored
fix --pager error (#211)
1 parent e31cba5 commit 986ee44

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
### Master
44

5+
- fix: fix `--pager` error
6+
- add: product sae
7+
58
### 3.0.22
69

710
- update: API meta data

openapi/pager.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,16 @@ func (a *Pager) GetResponseCollection() string {
109109
root := make(map[string]interface{})
110110
current := make(map[string]interface{})
111111
path := a.collectionPath
112-
113-
for {
114-
l := strings.Index(path, ".")
115-
tempSlice := strings.Split(path, ".")
116-
if l > 0 {
117-
tempSlice = tempSlice[len(tempSlice)-2:]
118-
root[tempSlice[0]] = current
119-
}
120-
key := strings.TrimSuffix(tempSlice[len(tempSlice)-1], "[]")
121-
current[key] = a.results
122-
break
123-
112+
l := strings.Index(path, ".")
113+
tempSlice := strings.Split(path, ".")
114+
if l > 0 {
115+
tempSlice = tempSlice[len(tempSlice)-2:]
116+
root[tempSlice[0]] = current
117+
} else {
118+
root = current
124119
}
120+
key := strings.TrimSuffix(tempSlice[len(tempSlice)-1], "[]")
121+
current[key] = a.results
125122

126123
s, err := json.Marshal(root)
127124
if err != nil {

0 commit comments

Comments
 (0)