Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restler not accepting boolean false

Tags:

restler

In my Restler API class I have an object defined like so (with lots of other params)

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;
}

And then I attempt to use it in my PATCH method:

  /**
   * 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)

If I pass in true for the pinned property it works fine, but if I pass false then I get a 400 from Restler with the message:

Bad Request: Invalid value specified for info[pinned]

like image 255
Gargoyle Avatar asked Feb 09 '17 04:02

Gargoyle


1 Answers

OK, discovered that Restler's Validator.php is failing to parse the @var property the way it's written. If you remove the |null part then it works as expected. I've submitted an issue to the github site.

like image 167
Gargoyle Avatar answered Nov 07 '22 17:11

Gargoyle