Skip to content

Commit ea28484

Browse files
authored
Ignore empty string for query parameter (#497)
1 parent 2bab995 commit ea28484

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

generator/src/main/resources/line-bot-sdk-go-generator/api.pebble

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,13 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
268268
{% if op.hasQueryParams -%}
269269
query := url.Values{}
270270
{% for qp in op.queryParams -%}
271+
{% if qp.isString and not qp.required -%}
272+
if {{ stringify(qp) }} != "" {
271273
query.Add("{{ qp.paramName }}", {{ stringify(qp) }})
274+
}
275+
{% else -%}
276+
query.Add("{{ qp.paramName }}", {{ stringify(qp) }})
277+
{% endif -%}
272278
{% endfor %}
273279
req.URL.RawQuery = query.Encode()
274280
{% endif %}

linebot/insight/api_insight.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ func (client *InsightAPI) GetNumberOfFollowersWithHttpInfo(
278278
}
279279

280280
query := url.Values{}
281-
query.Add("date", date)
281+
if date != "" {
282+
query.Add("date", date)
283+
}
282284

283285
req.URL.RawQuery = query.Encode()
284286

linebot/manage_audience/api_manage_audience.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,9 @@ func (client *ManageAudienceAPI) GetAudienceGroupsWithHttpInfo(
727727

728728
query := url.Values{}
729729
query.Add("page", strconv.FormatInt(page, 10))
730-
query.Add("description", description)
730+
if description != "" {
731+
query.Add("description", description)
732+
}
731733
query.Add("status", string(status))
732734
query.Add("size", strconv.FormatInt(size, 10))
733735
query.Add("includesExternalPublicGroups", strconv.FormatBool(includesExternalPublicGroups))

linebot/messaging_api/api_messaging_api.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,12 @@ func (client *MessagingApiAPI) GetAggregationUnitNameListWithHttpInfo(
697697
}
698698

699699
query := url.Values{}
700-
query.Add("limit", limit)
701-
query.Add("start", start)
700+
if limit != "" {
701+
query.Add("limit", limit)
702+
}
703+
if start != "" {
704+
query.Add("start", start)
705+
}
702706

703707
req.URL.RawQuery = query.Encode()
704708

@@ -936,7 +940,9 @@ func (client *MessagingApiAPI) GetFollowersWithHttpInfo(
936940
}
937941

938942
query := url.Values{}
939-
query.Add("start", start)
943+
if start != "" {
944+
query.Add("start", start)
945+
}
940946
query.Add("limit", strconv.FormatInt(int64(limit), 10))
941947

942948
req.URL.RawQuery = query.Encode()
@@ -1164,7 +1170,9 @@ func (client *MessagingApiAPI) GetGroupMembersIdsWithHttpInfo(
11641170
}
11651171

11661172
query := url.Values{}
1167-
query.Add("start", start)
1173+
if start != "" {
1174+
query.Add("start", start)
1175+
}
11681176

11691177
req.URL.RawQuery = query.Encode()
11701178

@@ -2561,7 +2569,9 @@ func (client *MessagingApiAPI) GetRoomMembersIdsWithHttpInfo(
25612569
}
25622570

25632571
query := url.Values{}
2564-
query.Add("start", start)
2572+
if start != "" {
2573+
query.Add("start", start)
2574+
}
25652575

25662576
req.URL.RawQuery = query.Encode()
25672577

linebot/module/api_line_module.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ func (client *LineModuleAPI) GetModulesWithHttpInfo(
308308
}
309309

310310
query := url.Values{}
311-
query.Add("start", start)
311+
if start != "" {
312+
query.Add("start", start)
313+
}
312314
query.Add("limit", strconv.FormatInt(int64(limit), 10))
313315

314316
req.URL.RawQuery = query.Encode()

0 commit comments

Comments
 (0)