From 846108e8fd6f595bb816c8c0a579ddc9fba9f56b Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Tue, 10 Mar 2015 14:30:01 +0530 Subject: [PATCH] Fill payload's body and schema with resolved asset --- src/drafter.coffee | 2 ++ test/fixtures/dataStructures.ast.json | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/drafter.coffee b/src/drafter.coffee index b8af2c2..3074dbf 100644 --- a/src/drafter.coffee +++ b/src/drafter.coffee @@ -55,6 +55,7 @@ generateBody = (payload, attributes, contentType, callback) -> content: body payload.content.push resolved + payload.body = body # For waterfall callback null, payload, attributes, contentType @@ -80,6 +81,7 @@ generateSchema = (payload, attributes, contentType, callback) -> content: body payload.content.push resolved + payload.schema = body # For waterfall callback null, payload, attributes, contentType diff --git a/test/fixtures/dataStructures.ast.json b/test/fixtures/dataStructures.ast.json index d8261a1..f0da241 100644 --- a/test/fixtures/dataStructures.ast.json +++ b/test/fixtures/dataStructures.ast.json @@ -59,8 +59,8 @@ "value": "application/json" } ], - "body": "", - "schema": "", + "body": "{\"id\":\"250FF\",\"percent_off\":25,\"redeem_by\":null,\"created\":null,\"modified\":null,\"created_at\":null,\"updated_at\":null}", + "schema": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"percent_off\":{\"type\":\"number\"},\"redeem_by\":{\"type\":\"number\",\"description\":\"Date after which the coupon can no longer be redeemed\"},\"created\":{\"type\":\"number\"},\"modified\":{\"type\":\"number\"},\"created_at\":{\"type\":\"number\"},\"updated_at\":{\"type\":\"number\"}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}", "content": [ { "element": "dataStructure", @@ -763,8 +763,8 @@ "value": "application/json" } ], - "body": "", - "schema": "", + "body": "{\"percent_off\":25,\"redeem_by\":null,\"created\":null,\"modified\":null,\"created_at\":null,\"updated_at\":null}", + "schema": "{\"type\":\"object\",\"properties\":{\"percent_off\":{\"type\":\"number\"},\"redeem_by\":{\"type\":\"number\",\"description\":\"Date after which the coupon can no longer be redeemed\"},\"created\":{\"type\":\"number\"},\"modified\":{\"type\":\"number\"},\"created_at\":{\"type\":\"number\"},\"updated_at\":{\"type\":\"number\"}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}", "content": [ { "element": "resolvedAsset", @@ -793,8 +793,8 @@ "value": "application/json" } ], - "body": "", - "schema": "", + "body": "{\"id\":\"250FF\",\"percent_off\":25,\"redeem_by\":null,\"created\":null,\"modified\":null,\"created_at\":null,\"updated_at\":null}", + "schema": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"percent_off\":{\"type\":\"number\"},\"redeem_by\":{\"type\":\"number\",\"description\":\"Date after which the coupon can no longer be redeemed\"},\"created\":{\"type\":\"number\"},\"modified\":{\"type\":\"number\"},\"created_at\":{\"type\":\"number\"},\"updated_at\":{\"type\":\"number\"}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}", "content": [ { "element": "dataStructure", @@ -2606,8 +2606,8 @@ "value": "application/json" } ], - "body": "", - "schema": "", + "body": "{\"id\":\"250FF\",\"percent_off\":25,\"redeem_by\":null,\"created\":null,\"modified\":null,\"created_at\":null,\"updated_at\":null}", + "schema": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"percent_off\":{\"type\":\"number\"},\"redeem_by\":{\"type\":\"number\",\"description\":\"Date after which the coupon can no longer be redeemed\"},\"created\":{\"type\":\"number\"},\"modified\":{\"type\":\"number\"},\"created_at\":{\"type\":\"number\"},\"updated_at\":{\"type\":\"number\"}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}", "content": [ { "element": "dataStructure", @@ -3310,8 +3310,8 @@ "value": "application/json" } ], - "body": "", - "schema": "", + "body": "{\"percent_off\":25,\"redeem_by\":null,\"created\":null,\"modified\":null,\"created_at\":null,\"updated_at\":null}", + "schema": "{\"type\":\"object\",\"properties\":{\"percent_off\":{\"type\":\"number\"},\"redeem_by\":{\"type\":\"number\",\"description\":\"Date after which the coupon can no longer be redeemed\"},\"created\":{\"type\":\"number\"},\"modified\":{\"type\":\"number\"},\"created_at\":{\"type\":\"number\"},\"updated_at\":{\"type\":\"number\"}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}", "content": [ { "element": "resolvedAsset", @@ -3340,8 +3340,8 @@ "value": "application/json" } ], - "body": "", - "schema": "", + "body": "{\"id\":\"250FF\",\"percent_off\":25,\"redeem_by\":null,\"created\":null,\"modified\":null,\"created_at\":null,\"updated_at\":null}", + "schema": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"percent_off\":{\"type\":\"number\"},\"redeem_by\":{\"type\":\"number\",\"description\":\"Date after which the coupon can no longer be redeemed\"},\"created\":{\"type\":\"number\"},\"modified\":{\"type\":\"number\"},\"created_at\":{\"type\":\"number\"},\"updated_at\":{\"type\":\"number\"}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}", "content": [ { "element": "dataStructure",