code: function addSchema(schema, key) {
      if (!schema) {
          throw new Error("Schema is required");
      }
      if (_.isArray(schema)) {
          if (key) {
              throw new Error("Cannot call add schema with an array of schemas and a key. Id from each schema will be used as the key");
          }
          return schema.forEach(function (schemaItem) {
              addSchema(schemaItem, null);
          });
      }
      if (!_.isObject(schema)) {
          throw new Error("Schema must be an object");
      }
      if (!key && !schema.$id) {
          throw new Error(util.format("No key was provided and no $id was set, for performance reasons don't do this. %j", schema));
      }
      if(!key){
          key = schema.$id;
      }
      try{
          ajv.addSchema(schema, key);
      }
      catch (err){
          throw new Error(util.format('Error adding schema "%s".\n%s\n', key, err.message));
      }
  }
docs: Adds schema(s) to the instance.
  @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
  @param {String} [key] Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
  @returns {void}
  @private