Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/http-specs"
---

Add test for xml pagination with next link
7 changes: 7 additions & 0 deletions .chronus/changes/specs-xmlPaging-2026-0-23-15-43-39.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/http-specs"
---

Add test for xml paging
98 changes: 98 additions & 0 deletions packages/http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -2835,6 +2835,104 @@ Two requests need to be tested.
}
```

### Payload_Pageable_XmlPagination_listWithContinuation

- Endpoint: `get /payload/pageable/xml/list-with-continuation`

Test case for XML pagination with continuation token. Continuation token is passed in the request query and response body.

Two requests need to be tested.

1. Initial request:
Expected route: /payload/pageable/xml/list

Expected response body:

```xml
<PetListResult>
<Pets>
<Pet>
<Id>1</Id>
<Name>dog</Name>
</Pet>
<Pet>
<Id>2</Id>
<Name>cat</Name>
</Pet>
</Pets>
<NextMarker>page2</NextMarker>
</PetListResult>
```

2. Next page request:
Expected route: /payload/pageable/xml/list?marker=page2

Expected response body:

```xml
<PetListResult>
<Pets>
<Pet>
<Id>3</Id>
<Name>bird</Name>
</Pet>
<Pet>
<Id>4</Id>
<Name>fish</Name>
</Pet>
</Pets>
</PetListResult>
```

### Payload_Pageable_XmlPagination_listWithNextLink

- Endpoint: `get /payload/pageable/xml/list-with-next-link`

Test case for XML pagination with next link.

Two requests need to be tested.

1. Initial request:
Expected route: /payload/pageable/xml/list-with-next-link

Expected response body:

```xml
<PetListResult>
<Pets>
<Pet>
<Id>1</Id>
<Name>dog</Name>
</Pet>
<Pet>
<Id>2</Id>
<Name>cat</Name>
</Pet>
</Pets>
<NextLink>http://[host]:[port]/payload/pageable/xml/list-with-next-link/nextPage</NextLink>
</PetListResult>
```

2. Next page request:
Expected route: /payload/pageable/xml/list-with-next-link/nextPage

Expected response body:

```xml
<PetListResult>
<Pets>
<Pet>
<Id>3</Id>
<Name>bird</Name>
</Pet>
<Pet>
<Id>4</Id>
<Name>fish</Name>
</Pet>
</Pets>
</PetListResult>
```

### Payload_Xml_ModelWithArrayOfModelValue_get

- Endpoint: `get /payload/xml/modelWithArrayOfModel`
Expand Down
140 changes: 140 additions & 0 deletions packages/http-specs/specs/payload/pageable/main.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import "@typespec/http";
import "@typespec/spector";
import "@typespec/xml";

using Http;
using Spector;
using Xml;

/**
* Test for pageable payload.
Expand Down Expand Up @@ -514,3 +516,141 @@ namespace PageSize {
pets: Pet[];
};
}

@doc("An XML pet item.")
@name("Pet")
model XmlPet {
@name("Id") id: string;
@name("Name") name: string;
}

@route("/xml")
namespace XmlPagination {
@scenario
@scenarioDoc("""
Test case for XML pagination with continuation token. Continuation token is passed in the request query and response body.

Two requests need to be tested.

1. Initial request:
Expected route: /payload/pageable/xml/list

Expected response body:
```xml
<PetListResult>
<Pets>
<Pet>
<Id>1</Id>
<Name>dog</Name>
</Pet>
<Pet>
<Id>2</Id>
<Name>cat</Name>
</Pet>
</Pets>
<NextMarker>page2</NextMarker>
</PetListResult>
```

2. Next page request:
Expected route: /payload/pageable/xml/list?marker=page2

Expected response body:
```xml
<PetListResult>
<Pets>
<Pet>
<Id>3</Id>
<Name>bird</Name>
</Pet>
<Pet>
<Id>4</Id>
<Name>fish</Name>
</Pet>
</Pets>
</PetListResult>
```
""")
@route("/list-with-continuation")
@list
op listWithContinuation(@continuationToken @query marker?: string): {
@header("content-type") contentType: "application/xml";
@body body: XmlPetListResult;
};

@scenario
@scenarioDoc("""
Test case for XML pagination with next link.

Two requests need to be tested.

1. Initial request:
Expected route: /payload/pageable/xml/list-with-next-link

Expected response body:
```xml
<PetListResult>
<Pets>
<Pet>
<Id>1</Id>
<Name>dog</Name>
</Pet>
<Pet>
<Id>2</Id>
<Name>cat</Name>
</Pet>
</Pets>
<NextLink>http://[host]:[port]/payload/pageable/xml/list-with-next-link/nextPage</NextLink>
</PetListResult>
```

2. Next page request:
Expected route: /payload/pageable/xml/list-with-next-link/nextPage

Expected response body:
```xml
<PetListResult>
<Pets>
<Pet>
<Id>3</Id>
<Name>bird</Name>
</Pet>
<Pet>
<Id>4</Id>
<Name>fish</Name>
</Pet>
</Pets>
</PetListResult>
```
""")
@route("/list-with-next-link")
@list
op listWithNextLink(): {
@header("content-type") contentType: "application/xml";
@body body: XmlPetListResultWithNextLink;
};
}

@doc("The XML response for listing pets.")
@name("PetListResult")
model XmlPetListResult {
@pageItems
@name("Pets")
pets: XmlPet[];

@continuationToken
@name("NextMarker")
nextMarker?: string;
}

@doc("The XML response for listing pets with next link.")
@name("PetListResult")
model XmlPetListResultWithNextLink {
@pageItems
@name("Pets")
pets: XmlPet[];

@nextLink
@name("NextLink")
nextLink?: url;
}
Loading
Loading