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

feat: option to request REST numeric enum values #1251

Merged
merged 3 commits into from
Sep 8, 2022

Conversation

alexander-fenster
Copy link
Contributor

Passing an option to turn on numeric enums for REST transport down the stack.

Copy link

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one question, which may be due to my not being familiar with the TS generator.

@@ -157,6 +157,11 @@ export class {{ service.name }}Client {
const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function');
opts = Object.assign({servicePath, port, clientConfig, fallback}, opts);
{%- endif %}
{%- if api.restNumericEnums %}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this inside something like if rest so it only gets applied when we generate REST transport?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed - we generate almost the same code for REST and gRPC client (the only difference being the default transport), so we want to pass this option down to gax even if the client is generated as a gRPC one, because the customer might choose to use it as a REST client by passing {fallback: 'rest'} to the constructor.

Copy link

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I don't claim expertise on the TS generator.

@alexander-fenster alexander-fenster merged commit 38427db into main Sep 8, 2022
@alexander-fenster alexander-fenster deleted the numeric-enums branch September 8, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants