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

Accept `2022-08-26T18:38:00.0000000Z` (7 fractional digit ticks, as emitted by .NET clients) as a valid RFC3339 UTC datetime form in the `ModelWithDatetime` XML scenario.
22 changes: 20 additions & 2 deletions packages/http-specs/specs/payload/xml/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ const modelWithDatetimeNoMs = `
</ModelWithDatetime>
`;

// Some clients (e.g. .NET) serialize UTC datetimes with 7 fractional digit ticks.
// "2022-08-26T18:38:00.0000000Z" is a valid representation of the same instant; accept it too.
const modelWithDatetimeWindowsMs = `
<ModelWithDatetime>
<rfc3339>2022-08-26T18:38:00.0000000Z</rfc3339>
<rfc7231>Fri, 26 Aug 2022 14:38:00 GMT</rfc7231>
</ModelWithDatetime>
`;

function createServerTests(uri: string, data?: any) {
return {
get: passOnSuccess({
Expand Down Expand Up @@ -280,15 +289,24 @@ Scenarios.Payload_Xml_ModelWithDatetimeValue_put = passOnSuccess({
},
handler: (req: MockRequest) => {
req.expect.containsHeader("content-type", "application/xml");
// Accept both "2022-08-26T18:38:00.000Z" and "2022-08-26T18:38:00Z" as equivalent UTC datetimes.
// Accept "2022-08-26T18:38:00.000Z", "2022-08-26T18:38:00Z", and
// "2022-08-26T18:38:00.0000000Z" as equivalent UTC datetimes.
let firstError: unknown;
try {
req.expect.xmlBodyEquals(modelWithDatetime);
} catch (e) {
firstError = e;
}
if (firstError !== undefined) {
req.expect.xmlBodyEquals(modelWithDatetimeNoMs);
let secondError: unknown;
try {
req.expect.xmlBodyEquals(modelWithDatetimeNoMs);
} catch (e) {
secondError = e;
}
if (secondError !== undefined) {
req.expect.xmlBodyEquals(modelWithDatetimeWindowsMs);
}
}
return {
status: 204,
Expand Down
Loading