Skip to content

Commit 8f3f81c

Browse files
authored
feat: When requesting numeric enums in responses, also send them in requests (#1405)
1 parent 46fe7f2 commit 8f3f81c

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

  • packages/gapic-generator/gapic
    • ads-templates/%namespace/%name/%version/%sub/services/%service/transports
    • templates/%namespace/%name_%version/%sub/services/%service/transports

packages/gapic-generator/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/transports/rest.py.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ class {{service.name}}RestTransport({{service.name}}Transport):
330330
body = {% if body_spec == '*' -%}
331331
{{method.input.ident}}.to_json(
332332
{{method.input.ident}}(transcoded_request['body']),
333-
{%- else -%}
333+
{% else -%}
334334
{{method.input.fields[body_spec].type.ident}}.to_json(
335335
{{method.input.fields[body_spec].type.ident}}(transcoded_request['body']),
336-
{%- endif %}{# body_spec == "*" #}
336+
{% endif %}{# body_spec == "*" #}
337337
including_default_value_fields=False,
338-
use_integers_for_enums=False
338+
use_integers_for_enums={{ opts.rest_numeric_enums }}
339339
)
340340
{%- endif %}{# body_spec #}
341341

@@ -346,7 +346,7 @@ class {{service.name}}RestTransport({{service.name}}Transport):
346346
query_params = json.loads({{method.input.ident}}.to_json(
347347
{{method.input.ident}}(transcoded_request['query_params']),
348348
including_default_value_fields=False,
349-
use_integers_for_enums=False
349+
use_integers_for_enums={{ opts.rest_numeric_enums }}
350350
))
351351

352352
{% if method.input.required_fields %}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,12 @@ class {{service.name}}RestTransport({{service.name}}Transport):
338338
body = {% if body_spec == '*' -%}
339339
{{method.input.ident}}.to_json(
340340
{{method.input.ident}}(transcoded_request['body']),
341-
{%- else -%}
341+
{% else -%}
342342
{{method.input.fields[body_spec].type.ident}}.to_json(
343343
{{method.input.fields[body_spec].type.ident}}(transcoded_request['body']),
344-
{%- endif %}{# body_spec == "*" #}
344+
{% endif %}{# body_spec == "*" #}
345345
including_default_value_fields=False,
346-
use_integers_for_enums=False
346+
use_integers_for_enums={{ opts.rest_numeric_enums }}
347347
)
348348
{%- endif %}{# body_spec #}
349349

@@ -354,7 +354,7 @@ class {{service.name}}RestTransport({{service.name}}Transport):
354354
query_params = json.loads({{method.input.ident}}.to_json(
355355
{{method.input.ident}}(transcoded_request['query_params']),
356356
including_default_value_fields=False,
357-
use_integers_for_enums=False
357+
use_integers_for_enums={{ opts.rest_numeric_enums }}
358358
))
359359

360360
{% if method.input.required_fields %}

0 commit comments

Comments
 (0)