diff --git a/.chronus/changes/fix-typespec-java-core-sync-2026-08-03-11-50-00.md b/.chronus/changes/fix-typespec-java-core-sync-2026-08-03-11-50-00.md new file mode 100644 index 0000000000..a0f512d652 --- /dev/null +++ b/.chronus/changes/fix-typespec-java-core-sync-2026-08-03-11-50-00.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-java" +--- + +Sync core to microsoft/typespec commit `2e1649b83`. Includes support for nested property paths and XML payloads in Azure pageable responses (core [#11504](https://github.com/microsoft/typespec/pull/11504)). diff --git a/packages/typespec-java/core-commit.json b/packages/typespec-java/core-commit.json index 2b72959897..57043c4c19 100644 --- a/packages/typespec-java/core-commit.json +++ b/packages/typespec-java/core-commit.json @@ -1 +1 @@ -{ "sha": "38de4f58cffc6429f8ae0234441cbc3b6b429777" } +{ "sha": "2e1649b83df10557748cde848af4c8300582285a" } diff --git a/packages/typespec-java/emitter-tests/Generate.ps1 b/packages/typespec-java/emitter-tests/Generate.ps1 index fcad8d5adc..1d411a4e7f 100644 --- a/packages/typespec-java/emitter-tests/Generate.ps1 +++ b/packages/typespec-java/emitter-tests/Generate.ps1 @@ -24,15 +24,6 @@ Write-Host "Parallelization: $Parallelization" $generateScript = { $tspFile = $_ - if ((($tspFile -match "payload[\\/]pageable[\\/]main\.tsp") -and (-not ($tspFile -match "azure[\\/]payload[\\/]pageable[\\/]main\.tsp")))) { - Write-Host " - SKIPPED - $tspFile - " - # nested pageItems/nextLink/continuationToken is not supported - return - } - $tspClientFile = $tspFile -replace 'main.tsp', 'client.tsp' if (($tspClientFile -match 'client.tsp$') -and (Test-Path $tspClientFile)) { $tspFile = $tspClientFile diff --git a/packages/typespec-java/emitter-tests/src/test/java/payload/pageable/PageableTests.java b/packages/typespec-java/emitter-tests/src/test/java/payload/pageable/PageableTests.java new file mode 100644 index 0000000000..10fa38a72d --- /dev/null +++ b/packages/typespec-java/emitter-tests/src/test/java/payload/pageable/PageableTests.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package payload.pageable; + +import com.azure.core.http.rest.PagedIterable; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import payload.pageable.models.Pet; +import payload.pageable.models.XmlPet; +import payload.pageable.serverdrivenpagination.alternateinitialverb.models.Filter; + +public class PageableTests { + + private final PageableClientBuilder builder = new PageableClientBuilder(); + + @Test + public void testLink() { + assertPetIds(builder.buildServerDrivenPaginationClient().link()); + } + + @Test + public void testLinkString() { + assertPetIds(builder.buildServerDrivenPaginationClient().linkString()); + } + + @Test + public void testNestedLink() { + assertPetIds(builder.buildServerDrivenPaginationClient().nestedLink()); + } + + @Test + public void testListWithoutContinuation() { + assertPetIds(builder.buildPageSizeClient().listWithoutContinuation()); + } + + @Test + public void testListWithPageSize() { + assertPetIds(builder.buildPageSizeClient().listWithPageSize(2), "1", "2"); + } + + @Test + public void testPost() { + assertPetIds(builder.buildServerDrivenPaginationAlternateInitialVerbClient().post(new Filter("foo eq bar"))); + } + + @Test + public void testXmlListWithNextLink() { + PagedIterable pagedIterable = builder.buildXmlPaginationClient().listWithNextLink(); + + Assertions.assertEquals(List.of("1", "2", "3", "4"), + pagedIterable.stream().map(XmlPet::getId).collect(Collectors.toList())); + } + + /* + * Continuation-token scenarios are intentionally not covered here. Azure V1 currently emits a single-page + * PagedIterable for them because it does not propagate a response continuation token into the next request. + * + * XML continuation-token paging is also intentionally not covered because it has the same token propagation + * limitation. + */ + + private static void assertPetIds(PagedIterable pagedIterable) { + assertPetIds(pagedIterable, "1", "2", "3", "4"); + } + + private static void assertPetIds(PagedIterable pagedIterable, String... expectedIds) { + Assertions.assertEquals(List.of(expectedIds), + pagedIterable.stream().map(Pet::getId).collect(Collectors.toList())); + } +}