Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http-client-java, migrate to http-specs #5215

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/http-client-java/eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ try {
if (!(Test-Path $coverageReportDir)) {
New-Item -ItemType Directory -Path $coverageReportDir

$sourceFile = Join-Path $packageRoot 'generator/http-client-generator-test/cadl-ranch-coverage-java-standard.json'
$targetFile = Join-Path $coverageReportDir 'cadl-ranch-coverage-java-standard.json'
$sourceFile = Join-Path $packageRoot 'generator/http-client-generator-test/tsp-spector-coverage-java-standard.json'
$targetFile = Join-Path $coverageReportDir 'tsp-spector-coverage-java-standard.json'
Copy-Item $sourceFile -Destination $targetFile
}
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ Set-StrictMode -Version 3.0
Write-Host "Running cadl ranch tests"

Write-Host "Starting the test server"
npm run testserver-start
npm run http-specs-start
npm run azure-http-specs-start
Write-Host "Compile and run the tests"
mvn clean test --no-transfer-progress -T 1C
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Write-Host "Stopping the test server"
npm run testserver-stop
npm run http-specs-stop
npm run azure-http-specs-stop

Write-Host "Finished running the cadl ranch tests"
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,18 @@ npx tsp compile ./tsp/partialupdate.tsp --option="@typespec/http-client-java.emi
Copy-Item -Path ./existingcode/src/main/java/tsptest/partialupdate -Destination ./src/main/java/tsptest/partialupdate -Recurse -Force
Remove-Item ./existingcode -Recurse -Force

# run cadl ranch tests sources
Copy-Item -Path node_modules/@azure-tools/cadl-ranch-specs/http -Destination ./ -Recurse -Force
# run http-specs / azure-http-specs tests sources
Copy-Item -Path node_modules/@typespec/http-specs/specs -Destination ./ -Recurse -Force
Copy-Item -Path node_modules/@azure-tools/azure-http-specs/specs -Destination ./ -Recurse -Force
# remove xml tests, emitter has not supported xml model
Remove-Item ./http/payload/xml -Recurse -Force
Remove-Item ./specs/payload/xml -Recurse -Force

$job = (Get-ChildItem ./http -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob
$job = (Get-ChildItem ./specs -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob

$job | Wait-Job -Timeout 1200
$job | Receive-Job

Remove-Item ./http -Recurse -Force
Remove-Item ./specs -Recurse -Force

Copy-Item -Path ./tsp-output/*/src -Destination ./ -Recurse -Force -Exclude @("ReadmeSamples.java", "module-info.java")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
"format": "npm run -s prettier -- --write",
"check-format": "npm run prettier -- --check",
"prettier": "prettier --config ./.prettierrc.yaml **/*.tsp",
"testserver-run": "cadl-ranch serve ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java-standard.json",
"testserver-start": "cadl-ranch server start ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java-standard.json",
"testserver-stop": "cadl-ranch server stop"
"http-specs-run": "tsp-spector serve ./node_modules/@typespec/http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json",
"http-specs-start": "tsp-spector server start ./node_modules/@typespec/http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json",
"http-specs-stop": "tsp-spector server stop",
"azure-http-specs-run": "tsp-spector serve ./node_modules/@azure-tools/azure-http-specs/specs --port 3001 --coverageFile ./tsp-spector-coverage-java-azure.json",
"azure-http-specs-start": "tsp-spector server start ./node_modules/@azure-tools/azure-http-specs/specs --port 3001 --coverageFile ./tsp-spector-coverage-java-azure.json",
"azure-http-specs-stop": "tsp-spector server stop"
},
"dependencies": {
"@azure-tools/cadl-ranch-specs": "0.39.4",
"@typespec/http-specs": "0.1.0-alpha.2",
"@azure-tools/azure-http-specs": "0.1.0-alpha.2",
"@typespec/http-client-java": "file:/../../typespec-http-client-java-0.1.2.tgz",
"@typespec/http-client-java-tests": "file:"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Mono<Response<BinaryData>> operationWithResponse(String name, RequestOptions req
}

/**
* Expected query parameter: kind= "real"
* Expected query parameter: kind="real"
* Expected response body:
* ```json
* {
Expand Down Expand Up @@ -147,7 +147,7 @@ Mono<OuterModel> operation(String name) {
}

/**
* Expected query parameter: kind= "real"
* Expected query parameter: kind="real"
* Expected response body:
* ```json
* {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Response<BinaryData> operationWithResponse(String name, RequestOptions requestOp
}

/**
* Expected query parameter: kind= "real"
* Expected query parameter: kind="real"
* Expected response body:
* ```json
* {
Expand Down Expand Up @@ -141,7 +141,7 @@ OuterModel operation(String name) {
}

/**
* Expected query parameter: kind= "real"
* Expected query parameter: kind="real"
* Expected response body:
* ```json
* {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public Response<BinaryData> operationWithResponse(String name, RequestOptions re
}

/**
* Expected query parameter: kind= "real"
* Expected query parameter: kind="real"
* Expected response body:
* ```json
* {
Expand Down Expand Up @@ -213,7 +213,7 @@ public Mono<Response<BinaryData>> discriminatorWithResponseAsync(String kind, Re
}

/**
* Expected query parameter: kind= "real"
* Expected query parameter: kind="real"
* Expected response body:
* ```json
* {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package type.model.templated;

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 reactor.core.publisher.Mono;
import type.model.templated.implementation.TemplatedClientImpl;
import type.model.templated.models.Float32ValuesType;
import type.model.templated.models.Int32Type;
import type.model.templated.models.Int32ValuesType;

/**
* Initializes a new instance of the asynchronous TemplatedClient type.
*/
@ServiceClient(builder = TemplatedClientBuilder.class, isAsync = true)
public final class TemplatedAsyncClient {
@Generated
private final TemplatedClientImpl serviceClient;

/**
* Initializes an instance of TemplatedAsyncClient class.
*
* @param serviceClient the service client implementation.
*/
@Generated
TemplatedAsyncClient(TemplatedClientImpl serviceClient) {
this.serviceClient = serviceClient;
}

/**
* The numericType operation.
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
* {@code
* {
* values (Required): [
* int (Required)
* ]
* value: int (Required)
* }
* }
* </pre>
*
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* values (Required): [
* int (Required)
* ]
* value: int (Required)
* }
* }
* </pre>
*
* @param input The input 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.
* @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<Response<BinaryData>> numericTypeWithResponse(BinaryData input, RequestOptions requestOptions) {
return this.serviceClient.numericTypeWithResponseAsync(input, requestOptions);
}

/**
* The float32Type operation.
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
* {@code
* {
* values (Required): [
* double (Required)
* ]
* value: double (Required)
* kind: String (Required)
* }
* }
* </pre>
*
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* values (Required): [
* double (Required)
* ]
* value: double (Required)
* kind: String (Required)
* }
* }
* </pre>
*
* @param input The input 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.
* @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 instantiated type representing float32 values type along with {@link Response} on successful
* completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> float32TypeWithResponse(BinaryData input, RequestOptions requestOptions) {
return this.serviceClient.float32TypeWithResponseAsync(input, requestOptions);
}

/**
* The int32Type operation.
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
* {@code
* {
* values (Required): [
* int (Required)
* ]
* value: int (Required)
* kind: String (Required)
* }
* }
* </pre>
*
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* values (Required): [
* int (Required)
* ]
* value: int (Required)
* kind: String (Required)
* }
* }
* </pre>
*
* @param input The input 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.
* @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 instantiated type representing int32 values type along with {@link Response} on successful completion
* of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> int32TypeWithResponse(BinaryData input, RequestOptions requestOptions) {
return this.serviceClient.int32TypeWithResponseAsync(input, requestOptions);
}

/**
* The numericType operation.
*
* @param input The input 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.
* @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<Int32Type> numericType(Int32Type input) {
// Generated convenience method for numericTypeWithResponse
RequestOptions requestOptions = new RequestOptions();
return numericTypeWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(Int32Type.class));
}

/**
* The float32Type operation.
*
* @param input The input 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.
* @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 instantiated type representing float32 values type on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Float32ValuesType> float32Type(Float32ValuesType input) {
// Generated convenience method for float32TypeWithResponse
RequestOptions requestOptions = new RequestOptions();
return float32TypeWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(Float32ValuesType.class));
}

/**
* The int32Type operation.
*
* @param input The input 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.
* @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 instantiated type representing int32 values type on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Int32ValuesType> int32Type(Int32ValuesType input) {
// Generated convenience method for int32TypeWithResponse
RequestOptions requestOptions = new RequestOptions();
return int32TypeWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(Int32ValuesType.class));
}
}
Loading
Loading