Repository: codekie/openapi-examples-validator (js)

Issue:
Not all `examples` of a schema get validated
If there is more than one example available for a schema, only the last one gets validated.

Pull request description:
Validate all examples of a schema
Fixes #45 

Patch:
diff --git a/src/cli.js b/src/cli.js
index f76edd5..c6d1434 100755
--- a/src/cli.js
+++ b/src/cli.js
@@ -63,15 +63,15 @@ function _handleResult(result) {
 
 function _printStatistics(statistics) {
     const {
-            responseSchemasWithExamples,
-            responseExamplesWithoutSchema,
-            responseExamplesTotal,
+            schemasWithExamples,
+            examplesWithoutSchema,
+            examplesTotal,
             matchingFilePathsMapping
         } = statistics,
         strStatistics = [
-            `Response schemas with examples found: ${ responseSchemasWithExamples }`,
-            `Response examples without schema found: ${ responseExamplesWithoutSchema }`,
-            `Total examples found: ${ responseExamplesTotal }`
+            `Schemas with examples found: ${ schemasWithExamples }`,
+            `Examples without schema found: ${ examplesWithoutSchema }`,
+            `Total examples found: ${ examplesTotal }`
         ];
     if (matchingFilePathsMapping != null) {
         strStatistics.push(`Matching mapping files found: ${ matchingFilePathsMapping }`);
diff --git a/src/impl/v2/index.js b/src/impl/v2/index.js
index 55ac4cc..34b86e2 100644
--- a/src/impl/v2/index.js
+++ b/src/impl/v2/index.js
@@ -35,7 +35,8 @@ function getJsonPathsToExamples() { return [PATH__EXAMPLES]; }
 function buildValidationMap(pathsExamples) {
     return pathsExamples.reduce((validationMap, pathExample) => {
         const pathSchema = _getSchemaPathOfExample(pathExample);
-        validationMap[pathSchema] = pathExample;
+        validationMap[pathSchema] = (validationMap[pathSchema] || new Set())
+            .add(pathExample);
         return validationMap;
     }, {});
 }
diff --git a/src/impl/v3/index.js b/src/impl/v3/index.js
index b0b381c..29bb2b1 100644
--- a/src/impl/v3/index.js
+++ b/src/impl/v3/index.js
@@ -64,7 +64,8 @@ function buildValidationMap(pathsExamples) {
             exampleTypeOfSchema !== exampleType && _throwMutuallyExclusiveError(pathSchemaAsArray);
         }
         exampleTypesOfSchemas.set(pathSchema, exampleType);
-        validationMap[pathSchema] = pathExample;
+        validationMap[pathSchema] = (validationMap[pathSchema] || new Set())
+            .add(pathExample);
         return validationMap;
     }, {});
 }
diff --git a/src/index.js b/src/index.js
index 6a2cbc1..a0ade94 100644
--- a/src/index.js
+++ b/src/index.js
@@ -60,9 +60,9 @@ module.exports = {
 /**
  * ValidationStatistics
  * @typedef {{
- *      responseSchemasWithExamples: number,
- *      responseExamplesTotal: number,
- *      responseExamplesWithoutSchema: number,
+ *      schemasWithExamples: number,
+ *      examplesTotal: number,
+ *      examplesWithoutSchema: number,
  *      [matchingFilePathsMapping]: number
  * }} ValidationStatistics
  */
@@ -118,8 +118,8 @@ function validateFile(filePath) {
  * Validates examples by mapping-files.
  * @param {string}  filePathSchema              File-path to the OpenAPI-spec
  * @param {string}  globMapExternalExamples     File-path (globs are supported) to the mapping-file containing JSON-
- *                                              paths to response-schemas as key and a single file-path or Array of
- *                                              file-paths to external examples
+ *                                              paths to schemas as key and a single file-path or Array of file-paths
+ *                                              to external examples
  * @param {boolean} [cwdToMappingFile=false]    Change working directory for resolving the example-paths (relative to
  *                                              the mapping-file)
  * @returns {ValidationResponse}
@@ -166,28 +166,28 @@ function validateExamplesByMap(filePathSchema, globMapExternalExamples, { cwdToM
 /**
  * Validates a single external example.
  * @param {String}  filePathSchema      File-path to the OpenAPI-spec
- * @param {String}  pathResponseSchema  JSON-path to the response-schema
+ * @param {String}  pathSchema          JSON-path to the schema
  * @param {String}  filePathExample     File-path to the external example-file
  * @returns {ValidationResponse}
  */
-function validateExample(filePathSchema, pathResponseSchema, filePathExample) {
+function validateExample(filePathSchema, pathSchema, filePathExample) {
     let example = null,
-        responseSchema = null,
+        schema = null,
         openapiSpec = null;
     try {
         example = JSON.parse(fs.readFileSync(filePathExample, 'utf-8'));
         openapiSpec = _parseSpec(filePathSchema);
         openapiSpec = Determiner.getImplementation(openapiSpec)
             .prepare(openapiSpec);
-        responseSchema = _extractResponseSchema(pathResponseSchema, openapiSpec);
+        schema = _extractSchema(pathSchema, openapiSpec);
     } catch (err) {
         return createValidationResponse({ errors: [ApplicationError.create(err)] });
     }
     return _validate(
-        [pathResponseSchema],
+        [pathSchema],
         statistics => _validateExample({
             createValidator: _initValidatorFactory(openapiSpec),
-            responseSchema,
+            schema,
             example,
             statistics,
             filePathExample
@@ -224,15 +224,15 @@ function _isFileTypeYaml(filePath) {
 /**
  * Top-level validator. Prepares common values, required for the validation, then calles the validator and prepares
  * the result for the output.
- * @param {Array.<String>}      pathsResponseSchema     JSON-paths to the schemas of the responses
+ * @param {Array.<String>}      schemaPaths             JSON-paths to the schemas
  * @param {ValidationHandler}   validationHandler       The handler which performs the validation. It will receive the
  *                                                      statistics-object as argument and has to return an Array of
  *                                                      errors (or an empty Array, when all examples are valid)
  * @returns {ValidationResponse}
  * @private
  */
-function _validate(pathsResponseSchema, validationHandler) {
-    const statistics = _initStatistics({ schemaPaths: pathsResponseSchema }),
+function _validate(schemaPaths, validationHandler) {
+    const statistics = _initStatistics({ schemaPaths }),
         errors = validationHandler(statistics);
     return createValidationResponse({ errors, statistics });
 }
@@ -240,9 +240,9 @@ function _validate(pathsResponseSchema, validationHandler) {
 /**
  * Validates examples by a mapping-file.
  * @param {Object}                  openapiSpec                     OpenAPI-spec
- * @param {Object}                  mapExternalExamples             Mapping-file containing JSON-paths to response-
- *                                                                  schemas as key and a single file-path or Array of
- *                                                                  file-paths to
+ * @param {Object}                  mapExternalExamples             Mapping-file containing JSON-paths to schemas as
+ *                                                                  key and a single file-path or Array of file-paths
+ *                                                                  to external examples
  * @param {ValidationStatistics}    statistics                      Validation-statistics
  * @param {boolean}                 [cwdToMappingFile=false]        Change working directory for resolving the example-
  *                                                                  paths (relative to the mapping-file)
@@ -255,12 +255,12 @@ function _handleExamplesByMapValidation(openapiSpec, mapExternalExamples, statis
 ) {
     return _(mapExternalExamples)
         .entries()
-        .flatMap(([pathResponseSchema, filePathsExample]) => {
-            let responseSchema = null;
+        .flatMap(([pathSchema, filePathsExample]) => {
+            let schema = null;
             try {
-                responseSchema = _extractResponseSchema(pathResponseSchema, openapiSpec);
+                schema = _extractSchema(pathSchema, openapiSpec);
             } catch (/** @type ErrorJsonPathNotFound */ err) {
-                // If the response-schema can't be found, don't even attempt to process the examples
+                // If the schema can't be found, don't even attempt to process the examples
                 return ApplicationError.create(err);
             }
             return _([filePathsExample])
@@ -277,7 +277,7 @@ function _handleExamplesByMapValidation(openapiSpec, mapExternalExamples, statis
                     }
                     return _validateExample({
                         createValidator: _initValidatorFactory(openapiSpec),
-                        responseSchema,
+                        schema,
                         example,
                         statistics,
                         filePathExample
@@ -303,7 +303,7 @@ function _mergeValidationResponses(response1, response2) {
             .reduce((res, [key, val]) => {
                 res[key] = val + response2.statistics[key];
                 return res;
-            }, _initStatistics({ schemaPaths: [] }))
+            }, _initStatistics())
     });
 }
 
@@ -354,57 +354,57 @@ function _validateExamplesPaths({ impl }, pathsExamples, openapiSpec) {
     }
     // Start validation
     const schemaPaths = Object.keys(validationMap);
-    validationResult.statistics.responseSchemasWithExamples = schemaPaths.length;
-    schemaPaths.forEach(pathResponseSchema => {
-        _validateResponseSchema({ openapiSpec, createValidator, pathResponseSchema, validationMap, statistics,
+    validationResult.statistics.schemasWithExamples = schemaPaths.length;
+    schemaPaths.forEach(pathSchema => {
+        _validateSchema({ openapiSpec, createValidator, pathSchema, validationMap, statistics,
             validationResult });
     });
     return validationResult;
 }
 
 /**
- * Validates a single response-schema.
+ * Validates a single schema.
  * @param {Object}                  openapiSpec         OpenAPI-spec
  * @param {ajv}                     createValidator     Factory, to create JSON-schema validator
- * @param {string}                  pathResponseSchema  JSON-path to response-schema
+ * @param {string}                  pathSchema          JSON-path to schema (for request- or response-property)
  * @param {Object.<String, String>} validationMap Map with schema-path as key and example-paths as value
  * @param {Object}                  statistics          Object to contain statistics metrics
  * @param {Object}                  validationResult    Container, for the validation-results
  * @private
  */
-function _validateResponseSchema({ openapiSpec, createValidator, pathResponseSchema, validationMap, statistics,
+function _validateSchema({ openapiSpec, createValidator, pathSchema, validationMap, statistics,
     validationResult }) {
-    const
-        errors = validationResult.errors,
-        pathExample = validationMap[pathResponseSchema],
-        example = _getObjectByPath(pathExample, openapiSpec),
-        // Missing response-schemas may occur and are considered valid
-        responseSchema = _extractResponseSchema(pathResponseSchema, openapiSpec, true),
-        curErrors = _validateExample({
-            createValidator,
-            responseSchema,
-            example,
-            statistics
-        }).map(error => {
-            error.examplePath = jsonPath.toPointer(jsonPath.toPathArray(pathExample));
-            return error;
-        });
-    if (!curErrors.length) { return; }
-    validationResult.valid = false;
-    errors.splice(errors.length - 1, 0, ...curErrors);
+    const errors = validationResult.errors;
+    validationMap[pathSchema].forEach(pathExample => {
+        const example = _getObjectByPath(pathExample, openapiSpec),
+            // Examples with missing schemas may occur and those are considered valid
+            schema = _extractSchema(pathSchema, openapiSpec, true),
+            curErrors = _validateExample({
+                createValidator,
+                schema,
+                example,
+                statistics
+            }).map(error => {
+                error.examplePath = jsonPath.toPointer(jsonPath.toPathArray(pathExample));
+                return error;
+            });
+        if (!curErrors.length) { return; }
+        validationResult.valid = false;
+        errors.splice(errors.length - 1, 0, ...curErrors);
+    });
 }
 
 /**
  * Creates a container-object for the validation statistics.
- * @param {Array.<String>}  [schemaPaths=[]]   JSON-paths to the response-schemas
+ * @param {Array.<String>}  [schemaPaths=[]]    JSON-paths schemas
  * @returns {ValidationStatistics}
  * @private
  */
-function _initStatistics({ schemaPaths = [] } = {}) {
+function _initStatistics({ schemaPaths=[] } = {}) {
     return {
-        responseSchemasWithExamples: schemaPaths.length,
-        responseExamplesTotal: 0,
-        responseExamplesWithoutSchema: 0
+        schemasWithExamples: schemaPaths.length,
+        examplesTotal: 0,
+        examplesWithoutSchema: 0
     };
 }
 
@@ -431,24 +431,24 @@ function _getObjectByPath(path, json) {
  * `pathExample` and `filePathExample` are exclusively mandatory.
  * itself
  * @param {Function}    createValidator     Factory, to create JSON-schema validator
- * @param {Object}      responseSchema      JSON-schema for the response
+ * @param {Object}      schema              JSON-schema
  * @param {Object}      example             Example to validate
  * @param {Object}      statistics          Object to contain statistics metrics
  * @param {String}      [filePathExample]   File-path to the example file
  * @returns {Array.<Object>} Array with errors. Empty array, if examples are valid
  * @private
  */
-function _validateExample({ createValidator, responseSchema, example, statistics, filePathExample }) {
+function _validateExample({ createValidator, schema, example, statistics, filePathExample }) {
     const
         errors = [];
-    statistics.responseExamplesTotal++;
+    statistics.examplesTotal++;
     // No schema, no validation (Examples without schema are considered valid)
-    if (!responseSchema) {
-        statistics.responseSchemasWithExamples--;
-        statistics.responseExamplesWithoutSchema++;
+    if (!schema) {
+        statistics.schemasWithExamples--;
+        statistics.examplesWithoutSchema++;
         return errors;
     }
-    const validate = compileValidate(createValidator(), responseSchema);
+    const validate = compileValidate(createValidator(), schema);
     if (validate(example)) { return errors; }
     return errors.concat(...validate.errors.map(ApplicationError.create))
         .map(error => {
@@ -471,22 +471,22 @@ function _initValidatorFactory(specSchema) {
 }
 
 /**
- * Extracts the response-schema in the OpenAPI-spec at the given JSON-path.
- * @param   {string}    pathResponseSchema                  JSON-path to response-schema
+ * Extracts the schema in the OpenAPI-spec at the given JSON-path.
+ * @param   {string}    pathSchema                          JSON-path to the schema
  * @param   {Object}    openapiSpec                         OpenAPI-spec
  * @param   {boolean}   [suppressErrorIfNotFound=false]     Don't throw `ErrorJsonPathNotFound` if the repsonse does not
  *                                                          exist at the given JSON-path
  * @returns {Object|Array.<Object>|undefined} Matching schema(s)
- * @throws  {ErrorJsonPathNotFound} Thrown, when there is no response-schema at the given path and
+ * @throws  {ErrorJsonPathNotFound} Thrown, when there is no schema at the given path and
  *                                  `suppressErrorIfNotFound` is false
  * @private
  */
-function _extractResponseSchema(pathResponseSchema, openapiSpec, suppressErrorIfNotFound = false) {
-    const schema = _getObjectByPath(pathResponseSchema, openapiSpec);
+function _extractSchema(pathSchema, openapiSpec, suppressErrorIfNotFound = false) {
+    const schema = _getObjectByPath(pathSchema, openapiSpec);
     if (!suppressErrorIfNotFound && !schema) {
-        throw new ErrorJsonPathNotFound(`Path to response-schema can't be found: '${pathResponseSchema}'`, {
+        throw new ErrorJsonPathNotFound(`Path to schema can't be found: '${ pathSchema }'`, {
             params: {
-                path: pathResponseSchema
+                path: pathSchema
             }
         });
     }


Test patch:
diff --git a/test/data/output-map-external-examples.js b/test/data/output-map-external-examples.js
index 48e6868..2853631 100644
--- a/test/data/output-map-external-examples.js
+++ b/test/data/output-map-external-examples.js
@@ -1,8 +1,8 @@
 /* eslint-disable max-len */
 module.exports = {
     text: `Validating with mapping file
-Response schemas with examples found: 2
-Response examples without schema found: 0
+Schemas with examples found: 2
+Examples without schema found: 0
 Total examples found: 0
 Matching mapping files found: 1
 
diff --git a/test/data/output-single-external-example-valid.js b/test/data/output-single-external-example-valid.js
index 73d2809..583035a 100644
--- a/test/data/output-single-external-example-valid.js
+++ b/test/data/output-single-external-example-valid.js
@@ -1,8 +1,8 @@
 /* eslint-disable max-len */
 module.exports = {
     text: `Validating single external example
-Response schemas with examples found: 1
-Response examples without schema found: 0
+Schemas with examples found: 1
+Examples without schema found: 0
 Total examples found: 1
 
 No errors found.
diff --git a/test/data/v3/request-invalid-requestbody-examples.json b/test/data/v3/request-invalid-requestbody-examples.json
index ed58241..c8efff1 100644
--- a/test/data/v3/request-invalid-requestbody-examples.json
+++ b/test/data/v3/request-invalid-requestbody-examples.json
@@ -42,11 +42,23 @@
               },
               "examples": {
                 "default": {
-                  "summary": "Standard example",
+                  "summary": "Standard invalid example",
                   "value": {
                     "name": 5,
                     "tag": "Doggo"
                   }
+                },
+                "example2": {
+                  "summary": "Another invalid example",
+                  "value": {
+                    "tag": "Doggo"
+                  }
+                },
+                "example3": {
+                  "summary": "Yet another invalid example",
+                  "value": {
+                    "name": "Ronald"
+                  }
                 }
               }
             }
diff --git a/test/data/v3/request-valid-parameter-examples.json b/test/data/v3/request-valid-parameter-examples.json
index e29f487..b2b7a49 100644
--- a/test/data/v3/request-valid-parameter-examples.json
+++ b/test/data/v3/request-valid-parameter-examples.json
@@ -116,6 +116,10 @@
               "default": {
                 "summary": "Standard example",
                 "value": 5
+              },
+              "generic1": {
+                "summary": "Standard example",
+                "value": 10
               }
             }
           }
diff --git a/test/data/v3/simple-api-with-examples.json b/test/data/v3/simple-api-with-examples.json
index 2b5f961..1364147 100644
--- a/test/data/v3/simple-api-with-examples.json
+++ b/test/data/v3/simple-api-with-examples.json
@@ -73,6 +73,39 @@
                         "tag": "Doggo"
                       }
                     ]
+                  },
+                  "two": {
+                    "value": [
+                      {
+                        "id": 0,
+                        "name": "Herbert",
+                        "tag": "Doggo"
+                      },
+                      {
+                        "id": 1,
+                        "name": "Mannie",
+                        "tag": "Cat"
+                      }
+                    ]
+                  },
+                  "three": {
+                    "value": [
+                      {
+                        "id": 0,
+                        "name": "Herbert",
+                        "tag": "Doggo"
+                      },
+                      {
+                        "id": 1,
+                        "name": "Mannie",
+                        "tag": "Cat"
+                      },
+                      {
+                        "id": 2,
+                        "name": "Fluffers",
+                        "tag": "Bunny"
+                      }
+                    ]
                   }
                 }
               }
diff --git a/test/specs/impl/v2/index.js b/test/specs/impl/v2/index.js
index 99c36a9..40088d9 100644
--- a/test/specs/impl/v2/index.js
+++ b/test/specs/impl/v2/index.js
@@ -240,7 +240,7 @@ describe('Main-module, for v2 should', () => {
                 result.valid.should.equal(false);
                 result.errors.should.deep.equal([
                     new ApplicationError(ErrorType.jsonPathNotFound, {
-                        message: "Path to response-schema can't be found: "
+                        message: "Path to schema can't be found: "
                             + `'${ PATH__SCHEMA_EXTERNAL_EXAMPLE_INVALID }'`,
                         params: {
                             path: PATH__SCHEMA_EXTERNAL_EXAMPLE_INVALID
@@ -256,7 +256,7 @@ describe('Main-module, for v2 should', () => {
                 result.errors.should.deep.equal([
                     new ApplicationError(ErrorType.jsonPathNotFound, {
                         mapFilePath: FILE_PATH__EXTERNAL_EXAMPLES_MAP_WITH_WRONG_SCHEMA_PATH,
-                        message: "Path to response-schema can't be found: "
+                        message: "Path to schema can't be found: "
                             + `'${ PATH__SCHEMA_EXTERNAL_EXAMPLE_INVALID }'`,
                         params: {
                             path: PATH__SCHEMA_EXTERNAL_EXAMPLE_INVALID
@@ -310,9 +310,9 @@ describe('Main-module, for v2 should', () => {
         it('should collect the statistics over all mapping-files', () => {
             validateExamplesByMap(FILE_PATH__EXTERNAL_EXAMPLES_SCHEMA, FILE_PATH__EXTERNAL_EXAMPLES_GLOB)
                 .statistics.should.deep.equal({
-                    responseSchemasWithExamples: 4,
-                    responseExamplesWithoutSchema: 0,
-                    responseExamplesTotal: 7,
+                    schemasWithExamples: 4,
+                    examplesWithoutSchema: 0,
+                    examplesTotal: 7,
                     matchingFilePathsMapping: 2
                 });
         });
@@ -323,9 +323,9 @@ describe('Main-module, for v2 should', () => {
                 FILE_PATH__EXTERNAL_EXAMPLES_MAP__RELATIVE, { cwdToMappingFile: true });
             result.valid.should.equal(true);
             result.statistics.should.deep.equal({
-                responseSchemasWithExamples: 2,
-                responseExamplesWithoutSchema: 0,
-                responseExamplesTotal: 3,
+                schemasWithExamples: 2,
+                examplesWithoutSchema: 0,
+                examplesTotal: 3,
                 matchingFilePathsMapping: 1
             });
         });
diff --git a/test/specs/impl/v3/index.js b/test/specs/impl/v3/index.js
index e3d6447..e2e96a7 100644
--- a/test/specs/impl/v3/index.js
+++ b/test/specs/impl/v3/index.js
@@ -54,7 +54,15 @@ describe('Main-module, for v3 should', function() {
             });
         });
         describe('`examples`-property', function() {
-            it('valid single example', function() {
+            it('statistics for multiple examples', function() {
+                const { statistics } = validateExamples(loadTestData(REL_PATH__EXAMPLES__SIMPLE));
+                statistics.should.deep.equal({
+                    examplesTotal: 3,
+                    examplesWithoutSchema: 0,
+                    schemasWithExamples: 1
+                });
+            });
+            it('valid examples', function() {
                 validateExamples(loadTestData(REL_PATH__EXAMPLES__SIMPLE)).valid.should.equal(true);
             });
             it('example with internal refs', function() {
@@ -86,6 +94,14 @@ describe('Main-module, for v3 should', function() {
     });
     describe('be able to validate request parameters', function() {
         describe('in example-property', function() {
+            it('with statistics', function() {
+                const { statistics } = validateFile(FILE_PATH__VALID__REQUEST_PARAMETER);
+                statistics.should.deep.equal({
+                    examplesTotal: 1,
+                    examplesWithoutSchema: 0,
+                    schemasWithExamples: 1
+                });
+            });
             it('with a valid example', function() {
                 validateFile(FILE_PATH__VALID__REQUEST_PARAMETER).valid.should.equal(true);
             });
@@ -94,6 +110,14 @@ describe('Main-module, for v3 should', function() {
             });
         });
         describe('in examples-property', function() {
+            it('with statistics', function() {
+                const { statistics } = validateFile(FILE_PATH__VALID__REQUEST_PARAMETER__EXAMPLES);
+                statistics.should.deep.equal({
+                    examplesTotal: 2,
+                    examplesWithoutSchema: 0,
+                    schemasWithExamples: 1
+                });
+            });
             it('with a valid example', function() {
                 validateFile(FILE_PATH__VALID__REQUEST_PARAMETER__EXAMPLES).valid.should.equal(true);
             });
@@ -104,6 +128,14 @@ describe('Main-module, for v3 should', function() {
     });
     describe('be able to validate request-bodies', function() {
         describe('in example-property', function() {
+            it('with statistics', function() {
+                const { statistics } = validateFile(FILE_PATH__VALID__REQUEST_BODY);
+                statistics.should.deep.equal({
+                    examplesTotal: 2,
+                    examplesWithoutSchema: 0,
+                    schemasWithExamples: 2
+                });
+            });
             it('with a valid example', function() {
                 validateFile(FILE_PATH__VALID__REQUEST_BODY).valid.should.equal(true);
             });
@@ -112,11 +144,27 @@ describe('Main-module, for v3 should', function() {
             });
         });
         describe('in examples-property', function() {
+            it('with statistics', function() {
+                const { statistics } = validateFile(FILE_PATH__VALID__REQUEST_BODY__EXAMPLES);
+                statistics.should.deep.equal({
+                    examplesTotal: 2,
+                    examplesWithoutSchema: 0,
+                    schemasWithExamples: 2
+                });
+            });
             it('with a valid example', function() {
                 validateFile(FILE_PATH__VALID__REQUEST_BODY__EXAMPLES).valid.should.equal(true);
             });
-            it('with an invalid example', function() {
-                validateFile(FILE_PATH__INVALID__REQUEST_BODY__EXAMPLES).valid.should.equal(false);
+            describe('with invalid examples', function() {
+                before(function() {
+                    this.validationResult = validateFile(FILE_PATH__INVALID__REQUEST_BODY__EXAMPLES);
+                });
+                it('should recognize it as invalid', function() {
+                    this.validationResult.valid.should.equal(false);
+                });
+                it('should recognize all errors', function() {
+                    this.validationResult.errors.length.should.equal(3);
+                });
             });
         });
     });
diff --git a/test/specs/index.js b/test/specs/index.js
index f32683c..b3c7dd9 100644
--- a/test/specs/index.js
+++ b/test/specs/index.js
@@ -78,25 +78,25 @@ describe('Main API', function() {
             it('with examples with missing schemas', () => {
                 validateFile(getPathOfTestData('simple-example')).statistics.should.deep
                     .equal({
-                        responseSchemasWithExamples: 1,
-                        responseExamplesWithoutSchema: 3,
-                        responseExamplesTotal: 4
+                        schemasWithExamples: 1,
+                        examplesWithoutSchema: 3,
+                        examplesTotal: 4
                     });
             });
             it('without examples', () => {
                 validateFile(getPathOfTestData('valid-without-examples')).statistics.should.deep
                     .equal({
-                        responseSchemasWithExamples: 1,
-                        responseExamplesWithoutSchema: 0,
-                        responseExamplesTotal: 1
+                        schemasWithExamples: 1,
+                        examplesWithoutSchema: 0,
+                        examplesTotal: 1
                     });
             });
             it('without schema', () => {
                 validateFile(getPathOfTestData('valid-without-schema')).statistics.should.deep
                     .equal({
-                        responseSchemasWithExamples: 1,
-                        responseExamplesWithoutSchema: 1,
-                        responseExamplesTotal: 2
+                        schemasWithExamples: 1,
+                        examplesWithoutSchema: 1,
+                        examplesTotal: 2
                     });
             });
         });