Skip to content

Commit

Permalink
upgrade to typespec 0.63 and typespec azure 0.49 (#1481)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadelesh authored Dec 18, 2024
1 parent 09c7c34 commit 147df49
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 205 deletions.
293 changes: 147 additions & 146 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions packages/typespec-go/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@
"homepage": "https://github.com/Azure/autorest.go#readme",
"readme": "https://github.com/Azure/autorest.go/blob/main/readme.md",
"devDependencies": {
"@azure-tools/cadl-ranch": "~0.16.1",
"@azure-tools/cadl-ranch-expect": "~0.15.6",
"@azure-tools/cadl-ranch-specs": "0.39.1",
"@azure-tools/typespec-autorest": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.6 <1.0.0",
"@azure-tools/cadl-ranch": "~0.16.2",
"@azure-tools/cadl-ranch-expect": "~0.15.7",
"@azure-tools/cadl-ranch-specs": "0.39.6",
"@azure-tools/typespec-autorest": ">=0.49.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.49.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.49.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.49.0 <1.0.0",
"@types/js-yaml": "~4.0.6",
"@types/node": "^18.16.3",
"@typescript-eslint/eslint-plugin": "~4.1.1",
"@typescript-eslint/parser": "~4.1.1",
"@typespec/compiler": ">=0.62.0 <1.0.0",
"@typespec/http": ">=0.62.0 <1.0.0",
"@typespec/openapi": ">=0.62.0 <1.0.0",
"@typespec/rest": ">=0.62.0 <1.0.0",
"@typespec/versioning": ">=0.62.0 <1.0.0",
"@typespec/xml": ">=0.62.0 <1.0.0",
"@typespec/compiler": ">=0.63.0 <1.0.0",
"@typespec/http": ">=0.63.0 <1.0.0",
"@typespec/openapi": ">=0.63.0 <1.0.0",
"@typespec/rest": ">=0.63.0 <1.0.0",
"@typespec/versioning": ">=0.63.0 <1.0.0",
"@typespec/xml": ">=0.63.0 <1.0.0",
"@types/jest": "~26.0.24",
"eslint": "~6.6.0",
"jest": "~27.0.6",
"ts-jest": "~27.0.4",
"typescript": "~5.1.3"
},
"peerDependencies": {
"@azure-tools/typespec-client-generator-core": ">=0.48.6 <1.0.0",
"@typespec/compiler": ">=0.62.0 <1.0.0",
"@typespec/http": ">=0.62.0 <1.0.0"
"@azure-tools/typespec-client-generator-core": ">=0.49.0 <1.0.0",
"@typespec/compiler": ">=0.63.0 <1.0.0",
"@typespec/http": ">=0.63.0 <1.0.0"
},
"dependencies": {
"@azure-tools/codegen": "~2.9.2",
Expand Down
11 changes: 7 additions & 4 deletions packages/typespec-go/src/tcgcadapter/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class clientAdapter {
}

// stuff all of the operation parameters into one array for easy traversal
type OperationParamType = tcgc.SdkBodyParameter | tcgc.SdkHeaderParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter;
type OperationParamType = tcgc.SdkBodyParameter | tcgc.SdkHeaderParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter | tcgc.SdkCookieParameter;
const allOpParams = new Array<OperationParamType>();
allOpParams.push(...sdkMethod.operation.parameters);
if (sdkMethod.operation.bodyParam) {
Expand Down Expand Up @@ -434,7 +434,7 @@ export class clientAdapter {
return contentType;
}

private adaptMethodParameter(param: tcgc.SdkBodyParameter | tcgc.SdkHeaderParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter, optionalGroup?: go.ParameterGroup): go.Parameter {
private adaptMethodParameter(param: tcgc.SdkBodyParameter | tcgc.SdkHeaderParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter | tcgc.SdkCookieParameter, optionalGroup?: go.ParameterGroup): go.Parameter {
if (param.isApiVersionParam && param.clientDefaultValue) {
// we emit the api version param inline as a literal, never as a param.
// the ClientOptions.APIVersion setting is used to change the version.
Expand All @@ -452,7 +452,7 @@ export class clientAdapter {
}

let location: go.ParameterLocation = 'method';
const getClientParamsKey = function (param: tcgc.SdkBodyParameter | tcgc.SdkHeaderParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter): string {
const getClientParamsKey = function (param: tcgc.SdkBodyParameter | tcgc.SdkHeaderParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter | tcgc.SdkCookieParameter): string {
// include the param kind in the key name as a client param can be used
// in different places across methods (path/query)
return `${param.name}-${param.kind}`;
Expand Down Expand Up @@ -500,6 +500,9 @@ export class clientAdapter {
}
} else if (param.kind === 'path') {
adaptedParam = new go.PathParameter(paramName, param.serializedName, !param.allowReserved, this.adaptPathParameterType(param.type), paramKind, byVal, location);
} else if (param.kind === 'cookie') {
// TODO: currently we don't have Azure service using cookie parameter. need to add support if needed in the future.
throw new Error('could not support cookie parameter');
} else {
if (param.collectionFormat) {
const type = this.ta.getPossibleType(param.type, true, false);
Expand Down Expand Up @@ -693,7 +696,7 @@ export class clientAdapter {
return type;
}

private adaptParameterKind(param: tcgc.SdkBodyParameter | tcgc.SdkEndpointParameter | tcgc.SdkHeaderParameter | tcgc.SdkMethodParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter): go.ParameterKind {
private adaptParameterKind(param: tcgc.SdkBodyParameter | tcgc.SdkEndpointParameter | tcgc.SdkHeaderParameter | tcgc.SdkMethodParameter | tcgc.SdkPathParameter | tcgc.SdkQueryParameter | tcgc.SdkCookieParameter): go.ParameterKind {
// NOTE: must check for constant type first as it will also set clientDefaultValue
if (param.type.kind === 'constant') {
if (param.optional) {
Expand Down
8 changes: 4 additions & 4 deletions packages/typespec-go/test/armapicenter/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/typespec-go/test/armcodesigning/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/typespec-go/test/armcommunitymanagement/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/typespec-go/test/armdatabasewatcher/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions packages/typespec-go/test/armlargeinstance/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/typespec-go/test/armlargeinstance/zz_models_serde.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/typespec-go/test/armloadtestservice/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/typespec-go/test/armmongocluster/zz_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/typespec-go/test/tsp/KeyVault.Keys/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ model KeyListResult {
/**
* The URL to get the next set of keys.
*/
@Azure.Core.nextLink
@nextLink
@visibility("read")
nextLink?: string;
}
Expand Down Expand Up @@ -1007,7 +1007,7 @@ model DeletedKeyListResult {
/**
* The URL to get the next set of deleted keys.
*/
@Azure.Core.nextLink
@nextLink
@visibility("read")
nextLink?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-go/test/tsp/Random.Management/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ model ThingsListResult {
value: FakeData[];

@doc("The link to the next page of items")
@Azure.Core.nextLink
@nextLink
nextLink?: string;

@doc("More fake things")
Expand Down

0 comments on commit 147df49

Please sign in to comment.