Skip to content

Commit

Permalink
fix: Check for default value presence for non-optional fields in REST (
Browse files Browse the repository at this point in the history
  • Loading branch information
vam-google authored May 7, 2021
1 parent 5339db1 commit 5748001
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,15 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
if {{ method.input.ident }}.{{ field }} in request:
query_params['{{ field|camel_case }}'] = request.{{ field }}
{% else %}
query_params['{{ field|camel_case }}'] = request.{{ field }}
if request.{{ field }}:
query_params['{{ field|camel_case }}'] = request.{{ field }}
{% endif %}
{% endfor %}

# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
# TODO(yon-mg): add test for proper url encoded strings
query_params = ['{k}={v}'.format(k=k, v=v) for k, v in query_params.items() if v]
query_params = ['{k}={v}'.format(k=k, v=v) for k, v in query_params.items()]
url += '?{}'.format('&'.join(query_params)).replace(' ', '+')

# Send the request
Expand Down

0 comments on commit 5748001

Please sign in to comment.