Skip to content

bug: Patch with a property in the body that is an array of related ids fails to generate correct code #21

@devdevx

Description

@devdevx

Current behavior:

The generated code didn't work properly and not updates the sub element list relations.

Expected behavior:

The generated code updates correctly the sub element list relations.

Steps to reproduce:

Given a generated code of a main entity (ex: Message) related many to many with another entity (ex: Tag), if we cant to update the Message resource to be related to different Tags, the code generated is wrong.

Patch body:

{
"tags": [{"id": 1}, {"id": 2}]
}

The expected code generated in the mapper should be

    public abstract void partialUpdate(PartialUpdateMessageByIdResource source,
            @MappingTarget Message target);

    public abstract Set<MessageTag> maMessageTags(Set<PartialUpdateMessageByIdResource.Tags> resource);

    public MessageTag map(PartialUpdateMessageByIdResource.Tags resource) {
        if (resource null || resource.getId() null) return null;
        return new MessageTag(resource.getId());
    }

instead it only generates

    public abstract void partialUpdate(PartialUpdateMessageByIdResource source,
            @MappingTarget Message target);

    public MessageTag map(PartialUpdateMessageByIdResource.Tags resource) {
        if (resource null || resource.getId() null) return null;
        return new MessageTag(resource.getId());
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions