Skip to content

Commit ea14b6d

Browse files
committed
fix preserve string date fields
1 parent f3084ba commit ea14b6d

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/gen/model/accounting/models.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,7 @@ export class ObjectSerializer {
579579
if (data == undefined) {
580580
return data;
581581
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
582-
if (type === "string" && data.toString().substring(0, 6) === "/Date(") {
583-
return this.deserializeDateFormats(type, data) // For MS dates that are of type 'string'
584-
}
585-
else {
586-
return data;
587-
}
582+
return data;
588583
} else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
589584
let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
590585
subType = subType.substring(0, subType.length - 1); // Type> => Type

src/test/objectSerializer.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ObjectSerializer } from '../gen/model/accounting/models';
2+
3+
describe('ObjectSerializer', () => {
4+
it('preserves invoice date fields as strings during deserialization', () => {
5+
const invoice = ObjectSerializer.deserialize(
6+
{
7+
Date: '/Date(1743638400000+0000)/',
8+
DueDate: '/Date(1743724800000+0000)/',
9+
},
10+
'Invoice',
11+
);
12+
13+
expect(invoice.date).toBe('/Date(1743638400000+0000)/');
14+
expect(invoice.dueDate).toBe('/Date(1743724800000+0000)/');
15+
});
16+
});

0 commit comments

Comments
 (0)