Skip to content

Commit 02dcd00

Browse files
Copilotv-jiaodi
andcommitted
Upgrade TCGC to latest dev version 0.61.0-dev.7 and fix breaking API changes
Co-authored-by: v-jiaodi <[email protected]>
1 parent 1408f0a commit 02dcd00

File tree

11 files changed

+36
-47
lines changed

11 files changed

+36
-47
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/typespec-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@azure-tools/typespec-autorest": "^0.60.0",
99
"@typespec/openapi3": "^1.4.0",
1010
"@azure-tools/typespec-azure-core": "^0.60.0",
11-
"@azure-tools/typespec-client-generator-core": "0.61.0-dev.5",
11+
"@azure-tools/typespec-client-generator-core": "0.61.0-dev.7",
1212
"@azure-tools/typespec-azure-resource-manager": "^0.60.0",
1313
"@azure-tools/typespec-azure-rulesets": "^0.60.0",
1414
"@typespec/compiler": "^1.4.0",

packages/typespec-test/test/parametrizedHost/generated/typespec-ts/review/parametrized-host.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export interface ConfidentialLedgerListCollectionsOptionalParams extends Operati
2121

2222
// @public
2323
export interface ConfidentialLedgerOperations {
24-
listCollections: (options?: ConfidentialLedgerListCollectionsOptionalParams) => Promise<Collection[]>;
24+
listCollections: (apiVersion: string, options?: ConfidentialLedgerListCollectionsOptionalParams) => Promise<Collection[]>;
2525
}
2626

2727
// @public (undocumented)
2828
export class ParametrizedHostClient {
29-
constructor(credential: TokenCredential, apiVersion: string, options?: ParametrizedHostClientOptionalParams);
29+
constructor(credential: TokenCredential, options?: ParametrizedHostClientOptionalParams);
3030
readonly confidentialLedger: ConfidentialLedgerOperations;
3131
readonly pipeline: Pipeline;
3232
}

packages/typespec-test/test/parametrizedHost/generated/typespec-ts/src/api/confidentialLedger/operations.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import {
1717

1818
export function _listCollectionsSend(
1919
context: Client,
20+
apiVersion: string,
2021
options: ConfidentialLedgerListCollectionsOptionalParams = {
2122
requestOptions: {},
2223
},
2324
): StreamableMethod {
2425
const path = expandUrlTemplate(
2526
"/app/collections{?api%2Dversion}",
2627
{
27-
"api%2Dversion": context.apiVersion,
28+
"api%2Dversion": apiVersion,
2829
},
2930
{
3031
allowReserved: options?.requestOptions?.skipUrlEncoding,
@@ -55,10 +56,11 @@ export async function _listCollectionsDeserialize(
5556
/** Collection ids are user-created collections of ledger entries */
5657
export async function listCollections(
5758
context: Client,
59+
apiVersion: string,
5860
options: ConfidentialLedgerListCollectionsOptionalParams = {
5961
requestOptions: {},
6062
},
6163
): Promise<Collection[]> {
62-
const result = await _listCollectionsSend(context, options);
64+
const result = await _listCollectionsSend(context, apiVersion, options);
6365
return _listCollectionsDeserialize(result);
6466
}

packages/typespec-test/test/parametrizedHost/generated/typespec-ts/src/api/parametrizedHostContext.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { logger } from "../logger.js";
55
import { Client, ClientOptions, getClient } from "@azure-rest/core-client";
66
import { TokenCredential } from "@azure/core-auth";
77

8-
export interface ParametrizedHostContext extends Client {
9-
/** The API version to use for this operation. */
10-
apiVersion: string;
11-
}
8+
export interface ParametrizedHostContext extends Client {}
129

1310
/** Optional parameters for the client. */
1411
export interface ParametrizedHostClientOptionalParams extends ClientOptions {
@@ -19,7 +16,6 @@ export interface ParametrizedHostClientOptionalParams extends ClientOptions {
1916

2017
export function createParametrizedHost(
2118
credential: TokenCredential,
22-
apiVersion: string,
2319
options: ParametrizedHostClientOptionalParams = {},
2420
): ParametrizedHostContext {
2521
const host = options.host ?? "one";
@@ -43,20 +39,10 @@ export function createParametrizedHost(
4339
};
4440
const clientContext = getClient(endpointUrl, credential, updatedOptions);
4541
clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });
46-
clientContext.pipeline.addPolicy({
47-
name: "ClientApiVersionPolicy",
48-
sendRequest: (req, next) => {
49-
// Use the apiVersion defined in request url directly
50-
// Append one if there is no apiVersion and we have one at client options
51-
const url = new URL(req.url);
52-
if (!url.searchParams.get("api-version")) {
53-
req.url = `${req.url}${
54-
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
55-
}api-version=${apiVersion}`;
56-
}
57-
58-
return next(req);
59-
},
60-
});
61-
return { ...clientContext, apiVersion } as ParametrizedHostContext;
42+
if (options.apiVersion) {
43+
logger.warning(
44+
"This client does not support client api-version, please change it at the operation level",
45+
);
46+
}
47+
return clientContext;
6248
}

packages/typespec-test/test/parametrizedHost/generated/typespec-ts/src/classic/confidentialLedger/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ import { Collection } from "../../models/models.js";
1010
export interface ConfidentialLedgerOperations {
1111
/** Collection ids are user-created collections of ledger entries */
1212
listCollections: (
13+
apiVersion: string,
1314
options?: ConfidentialLedgerListCollectionsOptionalParams,
1415
) => Promise<Collection[]>;
1516
}
1617

1718
function _getConfidentialLedger(context: ParametrizedHostContext) {
1819
return {
1920
listCollections: (
21+
apiVersion: string,
2022
options?: ConfidentialLedgerListCollectionsOptionalParams,
21-
) => listCollections(context, options),
23+
) => listCollections(context, apiVersion, options),
2224
};
2325
}
2426

packages/typespec-test/test/parametrizedHost/generated/typespec-ts/src/parametrizedHostClient.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ export class ParametrizedHostClient {
2222

2323
constructor(
2424
credential: TokenCredential,
25-
apiVersion: string,
2625
options: ParametrizedHostClientOptionalParams = {},
2726
) {
2827
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
2928
const userAgentPrefix = prefixFromOptions
3029
? `${prefixFromOptions} azsdk-js-client`
3130
: `azsdk-js-client`;
32-
this._client = createParametrizedHost(credential, apiVersion, {
31+
this._client = createParametrizedHost(credential, {
3332
...options,
3433
userAgentOptions: { userAgentPrefix },
3534
});

packages/typespec-ts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@azure-tools/typespec-autorest": "^0.60.0",
7474
"@azure-tools/typespec-azure-core": "^0.60.0",
7575
"@azure-tools/typespec-azure-resource-manager": "^0.60.0",
76-
"@azure-tools/typespec-client-generator-core": "0.61.0-dev.5",
76+
"@azure-tools/typespec-client-generator-core": "0.61.0-dev.7",
7777
"@azure/abort-controller": "^2.1.2",
7878
"@azure/core-auth": "^1.6.0",
7979
"@azure/core-lro": "^3.1.0",
@@ -116,7 +116,7 @@
116116
},
117117
"peerDependencies": {
118118
"@azure-tools/typespec-azure-core": "^0.60.0",
119-
"@azure-tools/typespec-client-generator-core": "0.61.0-dev.5",
119+
"@azure-tools/typespec-client-generator-core": "0.61.0-dev.7",
120120
"@typespec/compiler": "^1.4.0",
121121
"@typespec/http": "^1.4.0",
122122
"@typespec/rest": "^0.74.0",

packages/typespec-ts/src/transform/transformApiVersionInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function getOperationApiVersion(
7575
}
7676
const params = route.parameters.parameters.filter(
7777
(p) =>
78-
(p.type === "query" || p.type === "path") && isApiVersion(dpgContext, p)
78+
(p.type === "query" || p.type === "path") && isApiVersion(dpgContext, p.param)
7979
);
8080
params.map((p) => {
8181
const type = getSchemaForType(dpgContext, p.param.type, {

packages/typespec-ts/src/transform/transformParameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function transformQueryParameters(
225225
(p) =>
226226
p.type === "query" &&
227227
!(
228-
isApiVersion(dpgContext, p) &&
228+
isApiVersion(dpgContext, p.param) &&
229229
options.apiVersionInfo?.definedPosition === "query"
230230
)
231231
);

0 commit comments

Comments
 (0)