-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
ImprovementNew feature or requestNew feature or request
Description
If it's difference between API response and request body format,
- Response Body
{
"id": 1,
"username": "appleseed",
"image": {
"id": 42,
"url": "https://example.com/image.jpg"
}
}- Request Body
{
"id": 1,
"username": "appleseed",
"image": 42
}When decoding time, image will be Image class instance, but I don't want to encode it. I just want to send the image's id as image value in a request body.
Then EncodingKeys decorator works in just encoding time for property key mapping.
@EncodingKeys({
id: "id",
username: "username",
imageId: "image"
})
class Profile {
id: number;
username: string;
@CodableType(Image)
image: Image;
get imageId(): {
return this.image.id;
};
}This will be follows after encode.
{
"id": 1,
"username": "appleseed",
"image": 42
}Metadata
Metadata
Assignees
Labels
ImprovementNew feature or requestNew feature or request