Skip to content

Commit e631d18

Browse files
tsp, bump dependency (#2816)
1 parent d7b5ef3 commit e631d18

File tree

93 files changed

+807
-815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+807
-815
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@autorest/java",
3-
"version": "4.1.29",
3+
"version": "4.1.30",
44
"description": "The Java extension for classic generators in AutoRest.",
55
"scripts": {
66
"autorest": "autorest",

typespec-extension/changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Release History
22

3-
## 0.16.4 (Unreleased)
3+
## 0.17.0 (2024-06-14)
44

5-
Compatible with compiler 0.56.
5+
Compatible with compiler 0.57.
66

77
## 0.16.3 (2024-06-03)
88

typespec-extension/package-lock.json

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

typespec-extension/package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-tools/typespec-java",
3-
"version": "0.16.4",
3+
"version": "0.17.0",
44
"description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding",
55
"keywords": [
66
"TypeSpec"
@@ -45,38 +45,38 @@
4545
"target/emitter.jar"
4646
],
4747
"peerDependencies": {
48-
"@azure-tools/typespec-azure-core": ">=0.42.0 <1.0.0",
49-
"@azure-tools/typespec-azure-resource-manager": ">=0.42.1 <1.0.0",
50-
"@azure-tools/typespec-azure-rulesets": ">=0.42.1 <1.0.0",
51-
"@azure-tools/typespec-client-generator-core": ">=0.42.2 <1.0.0",
52-
"@typespec/compiler": ">=0.56.0 <1.0.0",
53-
"@typespec/http": ">=0.56.0 <1.0.0",
54-
"@typespec/openapi": ">=0.56.0 <1.0.0",
55-
"@typespec/rest": ">=0.56.0 <1.0.0",
56-
"@typespec/versioning": ">=0.56.0 <1.0.0"
48+
"@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0",
49+
"@azure-tools/typespec-azure-resource-manager": ">=0.43.0 <1.0.0",
50+
"@azure-tools/typespec-azure-rulesets": ">=0.43.0 <1.0.0",
51+
"@azure-tools/typespec-client-generator-core": ">=0.43.0 <1.0.0",
52+
"@typespec/compiler": ">=0.57.0 <1.0.0",
53+
"@typespec/http": ">=0.57.0 <1.0.0",
54+
"@typespec/openapi": ">=0.57.0 <1.0.0",
55+
"@typespec/rest": ">=0.57.0 <1.0.0",
56+
"@typespec/versioning": ">=0.57.0 <1.0.0"
5757
},
5858
"dependencies": {
5959
"@autorest/codemodel": "~4.20.0",
6060
"js-yaml": "~4.1.0",
6161
"lodash": "~4.17.21"
6262
},
6363
"devDependencies": {
64-
"@azure-tools/typespec-autorest": "0.42.1",
65-
"@azure-tools/typespec-azure-core": "0.42.0",
66-
"@azure-tools/typespec-azure-resource-manager": "0.42.1",
67-
"@azure-tools/typespec-azure-rulesets": "0.42.1",
68-
"@azure-tools/typespec-client-generator-core": "0.42.3",
64+
"@azure-tools/typespec-autorest": "0.43.0",
65+
"@azure-tools/typespec-azure-core": "0.43.0",
66+
"@azure-tools/typespec-azure-resource-manager": "0.43.0",
67+
"@azure-tools/typespec-azure-rulesets": "0.43.0",
68+
"@azure-tools/typespec-client-generator-core": "0.43.0",
6969
"@types/js-yaml": "~4.0.9",
7070
"@types/lodash": "~4.17.1",
7171
"@types/mocha": "~10.0.6",
7272
"@types/node": "~20.12.10",
7373
"@typescript-eslint/eslint-plugin": "~7.8.0",
7474
"@typescript-eslint/parser": "~7.8.0",
75-
"@typespec/compiler": "0.56.0",
76-
"@typespec/http": "0.56.0",
77-
"@typespec/openapi": "0.56.0",
78-
"@typespec/rest": "0.56.0",
79-
"@typespec/versioning": "0.56.0",
75+
"@typespec/compiler": "0.57.0",
76+
"@typespec/http": "0.57.0",
77+
"@typespec/openapi": "0.57.0",
78+
"@typespec/rest": "0.57.0",
79+
"@typespec/versioning": "0.57.0",
8080
"c8": "~9.1.0",
8181
"eslint": "~8.57.0",
8282
"eslint-plugin-deprecation": "~2.0.0",

typespec-extension/src/code-model-builder.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import {
104104
Authentication,
105105
HttpOperation,
106106
HttpOperationBody,
107+
HttpOperationMultipartBody,
107108
HttpOperationParameter,
108109
HttpOperationResponse,
109110
HttpServer,
@@ -152,6 +153,7 @@ import {
152153
ProcessingCache,
153154
getAccess,
154155
getDurationFormatFromSdkType,
156+
getNonNullSdkType,
155157
getUnionDescription,
156158
getUsage,
157159
hasScalarAsBase,
@@ -719,7 +721,7 @@ export class CodeModelBuilder {
719721
},
720722
});
721723

722-
codeModelOperation.crossLanguageDefinitionId = getCrossLanguageDefinitionId(operation);
724+
codeModelOperation.crossLanguageDefinitionId = getCrossLanguageDefinitionId(this.sdkContext, operation);
723725
codeModelOperation.internalApi = this.isInternal(this.sdkContext, operation);
724726

725727
const convenienceApiName = this.getConvenienceApiName(operation);
@@ -789,9 +791,9 @@ export class CodeModelBuilder {
789791
this.addAcceptHeaderParameter(codeModelOperation, op.responses);
790792
// body
791793
if (op.parameters.body) {
792-
if (op.parameters.body.parameter) {
793-
if (!isVoidType(op.parameters.body.parameter.type)) {
794-
this.processParameterBody(codeModelOperation, op, op.parameters.body.parameter);
794+
if (op.parameters.body.property) {
795+
if (!isVoidType(op.parameters.body.property.type)) {
796+
this.processParameterBody(codeModelOperation, op, op.parameters.body.property);
795797
}
796798
} else if (op.parameters.body.type) {
797799
let bodyType = this.getEffectiveSchemaType(op.parameters.body.type);
@@ -1018,7 +1020,7 @@ export class CodeModelBuilder {
10181020
} else {
10191021
// schema
10201022
let schema;
1021-
const sdkType = getClientType(this.sdkContext, param.param);
1023+
const sdkType = getNonNullSdkType(getClientType(this.sdkContext, param.param));
10221024
if (
10231025
param.type === "header" &&
10241026
param.param.type.kind === "Scalar" &&
@@ -1532,7 +1534,7 @@ export class CodeModelBuilder {
15321534
}
15331535
}
15341536

1535-
let responseBody: HttpOperationBody | undefined = undefined;
1537+
let responseBody: HttpOperationBody | HttpOperationMultipartBody | undefined = undefined;
15361538
let bodyType: Type | undefined = undefined;
15371539
let trackConvenienceApi: boolean = Boolean(op.convenienceApi);
15381540
if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) {
@@ -1802,10 +1804,18 @@ export class CodeModelBuilder {
18021804
}
18031805

18041806
private processArraySchemaFromSdkType(type: SdkArrayType, name: string): ArraySchema {
1805-
const elementSchema = this.processSchemaFromSdkType(type.valueType, name);
1807+
let nullableItems = false;
1808+
let elementType = type.valueType;
1809+
if (elementType.kind === "nullable") {
1810+
nullableItems = true;
1811+
elementType = elementType.type;
1812+
}
1813+
1814+
const elementSchema = this.processSchemaFromSdkType(elementType, name);
18061815
return this.codeModel.schemas.add(
18071816
new ArraySchema(name, type.details ?? "", elementSchema, {
18081817
summary: type.description,
1818+
nullableItems: nullableItems,
18091819
}),
18101820
);
18111821
}
@@ -1820,10 +1830,16 @@ export class CodeModelBuilder {
18201830
this.schemaCache.set(type, dictSchema);
18211831
}
18221832

1823-
const elementSchema = this.processSchemaFromSdkType(type.valueType, name);
1833+
let nullableItems = false;
1834+
let elementType = type.valueType;
1835+
if (elementType.kind === "nullable") {
1836+
nullableItems = true;
1837+
elementType = elementType.type;
1838+
}
1839+
const elementSchema = this.processSchemaFromSdkType(elementType, name);
18241840
dictSchema.elementType = elementSchema;
18251841

1826-
dictSchema.nullableItems = type.nullableValues;
1842+
dictSchema.nullableItems = nullableItems;
18271843

18281844
return this.codeModel.schemas.add(dictSchema);
18291845
}
@@ -2001,11 +2017,8 @@ export class CodeModelBuilder {
20012017
keyType: {
20022018
kind: "string",
20032019
encode: "string",
2004-
nullable: false,
20052020
},
20062021
description: type.description,
2007-
nullableValues: false,
2008-
nullable: false,
20092022
valueType: type.additionalProperties,
20102023
};
20112024
const parentSchema = this.processSchemaFromSdkType(sdkDictType, "Record");
@@ -2044,8 +2057,13 @@ export class CodeModelBuilder {
20442057
}
20452058

20462059
private processModelPropertyFromSdkType(prop: SdkModelPropertyType): Property {
2047-
let schema = this.processSchemaFromSdkType(prop.type, "");
2048-
let nullable = prop.nullable;
2060+
let nullable = false;
2061+
let nonNullType = prop.type;
2062+
if (nonNullType.kind === "nullable") {
2063+
nullable = true;
2064+
nonNullType = nonNullType.type;
2065+
}
2066+
let schema = this.processSchemaFromSdkType(nonNullType, "");
20492067

20502068
let extensions: Record<string, any> | undefined = undefined;
20512069
if (this.isSecret(prop)) {

typespec-extension/src/operation-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ export function operationRefersUnion(
221221
}
222222
// request body
223223
if (op.parameters.body) {
224-
if (op.parameters.body.parameter) {
225-
const ret = unionReferredByType(program, op.parameters.body.parameter.type, cache);
224+
if (op.parameters.body.property) {
225+
const ret = unionReferredByType(program, op.parameters.body.property.type, cache);
226226
if (ret) {
227227
return ret;
228228
}

typespec-extension/src/type-utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { SchemaContext } from "@autorest/codemodel";
2222
import { DurationSchema } from "./common/schemas/time.js";
2323
import { getNamespace } from "./utils.js";
2424
import { getUnionAsEnum } from "@azure-tools/typespec-azure-core";
25-
import { SdkDurationType, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core";
25+
import { SdkDurationType, SdkType, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core";
2626
import { Version } from "@typespec/versioning";
2727

2828
/** Acts as a cache for processing inputs.
@@ -91,6 +91,10 @@ export function isNullableType(type: Type): boolean {
9191
}
9292
}
9393

94+
export function getNonNullSdkType(type: SdkType): SdkType {
95+
return type.kind === "nullable" ? type.type : type;
96+
}
97+
9498
export function getDurationFormat(encode: EncodeData): DurationSchema["format"] {
9599
let format: DurationSchema["format"] = "duration-rfc3339";
96100
// duration encoded as seconds

typespec-tests/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010
},
1111
"dependencies": {
1212
"@azure-tools/cadl-ranch-specs": "0.33.4",
13-
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.16.4.tgz"
13+
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.17.0.tgz"
1414
},
1515
"devDependencies": {
16-
"@typespec/prettier-plugin-typespec": "~0.56.0",
16+
"@typespec/prettier-plugin-typespec": "~0.57.0",
1717
"prettier-plugin-organize-imports": "3.2.4",
1818
"prettier": "~3.2.5"
1919
},
2020
"overrides": {
21-
"@typespec/compiler": ">=0.56.0 <1.0.0",
22-
"@typespec/http": ">=0.56.0 <1.0.0",
23-
"@typespec/rest": ">=0.56.0 <1.0.0",
24-
"@typespec/versioning": ">=0.56.0 <1.0.0",
25-
"@typespec/openapi": ">=0.56.0 <1.0.0",
26-
"@azure-tools/typespec-azure-core": ">=0.42.0 <1.0.0",
27-
"@azure-tools/typespec-client-generator-core": ">=0.42.2 <1.0.0",
28-
"@azure-tools/typespec-azure-resource-manager": ">=0.42.0 <1.0.0",
29-
"@azure-tools/typespec-autorest": ">=0.42.0 <1.0.0"
21+
"@typespec/compiler": ">=0.57.0 <1.0.0",
22+
"@typespec/http": ">=0.57.0 <1.0.0",
23+
"@typespec/rest": ">=0.57.0 <1.0.0",
24+
"@typespec/versioning": ">=0.57.0 <1.0.0",
25+
"@typespec/openapi": ">=0.57.0 <1.0.0",
26+
"@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0",
27+
"@azure-tools/typespec-client-generator-core": ">=0.43.0 <1.0.0",
28+
"@azure-tools/typespec-azure-resource-manager": ">=0.43.0 <1.0.0",
29+
"@azure-tools/typespec-autorest": ">=0.43.0 <1.0.0"
3030
},
3131
"private": true
3232
}

typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/AbstractModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@Immutable
1919
public class AbstractModel implements JsonSerializable<AbstractModel> {
2020
/*
21-
* The kind property.
21+
* Discriminator property for AbstractModel.
2222
*/
2323
@Generated
2424
private String kind = "AbstractModel";
@@ -40,7 +40,7 @@ protected AbstractModel(String name) {
4040
}
4141

4242
/**
43-
* Get the kind property: The kind property.
43+
* Get the kind property: Discriminator property for AbstractModel.
4444
*
4545
* @return the kind value.
4646
*/

typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/RealModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@Immutable
1818
public final class RealModel extends AbstractModel {
1919
/*
20-
* The kind property.
20+
* Discriminator property for AbstractModel.
2121
*/
2222
@Generated
2323
private String kind = "real";
@@ -33,7 +33,7 @@ private RealModel(String name) {
3333
}
3434

3535
/**
36-
* Get the kind property: The kind property.
36+
* Get the kind property: Discriminator property for AbstractModel.
3737
*
3838
* @return the kind value.
3939
*/

typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface ArmResourceProviderClient {
2626
String getApiVersion();
2727

2828
/**
29-
* Gets The ID of the target subscription.
29+
* Gets The ID of the target subscription. The value must be an UUID.
3030
*
3131
* @return the subscriptionId value.
3232
*/

typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ public ArmResourceProviderClientBuilder endpoint(String endpoint) {
3636
}
3737

3838
/*
39-
* The ID of the target subscription.
39+
* The ID of the target subscription. The value must be an UUID.
4040
*/
4141
private String subscriptionId;
4242

4343
/**
44-
* Sets The ID of the target subscription.
44+
* Sets The ID of the target subscription. The value must be an UUID.
4545
*
4646
* @param subscriptionId the subscriptionId value.
4747
* @return the ArmResourceProviderClientBuilder.

typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public String getApiVersion() {
7171
}
7272

7373
/**
74-
* The ID of the target subscription.
74+
* The ID of the target subscription. The value must be an UUID.
7575
*/
7676
private final String subscriptionId;
7777

7878
/**
79-
* Gets The ID of the target subscription.
79+
* Gets The ID of the target subscription. The value must be an UUID.
8080
*
8181
* @return the subscriptionId value.
8282
*/
@@ -190,7 +190,7 @@ public OperationsClient getOperations() {
190190
* @param defaultPollInterval The default poll interval for long-running operation.
191191
* @param environment The Azure environment.
192192
* @param endpoint Server parameter.
193-
* @param subscriptionId The ID of the target subscription.
193+
* @param subscriptionId The ID of the target subscription. The value must be an UUID.
194194
*/
195195
ArmResourceProviderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter,
196196
Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) {

typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.azure.core.util.FluxUtil;
2828
import com.cadl.armresourceprovider.fluent.OperationsClient;
2929
import com.cadl.armresourceprovider.fluent.models.OperationInner;
30-
import com.cadl.armresourceprovider.implementation.models.PagedOperation;
30+
import com.cadl.armresourceprovider.implementation.models.OperationListResult;
3131
import reactor.core.publisher.Mono;
3232

3333
/**
@@ -66,14 +66,14 @@ public interface OperationsService {
6666
@Get("/providers/Cadl.ArmResourceProvider/operations")
6767
@ExpectedResponses({ 200 })
6868
@UnexpectedResponseExceptionType(ManagementException.class)
69-
Mono<Response<PagedOperation>> list(@HostParam("endpoint") String endpoint,
69+
Mono<Response<OperationListResult>> list(@HostParam("endpoint") String endpoint,
7070
@QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, Context context);
7171

7272
@Headers({ "Content-Type: application/json" })
7373
@Get("{nextLink}")
7474
@ExpectedResponses({ 200 })
7575
@UnexpectedResponseExceptionType(ManagementException.class)
76-
Mono<Response<PagedOperation>> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink,
76+
Mono<Response<OperationListResult>> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink,
7777
@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, Context context);
7878
}
7979

0 commit comments

Comments
 (0)