Skip to content

Commit

Permalink
Ignore empty string for query parameter (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
habara-k authored Oct 31, 2024
1 parent 2bab995 commit ea28484
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,13 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
{% if op.hasQueryParams -%}
query := url.Values{}
{% for qp in op.queryParams -%}
{% if qp.isString and not qp.required -%}
if {{ stringify(qp) }} != "" {
query.Add("{{ qp.paramName }}", {{ stringify(qp) }})
}
{% else -%}
query.Add("{{ qp.paramName }}", {{ stringify(qp) }})
{% endif -%}
{% endfor %}
req.URL.RawQuery = query.Encode()
{% endif %}
Expand Down
4 changes: 3 additions & 1 deletion linebot/insight/api_insight.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ func (client *InsightAPI) GetNumberOfFollowersWithHttpInfo(
}

query := url.Values{}
query.Add("date", date)
if date != "" {
query.Add("date", date)
}

req.URL.RawQuery = query.Encode()

Expand Down
4 changes: 3 additions & 1 deletion linebot/manage_audience/api_manage_audience.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,9 @@ func (client *ManageAudienceAPI) GetAudienceGroupsWithHttpInfo(

query := url.Values{}
query.Add("page", strconv.FormatInt(page, 10))
query.Add("description", description)
if description != "" {
query.Add("description", description)
}
query.Add("status", string(status))
query.Add("size", strconv.FormatInt(size, 10))
query.Add("includesExternalPublicGroups", strconv.FormatBool(includesExternalPublicGroups))
Expand Down
20 changes: 15 additions & 5 deletions linebot/messaging_api/api_messaging_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,12 @@ func (client *MessagingApiAPI) GetAggregationUnitNameListWithHttpInfo(
}

query := url.Values{}
query.Add("limit", limit)
query.Add("start", start)
if limit != "" {
query.Add("limit", limit)
}
if start != "" {
query.Add("start", start)
}

req.URL.RawQuery = query.Encode()

Expand Down Expand Up @@ -936,7 +940,9 @@ func (client *MessagingApiAPI) GetFollowersWithHttpInfo(
}

query := url.Values{}
query.Add("start", start)
if start != "" {
query.Add("start", start)
}
query.Add("limit", strconv.FormatInt(int64(limit), 10))

req.URL.RawQuery = query.Encode()
Expand Down Expand Up @@ -1164,7 +1170,9 @@ func (client *MessagingApiAPI) GetGroupMembersIdsWithHttpInfo(
}

query := url.Values{}
query.Add("start", start)
if start != "" {
query.Add("start", start)
}

req.URL.RawQuery = query.Encode()

Expand Down Expand Up @@ -2561,7 +2569,9 @@ func (client *MessagingApiAPI) GetRoomMembersIdsWithHttpInfo(
}

query := url.Values{}
query.Add("start", start)
if start != "" {
query.Add("start", start)
}

req.URL.RawQuery = query.Encode()

Expand Down
4 changes: 3 additions & 1 deletion linebot/module/api_line_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ func (client *LineModuleAPI) GetModulesWithHttpInfo(
}

query := url.Values{}
query.Add("start", start)
if start != "" {
query.Add("start", start)
}
query.Add("limit", strconv.FormatInt(int64(limit), 10))

req.URL.RawQuery = query.Encode()
Expand Down

0 comments on commit ea28484

Please sign in to comment.