在我的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/