Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 70c7925

Browse files
Merge pull request #368 from apiaryio/361-deprecate-amanda
Adds deprecation warning on JSON Schema Draft 3 usage
2 parents 5884b69 + 1c0f9b1 commit 70c7925

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/utils/warn-on-deprecation.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable no-console */
2+
3+
/**
4+
* Outputs a deprecation message.
5+
* Supports silencing the messages based on the environmental variable.
6+
* @param {string} message
7+
*/
8+
module.exports = function warnOnDeprecation(message) {
9+
const shouldOutputMessage =
10+
typeof process === 'undefined' ||
11+
!process.env.SUPPRESS_DEPRECATION_WARNINGS;
12+
13+
if (shouldOutputMessage) {
14+
console.warn(`DEPRECATED: ${message}`);
15+
}
16+
};

lib/validators/json-schema-legacy.js

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const jsonPointer = require('json-pointer');
55
const { JsonSchemaValidator, META_SCHEMA } = require('./json-schema-next');
66
const { ValidationErrors } = require('./validation-errors');
77
const toGavelResult = require('../utils/to-gavel-result');
8+
const warnOnDeprecation = require('../utils/warn-on-deprecation');
89

910
/**
1011
* Returns a proper article for a given string.
@@ -76,6 +77,10 @@ class JsonSchemaLegacy extends JsonSchemaValidator {
7677

7778
switch (this.jsonSchemaVersion) {
7879
case 'draftV3':
80+
warnOnDeprecation(
81+
'JSON Schema Draft V3 is deprecated. Please use a newer version of JSON Schema (Draft V4-7).'
82+
);
83+
7984
return this.validateUsingAmanda(parsedData);
8085
case 'draftV4':
8186
return this.validateUsingTV4(parsedData);

0 commit comments

Comments
 (0)