Skip to content
Draft
Changes from 2 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
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