apigen.springboot
apigen.springboot copied to clipboard
bug: Patch with a property in the body that is an array of related ids fails to generate correct code
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());
}