-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add api version in ClientOptions and policy inside generated client #2561
Add api version in ClientOptions and policy inside generated client #2561
Conversation
...st/test/NetworkAnalytics.Management/generated/typespec-ts/src/rest/networkAnalyticsClient.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, left a comment on how to avoid that createClient causes side effects, should be easy to address. Please consider taking the suggestion
packages/typespec-test/test/authoring/generated/typespec-ts/src/authoringClient.ts
Outdated
Show resolved
Hide resolved
...torest.typescript/test/rlcIntegration/generated/bodyComplexRest/src/bodyComplexRestClient.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just two minor remarks. 👍
fixes Azure/azure-sdk-for-js#29883 and #2396 (comment) in favor of Azure/azure-sdk-for-js#29904
if there's no client level api version, we will:
which means we will not generate a property of apiVersion in the ServiceClientOptions interface.
which means, we will generate code
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
after createClient from core-client-rest.if there's no client level api version, we will add a warning
logger.warning("This client does not support client api-version, please change it at the operation level");
if there's client level api version, but it's required, and it doesn't have a default value, apiVersion will be a positional argument for client factory function. we will ignore api version passed in options, and add a warning
logger.warning("This client does not support to set api-version in options, please change it at positional argument");
ApiVersionPolicy
will also be removed in this caseif there's no client level api version, we don't need to add this policy here, but if there's client level api version in the query position, according to [Deprecate]: deprecate apiVersion in ClientOptions from core-client-rest azure-sdk-for-js#29883 (comment) we will generate a new
ClientApiVersionPolicy
in the client side, so that we can remove theApiVersionPolicy
from core-client-rest in the future.Generate ApiVersion in Options: true
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: false
{ apiVersion = "default", …options }
Generate ApiVersion in Options: true
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: false
{ apiVersion = "default", …options }
Generate ApiVersion in Options: false
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: false
Options
logWarning: true
Generate apiVersion in options: true
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: false
{ apiVersion, …options }
Generate ApiVersion in Options: true
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: true
{ apiVersion = "default", …options }
Generate ApiVersion in Options: true
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: true
{ apiVersion = "default", …options }
Generate ApiVersion in Options: false
Remove ApiVersionPolicy: true
Add clientApiVersionPolicy: true
Options
logWarning: true
Generate apiVersion in options: true
Remove apiVersionPolicy: true
Add clientApiVersionPolicy: true
{ apiVersion, …options }