swagger-tools
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -902,2 +902,2 @@ /* | ||
var v1_2 = module.exports.v1_2 = new Specification('1.2'); // jshint ignore:line | ||
module.exports.v1_2 = new Specification('1.2'); // jshint ignore:line |
@@ -23,5 +23,22 @@ /* | ||
var expressStylePath = function expressStylePath (api) { | ||
// Since all path parameters must be required, no need to do any fancy parsing | ||
return (api.path || '').replace(/{/g, ':').replace(/}/g, ''); | ||
var expressStylePath = function expressStylePath (basePath, apiPath) { | ||
basePath = parseurl({url: basePath || '/'}).pathname || '/'; | ||
// Make sure the base path starts with '/' | ||
if (basePath.charAt(0) !== '/') { | ||
basePath = '/' + basePath; | ||
} | ||
// Make sure the base path ends with '/' | ||
if (basePath.charAt(basePath.length - 1) !== '/') { | ||
basePath = basePath + '/'; | ||
} | ||
// Make sure the api path does not start with '/' since the base path will end with '/' | ||
if (apiPath.charAt(0) === '/') { | ||
apiPath = apiPath.substring(1); | ||
} | ||
// Replace Swagger syntax for path parameters with Express' version (All Swagger path parameters are required) | ||
return (basePath + apiPath).replace(/{/g, ':').replace(/}/g, ''); | ||
}; | ||
@@ -69,3 +86,3 @@ | ||
var keys = []; | ||
var re = pathToRegexp(expressStylePath(api), keys); | ||
var re = pathToRegexp(expressStylePath(resource.basePath, api.path), keys); | ||
var reStr = re.toString(); | ||
@@ -72,0 +89,0 @@ |
@@ -24,3 +24,2 @@ /* | ||
var dateTimeRegExp = /^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$/; | ||
var spec = require('../').v1_2; // jshint ignore:line | ||
@@ -27,0 +26,0 @@ var isValid = function isValid (val, type, format) { |
{ | ||
"name": "swagger-tools", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "Various tools for using and integrating with Swagger.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81895
1782