diff options
Diffstat (limited to 'node_modules/ajv-keywords/keywords/switch.js')
-rw-r--r-- | node_modules/ajv-keywords/keywords/switch.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/node_modules/ajv-keywords/keywords/switch.js b/node_modules/ajv-keywords/keywords/switch.js index 8c22bf8b9..5b0f3f830 100644 --- a/node_modules/ajv-keywords/keywords/switch.js +++ b/node_modules/ajv-keywords/keywords/switch.js @@ -1,12 +1,11 @@ 'use strict'; +var util = require('./_util'); + module.exports = function defFunc(ajv) { - if (ajv.RULES.keywords.switch) - return console.warn('Keyword switch is already defined'); + if (ajv.RULES.keywords.switch && ajv.RULES.keywords.if) return; - var metaSchemaUri = ajv._opts.v5 - ? 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#' - : 'http://json-schema.org/draft-04/schema#'; + var metaSchemaRef = util.metaSchemaRef(ajv); defFunc.definition = { inline: require('./dotjs/switch'), @@ -17,11 +16,11 @@ module.exports = function defFunc(ajv) { items: { required: [ 'then' ], properties: { - 'if': { $ref: metaSchemaUri }, + 'if': metaSchemaRef, 'then': { anyOf: [ { type: 'boolean' }, - { $ref: metaSchemaUri } + metaSchemaRef ] }, 'continue': { type: 'boolean' } |