Skip to content

Commit c51ad5f

Browse files
http-client-java: refresh Node.js deps and align regenerated file tests with new content-type API (#10667)
This updates `http-client-java` Node.js dependencies across the emitter and Java generator test packages, including lockfile and version-alignment metadata. It also addresses dependency-driven test compile breaks caused by generated API shape changes in file-content operations. - **Dependency refresh (emitter + Java test packages)** - Updated package versions in: - `packages/http-client-java/package.json` - `packages/http-client-java/generator/http-client-generator-test/package.json` - `packages/http-client-java/generator/http-client-generator-clientcore-test/package.json` - Refreshed `packages/http-client-java/package-lock.json`. - **Version alignment cleanup** - Synced root `peerDependencies` ranges to the updated root `devDependencies` baselines. - Synced `overrides` in both generator test package manifests to match root dependency versions. - **Regenerated Java test assets for updated specs** - Regenerated checked-in Java sources/resources impacted by `@typespec/http-specs` / `@azure-tools/azure-http-specs` updates in: - `http-client-generator-test` - `http-client-generator-clientcore-test` - **Build-break fix for regenerated file tests** - Updated both file test suites to use the current generated no-arg download API for multi-content-type file download, removing stale enum-based invocation. - Affected files: - `.../http-client-generator-test/src/test/java/type/file/FileTests.java` - `.../http-client-generator-clientcore-test/src/test/java/type/file/FileTests.java` ```java // before client.downloadFileMultipleContentTypes(DownloadFileMultipleContentTypesContentType.IMAGE_PNG); // after client.downloadFileMultipleContentTypes(); ``` - **Changelog** - Added a Chronus `dependencies` entry for `@typespec/http-client-java`. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
1 parent f475856 commit c51ad5f

86 files changed

Lines changed: 5508 additions & 633 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: dependencies
3+
packages:
4+
- "@typespec/http-client-java"
5+
---
6+
7+
Update http-client-java Node.js dependencies and regenerate Java test assets

packages/http-client-java/generator/http-client-generator-clientcore-test/package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414
"dependencies": {
1515
"@typespec/spector": "0.1.0-alpha.25",
1616
"@typespec/spec-api": "0.1.0-alpha.14",
17-
"@typespec/http-specs": "0.1.0-alpha.36",
18-
"@typespec/json-schema": "1.11.0",
17+
"@typespec/http-specs": "0.1.0-alpha.37",
18+
"@typespec/json-schema": "1.12.0",
1919
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.8.1.tgz",
2020
"@typespec/http-client-java-tests": "file:"
2121
},
2222
"overrides": {
23-
"@typespec/compiler": "1.11.0",
24-
"@typespec/http": "1.11.0",
25-
"@typespec/rest": "0.81.0",
26-
"@typespec/versioning": "0.81.0",
27-
"@typespec/openapi": "1.11.0",
28-
"@typespec/xml": "0.81.0",
29-
"@typespec/events": "0.81.0",
30-
"@typespec/sse": "0.81.0",
31-
"@typespec/streams": "0.81.0",
32-
"@azure-tools/typespec-azure-core": "0.67.1",
33-
"@azure-tools/typespec-client-generator-core": "0.67.3",
34-
"@azure-tools/typespec-azure-resource-manager": "0.67.1",
35-
"@azure-tools/typespec-autorest": "0.67.0"
23+
"@typespec/compiler": "1.12.0",
24+
"@typespec/http": "1.12.0",
25+
"@typespec/rest": "0.82.0",
26+
"@typespec/versioning": "0.82.0",
27+
"@typespec/openapi": "1.12.0",
28+
"@typespec/xml": "0.82.0",
29+
"@typespec/events": "0.82.0",
30+
"@typespec/sse": "0.82.0",
31+
"@typespec/streams": "0.82.0",
32+
"@azure-tools/typespec-azure-core": "0.68.0",
33+
"@azure-tools/typespec-client-generator-core": "0.68.0",
34+
"@azure-tools/typespec-azure-resource-manager": "0.68.0",
35+
"@azure-tools/typespec-autorest": "0.68.0"
3636
},
3737
"private": true
3838
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package payload.head;
2+
3+
import io.clientcore.core.annotations.Metadata;
4+
import io.clientcore.core.annotations.MetadataProperties;
5+
import io.clientcore.core.annotations.ReturnType;
6+
import io.clientcore.core.annotations.ServiceClient;
7+
import io.clientcore.core.annotations.ServiceMethod;
8+
import io.clientcore.core.http.models.HttpResponseException;
9+
import io.clientcore.core.http.models.RequestContext;
10+
import io.clientcore.core.http.models.Response;
11+
import io.clientcore.core.instrumentation.Instrumentation;
12+
import payload.head.implementation.HeadClientImpl;
13+
14+
/**
15+
* Initializes a new instance of the synchronous HeadClient type.
16+
*/
17+
@ServiceClient(builder = HeadClientBuilder.class)
18+
public final class HeadClient {
19+
@Metadata(properties = { MetadataProperties.GENERATED })
20+
private final HeadClientImpl serviceClient;
21+
22+
private final Instrumentation instrumentation;
23+
24+
/**
25+
* Initializes an instance of HeadClient class.
26+
*
27+
* @param serviceClient the service client implementation.
28+
* @param instrumentation the instrumentation instance.
29+
*/
30+
@Metadata(properties = { MetadataProperties.GENERATED })
31+
HeadClient(HeadClientImpl serviceClient, Instrumentation instrumentation) {
32+
this.serviceClient = serviceClient;
33+
this.instrumentation = instrumentation;
34+
}
35+
36+
/**
37+
* The contentTypeHeaderInResponse operation.
38+
*
39+
* @param requestContext The context to configure the HTTP request before HTTP client sends it.
40+
* @throws IllegalArgumentException thrown if parameters fail the validation.
41+
* @throws HttpResponseException thrown if the service returns an error.
42+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
43+
* @return the {@link Response}.
44+
*/
45+
@Metadata(properties = { MetadataProperties.GENERATED })
46+
@ServiceMethod(returns = ReturnType.SINGLE)
47+
public Response<Void> contentTypeHeaderInResponseWithResponse(RequestContext requestContext) {
48+
return this.instrumentation.instrumentWithResponse("Payload.Head.contentTypeHeaderInResponse", requestContext,
49+
updatedContext -> this.serviceClient.contentTypeHeaderInResponseWithResponse(updatedContext));
50+
}
51+
52+
/**
53+
* The contentTypeHeaderInResponse operation.
54+
*
55+
* @throws HttpResponseException thrown if the service returns an error.
56+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
57+
*/
58+
@Metadata(properties = { MetadataProperties.GENERATED })
59+
@ServiceMethod(returns = ReturnType.SINGLE)
60+
public void contentTypeHeaderInResponse() {
61+
contentTypeHeaderInResponseWithResponse(RequestContext.none());
62+
}
63+
}
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
package payload.head;
2+
3+
import io.clientcore.core.annotations.Metadata;
4+
import io.clientcore.core.annotations.MetadataProperties;
5+
import io.clientcore.core.annotations.ServiceClientBuilder;
6+
import io.clientcore.core.http.client.HttpClient;
7+
import io.clientcore.core.http.models.ProxyOptions;
8+
import io.clientcore.core.http.pipeline.HttpInstrumentationOptions;
9+
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
10+
import io.clientcore.core.http.pipeline.HttpPipeline;
11+
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
12+
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
13+
import io.clientcore.core.http.pipeline.HttpRedirectOptions;
14+
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
15+
import io.clientcore.core.http.pipeline.HttpRetryOptions;
16+
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
17+
import io.clientcore.core.instrumentation.Instrumentation;
18+
import io.clientcore.core.instrumentation.SdkInstrumentationOptions;
19+
import io.clientcore.core.traits.ConfigurationTrait;
20+
import io.clientcore.core.traits.EndpointTrait;
21+
import io.clientcore.core.traits.HttpTrait;
22+
import io.clientcore.core.traits.ProxyTrait;
23+
import io.clientcore.core.utils.CoreUtils;
24+
import io.clientcore.core.utils.configuration.Configuration;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
import java.util.Map;
28+
import java.util.Objects;
29+
import payload.head.implementation.HeadClientImpl;
30+
31+
/**
32+
* A builder for creating a new instance of the HeadClient type.
33+
*/
34+
@ServiceClientBuilder(serviceClients = { HeadClient.class })
35+
public final class HeadClientBuilder implements HttpTrait<HeadClientBuilder>, ProxyTrait<HeadClientBuilder>,
36+
ConfigurationTrait<HeadClientBuilder>, EndpointTrait<HeadClientBuilder> {
37+
@Metadata(properties = { MetadataProperties.GENERATED })
38+
private static final String SDK_NAME = "name";
39+
40+
@Metadata(properties = { MetadataProperties.GENERATED })
41+
private static final String SDK_VERSION = "version";
42+
43+
@Metadata(properties = { MetadataProperties.GENERATED })
44+
private static final Map<String, String> PROPERTIES = CoreUtils.getProperties("payload-head.properties");
45+
46+
@Metadata(properties = { MetadataProperties.GENERATED })
47+
private final List<HttpPipelinePolicy> pipelinePolicies;
48+
49+
/**
50+
* Create an instance of the HeadClientBuilder.
51+
*/
52+
@Metadata(properties = { MetadataProperties.GENERATED })
53+
public HeadClientBuilder() {
54+
this.pipelinePolicies = new ArrayList<>();
55+
}
56+
57+
/*
58+
* The HTTP client used to send the request.
59+
*/
60+
@Metadata(properties = { MetadataProperties.GENERATED })
61+
private HttpClient httpClient;
62+
63+
/**
64+
* {@inheritDoc}.
65+
*/
66+
@Metadata(properties = { MetadataProperties.GENERATED })
67+
@Override
68+
public HeadClientBuilder httpClient(HttpClient httpClient) {
69+
this.httpClient = httpClient;
70+
return this;
71+
}
72+
73+
/*
74+
* The retry options to configure retry policy for failed requests.
75+
*/
76+
@Metadata(properties = { MetadataProperties.GENERATED })
77+
private HttpRetryOptions retryOptions;
78+
79+
/**
80+
* {@inheritDoc}.
81+
*/
82+
@Metadata(properties = { MetadataProperties.GENERATED })
83+
@Override
84+
public HeadClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) {
85+
this.retryOptions = retryOptions;
86+
return this;
87+
}
88+
89+
/**
90+
* {@inheritDoc}.
91+
*/
92+
@Metadata(properties = { MetadataProperties.GENERATED })
93+
@Override
94+
public HeadClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) {
95+
Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null.");
96+
pipelinePolicies.add(customPolicy);
97+
return this;
98+
}
99+
100+
/*
101+
* The redirect options to configure redirect policy
102+
*/
103+
@Metadata(properties = { MetadataProperties.GENERATED })
104+
private HttpRedirectOptions redirectOptions;
105+
106+
/**
107+
* {@inheritDoc}.
108+
*/
109+
@Metadata(properties = { MetadataProperties.GENERATED })
110+
@Override
111+
public HeadClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) {
112+
this.redirectOptions = redirectOptions;
113+
return this;
114+
}
115+
116+
/*
117+
* The instrumentation configuration for HTTP requests and responses.
118+
*/
119+
@Metadata(properties = { MetadataProperties.GENERATED })
120+
private HttpInstrumentationOptions httpInstrumentationOptions;
121+
122+
/**
123+
* {@inheritDoc}.
124+
*/
125+
@Metadata(properties = { MetadataProperties.GENERATED })
126+
@Override
127+
public HeadClientBuilder httpInstrumentationOptions(HttpInstrumentationOptions httpInstrumentationOptions) {
128+
this.httpInstrumentationOptions = httpInstrumentationOptions;
129+
return this;
130+
}
131+
132+
/*
133+
* The proxy options used during construction of the service client.
134+
*/
135+
@Metadata(properties = { MetadataProperties.GENERATED })
136+
private ProxyOptions proxyOptions;
137+
138+
/**
139+
* {@inheritDoc}.
140+
*/
141+
@Metadata(properties = { MetadataProperties.GENERATED })
142+
@Override
143+
public HeadClientBuilder proxyOptions(ProxyOptions proxyOptions) {
144+
this.proxyOptions = proxyOptions;
145+
return this;
146+
}
147+
148+
/*
149+
* The configuration store that is used during construction of the service client.
150+
*/
151+
@Metadata(properties = { MetadataProperties.GENERATED })
152+
private Configuration configuration;
153+
154+
/**
155+
* {@inheritDoc}.
156+
*/
157+
@Metadata(properties = { MetadataProperties.GENERATED })
158+
@Override
159+
public HeadClientBuilder configuration(Configuration configuration) {
160+
this.configuration = configuration;
161+
return this;
162+
}
163+
164+
/*
165+
* The service endpoint
166+
*/
167+
@Metadata(properties = { MetadataProperties.GENERATED })
168+
private String endpoint;
169+
170+
/**
171+
* {@inheritDoc}.
172+
*/
173+
@Metadata(properties = { MetadataProperties.GENERATED })
174+
@Override
175+
public HeadClientBuilder endpoint(String endpoint) {
176+
this.endpoint = endpoint;
177+
return this;
178+
}
179+
180+
/**
181+
* Builds an instance of HeadClientImpl with the provided parameters.
182+
*
183+
* @return an instance of HeadClientImpl.
184+
*/
185+
@Metadata(properties = { MetadataProperties.GENERATED })
186+
private HeadClientImpl buildInnerClient() {
187+
this.validateClient();
188+
String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000";
189+
HttpInstrumentationOptions localHttpInstrumentationOptions = this.httpInstrumentationOptions == null
190+
? new HttpInstrumentationOptions()
191+
: this.httpInstrumentationOptions;
192+
SdkInstrumentationOptions sdkInstrumentationOptions
193+
= new SdkInstrumentationOptions(PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"))
194+
.setSdkVersion(PROPERTIES.get(SDK_VERSION))
195+
.setEndpoint(localEndpoint);
196+
Instrumentation instrumentation
197+
= Instrumentation.create(localHttpInstrumentationOptions, sdkInstrumentationOptions);
198+
HeadClientImpl client = new HeadClientImpl(createHttpPipeline(), instrumentation, localEndpoint);
199+
return client;
200+
}
201+
202+
@Metadata(properties = { MetadataProperties.GENERATED })
203+
private void validateClient() {
204+
// This method is invoked from 'buildInnerClient'/'buildClient' method.
205+
// Developer can customize this method, to validate that the necessary conditions are met for the new client.
206+
}
207+
208+
@Metadata(properties = { MetadataProperties.GENERATED })
209+
private HttpPipeline createHttpPipeline() {
210+
Configuration buildConfiguration
211+
= (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
212+
HttpInstrumentationOptions localHttpInstrumentationOptions = this.httpInstrumentationOptions == null
213+
? new HttpInstrumentationOptions()
214+
: this.httpInstrumentationOptions;
215+
HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder();
216+
List<HttpPipelinePolicy> policies = new ArrayList<>();
217+
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
218+
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
219+
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
220+
policies.add(new HttpInstrumentationPolicy(localHttpInstrumentationOptions));
221+
policies.forEach(httpPipelineBuilder::addPolicy);
222+
return httpPipelineBuilder.httpClient(httpClient).build();
223+
}
224+
225+
/**
226+
* Builds an instance of HeadClient class.
227+
*
228+
* @return an instance of HeadClient.
229+
*/
230+
@Metadata(properties = { MetadataProperties.GENERATED })
231+
public HeadClient buildClient() {
232+
HeadClientImpl innerClient = buildInnerClient();
233+
return new HeadClient(innerClient, innerClient.getInstrumentation());
234+
}
235+
}

0 commit comments

Comments
 (0)