swagger-tools
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -901,3 +901,3 @@ /* | ||
_.difference(Object.keys(authScopes), Object.keys(seenAuthScopes)).forEach(function (unused) { | ||
result.errors.push({ | ||
result.warnings.push({ | ||
code: 'UNUSED_AUTHORIZATION', | ||
@@ -917,3 +917,3 @@ message: 'Authorization is defined but is not used: ' + unused, | ||
result.errors.push({ | ||
result.warnings.push({ | ||
code: 'UNUSED_AUTHORIZATION_SCOPE', | ||
@@ -920,0 +920,0 @@ message: 'Authorization scope is defined but is not used: ' + unused, |
{ | ||
"name": "swagger-tools", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Various tools for using and integrating with Swagger.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,4 @@ The project provides various tools for integrating and interacting with Swagger. This project is in its infancy but | ||
based on the [JSON Schema][json-schema] associated with that version of the specification | ||
* Semantic validation: Validates Swagger files individually and as a whole (resource listing combined with API | ||
declarations) _(See [Issue #1](https://github.com/apigee-127/swagger-tools/issues/1) for more details)_ | ||
@@ -31,2 +33,4 @@ ## Installation | ||
file | ||
* `validateApi`: This is a function used to validate a "full API" of Swagger documents including a resource listing and | ||
an array of API declarations | ||
@@ -42,2 +46,3 @@ Here is an example showing how to use both versions of the `validate` function *(For more details, the sources are | ||
var rlResults = spec.validate(rlJson, 'resourceListing.json'); | ||
var apiResults = spec.validateApi(rlJson, [petJson]); | ||
``` | ||
@@ -44,0 +49,0 @@ |
@@ -129,2 +129,11 @@ /* global describe, it */ | ||
describe('#validate', function () { | ||
it('should throw error when using invalid schema name', function () { | ||
try { | ||
spec.validate(allSampleFiles['pet.json'], 'fakeSchema.json'); | ||
} catch (err) { | ||
assert.equal(err.message, 'schemaName is not valid (fakeSchema.json). Valid schema names: ' + | ||
Object.keys(spec.schemas).join(', ')) | ||
} | ||
}); | ||
it('should return true for valid JSON files', function () { | ||
@@ -517,3 +526,3 @@ Object.keys(allSampleFiles).forEach(function (name) { | ||
it('should return errors for defined but unused authorizations in resource listing JSON files', function () { | ||
it('should return warnings for unused authorizations in resource listing JSON files', function () { | ||
var result = spec.validateApi(invalidApiResourceListingJson, [ | ||
@@ -524,5 +533,5 @@ invalidApiResource1Json, | ||
]); | ||
var errors = findAllErrorsOrWarnings('errors', 'UNUSED_AUTHORIZATION', result); | ||
var warnings = findAllErrorsOrWarnings('warnings', 'UNUSED_AUTHORIZATION', result); | ||
assert.deepEqual(errors, [ | ||
assert.deepEqual(warnings, [ | ||
{ | ||
@@ -539,3 +548,3 @@ code: 'UNUSED_AUTHORIZATION', | ||
it('should return errors for defined but unused authorization scopes in resource listing JSON files', function () { | ||
it('should return warnings for unused authorization scopes in resource listing JSON files', function () { | ||
var result = spec.validateApi(invalidApiResourceListingJson, [ | ||
@@ -546,5 +555,5 @@ invalidApiResource1Json, | ||
]); | ||
var errors = findAllErrorsOrWarnings('errors', 'UNUSED_AUTHORIZATION_SCOPE', result); | ||
var warnings = findAllErrorsOrWarnings('warnings', 'UNUSED_AUTHORIZATION_SCOPE', result); | ||
assert.deepEqual(errors, [ | ||
assert.deepEqual(warnings, [ | ||
{ | ||
@@ -653,3 +662,1 @@ code: 'UNUSED_AUTHORIZATION_SCOPE', | ||
}); | ||
// TODO: Add test for calling 'validate' with invalid schema name |
129671
3606
58