twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

data.js (1046B)


      1 'use strict';
      2 
      3 var KEYWORDS = [
      4   'multipleOf',
      5   'maximum',
      6   'exclusiveMaximum',
      7   'minimum',
      8   'exclusiveMinimum',
      9   'maxLength',
     10   'minLength',
     11   'pattern',
     12   'additionalItems',
     13   'maxItems',
     14   'minItems',
     15   'uniqueItems',
     16   'maxProperties',
     17   'minProperties',
     18   'required',
     19   'additionalProperties',
     20   'enum',
     21   'format',
     22   'const'
     23 ];
     24 
     25 module.exports = function (metaSchema, keywordsJsonPointers) {
     26   for (var i=0; i<keywordsJsonPointers.length; i++) {
     27     metaSchema = JSON.parse(JSON.stringify(metaSchema));
     28     var segments = keywordsJsonPointers[i].split('/');
     29     var keywords = metaSchema;
     30     var j;
     31     for (j=1; j<segments.length; j++)
     32       keywords = keywords[segments[j]];
     33 
     34     for (j=0; j<KEYWORDS.length; j++) {
     35       var key = KEYWORDS[j];
     36       var schema = keywords[key];
     37       if (schema) {
     38         keywords[key] = {
     39           anyOf: [
     40             schema,
     41             { $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
     42           ]
     43         };
     44       }
     45     }
     46   }
     47 
     48   return metaSchema;
     49 };