Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 5d1c6a3

Browse files
committed
fix: adding appropriate todos, addressing comments
1 parent 85be88d commit 5d1c6a3

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

gapic/schema/wrappers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,13 +769,13 @@ def http_opt(self) -> Optional[Dict[str, str]]:
769769

770770
@property
771771
def path_params(self) -> Sequence[str]:
772-
"""Return the path parameters found in the http annotation url"""
772+
"""Return the path parameters found in the http annotation path template"""
773773
# TODO(yon-mg): fully implement grpc transcoding (currently only handles basic case)
774774
if self.http_opt is None:
775775
return []
776-
pattern = r'\{\w+\}'
777776

778-
return [x[1:-1] for x in re.findall(pattern, self.http_opt['url'])]
777+
pattern = r'\{(\w+)\}'
778+
return re.findall(pattern, self.http_opt['url'])
779779

780780
@property
781781
def query_params(self) -> Set[str]:

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,16 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
168168
#}
169169
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
170170
# not required for GCE
171-
potentialParams = {
171+
query_params = {
172172
{%- for field in method.query_params %}
173173
'{{ field|camel_case }}': request.{{ field }},
174174
{%- endfor %}
175175
}
176-
potentialParams = ((k, v) for k, v in potentialParams.items() if v)
177-
for i, (param_name, param_value) in enumerate(potentialParams):
176+
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
177+
# discards default values
178+
# TODO(yon-mg): add test for proper url encoded strings
179+
query_params = ((k, v) for k, v in query_params.items() if v)
180+
for i, (param_name, param_value) in enumerate(query_params):
178181
q = '?' if i == 0 else '&'
179182
url += "{q}{name}={value}".format(q=q, name=param_name, value=param_value.replace(' ', '+'))
180183

0 commit comments

Comments
 (0)