Mangopay / mangopay2-nodejs-sdk

Node.js SDK for MANGOPAY
https://www.npmjs.com/package/mangopay2-nodejs-sdk
MIT License
51 stars 38 forks source link

Json stringify of any object extending EntityBase will mute and remove the CreationDate attribute #345

Closed fredleroy closed 11 months ago

fredleroy commented 1 year ago

Hi,

We sometimes log entities returned by the sdk. Our logger (winston) stringifies those entities. In the toJSON method of the EntityBase in the sdk, there is a mutating instruction removing CreationDate:

https://github.com/Mangopay/mangopay2-nodejs-sdk/blob/c65e6dbcd2318fea36634f3a959529353ccf6a68/lib/models/EntityBase.js#L47

This is quite annoying to us. I believe there are good reasons for having this specific toJSON override and stripping the creationDate property (even though we would enjoy having this information in the logs) but what is really challenging for us is that the toJSON mutates the logged object.

If you really need to keep this overridden serializer, do you think there could be a possibility to clone the object serialized before removing any field to it ?

Regards,

fredericdelordm commented 11 months ago

Close and merged with #355