swagger-tools
Advanced tools
Comparing version 0.5.3 to 0.5.4
/* | ||
* The MIT License (MIT) | ||
* | ||
* | ||
* Copyright (c) 2014 Apigee Corporation | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
@@ -12,6 +12,6 @@ * of this software and associated documentation files (the "Software"), to deal | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
@@ -117,2 +117,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// Attach Swagger metadata to the request | ||
if (!_.isUndefined(api)) { | ||
req.swagger = metadata; | ||
} | ||
// Collect the parameter values | ||
@@ -167,5 +172,2 @@ if (!_.isUndefined(metadata.operation)) { | ||
}); | ||
// Attach Swagger metadata to the request | ||
req.swagger = metadata; | ||
} catch (err) { | ||
@@ -172,0 +174,0 @@ return next(err.message); |
@@ -86,18 +86,18 @@ /* | ||
if (req.swagger) { | ||
handlerName = getHandlerName('1.2', req); | ||
operation = req.swagger.operation; | ||
req.swagger.useStubs = options.useStubs; | ||
} | ||
if (_.isUndefined(operation)) { | ||
send405(req, res); | ||
} else { | ||
handler = handlerCache[handlerName]; | ||
if (_.isUndefined(operation)) { | ||
send405(req, res); | ||
} else { | ||
handlerName = getHandlerName('1.2', req); | ||
handler = handlerCache[handlerName]; | ||
if (_.isUndefined(handler) && options.useStubs === true) { | ||
handler = handlerCache[handlerName] = createStubHandler(req, res, '1.2'); | ||
} | ||
if (_.isUndefined(handler) && options.useStubs === true) { | ||
handler = handlerCache[handlerName] = createStubHandler(req, res, '1.2'); | ||
} | ||
if (!_.isUndefined(handler)) { | ||
return handler(req, res, next); | ||
if (!_.isUndefined(handler)) { | ||
return handler(req, res, next); | ||
} | ||
} | ||
@@ -104,0 +104,0 @@ } |
/* | ||
* The MIT License (MIT) | ||
* | ||
* | ||
* Copyright (c) 2014 Apigee Corporation | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
@@ -12,6 +12,6 @@ * of this software and associated documentation files (the "Software"), to deal | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
@@ -98,2 +98,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// Attach Swagger metadata to the request | ||
if (!_.isUndefined(path)) { | ||
req.swagger = metadata; | ||
} | ||
// Collect the parameter values | ||
@@ -152,5 +157,2 @@ if (!_.isUndefined(metadata.operation)) { | ||
}); | ||
// Attach Swagger metadata to the request | ||
req.swagger = metadata; | ||
} catch (err) { | ||
@@ -157,0 +159,0 @@ return next(err.message); |
@@ -89,29 +89,29 @@ /* | ||
if (req.swagger) { | ||
handlerName = getHandlerName('2.0', req); | ||
operation = req.swagger.operation; | ||
req.swagger.useStubs = options.useStubs; | ||
} | ||
if (_.isUndefined(operation)) { | ||
send405(req, res); | ||
} else { | ||
handler = handlerCache[handlerName]; | ||
if (_.isUndefined(operation)) { | ||
send405(req, res); | ||
} else { | ||
handlerName = getHandlerName('2.0', req); | ||
handler = handlerCache[handlerName]; | ||
if (_.isUndefined(handler) && options.useStubs === true) { | ||
responseModel = _.find(operation.responses, function (responseModel, responseCode) { | ||
if (responseCode === '200') { | ||
return responseModel.responseModel; | ||
if (_.isUndefined(handler) && options.useStubs === true) { | ||
responseModel = _.find(operation.responses, function (responseModel, responseCode) { | ||
if (responseCode === '200') { | ||
return responseModel.responseModel; | ||
} | ||
}); | ||
if (_.isUndefined(responseModel)) { | ||
responseModel = operation.responses.default; | ||
} | ||
}); | ||
if (_.isUndefined(responseModel)) { | ||
responseModel = operation.responses.default; | ||
handler = handlerCache[handlerName] = createStubHandler(req, res, '2.0', handlerName, responseModel); | ||
} | ||
handler = handlerCache[handlerName] = createStubHandler(req, res, '2.0', handlerName, responseModel); | ||
if (!_.isUndefined(handler)) { | ||
return handler(req, res, next); | ||
} | ||
} | ||
if (!_.isUndefined(handler)) { | ||
return handler(req, res, next); | ||
} | ||
} | ||
@@ -118,0 +118,0 @@ |
{ | ||
"name": "swagger-tools", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Various tools for using and integrating with Swagger.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
149591
3638