From 180c01fc94c95212afc3d6a67faff55ce5d9fadd Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Jun 2024 09:16:01 +0800 Subject: [PATCH] tsp, update local test for spread (#2835) --- typespec-extension/package-lock.json | 1 + typespec-extension/package.json | 2 + .../cadl/internal/InternalAsyncClient.java | 12 ++-- .../com/cadl/internal/InternalClient.java | 12 ++-- .../implementation/InternalOpsImpl.java | 17 +++--- .../LiteralServiceAsyncClient.java | 18 +++--- .../literalservice/LiteralServiceClient.java | 18 +++--- .../implementation/LiteralOpsImpl.java | 16 ++--- .../longrunning/LongRunningAsyncClient.java | 12 ++-- .../cadl/longrunning/LongRunningClient.java | 12 ++-- .../implementation/LongRunningClientImpl.java | 40 ++++++------- .../com/cadl/naming/NamingAsyncClient.java | 25 +++----- .../java/com/cadl/naming/NamingClient.java | 22 +++---- .../naming/implementation/NamingOpsImpl.java | 20 +++---- .../cadl/wiretype/WireTypeAsyncClient.java | 41 ++++++------- .../com/cadl/wiretype/WireTypeClient.java | 38 ++++++------ .../implementation/WireTypeOpsImpl.java | 59 +++++++++---------- typespec-tests/tsp/internal.tsp | 2 +- typespec-tests/tsp/literal.tsp | 2 +- typespec-tests/tsp/lro.tsp | 7 ++- typespec-tests/tsp/naming.tsp | 2 +- typespec-tests/tsp/wire-type.tsp | 6 +- 22 files changed, 182 insertions(+), 202 deletions(-) diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index dd8011b681..1fa942feef 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -42,6 +42,7 @@ "node": ">=14.0.0" }, "peerDependencies": { + "@azure-tools/typespec-autorest": ">=0.43.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", diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 925c156e82..8bd7192be5 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -47,6 +47,7 @@ "peerDependencies": { "@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-autorest": ">=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", @@ -63,6 +64,7 @@ "devDependencies": { "@azure-tools/typespec-azure-core": "0.43.0", "@azure-tools/typespec-azure-resource-manager": "0.43.0", + "@azure-tools/typespec-autorest": "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", diff --git a/typespec-tests/src/main/java/com/cadl/internal/InternalAsyncClient.java b/typespec-tests/src/main/java/com/cadl/internal/InternalAsyncClient.java index 37e040a125..a593b6c1ee 100644 --- a/typespec-tests/src/main/java/com/cadl/internal/InternalAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/internal/InternalAsyncClient.java @@ -62,7 +62,7 @@ public final class InternalAsyncClient { * } * } * - * @param apiRequest The apiRequest 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. @@ -72,8 +72,8 @@ public final class InternalAsyncClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - Mono> postInternalWithResponse(BinaryData apiRequest, RequestOptions requestOptions) { - return this.serviceClient.postInternalWithResponseAsync(apiRequest, requestOptions); + Mono> postInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postInternalWithResponseAsync(body, requestOptions); } /** @@ -126,7 +126,7 @@ Mono> postProtocalInternalWithResponse(BinaryData body, RequestOp /** * The postInternal operation. * - * @param apiRequest The apiRequest 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. @@ -137,10 +137,10 @@ Mono> postProtocalInternalWithResponse(BinaryData body, RequestOp */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - Mono postInternal(ApiRequest apiRequest) { + Mono postInternal(ApiRequest body) { // Generated convenience method for postInternalWithResponse RequestOptions requestOptions = new RequestOptions(); - return postInternalWithResponse(BinaryData.fromObject(apiRequest), requestOptions).flatMap(FluxUtil::toMono) + return postInternalWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ResponseInternal.class)); } diff --git a/typespec-tests/src/main/java/com/cadl/internal/InternalClient.java b/typespec-tests/src/main/java/com/cadl/internal/InternalClient.java index 0a879dadb2..7f9951e5e8 100644 --- a/typespec-tests/src/main/java/com/cadl/internal/InternalClient.java +++ b/typespec-tests/src/main/java/com/cadl/internal/InternalClient.java @@ -60,7 +60,7 @@ public final class InternalClient { * } * } * - * @param apiRequest The apiRequest 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. @@ -70,8 +70,8 @@ public final class InternalClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - Response postInternalWithResponse(BinaryData apiRequest, RequestOptions requestOptions) { - return this.serviceClient.postInternalWithResponse(apiRequest, requestOptions); + Response postInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postInternalWithResponse(body, requestOptions); } /** @@ -124,7 +124,7 @@ Response postProtocalInternalWithResponse(BinaryData body, RequestOptions /** * The postInternal operation. * - * @param apiRequest The apiRequest 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. @@ -135,10 +135,10 @@ Response postProtocalInternalWithResponse(BinaryData body, RequestOptions */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - ResponseInternal postInternal(ApiRequest apiRequest) { + ResponseInternal postInternal(ApiRequest body) { // Generated convenience method for postInternalWithResponse RequestOptions requestOptions = new RequestOptions(); - return postInternalWithResponse(BinaryData.fromObject(apiRequest), requestOptions).getValue() + return postInternalWithResponse(BinaryData.fromObject(body), requestOptions).getValue() .toObject(ResponseInternal.class); } diff --git a/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java b/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java index 3f91c75c64..091af0d13c 100644 --- a/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java @@ -66,7 +66,7 @@ public interface InternalOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> postInternal(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData apiRequest, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/internal") @@ -76,7 +76,7 @@ Mono> postInternal(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response postInternalSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData apiRequest, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Get("/internal") @@ -140,7 +140,7 @@ Response postProtocalInternalSync(@HostParam("endpoint") String endpoint, * } * } * - * @param apiRequest The apiRequest 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. @@ -149,11 +149,10 @@ Response postProtocalInternalSync(@HostParam("endpoint") String endpoint, * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> postInternalWithResponseAsync(BinaryData apiRequest, - RequestOptions requestOptions) { + public Mono> postInternalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil.withContext( - context -> service.postInternal(this.client.getEndpoint(), accept, apiRequest, requestOptions, context)); + context -> service.postInternal(this.client.getEndpoint(), accept, body, requestOptions, context)); } /** @@ -178,7 +177,7 @@ public Mono> postInternalWithResponseAsync(BinaryData apiRe * } * } * - * @param apiRequest The apiRequest 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. @@ -187,9 +186,9 @@ public Mono> postInternalWithResponseAsync(BinaryData apiRe * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response postInternalWithResponse(BinaryData apiRequest, RequestOptions requestOptions) { + public Response postInternalWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.postInternalSync(this.client.getEndpoint(), accept, apiRequest, requestOptions, Context.NONE); + return service.postInternalSync(this.client.getEndpoint(), accept, body, requestOptions, Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java b/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java index 7b7f0d2cf2..24f46a7f9e 100644 --- a/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java @@ -67,7 +67,7 @@ public final class LiteralServiceAsyncClient { * } * } * - * @param model The model 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. @@ -77,14 +77,14 @@ public final class LiteralServiceAsyncClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> putWithResponse(BinaryData model, RequestOptions requestOptions) { - return this.serviceClient.putWithResponseAsync(model, requestOptions); + public Mono> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); } /** * The put operation. * - * @param model The model parameter. + * @param body The body parameter. * @param optionalLiteralParam The optionalLiteralParam parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -96,20 +96,20 @@ public Mono> putWithResponse(BinaryData model, RequestOptio */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono put(Model model, PutRequestOptionalLiteralParam optionalLiteralParam) { + public Mono put(Model body, PutRequestOptionalLiteralParam optionalLiteralParam) { // Generated convenience method for putWithResponse RequestOptions requestOptions = new RequestOptions(); if (optionalLiteralParam != null) { requestOptions.addQueryParam("optionalLiteralParam", optionalLiteralParam.toString(), false); } - return putWithResponse(BinaryData.fromObject(model), requestOptions).flatMap(FluxUtil::toMono) + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(Model.class)); } /** * The put operation. * - * @param model The model 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. @@ -120,10 +120,10 @@ public Mono put(Model model, PutRequestOptionalLiteralParam optionalLiter */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono put(Model model) { + public Mono put(Model body) { // Generated convenience method for putWithResponse RequestOptions requestOptions = new RequestOptions(); - return putWithResponse(BinaryData.fromObject(model), requestOptions).flatMap(FluxUtil::toMono) + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(Model.class)); } } diff --git a/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceClient.java b/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceClient.java index 6234e31bf6..a949054224 100644 --- a/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceClient.java +++ b/typespec-tests/src/main/java/com/cadl/literalservice/LiteralServiceClient.java @@ -65,7 +65,7 @@ public final class LiteralServiceClient { * } * } * - * @param model The model 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. @@ -75,14 +75,14 @@ public final class LiteralServiceClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response putWithResponse(BinaryData model, RequestOptions requestOptions) { - return this.serviceClient.putWithResponse(model, requestOptions); + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); } /** * The put operation. * - * @param model The model parameter. + * @param body The body parameter. * @param optionalLiteralParam The optionalLiteralParam parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -94,19 +94,19 @@ public Response putWithResponse(BinaryData model, RequestOptions req */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Model put(Model model, PutRequestOptionalLiteralParam optionalLiteralParam) { + public Model put(Model body, PutRequestOptionalLiteralParam optionalLiteralParam) { // Generated convenience method for putWithResponse RequestOptions requestOptions = new RequestOptions(); if (optionalLiteralParam != null) { requestOptions.addQueryParam("optionalLiteralParam", optionalLiteralParam.toString(), false); } - return putWithResponse(BinaryData.fromObject(model), requestOptions).getValue().toObject(Model.class); + return putWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(Model.class); } /** * The put operation. * - * @param model The model 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. @@ -117,9 +117,9 @@ public Model put(Model model, PutRequestOptionalLiteralParam optionalLiteralPara */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Model put(Model model) { + public Model put(Model body) { // Generated convenience method for putWithResponse RequestOptions requestOptions = new RequestOptions(); - return putWithResponse(BinaryData.fromObject(model), requestOptions).getValue().toObject(Model.class); + return putWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(Model.class); } } diff --git a/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java b/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java index 156f1f896b..081273e360 100644 --- a/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java @@ -67,7 +67,7 @@ public interface LiteralOpsService { @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> put(@HostParam("endpoint") String endpoint, @QueryParam("literalParam") String literalParam, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData model, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/literal/put") @ExpectedResponses({ 200 }) @@ -77,7 +77,7 @@ Mono> put(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response putSync(@HostParam("endpoint") String endpoint, @QueryParam("literalParam") String literalParam, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData model, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -108,7 +108,7 @@ Response putSync(@HostParam("endpoint") String endpoint, * } * } * - * @param model The model 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,11 +117,11 @@ Response putSync(@HostParam("endpoint") String endpoint, * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> putWithResponseAsync(BinaryData model, RequestOptions requestOptions) { + public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String literalParam = "literalParam"; final String accept = "application/json"; return FluxUtil.withContext( - context -> service.put(this.client.getEndpoint(), literalParam, accept, model, requestOptions, context)); + context -> service.put(this.client.getEndpoint(), literalParam, accept, body, requestOptions, context)); } /** @@ -152,7 +152,7 @@ public Mono> putWithResponseAsync(BinaryData model, Request * } * } * - * @param model The model 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. @@ -161,9 +161,9 @@ public Mono> putWithResponseAsync(BinaryData model, Request * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response putWithResponse(BinaryData model, RequestOptions requestOptions) { + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { final String literalParam = "literalParam"; final String accept = "application/json"; - return service.putSync(this.client.getEndpoint(), literalParam, accept, model, requestOptions, Context.NONE); + return service.putSync(this.client.getEndpoint(), literalParam, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java b/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java index 20cac2bdb6..2149dcf05b 100644 --- a/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java @@ -147,7 +147,7 @@ public Mono> getJobWithResponse(String id, RequestOptions r * } * } * - * @param jobData The jobData 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. @@ -157,8 +157,8 @@ public Mono> getJobWithResponse(String id, RequestOptions r */ @Generated @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginCreateJob(BinaryData jobData, RequestOptions requestOptions) { - return this.serviceClient.beginCreateJobAsync(jobData, requestOptions); + public PollerFlux beginCreateJob(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.beginCreateJobAsync(body, requestOptions); } /** @@ -203,7 +203,7 @@ public Mono getJob(String id) { /** * A remote procedure call (RPC) operation. * - * @param jobData The jobData 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. @@ -214,9 +214,9 @@ public Mono getJob(String id) { */ @Generated @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginCreateJob(JobData jobData) { + public PollerFlux beginCreateJob(JobData body) { // Generated convenience method for beginCreateJobWithModel RequestOptions requestOptions = new RequestOptions(); - return serviceClient.beginCreateJobWithModelAsync(BinaryData.fromObject(jobData), requestOptions); + return serviceClient.beginCreateJobWithModelAsync(BinaryData.fromObject(body), requestOptions); } } diff --git a/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningClient.java b/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningClient.java index 0603a0a123..7b3d921fef 100644 --- a/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningClient.java +++ b/typespec-tests/src/main/java/com/cadl/longrunning/LongRunningClient.java @@ -145,7 +145,7 @@ public Response getJobWithResponse(String id, RequestOptions request * } * } * - * @param jobData The jobData 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. @@ -155,8 +155,8 @@ public Response getJobWithResponse(String id, RequestOptions request */ @Generated @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginCreateJob(BinaryData jobData, RequestOptions requestOptions) { - return this.serviceClient.beginCreateJob(jobData, requestOptions); + public SyncPoller beginCreateJob(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.beginCreateJob(body, requestOptions); } /** @@ -200,7 +200,7 @@ public JobResult getJob(String id) { /** * A remote procedure call (RPC) operation. * - * @param jobData The jobData 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. @@ -211,9 +211,9 @@ public JobResult getJob(String id) { */ @Generated @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginCreateJob(JobData jobData) { + public SyncPoller beginCreateJob(JobData body) { // Generated convenience method for beginCreateJobWithModel RequestOptions requestOptions = new RequestOptions(); - return serviceClient.beginCreateJobWithModel(BinaryData.fromObject(jobData), requestOptions); + return serviceClient.beginCreateJobWithModel(BinaryData.fromObject(body), requestOptions); } } diff --git a/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java b/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java index eb6fd7fb33..5b2e4f521d 100644 --- a/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java @@ -207,7 +207,7 @@ Response getJobSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> createJob(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData jobData, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/long-running/jobs") @ExpectedResponses({ 202 }) @@ -217,7 +217,7 @@ Mono> createJob(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response createJobSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData jobData, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -471,7 +471,7 @@ public Response getJobWithResponse(String id, RequestOptions request * } * } * - * @param jobData The jobData 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. @@ -480,7 +480,7 @@ public Response getJobWithResponse(String id, RequestOptions request * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createJobWithResponseAsync(BinaryData jobData, RequestOptions requestOptions) { + private Mono> createJobWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; String repeatabilityRequestId = UUID.randomUUID().toString(); @@ -498,7 +498,7 @@ private Mono> createJobWithResponseAsync(BinaryData jobData } }); return FluxUtil.withContext(context -> service.createJob(this.getEndpoint(), - this.getServiceVersion().getVersion(), accept, jobData, requestOptionsLocal, context)); + this.getServiceVersion().getVersion(), accept, body, requestOptionsLocal, context)); } /** @@ -547,7 +547,7 @@ private Mono> createJobWithResponseAsync(BinaryData jobData * } * } * - * @param jobData The jobData 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. @@ -556,7 +556,7 @@ private Mono> createJobWithResponseAsync(BinaryData jobData * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Response createJobWithResponse(BinaryData jobData, RequestOptions requestOptions) { + private Response createJobWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; String repeatabilityRequestId = UUID.randomUUID().toString(); @@ -573,7 +573,7 @@ private Response createJobWithResponse(BinaryData jobData, RequestOp .set(HttpHeaderName.fromString("repeatability-first-sent"), repeatabilityFirstSent); } }); - return service.createJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, jobData, + return service.createJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, body, requestOptionsLocal, Context.NONE); } @@ -623,7 +623,7 @@ private Response createJobWithResponse(BinaryData jobData, RequestOp * } * } * - * @param jobData The jobData 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. @@ -632,8 +632,8 @@ private Response createJobWithResponse(BinaryData jobData, RequestOp * @return the {@link PollerFlux} for polling of long-running operation. */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginCreateJobAsync(BinaryData jobData, RequestOptions requestOptions) { - return PollerFlux.create(Duration.ofSeconds(1), () -> this.createJobWithResponseAsync(jobData, requestOptions), + public PollerFlux beginCreateJobAsync(BinaryData body, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.createJobWithResponseAsync(body, requestOptions), new com.cadl.longrunning.implementation.OperationLocationPollingStrategy<>( new PollingStrategyOptions(this.getHttpPipeline()) .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) @@ -691,7 +691,7 @@ public PollerFlux beginCreateJobAsync(BinaryData jobData * } * } * - * @param jobData The jobData 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. @@ -700,8 +700,8 @@ public PollerFlux beginCreateJobAsync(BinaryData jobData * @return the {@link SyncPoller} for polling of long-running operation. */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginCreateJob(BinaryData jobData, RequestOptions requestOptions) { - return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.createJobWithResponse(jobData, requestOptions), + public SyncPoller beginCreateJob(BinaryData body, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.createJobWithResponse(body, requestOptions), new com.cadl.longrunning.implementation.SyncOperationLocationPollingStrategy<>( new PollingStrategyOptions(this.getHttpPipeline()) .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) @@ -759,7 +759,7 @@ public SyncPoller beginCreateJob(BinaryData jobData, Req * } * } * - * @param jobData The jobData 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. @@ -768,9 +768,9 @@ public SyncPoller beginCreateJob(BinaryData jobData, Req * @return the {@link PollerFlux} for polling of long-running operation. */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginCreateJobWithModelAsync(BinaryData jobData, + public PollerFlux beginCreateJobWithModelAsync(BinaryData body, RequestOptions requestOptions) { - return PollerFlux.create(Duration.ofSeconds(1), () -> this.createJobWithResponseAsync(jobData, requestOptions), + return PollerFlux.create(Duration.ofSeconds(1), () -> this.createJobWithResponseAsync(body, requestOptions), new com.cadl.longrunning.implementation.OperationLocationPollingStrategy<>( new PollingStrategyOptions(this.getHttpPipeline()) .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) @@ -828,7 +828,7 @@ public PollerFlux beginCreateJobWithModelAsync(Binar * } * } * - * @param jobData The jobData 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. @@ -837,9 +837,9 @@ public PollerFlux beginCreateJobWithModelAsync(Binar * @return the {@link SyncPoller} for polling of long-running operation. */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginCreateJobWithModel(BinaryData jobData, + public SyncPoller beginCreateJobWithModel(BinaryData body, RequestOptions requestOptions) { - return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.createJobWithResponse(jobData, requestOptions), + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.createJobWithResponse(body, requestOptions), new com.cadl.longrunning.implementation.SyncOperationLocationPollingStrategy<>( new PollingStrategyOptions(this.getHttpPipeline()) .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) diff --git a/typespec-tests/src/main/java/com/cadl/naming/NamingAsyncClient.java b/typespec-tests/src/main/java/com/cadl/naming/NamingAsyncClient.java index c9e45422e9..53cdb56fea 100644 --- a/typespec-tests/src/main/java/com/cadl/naming/NamingAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/naming/NamingAsyncClient.java @@ -87,9 +87,7 @@ public final class NamingAsyncClient { * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @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. @@ -99,9 +97,8 @@ public final class NamingAsyncClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> postWithResponse(String name, BinaryData dataRequest, - RequestOptions requestOptions) { - return this.serviceClient.postWithResponseAsync(name, dataRequest, requestOptions); + public Mono> postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponseAsync(name, body, requestOptions); } /** @@ -135,9 +132,7 @@ public Mono> getAnonymousWithResponse(RequestOptions reques * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @param body The body parameter. * @param etag summary of etag header parameter * * description of etag header parameter. @@ -151,13 +146,13 @@ public Mono> getAnonymousWithResponse(RequestOptions reques */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono post(String name, DataRequest dataRequest, String etag) { + public Mono post(String name, DataRequest body, String etag) { // Generated convenience method for postWithResponse RequestOptions requestOptions = new RequestOptions(); if (etag != null) { requestOptions.setHeader(HttpHeaderName.ETAG, etag); } - return postWithResponse(name, BinaryData.fromObject(dataRequest), requestOptions).flatMap(FluxUtil::toMono) + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(DataResponse.class)); } @@ -169,9 +164,7 @@ public Mono post(String name, DataRequest dataRequest, String etag * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @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. @@ -182,10 +175,10 @@ public Mono post(String name, DataRequest dataRequest, String etag */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono post(String name, DataRequest dataRequest) { + public Mono post(String name, DataRequest body) { // Generated convenience method for postWithResponse RequestOptions requestOptions = new RequestOptions(); - return postWithResponse(name, BinaryData.fromObject(dataRequest), requestOptions).flatMap(FluxUtil::toMono) + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(DataResponse.class)); } diff --git a/typespec-tests/src/main/java/com/cadl/naming/NamingClient.java b/typespec-tests/src/main/java/com/cadl/naming/NamingClient.java index f882696956..2c435a7576 100644 --- a/typespec-tests/src/main/java/com/cadl/naming/NamingClient.java +++ b/typespec-tests/src/main/java/com/cadl/naming/NamingClient.java @@ -43,7 +43,7 @@ public final class NamingClient { * Protocol method for POST operation. * * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @param dataRequest summary of Request + * @param body The body parameter. * @param name summary of name query parameter * @return summary of Response along with {@link Response}. * @throws ResourceModifiedException ResourceModifiedException thrown if the request is rejected by server on status @@ -56,8 +56,8 @@ public final class NamingClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response postWithResponse(String name, BinaryData dataRequest, RequestOptions requestOptions) { - return this.serviceClient.postWithResponse(name, dataRequest, requestOptions); + public Response postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponse(name, body, requestOptions); } /** @@ -91,9 +91,7 @@ public Response getAnonymousWithResponse(RequestOptions requestOptio * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @param body The body parameter. * @param etag summary of etag header parameter * * description of etag header parameter. @@ -107,13 +105,13 @@ public Response getAnonymousWithResponse(RequestOptions requestOptio */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public DataResponse post(String name, DataRequest dataRequest, String etag) { + public DataResponse post(String name, DataRequest body, String etag) { // Generated convenience method for postWithResponse RequestOptions requestOptions = new RequestOptions(); if (etag != null) { requestOptions.setHeader(HttpHeaderName.ETAG, etag); } - return postWithResponse(name, BinaryData.fromObject(dataRequest), requestOptions).getValue() + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).getValue() .toObject(DataResponse.class); } @@ -125,9 +123,7 @@ public DataResponse post(String name, DataRequest dataRequest, String etag) { * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @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. @@ -138,10 +134,10 @@ public DataResponse post(String name, DataRequest dataRequest, String etag) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public DataResponse post(String name, DataRequest dataRequest) { + public DataResponse post(String name, DataRequest body) { // Generated convenience method for postWithResponse RequestOptions requestOptions = new RequestOptions(); - return postWithResponse(name, BinaryData.fromObject(dataRequest), requestOptions).getValue() + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).getValue() .toObject(DataResponse.class); } diff --git a/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java b/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java index 7cb9e84888..7099e00ac3 100644 --- a/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java @@ -67,7 +67,7 @@ public interface NamingOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> post(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData dataRequest, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/naming") @@ -77,7 +77,7 @@ Mono> post(@HostParam("endpoint") String endpoint, @QueryPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response postSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData dataRequest, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Get("/naming") @@ -145,9 +145,7 @@ Response getAnonymousSync(@HostParam("endpoint") String endpoint, * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @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. @@ -156,11 +154,11 @@ Response getAnonymousSync(@HostParam("endpoint") String endpoint, * @return summary of Response along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> postWithResponseAsync(String name, BinaryData dataRequest, + public Mono> postWithResponseAsync(String name, BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil.withContext( - context -> service.post(this.client.getEndpoint(), name, accept, dataRequest, requestOptions, context)); + context -> service.post(this.client.getEndpoint(), name, accept, body, requestOptions, context)); } /** @@ -209,9 +207,7 @@ public Mono> postWithResponseAsync(String name, BinaryData * @param name summary of name query parameter * * description of name query parameter. - * @param dataRequest summary of Request - * - * description of Request. + * @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. @@ -220,9 +216,9 @@ public Mono> postWithResponseAsync(String name, BinaryData * @return summary of Response along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response postWithResponse(String name, BinaryData dataRequest, RequestOptions requestOptions) { + public Response postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.postSync(this.client.getEndpoint(), name, accept, dataRequest, requestOptions, Context.NONE); + return service.postSync(this.client.getEndpoint(), name, accept, body, requestOptions, Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java b/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java index 1cf27988c7..b85ecb9d6b 100644 --- a/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java @@ -60,7 +60,7 @@ public final class WireTypeAsyncClient { * } * } * - * @param subClass The subClass 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. @@ -70,9 +70,8 @@ public final class WireTypeAsyncClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> superClassMismatchWithResponse(BinaryData subClass, - RequestOptions requestOptions) { - return this.serviceClient.superClassMismatchWithResponseAsync(subClass, requestOptions); + public Mono> superClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.superClassMismatchWithResponseAsync(body, requestOptions); } /** @@ -95,7 +94,7 @@ public Mono> superClassMismatchWithResponse(BinaryData subC * } * } * - * @param subClassMismatch The subClassMismatch 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. @@ -105,9 +104,8 @@ public Mono> superClassMismatchWithResponse(BinaryData subC */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> subClassMismatchWithResponse(BinaryData subClassMismatch, - RequestOptions requestOptions) { - return this.serviceClient.subClassMismatchWithResponseAsync(subClassMismatch, requestOptions); + public Mono> subClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.subClassMismatchWithResponseAsync(body, requestOptions); } /** @@ -130,7 +128,7 @@ public Mono> subClassMismatchWithResponse(BinaryData subCla * } * } * - * @param subClassBothMismatch The subClassBothMismatch 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. @@ -140,15 +138,14 @@ public Mono> subClassMismatchWithResponse(BinaryData subCla */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> bothClassMismatchWithResponse(BinaryData subClassBothMismatch, - RequestOptions requestOptions) { - return this.serviceClient.bothClassMismatchWithResponseAsync(subClassBothMismatch, requestOptions); + public Mono> bothClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.bothClassMismatchWithResponseAsync(body, requestOptions); } /** * The superClassMismatch operation. * - * @param subClass The subClass 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. @@ -159,17 +156,17 @@ public Mono> bothClassMismatchWithResponse(BinaryData subCl */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono superClassMismatch(SubClass subClass) { + public Mono superClassMismatch(SubClass body) { // Generated convenience method for superClassMismatchWithResponse RequestOptions requestOptions = new RequestOptions(); - return superClassMismatchWithResponse(BinaryData.fromObject(subClass), requestOptions).flatMap(FluxUtil::toMono) + return superClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(SubClass.class)); } /** * The subClassMismatch operation. * - * @param subClassMismatch The subClassMismatch 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. @@ -180,18 +177,17 @@ public Mono superClassMismatch(SubClass subClass) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono subClassMismatch(SubClassMismatch subClassMismatch) { + public Mono subClassMismatch(SubClassMismatch body) { // Generated convenience method for subClassMismatchWithResponse RequestOptions requestOptions = new RequestOptions(); - return subClassMismatchWithResponse(BinaryData.fromObject(subClassMismatch), requestOptions) - .flatMap(FluxUtil::toMono) + return subClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(SubClassMismatch.class)); } /** * The bothClassMismatch operation. * - * @param subClassBothMismatch The subClassBothMismatch 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. @@ -202,11 +198,10 @@ public Mono subClassMismatch(SubClassMismatch subClassMismatch */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono bothClassMismatch(SubClassBothMismatch subClassBothMismatch) { + public Mono bothClassMismatch(SubClassBothMismatch body) { // Generated convenience method for bothClassMismatchWithResponse RequestOptions requestOptions = new RequestOptions(); - return bothClassMismatchWithResponse(BinaryData.fromObject(subClassBothMismatch), requestOptions) - .flatMap(FluxUtil::toMono) + return bothClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(SubClassBothMismatch.class)); } } diff --git a/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeClient.java b/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeClient.java index c738321afa..fc83bfc091 100644 --- a/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeClient.java +++ b/typespec-tests/src/main/java/com/cadl/wiretype/WireTypeClient.java @@ -58,7 +58,7 @@ public final class WireTypeClient { * } * } * - * @param subClass The subClass 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. @@ -68,8 +68,8 @@ public final class WireTypeClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response superClassMismatchWithResponse(BinaryData subClass, RequestOptions requestOptions) { - return this.serviceClient.superClassMismatchWithResponse(subClass, requestOptions); + public Response superClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.superClassMismatchWithResponse(body, requestOptions); } /** @@ -92,7 +92,7 @@ public Response superClassMismatchWithResponse(BinaryData subClass, * } * } * - * @param subClassMismatch The subClassMismatch 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. @@ -102,9 +102,8 @@ public Response superClassMismatchWithResponse(BinaryData subClass, */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response subClassMismatchWithResponse(BinaryData subClassMismatch, - RequestOptions requestOptions) { - return this.serviceClient.subClassMismatchWithResponse(subClassMismatch, requestOptions); + public Response subClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.subClassMismatchWithResponse(body, requestOptions); } /** @@ -127,7 +126,7 @@ public Response subClassMismatchWithResponse(BinaryData subClassMism * } * } * - * @param subClassBothMismatch The subClassBothMismatch 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. @@ -137,15 +136,14 @@ public Response subClassMismatchWithResponse(BinaryData subClassMism */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response bothClassMismatchWithResponse(BinaryData subClassBothMismatch, - RequestOptions requestOptions) { - return this.serviceClient.bothClassMismatchWithResponse(subClassBothMismatch, requestOptions); + public Response bothClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.bothClassMismatchWithResponse(body, requestOptions); } /** * The superClassMismatch operation. * - * @param subClass The subClass 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. @@ -156,17 +154,17 @@ public Response bothClassMismatchWithResponse(BinaryData subClassBot */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public SubClass superClassMismatch(SubClass subClass) { + public SubClass superClassMismatch(SubClass body) { // Generated convenience method for superClassMismatchWithResponse RequestOptions requestOptions = new RequestOptions(); - return superClassMismatchWithResponse(BinaryData.fromObject(subClass), requestOptions).getValue() + return superClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).getValue() .toObject(SubClass.class); } /** * The subClassMismatch operation. * - * @param subClassMismatch The subClassMismatch 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. @@ -177,17 +175,17 @@ public SubClass superClassMismatch(SubClass subClass) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public SubClassMismatch subClassMismatch(SubClassMismatch subClassMismatch) { + public SubClassMismatch subClassMismatch(SubClassMismatch body) { // Generated convenience method for subClassMismatchWithResponse RequestOptions requestOptions = new RequestOptions(); - return subClassMismatchWithResponse(BinaryData.fromObject(subClassMismatch), requestOptions).getValue() + return subClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).getValue() .toObject(SubClassMismatch.class); } /** * The bothClassMismatch operation. * - * @param subClassBothMismatch The subClassBothMismatch 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. @@ -198,10 +196,10 @@ public SubClassMismatch subClassMismatch(SubClassMismatch subClassMismatch) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public SubClassBothMismatch bothClassMismatch(SubClassBothMismatch subClassBothMismatch) { + public SubClassBothMismatch bothClassMismatch(SubClassBothMismatch body) { // Generated convenience method for bothClassMismatchWithResponse RequestOptions requestOptions = new RequestOptions(); - return bothClassMismatchWithResponse(BinaryData.fromObject(subClassBothMismatch), requestOptions).getValue() + return bothClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).getValue() .toObject(SubClassBothMismatch.class); } } diff --git a/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java b/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java index c539a58403..ef9a7b989f 100644 --- a/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java @@ -65,7 +65,7 @@ public interface WireTypeOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> superClassMismatch(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData subClass, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/superClassMismatch") @@ -75,7 +75,7 @@ Mono> superClassMismatch(@HostParam("endpoint") String endp @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response superClassMismatchSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData subClass, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/subClassMismatch") @@ -85,7 +85,7 @@ Response superClassMismatchSync(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> subClassMismatch(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData subClassMismatch, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/subClassMismatch") @@ -95,7 +95,7 @@ Mono> subClassMismatch(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response subClassMismatchSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData subClassMismatch, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/bothClassMismatch") @@ -105,7 +105,7 @@ Response subClassMismatchSync(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> bothClassMismatch(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData subClassBothMismatch, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/bothClassMismatch") @@ -115,7 +115,7 @@ Mono> bothClassMismatch(@HostParam("endpoint") String endpo @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response bothClassMismatchSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData subClassBothMismatch, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -139,7 +139,7 @@ Response bothClassMismatchSync(@HostParam("endpoint") String endpoin * } * } * - * @param subClass The subClass 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. @@ -148,11 +148,11 @@ Response bothClassMismatchSync(@HostParam("endpoint") String endpoin * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> superClassMismatchWithResponseAsync(BinaryData subClass, + public Mono> superClassMismatchWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.superClassMismatch(this.client.getEndpoint(), accept, subClass, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.superClassMismatch(this.client.getEndpoint(), accept, body, requestOptions, context)); } /** @@ -175,7 +175,7 @@ public Mono> superClassMismatchWithResponseAsync(BinaryData * } * } * - * @param subClass The subClass 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. @@ -184,10 +184,9 @@ public Mono> superClassMismatchWithResponseAsync(BinaryData * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response superClassMismatchWithResponse(BinaryData subClass, RequestOptions requestOptions) { + public Response superClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.superClassMismatchSync(this.client.getEndpoint(), accept, subClass, requestOptions, - Context.NONE); + return service.superClassMismatchSync(this.client.getEndpoint(), accept, body, requestOptions, Context.NONE); } /** @@ -210,7 +209,7 @@ public Response superClassMismatchWithResponse(BinaryData subClass, * } * } * - * @param subClassMismatch The subClassMismatch 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. @@ -219,11 +218,11 @@ public Response superClassMismatchWithResponse(BinaryData subClass, * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> subClassMismatchWithResponseAsync(BinaryData subClassMismatch, + public Mono> subClassMismatchWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.subClassMismatch(this.client.getEndpoint(), accept, - subClassMismatch, requestOptions, context)); + return FluxUtil.withContext( + context -> service.subClassMismatch(this.client.getEndpoint(), accept, body, requestOptions, context)); } /** @@ -246,7 +245,7 @@ public Mono> subClassMismatchWithResponseAsync(BinaryData s * } * } * - * @param subClassMismatch The subClassMismatch 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. @@ -255,11 +254,9 @@ public Mono> subClassMismatchWithResponseAsync(BinaryData s * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response subClassMismatchWithResponse(BinaryData subClassMismatch, - RequestOptions requestOptions) { + public Response subClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.subClassMismatchSync(this.client.getEndpoint(), accept, subClassMismatch, requestOptions, - Context.NONE); + return service.subClassMismatchSync(this.client.getEndpoint(), accept, body, requestOptions, Context.NONE); } /** @@ -282,7 +279,7 @@ public Response subClassMismatchWithResponse(BinaryData subClassMism * } * } * - * @param subClassBothMismatch The subClassBothMismatch 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. @@ -291,11 +288,11 @@ public Response subClassMismatchWithResponse(BinaryData subClassMism * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> bothClassMismatchWithResponseAsync(BinaryData subClassBothMismatch, + public Mono> bothClassMismatchWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.bothClassMismatch(this.client.getEndpoint(), accept, - subClassBothMismatch, requestOptions, context)); + return FluxUtil.withContext( + context -> service.bothClassMismatch(this.client.getEndpoint(), accept, body, requestOptions, context)); } /** @@ -318,7 +315,7 @@ public Mono> bothClassMismatchWithResponseAsync(BinaryData * } * } * - * @param subClassBothMismatch The subClassBothMismatch 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. @@ -327,10 +324,8 @@ public Mono> bothClassMismatchWithResponseAsync(BinaryData * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response bothClassMismatchWithResponse(BinaryData subClassBothMismatch, - RequestOptions requestOptions) { + public Response bothClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { final String accept = "application/json"; - return service.bothClassMismatchSync(this.client.getEndpoint(), accept, subClassBothMismatch, requestOptions, - Context.NONE); + return service.bothClassMismatchSync(this.client.getEndpoint(), accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/tsp/internal.tsp b/typespec-tests/tsp/internal.tsp index 207142c578..2da6ff253e 100644 --- a/typespec-tests/tsp/internal.tsp +++ b/typespec-tests/tsp/internal.tsp @@ -96,7 +96,7 @@ interface InternalOp { @access(Access.public, "python") @access(Access.internal, "client") @post - postInternal(...ApiRequest): ResponseInternal; + postInternal(@body body: ApiRequest): ResponseInternal; // test ApiResponse with Access.public @get diff --git a/typespec-tests/tsp/literal.tsp b/typespec-tests/tsp/literal.tsp index 753077f738..1f4edb036f 100644 --- a/typespec-tests/tsp/literal.tsp +++ b/typespec-tests/tsp/literal.tsp @@ -26,5 +26,5 @@ alias Request = { interface LiteralOp { @put @route("/put") - put(...Request, ...Model): Model; + put(...Request, @body body: Model): Model; } diff --git a/typespec-tests/tsp/lro.tsp b/typespec-tests/tsp/lro.tsp index faf3984a42..25de310334 100644 --- a/typespec-tests/tsp/lro.tsp +++ b/typespec-tests/tsp/lro.tsp @@ -34,7 +34,12 @@ namespace Cadl.LongRunning { @pollingOperation(LongRunning.getJob) @route("/jobs") - op createJob is LroLongRunningRpcOperation; + op createJob is LroLongRunningRpcOperation< + { + @body body: JobData; + }, + JobResult + >; model JobData { configuration?: string; diff --git a/typespec-tests/tsp/naming.tsp b/typespec-tests/tsp/naming.tsp index e692ef7357..17734726de 100644 --- a/typespec-tests/tsp/naming.tsp +++ b/typespec-tests/tsp/naming.tsp @@ -123,7 +123,7 @@ interface NamingOp { @summary("summary of POST op") @doc("description of POST op") @post - post(...Request): Response | ErrorResponse; + post(@bodyRoot body: Request): Response | ErrorResponse; getAnonymous(): { name: string; diff --git a/typespec-tests/tsp/wire-type.tsp b/typespec-tests/tsp/wire-type.tsp index 5e1e7aec06..6df766f1b3 100644 --- a/typespec-tests/tsp/wire-type.tsp +++ b/typespec-tests/tsp/wire-type.tsp @@ -37,13 +37,13 @@ model SubClassBothMismatch extends SuperClassMismatch { interface WireTypeOp { @route("/superClassMismatch") @put - superClassMismatch(...SubClass): SubClass; + superClassMismatch(@body body: SubClass): SubClass; @route("/subClassMismatch") @put - subClassMismatch(...SubClassMismatch): SubClassMismatch; + subClassMismatch(@body body: SubClassMismatch): SubClassMismatch; @route("/bothClassMismatch") @put - bothClassMismatch(...SubClassBothMismatch): SubClassBothMismatch; + bothClassMismatch(@body body: SubClassBothMismatch): SubClassBothMismatch; }