Skip to content

Commit eec5d5e

Browse files
authored
feat: Add BUILD rule parameter to allow setting numeric enums (#1411)
This allows generator users to set the numeric-enum-response parameter at generation time via the BUILD rule. The default is `False` for backward compatibility.
1 parent 8011c96 commit eec5d5e

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/gapic-generator/docs/getting-started/bazel.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ your ``BUILD.bazel`` file. You can use the Python section of the Document AI
9494
":documentai_py_gapic",
9595
],
9696
)
97+
98+
Some of the ``py_gapic_library`` rule that may be of interest:
99+
* ``transport``: the desired transport(s) to generate, delimited by ``+`` e.g. ``grpc+rest``.
100+
- Acceptable values are ``grpc`` and ``rest``.
101+
- Defaults to ``grpc``.
102+
103+
* ``rest_numeric_enums``: if ``True``, enables generation of system parameter requesting response enums be encoded as numbers.
104+
- Default is ``False``.
105+
- Only effective when ``rest`` is included as a ``transport`` to be generated.
106+
97107
.. _BUILD.bazel: https://github.com/googleapis/googleapis/blob/master/google/cloud/documentai/v1beta2/BUILD.bazel
98108

99109
Compiling an API

packages/gapic-generator/rules_python_gapic/py_gapic.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def py_gapic_library(
4343
metadata = True,
4444
service_yaml = None,
4545
transport = None,
46+
rest_numeric_enums = False,
4647
deps = [],
4748
**kwargs):
4849
srcjar_target_name = "%s_srcjar" % name
@@ -63,6 +64,9 @@ def py_gapic_library(
6364
if transport:
6465
opt_args = opt_args + ["transport=%s" % transport]
6566

67+
if rest_numeric_enums:
68+
opt_args = opt_args + ["rest-numeric-enums"]
69+
6670
proto_custom_library(
6771
name = srcjar_target_name,
6872
deps = srcs,

0 commit comments

Comments
 (0)