Skip to content

Commit

Permalink
support unit tests for models with schema type as array krakenjs#69
Browse files Browse the repository at this point in the history
  • Loading branch information
subeeshcbabu committed Feb 11, 2016
1 parent ee8cd66 commit 7ed6487
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/templates/_test_express.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test('api', function (t) {
<%
var path = operation.path;
var body;
var ref;
var responseCode = operation.responses && Object.keys(operation.responses)[0];
var response = responseCode && operation.responses[responseCode];
var responseSchema = response && response.schema;
Expand All @@ -46,8 +47,16 @@ test('api', function (t) {
}
});
}
if (param.in === 'body' && param.schema && param.schema.$ref) {
body = models[param.schema.$ref.slice(param.schema.$ref.lastIndexOf('/') + 1)];
if (param.in === 'body' && param.schema ) {
ref = param.schema.$ref;
//If the schema type is array then the definition $ref will be items
if (param.schema.type === 'array' && param.schema.items) {
ref = param.schema.items.$ref;
}
//Skip if ref is undefined
if (ref) {
body = models[param.schema.$ref.slice(param.schema.$ref.lastIndexOf('/') + 1)];
}
}
});
}
Expand Down

0 comments on commit 7ed6487

Please sign in to comment.