ReSTLer不接受 bool 值false

标签 restler

在我的ReSTLer API类中,我有一个像这样定义的对象(带有许多其他参数)

class PatchTaskObj extends TaskObj {
    /**
     * @var bool|null Whether or not this Task should be pinned to the top of the list {@required false}
     */
    public $pinned = null;
}

然后我尝试在我的PATCH方法中使用它:

  /**
   * Updates an existing Task record.
   *
   * @param int          $id   The SQL ident of the task you wish to update. {@min 1} {@from path}
   * @param PatchTaskObj $info The properties of the Task to update.
   *
   * @throws RestException 412 Thrown if at least one update isn't passed in.
   *
   * @status 204
   */
  function patch($id, PatchTaskObj $info)

如果我为true属性传递pinned,它可以正常工作,但是如果我传递false,那么我会从ReSTLer得到400并显示以下消息:

Bad Request: Invalid value specified for info[pinned]

最佳答案

好的,发现ReSTLer的Validator.php无法以编写方式解析@var属性。如果删除|null部分,则它将按预期工作。我已经向github站点提交了一个问题。

关于ReSTLer不接受 bool 值false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42128355/

相关文章:

javascript - 在 Node.js 中使用 reSTLer 获取 HTTP 响应

php - 如何正确格式化 PDO 结果? - 以字符串形式返回的数字结果?

php - 所有 Url 的 ReSTLer 都出现 404 错误

php - reSTLer 资源管理器提示查看器与 REQUEST_BODY json

php ReSTLer 路由

php - ReSTLer 总是返回 404 : Not found

php - ReSTLer 3 - 参数的默认值阻止传递参数的能力

php - 我可以将 namespace 与 reSTLer 一起使用吗?