Skip to content

Commit 60e1549

Browse files
committed
fix lint & update integration test
1 parent d9cc065 commit 60e1549

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

typesense/api/generator/main.go

+15-16
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,15 @@ func unwrapSearchParameters(m *yml) {
215215
newMap["in"] = query
216216
newMap["schema"] = make(yml)
217217
if obj.Value.(yml)["oneOf"] == nil {
218+
switch {
218219
// if the param is referencing a schema
219-
if obj.Value.(yml)["type"] == nil {
220+
case obj.Value.(yml)["type"] == nil:
220221
newMap["schema"].(yml)["$ref"] = obj.Value.(yml)["$ref"].(string)
221-
} else {
222-
if obj.Value.(yml)["type"].(string) == array {
223-
newMap["schema"].(yml)["type"] = array
224-
newMap["schema"].(yml)["items"] = obj.Value.(yml)["items"]
225-
} else {
226-
newMap["schema"].(yml)["type"] = obj.Value.(yml)["type"].(string)
227-
}
222+
case obj.Value.(yml)["type"].(string) == array:
223+
newMap["schema"].(yml)["type"] = array
224+
newMap["schema"].(yml)["items"] = obj.Value.(yml)["items"]
225+
default:
226+
newMap["schema"].(yml)["type"] = obj.Value.(yml)["type"].(string)
228227
}
229228
} else {
230229
newMap["schema"].(yml)["oneOf"] = obj.Value.(yml)["oneOf"]
@@ -246,15 +245,15 @@ func unwrapMultiSearchParameters(m *yml) {
246245
newMap["in"] = query
247246
newMap["schema"] = make(yml)
248247
if obj.Value.(yml)["oneOf"] == nil {
249-
if obj.Value.(yml)["type"] == nil {
248+
switch {
249+
// if the param is referencing a schema
250+
case obj.Value.(yml)["type"] == nil:
250251
newMap["schema"].(yml)["$ref"] = obj.Value.(yml)["$ref"].(string)
251-
} else {
252-
if obj.Value.(yml)["type"].(string) == array {
253-
newMap["schema"].(yml)["type"] = array
254-
newMap["schema"].(yml)["items"] = obj.Value.(yml)["items"]
255-
} else {
256-
newMap["schema"].(yml)["type"] = obj.Value.(yml)["type"].(string)
257-
}
252+
case obj.Value.(yml)["type"].(string) == array:
253+
newMap["schema"].(yml)["type"] = array
254+
newMap["schema"].(yml)["items"] = obj.Value.(yml)["items"]
255+
default:
256+
newMap["schema"].(yml)["type"] = obj.Value.(yml)["type"].(string)
258257
}
259258
} else {
260259
newMap["schema"].(yml)["oneOf"] = obj.Value.(yml)["oneOf"]

typesense/test/dbhelpers_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func expectedNewCollection(name string) *api.CollectionResponse {
5757
Sort: pointer.False(),
5858
Drop: nil,
5959
Store: pointer.True(),
60+
Stem: pointer.False(),
6061
},
6162
{
6263
Name: "num_employees",
@@ -69,6 +70,7 @@ func expectedNewCollection(name string) *api.CollectionResponse {
6970
Sort: pointer.True(),
7071
Drop: nil,
7172
Store: pointer.True(),
73+
Stem: pointer.False(),
7274
},
7375
{
7476
Name: "country",
@@ -81,6 +83,7 @@ func expectedNewCollection(name string) *api.CollectionResponse {
8183
Sort: pointer.False(),
8284
Drop: nil,
8385
Store: pointer.True(),
86+
Stem: pointer.False(),
8487
},
8588
},
8689
EnableNestedFields: pointer.False(),

0 commit comments

Comments
 (0)