diff --git a/typespec-extension/changelog.md b/typespec-extension/changelog.md index d79ee0136d..b075d154d5 100644 --- a/typespec-extension/changelog.md +++ b/typespec-extension/changelog.md @@ -1,6 +1,6 @@ # Release History -## 0.17.1 (Unreleased) +## 0.17.1 (2024-07-03) Compatible with compiler 0.57. diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index aabf399eab..748e98756b 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/typespec-java", - "version": "0.17.0", + "version": "0.17.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/typespec-java", - "version": "0.17.0", + "version": "0.17.1", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.0", diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 2186051c94..66b6e21caa 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-java", - "version": "0.17.0", + "version": "0.17.1", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" diff --git a/typespec-extension/src/code-model-builder.ts b/typespec-extension/src/code-model-builder.ts index 0bd5bd6f5b..ba9f69ac9f 100644 --- a/typespec-extension/src/code-model-builder.ts +++ b/typespec-extension/src/code-model-builder.ts @@ -111,12 +111,17 @@ import { HttpStatusCodesEntry, Visibility, getAuthentication, + getHeaderFieldName, getHeaderFieldOptions, getHttpOperation, + getPathParamName, + getQueryParamName, getQueryParamOptions, getServers, getStatusCodeDescription, + isHeader, isPathParam, + isQueryParam, } from "@typespec/http"; import { getResourceOperation, getSegment } from "@typespec/rest"; import { Version, getAddedOnVersions, getVersion } from "@typespec/versioning"; @@ -2256,8 +2261,16 @@ export class CodeModelBuilder { } private getSerializedName(target: ModelProperty): string { - // TODO: currently this is only for JSON - return getWireName(this.sdkContext, target); + if (isHeader(this.program, target)) { + return getHeaderFieldName(this.program, target); + } else if (isQueryParam(this.program, target)) { + return getQueryParamName(this.program, target); + } else if (isPathParam(this.program, target)) { + return getPathParamName(this.program, target); + } else { + // TODO: currently this is only for JSON + return getWireName(this.sdkContext, target); + } } private isReadOnly(target: SdkModelPropertyType): boolean { diff --git a/typespec-tests/package.json b/typespec-tests/package.json index 2f2d118e01..316046f1f1 100644 --- a/typespec-tests/package.json +++ b/typespec-tests/package.json @@ -9,8 +9,8 @@ "testserver-run": "npx cadl-ranch serve ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java.json" }, "dependencies": { - "@azure-tools/cadl-ranch-specs": "0.34.1", - "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.17.0.tgz" + "@azure-tools/cadl-ranch-specs": "0.34.3", + "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.17.1.tgz" }, "devDependencies": { "@typespec/prettier-plugin-typespec": "~0.57.0", diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelAsyncClient.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelAsyncClient.java new file mode 100644 index 0000000000..1f518dac04 --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelAsyncClient.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com._specs_.azure.core.model.implementation.AzureCoreEmbeddingVectorsImpl; +import com._specs_.azure.core.model.models.AzureEmbeddingModel; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.TypeReference; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ModelClient type. + */ +@ServiceClient(builder = ModelClientBuilder.class, isAsync = true) +public final class ModelAsyncClient { + @Generated + private final AzureCoreEmbeddingVectorsImpl serviceClient; + + /** + * Initializes an instance of ModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelAsyncClient(AzureCoreEmbeddingVectorsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an embedding vector along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponseAsync(body, requestOptions); + } + + /** + * get an embedding vector. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an embedding vector on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_INTEGER)); + } + + /** + * put an embedding vector. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * post a model which has an embeddingVector property. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono post(AzureEmbeddingModel body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AzureEmbeddingModel.class)); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClient.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClient.java new file mode 100644 index 0000000000..170aadb44c --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com._specs_.azure.core.model.implementation.AzureCoreEmbeddingVectorsImpl; +import com._specs_.azure.core.model.models.AzureEmbeddingModel; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.serializer.TypeReference; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ModelClient type. + */ +@ServiceClient(builder = ModelClientBuilder.class) +public final class ModelClient { + @Generated + private final AzureCoreEmbeddingVectorsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelClient(AzureCoreEmbeddingVectorsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an embedding vector along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponse(body, requestOptions); + } + + /** + * get an embedding vector. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an embedding vector. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_INTEGER); + } + + /** + * put an embedding vector. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * post a model which has an embeddingVector property. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AzureEmbeddingModel post(AzureEmbeddingModel body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(AzureEmbeddingModel.class); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java new file mode 100644 index 0000000000..24a5ebd756 --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com._specs_.azure.core.model.implementation.ModelClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ModelClient type. + */ +@ServiceClientBuilder(serviceClients = { ModelClient.class, ModelAsyncClient.class }) +public final class ModelClientBuilder implements HttpTrait, ConfigurationTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final Map PROPERTIES + = CoreUtils.getProperties("_specs_-azure-core-model.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ModelClientBuilder. + */ + @Generated + public ModelClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * Service version + */ + @Generated + private ModelServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ModelClientBuilder. + */ + @Generated + public ModelClientBuilder serviceVersion(ModelServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the ModelClientBuilder. + */ + @Generated + public ModelClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ModelClientImpl with the provided parameters. + * + * @return an instance of ModelClientImpl. + */ + @Generated + private ModelClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ModelServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ModelServiceVersion.getLatest(); + ModelClientImpl client + = new ModelClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localServiceVersion); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of ModelAsyncClient class. + * + * @return an instance of ModelAsyncClient. + */ + @Generated + public ModelAsyncClient buildAsyncClient() { + return new ModelAsyncClient(buildInnerClient().getAzureCoreEmbeddingVectors()); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Generated + public ModelClient buildClient() { + return new ModelClient(buildInnerClient().getAzureCoreEmbeddingVectors()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ModelClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelServiceVersion.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelServiceVersion.java new file mode 100644 index 0000000000..a8bb4574db --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ModelClient. + */ +public enum ModelServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + ModelServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ModelServiceVersion}. + */ + public static ModelServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java new file mode 100644 index 0000000000..1d5e9da27b --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.implementation; + +import com._specs_.azure.core.model.ModelServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in AzureCoreEmbeddingVectors. + */ +public final class AzureCoreEmbeddingVectorsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AzureCoreEmbeddingVectorsService service; + + /** + * The service client containing this operation class. + */ + private final ModelClientImpl client; + + /** + * Initializes an instance of AzureCoreEmbeddingVectorsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AzureCoreEmbeddingVectorsImpl(ModelClientImpl client) { + this.service = RestProxy.create(AzureCoreEmbeddingVectorsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ModelServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ModelClientAzureCoreEmbeddingVectors to be used by the proxy service + * to perform REST calls. + */ + @Host("http://localhost:3000") + @ServiceInterface(name = "ModelClientAzureCore") + public interface AzureCoreEmbeddingVectorsService { + @Get("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/azure/core/model/embeddingVector") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/azure/core/model/embeddingVector") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> post(@HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postSync(@HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an embedding vector along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an embedding vector along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(accept, requestOptions, Context.NONE); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.putSync(accept, body, requestOptions, Context.NONE); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.post(accept, body, requestOptions, context)); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.postSync(accept, body, requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java new file mode 100644 index 0000000000..1453d155e2 --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.implementation; + +import com._specs_.azure.core.model.ModelServiceVersion; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ModelClient type. + */ +public final class ModelClientImpl { + /** + * Service version. + */ + private final ModelServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ModelServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The AzureCoreEmbeddingVectorsImpl object to access its operations. + */ + private final AzureCoreEmbeddingVectorsImpl azureCoreEmbeddingVectors; + + /** + * Gets the AzureCoreEmbeddingVectorsImpl object to access its operations. + * + * @return the AzureCoreEmbeddingVectorsImpl object. + */ + public AzureCoreEmbeddingVectorsImpl getAzureCoreEmbeddingVectors() { + return this.azureCoreEmbeddingVectors; + } + + /** + * Initializes an instance of ModelClient client. + * + * @param serviceVersion Service version. + */ + public ModelClientImpl(ModelServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + } + + /** + * Initializes an instance of ModelClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serviceVersion Service version. + */ + public ModelClientImpl(HttpPipeline httpPipeline, ModelServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + } + + /** + * Initializes an instance of ModelClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param serviceVersion Service version. + */ + public ModelClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + ModelServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.serviceVersion = serviceVersion; + this.azureCoreEmbeddingVectors = new AzureCoreEmbeddingVectorsImpl(this); + } +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/package-info.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/package-info.java new file mode 100644 index 0000000000..038f112701 --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the implementations for Model. + * + */ +package com._specs_.azure.core.model.implementation; diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/models/AzureEmbeddingModel.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/models/AzureEmbeddingModel.java new file mode 100644 index 0000000000..25cac4f4ff --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/models/AzureEmbeddingModel.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The AzureEmbeddingModel model. + */ +@Immutable +public final class AzureEmbeddingModel implements JsonSerializable { + /* + * The embedding property. + */ + @Generated + private final List embedding; + + /** + * Creates an instance of AzureEmbeddingModel class. + * + * @param embedding the embedding value to set. + */ + @Generated + public AzureEmbeddingModel(List embedding) { + this.embedding = embedding; + } + + /** + * Get the embedding property: The embedding property. + * + * @return the embedding value. + */ + @Generated + public List getEmbedding() { + return this.embedding; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("embedding", this.embedding, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureEmbeddingModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureEmbeddingModel if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureEmbeddingModel. + */ + @Generated + public static AzureEmbeddingModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List embedding = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("embedding".equals(fieldName)) { + embedding = reader.readArray(reader1 -> reader1.getInt()); + } else { + reader.skipChildren(); + } + } + return new AzureEmbeddingModel(embedding); + }); + } +} diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/models/package-info.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/models/package-info.java new file mode 100644 index 0000000000..3f230c8828 --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/models/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the data models for Model. + * + */ +package com._specs_.azure.core.model.models; diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/package-info.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/package-info.java new file mode 100644 index 0000000000..a828f7154e --- /dev/null +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the classes for Model. + * + */ +package com._specs_.azure.core.model; diff --git a/typespec-tests/src/main/java/com/client/naming/NamingAsyncClient.java b/typespec-tests/src/main/java/com/client/naming/NamingAsyncClient.java index 5d50c24175..431994ec29 100644 --- a/typespec-tests/src/main/java/com/client/naming/NamingAsyncClient.java +++ b/typespec-tests/src/main/java/com/client/naming/NamingAsyncClient.java @@ -83,7 +83,7 @@ public Mono> parameterWithResponse(String clientName, RequestOpti * } * } * - * @param clientNameModel The clientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -93,8 +93,8 @@ public Mono> parameterWithResponse(String clientName, RequestOpti */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clientWithResponse(BinaryData clientNameModel, RequestOptions requestOptions) { - return this.serviceClient.clientWithResponseAsync(clientNameModel, requestOptions); + public Mono> clientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.clientWithResponseAsync(body, requestOptions); } /** @@ -107,7 +107,7 @@ public Mono> clientWithResponse(BinaryData clientNameModel, Reque * } * } * - * @param languageClientNameModel The languageClientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -117,9 +117,8 @@ public Mono> clientWithResponse(BinaryData clientNameModel, Reque */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> languageWithResponse(BinaryData languageClientNameModel, - RequestOptions requestOptions) { - return this.serviceClient.languageWithResponseAsync(languageClientNameModel, requestOptions); + public Mono> languageWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.languageWithResponseAsync(body, requestOptions); } /** @@ -132,7 +131,7 @@ public Mono> languageWithResponse(BinaryData languageClientNameMo * } * } * - * @param clientNameAndJsonEncodedNameModel The clientNameAndJsonEncodedNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -142,10 +141,8 @@ public Mono> languageWithResponse(BinaryData languageClientNameMo */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> compatibleWithEncodedNameWithResponse(BinaryData clientNameAndJsonEncodedNameModel, - RequestOptions requestOptions) { - return this.serviceClient.compatibleWithEncodedNameWithResponseAsync(clientNameAndJsonEncodedNameModel, - requestOptions); + public Mono> compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.compatibleWithEncodedNameWithResponseAsync(body, requestOptions); } /** @@ -222,7 +219,7 @@ public Mono parameter(String clientName) { /** * The client operation. * - * @param clientNameModel The clientNameModel parameter. + * @param body The body parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -233,16 +230,16 @@ public Mono parameter(String clientName) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono client(ClientNameModel clientNameModel) { + public Mono client(ClientNameModel body) { // Generated convenience method for clientWithResponse RequestOptions requestOptions = new RequestOptions(); - return clientWithResponse(BinaryData.fromObject(clientNameModel), requestOptions).flatMap(FluxUtil::toMono); + return clientWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); } /** * The language operation. * - * @param languageClientNameModel The languageClientNameModel parameter. + * @param body The body parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -253,17 +250,16 @@ public Mono client(ClientNameModel clientNameModel) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono language(LanguageClientNameModel languageClientNameModel) { + public Mono language(LanguageClientNameModel body) { // Generated convenience method for languageWithResponse RequestOptions requestOptions = new RequestOptions(); - return languageWithResponse(BinaryData.fromObject(languageClientNameModel), requestOptions) - .flatMap(FluxUtil::toMono); + return languageWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); } /** * The compatibleWithEncodedName operation. * - * @param clientNameAndJsonEncodedNameModel The clientNameAndJsonEncodedNameModel parameter. + * @param body The body parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -274,11 +270,11 @@ public Mono language(LanguageClientNameModel languageClientNameModel) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono compatibleWithEncodedName(ClientNameAndJsonEncodedNameModel clientNameAndJsonEncodedNameModel) { + public Mono compatibleWithEncodedName(ClientNameAndJsonEncodedNameModel body) { // Generated convenience method for compatibleWithEncodedNameWithResponse RequestOptions requestOptions = new RequestOptions(); - return compatibleWithEncodedNameWithResponse(BinaryData.fromObject(clientNameAndJsonEncodedNameModel), - requestOptions).flatMap(FluxUtil::toMono); + return compatibleWithEncodedNameWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono); } /** diff --git a/typespec-tests/src/main/java/com/client/naming/NamingClient.java b/typespec-tests/src/main/java/com/client/naming/NamingClient.java index 25f5ff2233..0bde965520 100644 --- a/typespec-tests/src/main/java/com/client/naming/NamingClient.java +++ b/typespec-tests/src/main/java/com/client/naming/NamingClient.java @@ -81,7 +81,7 @@ public Response parameterWithResponse(String clientName, RequestOptions re * } * } * - * @param clientNameModel The clientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -91,8 +91,8 @@ public Response parameterWithResponse(String clientName, RequestOptions re */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response clientWithResponse(BinaryData clientNameModel, RequestOptions requestOptions) { - return this.serviceClient.clientWithResponse(clientNameModel, requestOptions); + public Response clientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.clientWithResponse(body, requestOptions); } /** @@ -105,7 +105,7 @@ public Response clientWithResponse(BinaryData clientNameModel, RequestOpti * } * } * - * @param languageClientNameModel The languageClientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -115,8 +115,8 @@ public Response clientWithResponse(BinaryData clientNameModel, RequestOpti */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response languageWithResponse(BinaryData languageClientNameModel, RequestOptions requestOptions) { - return this.serviceClient.languageWithResponse(languageClientNameModel, requestOptions); + public Response languageWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.languageWithResponse(body, requestOptions); } /** @@ -129,7 +129,7 @@ public Response languageWithResponse(BinaryData languageClientNameModel, R * } * } * - * @param clientNameAndJsonEncodedNameModel The clientNameAndJsonEncodedNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -139,10 +139,8 @@ public Response languageWithResponse(BinaryData languageClientNameModel, R */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response compatibleWithEncodedNameWithResponse(BinaryData clientNameAndJsonEncodedNameModel, - RequestOptions requestOptions) { - return this.serviceClient.compatibleWithEncodedNameWithResponse(clientNameAndJsonEncodedNameModel, - requestOptions); + public Response compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.compatibleWithEncodedNameWithResponse(body, requestOptions); } /** @@ -217,7 +215,7 @@ public void parameter(String clientName) { /** * The client operation. * - * @param clientNameModel The clientNameModel parameter. + * @param body The body parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -227,16 +225,16 @@ public void parameter(String clientName) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void client(ClientNameModel clientNameModel) { + public void client(ClientNameModel body) { // Generated convenience method for clientWithResponse RequestOptions requestOptions = new RequestOptions(); - clientWithResponse(BinaryData.fromObject(clientNameModel), requestOptions).getValue(); + clientWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); } /** * The language operation. * - * @param languageClientNameModel The languageClientNameModel parameter. + * @param body The body parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -246,16 +244,16 @@ public void client(ClientNameModel clientNameModel) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void language(LanguageClientNameModel languageClientNameModel) { + public void language(LanguageClientNameModel body) { // Generated convenience method for languageWithResponse RequestOptions requestOptions = new RequestOptions(); - languageWithResponse(BinaryData.fromObject(languageClientNameModel), requestOptions).getValue(); + languageWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); } /** * The compatibleWithEncodedName operation. * - * @param clientNameAndJsonEncodedNameModel The clientNameAndJsonEncodedNameModel parameter. + * @param body The body parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -265,11 +263,10 @@ public void language(LanguageClientNameModel languageClientNameModel) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void compatibleWithEncodedName(ClientNameAndJsonEncodedNameModel clientNameAndJsonEncodedNameModel) { + public void compatibleWithEncodedName(ClientNameAndJsonEncodedNameModel body) { // Generated convenience method for compatibleWithEncodedNameWithResponse RequestOptions requestOptions = new RequestOptions(); - compatibleWithEncodedNameWithResponse(BinaryData.fromObject(clientNameAndJsonEncodedNameModel), requestOptions) - .getValue(); + compatibleWithEncodedNameWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); } /** diff --git a/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java b/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java index 9ed5aa375d..e724ef048a 100644 --- a/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java +++ b/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java @@ -178,7 +178,7 @@ Response parameterSync(@QueryParam("defaultName") String clientName, @Head @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> client(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData clientNameModel, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/client/naming/property/client") @ExpectedResponses({ 204 }) @@ -186,8 +186,8 @@ Mono> client(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response clientSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData clientNameModel, RequestOptions requestOptions, Context context); + Response clientSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); @Post("/client/naming/property/language") @ExpectedResponses({ 204 }) @@ -196,8 +196,7 @@ Response clientSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> language(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData languageClientNameModel, RequestOptions requestOptions, - Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/client/naming/property/language") @ExpectedResponses({ 204 }) @@ -206,8 +205,7 @@ Mono> language(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response languageSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData languageClientNameModel, RequestOptions requestOptions, - Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/client/naming/property/compatible-with-encoded-name") @ExpectedResponses({ 204 }) @@ -216,8 +214,7 @@ Response languageSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> compatibleWithEncodedName(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData clientNameAndJsonEncodedNameModel, RequestOptions requestOptions, - Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/client/naming/property/compatible-with-encoded-name") @ExpectedResponses({ 204 }) @@ -226,8 +223,7 @@ Mono> compatibleWithEncodedName(@HeaderParam("accept") String acc @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response compatibleWithEncodedNameSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData clientNameAndJsonEncodedNameModel, RequestOptions requestOptions, - Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/client/naming/header") @ExpectedResponses({ 204 }) @@ -342,7 +338,7 @@ public Response parameterWithResponse(String clientName, RequestOptions re * } * } * - * @param clientNameModel The clientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -351,9 +347,9 @@ public Response parameterWithResponse(String clientName, RequestOptions re * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clientWithResponseAsync(BinaryData clientNameModel, RequestOptions requestOptions) { + public Mono> clientWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.client(accept, clientNameModel, requestOptions, context)); + return FluxUtil.withContext(context -> service.client(accept, body, requestOptions, context)); } /** @@ -366,7 +362,7 @@ public Mono> clientWithResponseAsync(BinaryData clientNameModel, * } * } * - * @param clientNameModel The clientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -375,9 +371,9 @@ public Mono> clientWithResponseAsync(BinaryData clientNameModel, * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response clientWithResponse(BinaryData clientNameModel, RequestOptions requestOptions) { + public Response clientWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.clientSync(accept, clientNameModel, requestOptions, Context.NONE); + return service.clientSync(accept, body, requestOptions, Context.NONE); } /** @@ -390,7 +386,7 @@ public Response clientWithResponse(BinaryData clientNameModel, RequestOpti * } * } * - * @param languageClientNameModel The languageClientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -399,11 +395,9 @@ public Response clientWithResponse(BinaryData clientNameModel, RequestOpti * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> languageWithResponseAsync(BinaryData languageClientNameModel, - RequestOptions requestOptions) { + public Mono> languageWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.language(accept, languageClientNameModel, requestOptions, context)); + return FluxUtil.withContext(context -> service.language(accept, body, requestOptions, context)); } /** @@ -416,7 +410,7 @@ public Mono> languageWithResponseAsync(BinaryData languageClientN * } * } * - * @param languageClientNameModel The languageClientNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -425,9 +419,9 @@ public Mono> languageWithResponseAsync(BinaryData languageClientN * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response languageWithResponse(BinaryData languageClientNameModel, RequestOptions requestOptions) { + public Response languageWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.languageSync(accept, languageClientNameModel, requestOptions, Context.NONE); + return service.languageSync(accept, body, requestOptions, Context.NONE); } /** @@ -440,7 +434,7 @@ public Response languageWithResponse(BinaryData languageClientNameModel, R * } * } * - * @param clientNameAndJsonEncodedNameModel The clientNameAndJsonEncodedNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -449,11 +443,11 @@ public Response languageWithResponse(BinaryData languageClientNameModel, R * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> compatibleWithEncodedNameWithResponseAsync(BinaryData clientNameAndJsonEncodedNameModel, + public Mono> compatibleWithEncodedNameWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.compatibleWithEncodedName(accept, - clientNameAndJsonEncodedNameModel, requestOptions, context)); + return FluxUtil + .withContext(context -> service.compatibleWithEncodedName(accept, body, requestOptions, context)); } /** @@ -466,7 +460,7 @@ public Mono> compatibleWithEncodedNameWithResponseAsync(BinaryDat * } * } * - * @param clientNameAndJsonEncodedNameModel The clientNameAndJsonEncodedNameModel parameter. + * @param body The body parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -475,11 +469,9 @@ public Mono> compatibleWithEncodedNameWithResponseAsync(BinaryDat * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response compatibleWithEncodedNameWithResponse(BinaryData clientNameAndJsonEncodedNameModel, - RequestOptions requestOptions) { + public Response compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.compatibleWithEncodedNameSync(accept, clientNameAndJsonEncodedNameModel, requestOptions, - Context.NONE); + return service.compatibleWithEncodedNameSync(accept, body, requestOptions, Context.NONE); } /** diff --git a/typespec-tests/src/main/resources/_specs_-azure-core-model.properties b/typespec-tests/src/main/resources/_specs_-azure-core-model.properties new file mode 100644 index 0000000000..ca812989b4 --- /dev/null +++ b/typespec-tests/src/main/resources/_specs_-azure-core-model.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java new file mode 100644 index 0000000000..5c53f73869 --- /dev/null +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com._specs_.azure.core.model.ModelClient; +import com._specs_.azure.core.model.ModelClientBuilder; +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; + +class ModelClientTestBase extends TestProxyTestBase { + protected ModelClient modelClient; + + @Override + protected void beforeTest() { + ModelClientBuilder modelClientbuilder = new ModelClientBuilder().httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelClient = modelClientbuilder.buildClient(); + + } +} diff --git a/typespec-tests/src/test/java/com/type/property/additionalproperties/ExtendsTests.java b/typespec-tests/src/test/java/com/type/property/additionalproperties/ExtendsTests.java index fabf5105e3..6f8fae9420 100644 --- a/typespec-tests/src/test/java/com/type/property/additionalproperties/ExtendsTests.java +++ b/typespec-tests/src/test/java/com/type/property/additionalproperties/ExtendsTests.java @@ -131,7 +131,7 @@ public void testExtendsUnknownDerivedClient() { additionalProperty.put("prop2", true) ; additionalProperty.put("prop3", "abc") ; ExtendsUnknownAdditionalPropertiesDerived body = new ExtendsUnknownAdditionalPropertiesDerived("ExtendsUnknownAdditionalProperties", 314) - .setAge(2.71828); + .setAge(2.71875); body.setAdditionalProperties(additionalProperty); extendsUnknownDerivedClient.put(body); @@ -149,7 +149,7 @@ public void testExtendsUnknownDiscriminatedClient() { additionalProperty.put("prop2", true) ; additionalProperty.put("prop3", "abc") ; ExtendsUnknownAdditionalPropertiesDiscriminatedDerived body = new ExtendsUnknownAdditionalPropertiesDiscriminatedDerived("Derived", 314) - .setAge(2.71828); + .setAge(2.71875); body.setAdditionalProperties(additionalProperty); extendsUnknownDiscriminatedClient.put(body); diff --git a/typespec-tests/src/test/java/com/type/property/additionalproperties/IsUnknownClientTest.java b/typespec-tests/src/test/java/com/type/property/additionalproperties/IsUnknownClientTest.java index d7a448d9cb..a3a5acae2a 100644 --- a/typespec-tests/src/test/java/com/type/property/additionalproperties/IsUnknownClientTest.java +++ b/typespec-tests/src/test/java/com/type/property/additionalproperties/IsUnknownClientTest.java @@ -44,14 +44,14 @@ public void testIsUnknownDerivedClient() { additionalProperty.put("prop3", "abc") ; IsUnknownAdditionalPropertiesDerived body = new IsUnknownAdditionalPropertiesDerived("IsUnknownAdditionalProperties", 314) - .setAge(2.71828); + .setAge(2.71875); body.setAdditionalProperties(additionalProperty); isUnknownDerivedClient.put(body); IsUnknownAdditionalPropertiesDerived properties = isUnknownDerivedClient.get(); Assertions.assertNotNull(properties); Assertions.assertNotNull(properties.getAdditionalProperties()); - Assertions.assertEquals(2.71828, properties.getAge()); + Assertions.assertEquals(2.71875, properties.getAge()); Assertions.assertEquals(314, properties.getIndex()); Assertions.assertEquals(additionalProperty, properties.getAdditionalProperties()); } @@ -64,7 +64,7 @@ public void testIsUnknownDiscriminatedClient() { additionalProperty.put("prop3", "abc") ; IsUnknownAdditionalPropertiesDiscriminatedDerived body = new IsUnknownAdditionalPropertiesDiscriminatedDerived("Derived", 314) - .setAge(2.71828); + .setAge(2.71875); body.setAdditionalProperties(additionalProperty); isUnknownDiscriminatedClient.put(body);