code: function model_jsonSchema(fields, populate, readonly) {
    var jsonSchema = this.schema.jsonSchema(this.modelName);
  
    if (populate != null) {
      jsonSchema = __populate.call(this, jsonSchema, populate);
    };
  
    __excludedPaths(this.schema, fields).forEach(
      __delPath.bind(null, jsonSchema)
    );
  
    if (readonly) {
      __excludedReadonlyPaths(jsonSchema, readonly);
    }
  
    if (fields) __removeRequired(jsonSchema);
  
    return jsonSchema;
  }
docs: model_jsonSchema - builds json schema for model considering
  the selection and population
  
  if `fields` specified the method removes `required` contraints
  
  @memberof mongoose.Model
  
  @param  {String|Array|Object} fields   mongoose selection object
  @param  {String|Object} populate mongoose population options
  @return {object}          json schema