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
7 changes: 1 addition & 6 deletions src/gen/model/accounting/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,7 @@ export class ObjectSerializer {
if (data == undefined) {
return data;
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
if (type === "string" && data.toString().substring(0, 6) === "/Date(") {
return this.deserializeDateFormats(type, data) // For MS dates that are of type 'string'
}
else {
return data;
}
return data;
} else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
subType = subType.substring(0, subType.length - 1); // Type> => Type
Expand Down
16 changes: 16 additions & 0 deletions src/test/objectSerializer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ObjectSerializer } from '../gen/model/accounting/models';

describe('ObjectSerializer', () => {
it('preserves invoice date fields as strings during deserialization', () => {
const invoice = ObjectSerializer.deserialize(
{
Date: '/Date(1743638400000+0000)/',
DueDate: '/Date(1743724800000+0000)/',
},
'Invoice',
);

expect(invoice.date).toBe('/Date(1743638400000+0000)/');
expect(invoice.dueDate).toBe('/Date(1743724800000+0000)/');
});
});