swagger-tools
Advanced tools
Comparing version 0.9.9 to 0.9.10
@@ -81,3 +81,5 @@ /* | ||
if (process.env.NODE_ENV === 'test') { | ||
throw err; | ||
// This is not an official mechanism and is done this way only to support our tests. The reason this is | ||
// required is because JsonRefs uses Promises and this causes some issues with how our tests were written. | ||
return callback(err); | ||
} else { | ||
@@ -84,0 +86,0 @@ helpers.printValidationResults(spec.version, rlOrSO, resources, results, true); |
@@ -567,3 +567,2 @@ /* | ||
_.each(JsonRefs.findRefs(documentMetadata.original), function (ref, refPtr) { | ||
if (documentMetadata.swaggerVersion === '1.2') { | ||
@@ -581,7 +580,7 @@ ref = '#/models/' + ref; | ||
_.each(documentMetadata.referencesMetadata, function (details, ref) { | ||
if (JsonRefs.isRemotePointer(details.ref) && !_.has(details, 'value')) { | ||
if (JsonRefs.isRemotePointer(details.ref) && details.missing === true) { | ||
results.errors.push({ | ||
code: 'UNRESOLVABLE_REFERENCE', | ||
message: 'Reference could not be resolved: ' + details.ref, | ||
path: JsonRefs.pathFromPointer(ref) | ||
path: JsonRefs.pathFromPointer(ref).concat('$ref') | ||
}); | ||
@@ -1337,3 +1336,3 @@ } | ||
* @param {string} modelIdOrRef - The model id (1.2) or the reference to the model (1.2 or 2.0) | ||
* @param {object} data - The model to validate | ||
* @param {*} data - The model to validate | ||
* @param {resultCallback} callback - The result callback | ||
@@ -1340,0 +1339,0 @@ * |
@@ -157,2 +157,3 @@ /* | ||
delete obj.params; | ||
delete obj.schemaId; | ||
@@ -222,3 +223,5 @@ if (obj.inner) { | ||
var contentType = isResponse ? reqOrRes.getHeader('content-type') : reqOrRes.headers['content-type']; | ||
var pOrC = _.union(gPOrC, oPOrC); | ||
var pOrC = _.map(_.union(gPOrC, oPOrC), function (contentType) { | ||
return contentType.split(';')[0]; | ||
}); | ||
@@ -233,3 +236,2 @@ if (!contentType) { | ||
// Get only the content type | ||
contentType = contentType.split(';')[0]; | ||
@@ -563,3 +565,3 @@ | ||
* | ||
* @param {string} swaggerVersion - The Swagger version | ||
* @param {string} version - The Swagger version | ||
* @param {object} schema - The schema to use to validate things | ||
@@ -571,3 +573,3 @@ * @param {string[]} path - The path to the schema | ||
*/ | ||
module.exports.validateSchemaConstraints = function (swaggerVersion, schema, path, val) { | ||
var validateSchemaConstraints = module.exports.validateSchemaConstraints = function (version, schema, path, val) { | ||
var resolveSchema = function (schema) { | ||
@@ -611,5 +613,5 @@ var resolved = schema; | ||
if (_.isUndefined(val)) { | ||
val = swaggerVersion === '1.2' ? schema.defaultValue : schema.default; | ||
val = version === '1.2' ? schema.defaultValue : schema.default; | ||
path = path.concat([swaggerVersion === '1.2' ? 'defaultValue' : 'default']); | ||
path = path.concat([version === '1.2' ? 'defaultValue' : 'default']); | ||
} | ||
@@ -623,13 +625,14 @@ | ||
if (type === 'array') { | ||
if (!_.isUndefined(schema.items)) { | ||
validateTypeAndFormat(swaggerVersion, val, type === 'array' ? schema.items.type : type, | ||
type === 'array' && schema.items.format ? | ||
schema.items.format : | ||
schema.format, | ||
allowEmptyValue); | ||
} else { | ||
validateTypeAndFormat(swaggerVersion, val, type, schema.format, allowEmptyValue); | ||
} | ||
_.each(val, function (val, index) { | ||
try { | ||
validateSchemaConstraints(version, schema.items || {}, path.concat(index.toString()), val); | ||
} catch (err) { | ||
err.message = 'Value at index ' + index + ' ' + (err.code === 'INVALID_TYPE' ? 'is ' : '') + | ||
err.message.charAt(0).toLowerCase() + err.message.substring(1); | ||
throw err; | ||
} | ||
}); | ||
} else { | ||
validateTypeAndFormat(swaggerVersion, val, type, schema.format, allowEmptyValue); | ||
validateTypeAndFormat(version, val, type, schema.format, allowEmptyValue); | ||
} | ||
@@ -636,0 +639,0 @@ |
@@ -129,3 +129,3 @@ /* | ||
case 'array': | ||
if (_.isString(value) && schema.collectionFormat !== 'multi') { | ||
if (_.isString(value)) { | ||
switch (schema.collectionFormat) { | ||
@@ -136,2 +136,5 @@ case 'csv': | ||
break; | ||
case 'multi': | ||
value = [value]; | ||
break; | ||
case 'pipes': | ||
@@ -138,0 +141,0 @@ value = value.split('|'); |
{ | ||
"name": "swagger-tools", | ||
"version": "0.9.9", | ||
"version": "0.9.10", | ||
"description": "Various tools for using and integrating with Swagger.", | ||
@@ -71,3 +71,3 @@ "main": "index.js", | ||
"js-yaml": "^3.3.1", | ||
"json-refs": "^0.3.2", | ||
"json-refs": "^1.2.1", | ||
"lodash-compat": "^3.10.0", | ||
@@ -74,0 +74,0 @@ "multer": "^0.1.8", |
3742201
45182
+ Addedformidable@1.0.17(transitive)
+ Addedjson-refs@1.3.0(transitive)
+ Addedpath-loader@0.2.1(transitive)
- Removedasync@0.9.2(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcomponent-emitter@1.1.2(transitive)
- Removedcookiejar@2.0.1(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedextend@1.2.1(transitive)
- Removedform-data@0.2.0(transitive)
- Removedformidable@1.0.14(transitive)
- Removedjson-refs@0.3.2(transitive)
- Removedmethods@1.0.1(transitive)
- Removednative-promise-only@0.7.8-a(transitive)
- Removedpath-loader@0.0.2(transitive)
- Removedsuperagent@1.2.0(transitive)
Updatedjson-refs@^1.2.1