Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Check for default value presence for non-optional fields in REST #868

Merged
merged 2 commits into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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