Skip to content

Commit

Permalink
Added support for rest-json outputs with list payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisradek committed Oct 28, 2015
1 parent 4e8ae64 commit 8bfd0d6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/protocol/rest_json.js
Expand Up @@ -47,7 +47,7 @@ function extractData(resp) {
var body = resp.httpResponse.body;
if (payloadMember.isStreaming) {
resp.data[rules.payload] = body;
} else if (payloadMember.type === 'structure') {
} else if (payloadMember.type === 'structure' || payloadMember.type === 'list') {
var parser = new JsonParser();
resp.data[rules.payload] = parser.parse(body, payloadMember);
} else {
Expand Down
52 changes: 52 additions & 0 deletions test/fixtures/protocol/output/rest-json.json
Expand Up @@ -625,6 +625,58 @@
}
]
},
{
"description": "List payload",
"metadata": {
"protocol": "rest-json"
},
"shapes": {
"OutputShape": {
"type": "structure",
"payload": "ListData",
"members": {
"Header": {
"shape": "StringType",
"location": "header",
"locationName": "X-Foo"
},
"ListData": {
"shape": "ListType"
}
}
},
"ListType": {
"type": "list",
"member": {
"shape": "StringType"
}
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"output": {
"shape": "OutputShape"
},
"name": "OperationName"
},
"result": {
"Header": "baz",
"ListData": ["a", "b", "c"]
},
"response": {
"status_code": 200,
"headers": {
"X-Foo": "baz"
},
"body": "[\"a\", \"b\", \"c\"]"
}
}
]
},
{
"description": "JSON payload",
"metadata": {
Expand Down

0 comments on commit 8bfd0d6

Please sign in to comment.