swagger-node-express
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -122,5 +122,4 @@ /** | ||
var op = api.operations[opKey]; | ||
var path = api.path.replace(/{.*\}/, "*"); | ||
if (!canAccessResource(req, route + path, op.httpMethod)) { | ||
var path = api.path.replace(formatString, "").replace(/{.*\}/, "*"); | ||
if (!canAccessResource(req, path, op.httpMethod)) { | ||
excludedPaths.push(op.httpMethod + ":" + api.path); } | ||
@@ -330,3 +329,6 @@ } | ||
exports.setHeaders(res); | ||
if (!canAccessResource(req, req.url.substr(1).split('?')[0].replace('.json', '.*'), req.method)) { | ||
// todo: needs to do smarter matching against the defined paths | ||
var path = req.url.split('?')[0].replace(jsonSuffix, "").replace(/{.*\}/, "*"); | ||
if (!canAccessResource(req, path, req.method)) { | ||
res.send(JSON.stringify({"description":"forbidden", "code":403}), 403); | ||
@@ -503,3 +505,3 @@ } else { | ||
function error(code, description) { | ||
return {"code" : code, "reason" : description}; | ||
return {"code" : code, "description" : description}; | ||
} | ||
@@ -520,17 +522,17 @@ | ||
if (!res) { | ||
return {"code": 404, "reason": field + ' not found'}; } | ||
return {"code": 404, "description": field + ' not found'}; } | ||
else { | ||
res.send({"code": 404, "reason": field + ' not found'}, 404); } | ||
res.send({"code": 404, "description": field + ' not found'}, 404); } | ||
}, | ||
'invalid': function(field, res) { | ||
if (!res) { | ||
return {"code": 400, "reason": 'invalid ' + field}; } | ||
return {"code": 400, "description": 'invalid ' + field}; } | ||
else { | ||
res.send({"code": 400, "reason": 'invalid ' + field}, 404); } | ||
res.send({"code": 400, "description": 'invalid ' + field}, 404); } | ||
}, | ||
'forbidden': function(res) { | ||
if (!res) { | ||
return {"code": 403, "reason": 'forbidden' }; } | ||
return {"code": 403, "description": 'forbidden' }; } | ||
else { | ||
res.send({"code": 403, "reason": 'forbidden'}, 403); } | ||
res.send({"code": 403, "description": 'forbidden'}, 403); } | ||
} | ||
@@ -537,0 +539,0 @@ }; |
{ | ||
"name": "swagger-node-express", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Tony Tam", |
Sorry, the diff of this file is not supported yet
750
180701