Skip to content

Commit 315519b

Browse files
http-client-java, bug fix on paged response (microsoft#8078)
fix microsoft#8071 also local test pass for quota (the tsp for this bug)
1 parent 689ef0e commit 315519b

File tree

11 files changed

+33
-25
lines changed

11 files changed

+33
-25
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"@typespec/streams": "0.72.1",
3232
"@azure-tools/typespec-azure-core": "0.58.0",
3333
"@azure-tools/typespec-client-generator-core": "0.58.0",
34-
"@azure-tools/typespec-azure-resource-manager": "0.58.0",
35-
"@azure-tools/typespec-autorest": "0.58.0"
34+
"@azure-tools/typespec-azure-resource-manager": "0.58.1",
35+
"@azure-tools/typespec-autorest": "0.58.1"
3636
},
3737
"private": true
3838
}

packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/SchemaUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,10 @@ public static String getDiscriminatorSerializedName(ObjectSchema compositeType)
178178
* @return whether response of the operation contains headers
179179
*/
180180
public static boolean responseContainsHeaderSchemas(Operation operation, JavaSettings settings) {
181-
if (operation.isLro() && (settings.isFluent() || settings.isDataPlaneClient())) {
181+
if ((operation.isLro() || operation.isPageable()) && (settings.isFluent() || settings.isDataPlaneClient())) {
182182
// Response headers will be omitted, as LRO method has return type as SyncPoller or PollerFlux, not
183183
// Response.
184+
// Same for pageable methods, as they return PagedFlux or PagedIterable. And PagedResponse contains headers.
184185
return false;
185186
}
186187
return operation.hasHeaderSchemaResponse();

packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armresourceprovider/fluent/ChildResourcesInterfacesClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ SyncPoller<PollResult<Void>, Void> beginDelete(String resourceGroupName, String
374374
* @throws IllegalArgumentException thrown if parameters fail the validation.
375375
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
376376
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
377-
* @return the response of a ChildResource list operation as paginated response with {@link PagedFlux}.
377+
* @return paged collection of ChildResource items as paginated response with {@link PagedFlux}.
378378
*/
379379
@ServiceMethod(returns = ReturnType.COLLECTION)
380380
PagedFlux<ChildResourceInner> listByTopLevelArmResourceAsync(String resourceGroupName,
@@ -388,7 +388,7 @@ PagedFlux<ChildResourceInner> listByTopLevelArmResourceAsync(String resourceGrou
388388
* @throws IllegalArgumentException thrown if parameters fail the validation.
389389
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
390390
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
391-
* @return the response of a ChildResource list operation as paginated response with {@link PagedIterable}.
391+
* @return paged collection of ChildResource items as paginated response with {@link PagedIterable}.
392392
*/
393393
@ServiceMethod(returns = ReturnType.COLLECTION)
394394
PagedIterable<ChildResourceInner> listByTopLevelArmResource(String resourceGroupName,
@@ -403,7 +403,7 @@ PagedIterable<ChildResourceInner> listByTopLevelArmResource(String resourceGroup
403403
* @throws IllegalArgumentException thrown if parameters fail the validation.
404404
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
405405
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
406-
* @return the response of a ChildResource list operation as paginated response with {@link PagedIterable}.
406+
* @return paged collection of ChildResource items as paginated response with {@link PagedIterable}.
407407
*/
408408
@ServiceMethod(returns = ReturnType.COLLECTION)
409409
PagedIterable<ChildResourceInner> listByTopLevelArmResource(String resourceGroupName,

packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,8 @@ public void delete(String resourceGroupName, String topLevelArmResourceName, Str
996996
* @throws IllegalArgumentException thrown if parameters fail the validation.
997997
* @throws ManagementException thrown if the request is rejected by server.
998998
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
999-
* @return the response of a ChildResource list operation along with {@link PagedResponse} on successful completion
1000-
* of {@link Mono}.
999+
* @return paged collection of ChildResource items along with {@link PagedResponse} on successful completion of
1000+
* {@link Mono}.
10011001
*/
10021002
@ServiceMethod(returns = ReturnType.SINGLE)
10031003
private Mono<PagedResponse<ChildResourceInner>> listByTopLevelArmResourceSinglePageAsync(String resourceGroupName,
@@ -1036,7 +1036,7 @@ private Mono<PagedResponse<ChildResourceInner>> listByTopLevelArmResourceSingleP
10361036
* @throws IllegalArgumentException thrown if parameters fail the validation.
10371037
* @throws ManagementException thrown if the request is rejected by server.
10381038
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1039-
* @return the response of a ChildResource list operation as paginated response with {@link PagedFlux}.
1039+
* @return paged collection of ChildResource items as paginated response with {@link PagedFlux}.
10401040
*/
10411041
@ServiceMethod(returns = ReturnType.COLLECTION)
10421042
public PagedFlux<ChildResourceInner> listByTopLevelArmResourceAsync(String resourceGroupName,
@@ -1054,7 +1054,7 @@ public PagedFlux<ChildResourceInner> listByTopLevelArmResourceAsync(String resou
10541054
* @throws IllegalArgumentException thrown if parameters fail the validation.
10551055
* @throws ManagementException thrown if the request is rejected by server.
10561056
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1057-
* @return the response of a ChildResource list operation along with {@link PagedResponse}.
1057+
* @return paged collection of ChildResource items along with {@link PagedResponse}.
10581058
*/
10591059
@ServiceMethod(returns = ReturnType.SINGLE)
10601060
private PagedResponse<ChildResourceInner> listByTopLevelArmResourceSinglePage(String resourceGroupName,
@@ -1094,7 +1094,7 @@ private PagedResponse<ChildResourceInner> listByTopLevelArmResourceSinglePage(St
10941094
* @throws IllegalArgumentException thrown if parameters fail the validation.
10951095
* @throws ManagementException thrown if the request is rejected by server.
10961096
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1097-
* @return the response of a ChildResource list operation along with {@link PagedResponse}.
1097+
* @return paged collection of ChildResource items along with {@link PagedResponse}.
10981098
*/
10991099
@ServiceMethod(returns = ReturnType.SINGLE)
11001100
private PagedResponse<ChildResourceInner> listByTopLevelArmResourceSinglePage(String resourceGroupName,
@@ -1133,7 +1133,7 @@ private PagedResponse<ChildResourceInner> listByTopLevelArmResourceSinglePage(St
11331133
* @throws IllegalArgumentException thrown if parameters fail the validation.
11341134
* @throws ManagementException thrown if the request is rejected by server.
11351135
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1136-
* @return the response of a ChildResource list operation as paginated response with {@link PagedIterable}.
1136+
* @return paged collection of ChildResource items as paginated response with {@link PagedIterable}.
11371137
*/
11381138
@ServiceMethod(returns = ReturnType.COLLECTION)
11391139
public PagedIterable<ChildResourceInner> listByTopLevelArmResource(String resourceGroupName,
@@ -1152,7 +1152,7 @@ public PagedIterable<ChildResourceInner> listByTopLevelArmResource(String resour
11521152
* @throws IllegalArgumentException thrown if parameters fail the validation.
11531153
* @throws ManagementException thrown if the request is rejected by server.
11541154
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1155-
* @return the response of a ChildResource list operation as paginated response with {@link PagedIterable}.
1155+
* @return paged collection of ChildResource items as paginated response with {@link PagedIterable}.
11561156
*/
11571157
@ServiceMethod(returns = ReturnType.COLLECTION)
11581158
public PagedIterable<ChildResourceInner> listByTopLevelArmResource(String resourceGroupName,
@@ -1405,8 +1405,8 @@ public void actionWithoutBody(String resourceGroupName, String topLevelArmResour
14051405
* @throws IllegalArgumentException thrown if parameters fail the validation.
14061406
* @throws ManagementException thrown if the request is rejected by server.
14071407
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1408-
* @return the response of a ChildResource list operation along with {@link PagedResponse} on successful completion
1409-
* of {@link Mono}.
1408+
* @return paged collection of ChildResource items along with {@link PagedResponse} on successful completion of
1409+
* {@link Mono}.
14101410
*/
14111411
@ServiceMethod(returns = ReturnType.SINGLE)
14121412
private Mono<PagedResponse<ChildResourceInner>> listByTopLevelArmResourceNextSinglePageAsync(String nextLink) {
@@ -1433,7 +1433,7 @@ private Mono<PagedResponse<ChildResourceInner>> listByTopLevelArmResourceNextSin
14331433
* @throws IllegalArgumentException thrown if parameters fail the validation.
14341434
* @throws ManagementException thrown if the request is rejected by server.
14351435
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1436-
* @return the response of a ChildResource list operation along with {@link PagedResponse}.
1436+
* @return paged collection of ChildResource items along with {@link PagedResponse}.
14371437
*/
14381438
@ServiceMethod(returns = ReturnType.SINGLE)
14391439
private PagedResponse<ChildResourceInner> listByTopLevelArmResourceNextSinglePage(String nextLink) {
@@ -1461,7 +1461,7 @@ private PagedResponse<ChildResourceInner> listByTopLevelArmResourceNextSinglePag
14611461
* @throws IllegalArgumentException thrown if parameters fail the validation.
14621462
* @throws ManagementException thrown if the request is rejected by server.
14631463
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
1464-
* @return the response of a ChildResource list operation along with {@link PagedResponse}.
1464+
* @return paged collection of ChildResource items along with {@link PagedResponse}.
14651465
*/
14661466
@ServiceMethod(returns = ReturnType.SINGLE)
14671467
private PagedResponse<ChildResourceInner> listByTopLevelArmResourceNextSinglePage(String nextLink,

packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armresourceprovider/implementation/models/ChildResourceListResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import tsptest.armresourceprovider.fluent.models.ChildResourceInner;
1616

1717
/**
18-
* The response of a ChildResource list operation.
18+
* Paged collection of ChildResource items.
1919
*/
2020
@Immutable
2121
public final class ChildResourceListResult implements JsonSerializable<ChildResourceListResult> {

packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armresourceprovider/models/ChildResourcesInterfaces.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Response<ChildResource> getWithResponse(String resourceGroupName, String topLeve
7373
* @throws IllegalArgumentException thrown if parameters fail the validation.
7474
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
7575
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
76-
* @return the response of a ChildResource list operation as paginated response with {@link PagedIterable}.
76+
* @return paged collection of ChildResource items as paginated response with {@link PagedIterable}.
7777
*/
7878
PagedIterable<ChildResource> listByTopLevelArmResource(String resourceGroupName, String topLevelArmResourceName);
7979

@@ -86,7 +86,7 @@ Response<ChildResource> getWithResponse(String resourceGroupName, String topLeve
8686
* @throws IllegalArgumentException thrown if parameters fail the validation.
8787
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
8888
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
89-
* @return the response of a ChildResource list operation as paginated response with {@link PagedIterable}.
89+
* @return paged collection of ChildResource items as paginated response with {@link PagedIterable}.
9090
*/
9191
PagedIterable<ChildResource> listByTopLevelArmResource(String resourceGroupName, String topLevelArmResourceName,
9292
Context context);

packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armresourceprovider-generated_apiview_properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"tsptest.armresourceprovider.fluent.models.TopLevelArmResourceUpdateProperties": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties",
133133
"tsptest.armresourceprovider.implementation.ArmClientBuilder": "TspTest.ArmResourceProvider",
134134
"tsptest.armresourceprovider.implementation.models.ChildExtensionResourceListResult": "Azure.ResourceManager.ResourceListResult",
135-
"tsptest.armresourceprovider.implementation.models.ChildResourceListResult": "Azure.ResourceManager.ResourceListResult",
135+
"tsptest.armresourceprovider.implementation.models.ChildResourceListResult": "TspTest.ArmResourceProvider.ChildResourceListResult",
136136
"tsptest.armresourceprovider.implementation.models.OperationListResult": "Azure.ResourceManager.CommonTypes.OperationListResult",
137137
"tsptest.armresourceprovider.implementation.models.ResourceListResult": "Azure.ResourceManager.ResourceListResult",
138138
"tsptest.armresourceprovider.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType",

packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armresourceprovider-generated_metadata.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/http-client-java/generator/http-client-generator-test/tsp/arm.tsp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,18 @@ model NginxConfigurationRequest {
264264
rootFile?: string;
265265
}
266266

267+
model ChildResourceListResult is Azure.Core.Page<ChildResource>;
268+
267269
//----------------------- Paths -----------------------
268270
@armResourceOperations
269271
interface ChildResourcesInterface
270272
extends ResourceInstanceOperations<ChildResource, ChildResourceProperties> {
271-
listByTopLevelArmResource is ArmResourceListByParent<ChildResource>;
273+
listByTopLevelArmResource is ArmResourceListByParent<
274+
ChildResource,
275+
Response = ArmResponse<ChildResourceListResult & {
276+
@header("ETag") eTag: string;
277+
}>
278+
>;
272279
actionWithoutBody is ArmResourceActionAsync<ChildResource, void, void>;
273280
}
274281

packages/http-client-java/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)