Skip to content

Commit

Permalink
refactor: uses raw TV4 error format for header-related error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed Dec 2, 2019
1 parent 75650c2 commit 9bccf12
Show file tree
Hide file tree
Showing 6 changed files with 828 additions and 816 deletions.
13 changes: 6 additions & 7 deletions lib/validators/headers-json-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
SchemaV4Generator,
SchemaV4Properties
} = require('../utils/schema-v4-generator');
const tv4ToHeadersMessage = require('../utils/tv4-to-headers-message');

const resolveHeaders = (headers) => {
if (typeof headers !== 'object') {
Expand Down Expand Up @@ -67,12 +66,12 @@ class HeadersJsonExample extends JsonSchemaLegacy {
const resolvedData = resolveHeaders(data);
const results = super.validate(resolvedData);

return results.map((result) => {
return {
...result,
message: tv4ToHeadersMessage(result.message, this.expected)
};
});
/**
* @TODO Revert custom formatting of TV4 header-related validation errors.
* @see https://github.com/apiaryio/gavel.js/issues/360
* @see https://github.com/apiaryio/gavel.js/blob/816b7ab1fb8fec345f842e93edc214a532758323/lib/validators/headers-json-example.js#L76-L81
*/
return results;
}
}

Expand Down
7 changes: 0 additions & 7 deletions lib/validators/json-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ class JsonExample extends JsonSchema {
validate(actual) {
const { jsonSchema: expected } = this;

console.log(
'JsonExample: Validating',
JSON.stringify(actual, null, 2),
'against',
JSON.stringify(expected, null, 2)
);

if (typeof actual !== 'string') {
const outError = new errors.MalformedDataError(
'JsonExample validator: provided actual data is not string'
Expand Down
1 change: 0 additions & 1 deletion lib/validators/json-schema-next.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class JsonSchemaValidator {
try {
resolvedData = parseJson(data);
} catch (error) {
console.log('failed json', data);
const dataError = new errors.DataNotJsonParsableError(
`Expected data to be a valid JSON, but got: ${data}. ${error.message}`
);
Expand Down
Loading

0 comments on commit 9bccf12

Please sign in to comment.