Skip to content

Commit

Permalink
Merge pull request #52 from jolson88/master
Browse files Browse the repository at this point in the history
Upgrade Sway dependency to 1.0.0 release
  • Loading branch information
theganyo authored Aug 7, 2016
2 parents 20f123d + efce7b8 commit 56cbdc0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions fittings/swagger_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ module.exports = function create(fittingDef, bagpipes) {
var statusCode = parseInt(context.request.get('_mockreturnstatus')) || 200;

var mimetype = context.request.get('accept') || 'application/json';
var mock = operation.getResponseExample(statusCode, mimetype);
var mock = operation.getResponse(statusCode).getExample(mimetype);

if (mock) {
debug('returning mock example value', mock);
} else {
mock = operation.getResponseSample(statusCode);
mock = operation.getResponse(statusCode).getSample();
debug('returning mock sample value', mock);
}

Expand Down
6 changes: 5 additions & 1 deletion lib/connect_middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ function hookResponseForValidation(context, eventEmitter) {
var headers = res._headers || res.headers || {};
var body = data || written;
debugContent('response body type: %s value: %s', typeof body, body);
var validateResult = context.request.swagger.operation.validateResponse(res.statusCode, headers, body);
var validateResult = context.request.swagger.operation.validateResponse({
statusCode: res.statusCode,
headers: headers,
body: body
});
debug('validation result:', validateResult);
if (validateResult.errors.length || validateResult.warnings.length) {
debug('emitting responseValidationError');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swagger-node-runner",
"version": "0.6.16",
"version": "0.7.0",
"description": "Swagger loader and middleware utilities",
"keywords": [
"swagger",
Expand Down Expand Up @@ -31,7 +31,7 @@
"multer": "^1.0.6",
"parseurl": "^1.3.0",
"qs": "^5.2.0",
"sway": "^0.6.0",
"sway": "^1.0.0",
"type-is": "^1.6.9"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions test/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ module.exports = function() {
should.exist(res);
validationResponse.errors.should.be.an.Array;
validationResponse.errors.length.should.eql(1);
validationResponse.errors[0].should.eql({
validationResponse.errors[0].should.containDeep({
code: 'INVALID_RESPONSE_HEADER',
errors:
[ { code: 'INVALID_TYPE',
Expand Down Expand Up @@ -484,7 +484,7 @@ module.exports = function() {
should.exist(res);
validationResponse.errors.should.be.an.Array;
validationResponse.errors.length.should.eql(1);
validationResponse.errors[0].should.eql({
validationResponse.errors[0].should.containDeep({
code: 'INVALID_RESPONSE_BODY',
errors:
[ { code: 'INVALID_TYPE',
Expand Down

0 comments on commit 56cbdc0

Please sign in to comment.