class-transformer
class-transformer copied to clipboard
feat: extends discriminator lookup
Description
I truly appreciate the possibility to have polymorphic objects in my models. Unfortunately, it's not always possible to add a new specific property to make the discriminator lookup working and moreover, quite often the discriminator itself can already be found in the parent object (in my use cases at least).
My proposal is the following :
- add a
parentPropertyflag inDiscriminatorDescriptorto indicate if we should look for the discriminator in the parent - allow
DiscriminatorDescriptor.subTypes.nameto be string or a number - allow
DiscriminatorDescriptor.propertyto be either string or string[] to provide more complex path - create new helpers (
getDiscriminator,setFromDiscriminator,removeDiscriminator) inTransformOperationExecutor.tsto delegate lookup and object updates. - update
transformflow when the discriminator options are provided
Checklist
- [x] the pull request title describes what this PR does (not a vague title like
Update index.md) - [x] the pull request targets the default branch of the repository (
develop) - [x] the code follows the established code style of the repository
npm run prettier:checkpassesnpm run lint:checkpasses
- [x] tests are added for the changes I made (if any source code was modified)
- [x] documentation added or updated
- [x] I have run the project locally and verified that there are no errors
- [x] add extra unit tests in
custom-transform.spec
Fixes
fixes #857
Do you plan to review it ?
Is there have any update?
Please merge this PR
@NoNameProvided Hey, would it be possible for you to have a look at this PR, and/or eventually give your opinion on such a feature ?