Spaces:
Running
Running
Hozifa Elgharbawy
commited on
Commit
·
e22ef60
1
Parent(s):
6e7faac
Serialize ingredients in MealPopulateSerialization
Browse files
src/common/serializers/mealPopulate.serialization.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
-
import { Expose } from "class-transformer";
|
2 |
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
3 |
import { IngredientSerialization } from "./ingredient.serialization";
|
|
|
4 |
|
5 |
|
6 |
export class MealPopulateSerialization {
|
7 |
@Expose({ name: "_id" })
|
8 |
@SwaggerResponseProperty({ type: "string" })
|
9 |
id: string;
|
10 |
-
|
11 |
@Expose()
|
12 |
@SwaggerResponseProperty({ type: "string" })
|
13 |
name: string;
|
@@ -18,6 +19,9 @@ export class MealPopulateSerialization {
|
|
18 |
|
19 |
@Expose()
|
20 |
@SwaggerResponseProperty({ type: [IngredientSerialization] })
|
|
|
|
|
|
|
21 |
ingredients: any;
|
22 |
|
23 |
@Expose()
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
3 |
import { IngredientSerialization } from "./ingredient.serialization";
|
4 |
+
import { serialize } from "@helpers/serialize";
|
5 |
|
6 |
|
7 |
export class MealPopulateSerialization {
|
8 |
@Expose({ name: "_id" })
|
9 |
@SwaggerResponseProperty({ type: "string" })
|
10 |
id: string;
|
11 |
+
|
12 |
@Expose()
|
13 |
@SwaggerResponseProperty({ type: "string" })
|
14 |
name: string;
|
|
|
19 |
|
20 |
@Expose()
|
21 |
@SwaggerResponseProperty({ type: [IngredientSerialization] })
|
22 |
+
@Transform(
|
23 |
+
({ value }) => serialize(value, IngredientSerialization)
|
24 |
+
)
|
25 |
ingredients: any;
|
26 |
|
27 |
@Expose()
|