defaults = (schema, definitions) => {
    if (typeof schema.default !== 'undefined') {
      return schema.default;
    } if (typeof schema.allOf !== 'undefined') {
      const mergedItem = mergeAllOf(schema.allOf, definitions);
      return defaults(mergedItem, definitions);
    } if (typeof schema.$ref !== 'undefined') {
      const reference = getLocalRef(schema.$ref, definitions);
      return defaults(reference, definitions);
    } if (schema.type === 'object') {
      if (!schema.properties) {
        return undefined;
      }

      Object.keys(schema.properties).forEach((key) => {
        schema.properties[key] = defaults(schema.properties[key], definitions);

        if (typeof schema.properties[key] === 'undefined') {
          delete schema.properties[key];
        }
      });

      return schema.properties;
    } if (schema.type === 'array') {
      if (!schema.items) {
        return [];
      }

      // minimum item count
      const ct = schema.minItems || 0;
      // tuple-typed arrays
      if (schema.items.constructor === Array) {
        const values = schema.items.map((item) => defaults(item, definitions));
        // remove undefined items at the end (unless required by minItems)
        for (let i = values.length - 1; i >= 0; i -= 1) {
          if (typeof values[i] !== 'undefined') {
            break;
          }
          if (i + 1 > ct) {
            values.pop();
          }
        }
        return values;
      }
      // object-typed arrays
      const value = defaults(schema.items, definitions);
      if (typeof value === 'undefined') {
        return [];
      }
      const vals = [];
      for (let j = 0; j < Math.max(1, ct); j += 1) {
        vals.push(cloneJSON(value));
      }
      return vals;
    }
  }
returns a object that built with default values from json schema

@param {Object} schema
@param {Object} definitions
@return {Object}