Skip to content

Commit

Permalink
tsp, bump dependency (#2816)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Jun 14, 2024
1 parent d7b5ef3 commit e631d18
Show file tree
Hide file tree
Showing 93 changed files with 807 additions and 815 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/java",
"version": "4.1.29",
"version": "4.1.30",
"description": "The Java extension for classic generators in AutoRest.",
"scripts": {
"autorest": "autorest",
Expand Down
4 changes: 2 additions & 2 deletions typespec-extension/changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Release History

## 0.16.4 (Unreleased)
## 0.17.0 (2024-06-14)

Compatible with compiler 0.56.
Compatible with compiler 0.57.

## 0.16.3 (2024-06-03)

Expand Down
221 changes: 101 additions & 120 deletions typespec-extension/package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions typespec-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/typespec-java",
"version": "0.16.4",
"version": "0.17.0",
"description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding",
"keywords": [
"TypeSpec"
Expand Down Expand Up @@ -45,38 +45,38 @@
"target/emitter.jar"
],
"peerDependencies": {
"@azure-tools/typespec-azure-core": ">=0.42.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.42.1 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.42.1 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.42.2 <1.0.0",
"@typespec/compiler": ">=0.56.0 <1.0.0",
"@typespec/http": ">=0.56.0 <1.0.0",
"@typespec/openapi": ">=0.56.0 <1.0.0",
"@typespec/rest": ">=0.56.0 <1.0.0",
"@typespec/versioning": ">=0.56.0 <1.0.0"
"@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.43.0 <1.0.0",
"@typespec/compiler": ">=0.57.0 <1.0.0",
"@typespec/http": ">=0.57.0 <1.0.0",
"@typespec/openapi": ">=0.57.0 <1.0.0",
"@typespec/rest": ">=0.57.0 <1.0.0",
"@typespec/versioning": ">=0.57.0 <1.0.0"
},
"dependencies": {
"@autorest/codemodel": "~4.20.0",
"js-yaml": "~4.1.0",
"lodash": "~4.17.21"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "0.42.1",
"@azure-tools/typespec-azure-core": "0.42.0",
"@azure-tools/typespec-azure-resource-manager": "0.42.1",
"@azure-tools/typespec-azure-rulesets": "0.42.1",
"@azure-tools/typespec-client-generator-core": "0.42.3",
"@azure-tools/typespec-autorest": "0.43.0",
"@azure-tools/typespec-azure-core": "0.43.0",
"@azure-tools/typespec-azure-resource-manager": "0.43.0",
"@azure-tools/typespec-azure-rulesets": "0.43.0",
"@azure-tools/typespec-client-generator-core": "0.43.0",
"@types/js-yaml": "~4.0.9",
"@types/lodash": "~4.17.1",
"@types/mocha": "~10.0.6",
"@types/node": "~20.12.10",
"@typescript-eslint/eslint-plugin": "~7.8.0",
"@typescript-eslint/parser": "~7.8.0",
"@typespec/compiler": "0.56.0",
"@typespec/http": "0.56.0",
"@typespec/openapi": "0.56.0",
"@typespec/rest": "0.56.0",
"@typespec/versioning": "0.56.0",
"@typespec/compiler": "0.57.0",
"@typespec/http": "0.57.0",
"@typespec/openapi": "0.57.0",
"@typespec/rest": "0.57.0",
"@typespec/versioning": "0.57.0",
"c8": "~9.1.0",
"eslint": "~8.57.0",
"eslint-plugin-deprecation": "~2.0.0",
Expand Down
46 changes: 32 additions & 14 deletions typespec-extension/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
Authentication,
HttpOperation,
HttpOperationBody,
HttpOperationMultipartBody,
HttpOperationParameter,
HttpOperationResponse,
HttpServer,
Expand Down Expand Up @@ -152,6 +153,7 @@ import {
ProcessingCache,
getAccess,
getDurationFormatFromSdkType,
getNonNullSdkType,
getUnionDescription,
getUsage,
hasScalarAsBase,
Expand Down Expand Up @@ -719,7 +721,7 @@ export class CodeModelBuilder {
},
});

codeModelOperation.crossLanguageDefinitionId = getCrossLanguageDefinitionId(operation);
codeModelOperation.crossLanguageDefinitionId = getCrossLanguageDefinitionId(this.sdkContext, operation);
codeModelOperation.internalApi = this.isInternal(this.sdkContext, operation);

const convenienceApiName = this.getConvenienceApiName(operation);
Expand Down Expand Up @@ -789,9 +791,9 @@ export class CodeModelBuilder {
this.addAcceptHeaderParameter(codeModelOperation, op.responses);
// body
if (op.parameters.body) {
if (op.parameters.body.parameter) {
if (!isVoidType(op.parameters.body.parameter.type)) {
this.processParameterBody(codeModelOperation, op, op.parameters.body.parameter);
if (op.parameters.body.property) {
if (!isVoidType(op.parameters.body.property.type)) {
this.processParameterBody(codeModelOperation, op, op.parameters.body.property);
}
} else if (op.parameters.body.type) {
let bodyType = this.getEffectiveSchemaType(op.parameters.body.type);
Expand Down Expand Up @@ -1018,7 +1020,7 @@ export class CodeModelBuilder {
} else {
// schema
let schema;
const sdkType = getClientType(this.sdkContext, param.param);
const sdkType = getNonNullSdkType(getClientType(this.sdkContext, param.param));
if (
param.type === "header" &&
param.param.type.kind === "Scalar" &&
Expand Down Expand Up @@ -1532,7 +1534,7 @@ export class CodeModelBuilder {
}
}

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

private processArraySchemaFromSdkType(type: SdkArrayType, name: string): ArraySchema {
const elementSchema = this.processSchemaFromSdkType(type.valueType, name);
let nullableItems = false;
let elementType = type.valueType;
if (elementType.kind === "nullable") {
nullableItems = true;
elementType = elementType.type;
}

const elementSchema = this.processSchemaFromSdkType(elementType, name);
return this.codeModel.schemas.add(
new ArraySchema(name, type.details ?? "", elementSchema, {
summary: type.description,
nullableItems: nullableItems,
}),
);
}
Expand All @@ -1820,10 +1830,16 @@ export class CodeModelBuilder {
this.schemaCache.set(type, dictSchema);
}

const elementSchema = this.processSchemaFromSdkType(type.valueType, name);
let nullableItems = false;
let elementType = type.valueType;
if (elementType.kind === "nullable") {
nullableItems = true;
elementType = elementType.type;
}
const elementSchema = this.processSchemaFromSdkType(elementType, name);
dictSchema.elementType = elementSchema;

dictSchema.nullableItems = type.nullableValues;
dictSchema.nullableItems = nullableItems;

return this.codeModel.schemas.add(dictSchema);
}
Expand Down Expand Up @@ -2001,11 +2017,8 @@ export class CodeModelBuilder {
keyType: {
kind: "string",
encode: "string",
nullable: false,
},
description: type.description,
nullableValues: false,
nullable: false,
valueType: type.additionalProperties,
};
const parentSchema = this.processSchemaFromSdkType(sdkDictType, "Record");
Expand Down Expand Up @@ -2044,8 +2057,13 @@ export class CodeModelBuilder {
}

private processModelPropertyFromSdkType(prop: SdkModelPropertyType): Property {
let schema = this.processSchemaFromSdkType(prop.type, "");
let nullable = prop.nullable;
let nullable = false;
let nonNullType = prop.type;
if (nonNullType.kind === "nullable") {
nullable = true;
nonNullType = nonNullType.type;
}
let schema = this.processSchemaFromSdkType(nonNullType, "");

let extensions: Record<string, any> | undefined = undefined;
if (this.isSecret(prop)) {
Expand Down
4 changes: 2 additions & 2 deletions typespec-extension/src/operation-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ export function operationRefersUnion(
}
// request body
if (op.parameters.body) {
if (op.parameters.body.parameter) {
const ret = unionReferredByType(program, op.parameters.body.parameter.type, cache);
if (op.parameters.body.property) {
const ret = unionReferredByType(program, op.parameters.body.property.type, cache);
if (ret) {
return ret;
}
Expand Down
6 changes: 5 additions & 1 deletion typespec-extension/src/type-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { SchemaContext } from "@autorest/codemodel";
import { DurationSchema } from "./common/schemas/time.js";
import { getNamespace } from "./utils.js";
import { getUnionAsEnum } from "@azure-tools/typespec-azure-core";
import { SdkDurationType, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core";
import { SdkDurationType, SdkType, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core";
import { Version } from "@typespec/versioning";

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

export function getNonNullSdkType(type: SdkType): SdkType {
return type.kind === "nullable" ? type.type : type;
}

export function getDurationFormat(encode: EncodeData): DurationSchema["format"] {
let format: DurationSchema["format"] = "duration-rfc3339";
// duration encoded as seconds
Expand Down
22 changes: 11 additions & 11 deletions typespec-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
},
"dependencies": {
"@azure-tools/cadl-ranch-specs": "0.33.4",
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.16.4.tgz"
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.17.0.tgz"
},
"devDependencies": {
"@typespec/prettier-plugin-typespec": "~0.56.0",
"@typespec/prettier-plugin-typespec": "~0.57.0",
"prettier-plugin-organize-imports": "3.2.4",
"prettier": "~3.2.5"
},
"overrides": {
"@typespec/compiler": ">=0.56.0 <1.0.0",
"@typespec/http": ">=0.56.0 <1.0.0",
"@typespec/rest": ">=0.56.0 <1.0.0",
"@typespec/versioning": ">=0.56.0 <1.0.0",
"@typespec/openapi": ">=0.56.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.42.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.42.2 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.42.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.42.0 <1.0.0"
"@typespec/compiler": ">=0.57.0 <1.0.0",
"@typespec/http": ">=0.57.0 <1.0.0",
"@typespec/rest": ">=0.57.0 <1.0.0",
"@typespec/versioning": ">=0.57.0 <1.0.0",
"@typespec/openapi": ">=0.57.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.43.0 <1.0.0"
},
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Immutable
public class AbstractModel implements JsonSerializable<AbstractModel> {
/*
* The kind property.
* Discriminator property for AbstractModel.
*/
@Generated
private String kind = "AbstractModel";
Expand All @@ -40,7 +40,7 @@ protected AbstractModel(String name) {
}

/**
* Get the kind property: The kind property.
* Get the kind property: Discriminator property for AbstractModel.
*
* @return the kind value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Immutable
public final class RealModel extends AbstractModel {
/*
* The kind property.
* Discriminator property for AbstractModel.
*/
@Generated
private String kind = "real";
Expand All @@ -33,7 +33,7 @@ private RealModel(String name) {
}

/**
* Get the kind property: The kind property.
* Get the kind property: Discriminator property for AbstractModel.
*
* @return the kind value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface ArmResourceProviderClient {
String getApiVersion();

/**
* Gets The ID of the target subscription.
* Gets The ID of the target subscription. The value must be an UUID.
*
* @return the subscriptionId value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public ArmResourceProviderClientBuilder endpoint(String endpoint) {
}

/*
* The ID of the target subscription.
* The ID of the target subscription. The value must be an UUID.
*/
private String subscriptionId;

/**
* Sets The ID of the target subscription.
* Sets The ID of the target subscription. The value must be an UUID.
*
* @param subscriptionId the subscriptionId value.
* @return the ArmResourceProviderClientBuilder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public String getApiVersion() {
}

/**
* The ID of the target subscription.
* The ID of the target subscription. The value must be an UUID.
*/
private final String subscriptionId;

/**
* Gets The ID of the target subscription.
* Gets The ID of the target subscription. The value must be an UUID.
*
* @return the subscriptionId value.
*/
Expand Down Expand Up @@ -190,7 +190,7 @@ public OperationsClient getOperations() {
* @param defaultPollInterval The default poll interval for long-running operation.
* @param environment The Azure environment.
* @param endpoint Server parameter.
* @param subscriptionId The ID of the target subscription.
* @param subscriptionId The ID of the target subscription. The value must be an UUID.
*/
ArmResourceProviderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter,
Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.azure.core.util.FluxUtil;
import com.cadl.armresourceprovider.fluent.OperationsClient;
import com.cadl.armresourceprovider.fluent.models.OperationInner;
import com.cadl.armresourceprovider.implementation.models.PagedOperation;
import com.cadl.armresourceprovider.implementation.models.OperationListResult;
import reactor.core.publisher.Mono;

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

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

Expand Down
Loading

0 comments on commit e631d18

Please sign in to comment.