繁体   English   中英

使用Restler进行许多可选参数的服务

[英]Service with many optional parameters with Restler

我有使用许多可选参数的服务:

/**
 * Change user settings
 *
 * @smart-auto-routing false
 * @url POST settings/
 * @param string $name New name of the user {@min 2}{@max 64}
 * @param string $surname New surname of the user {@min 2}{@max 64}
 * @param bool $sex 0 for man, 1 for girl
 * @param string $email New email address of the user {@type email}
 * @param bool $emailing 1 if user want to receive email from ilerter, 0 else
 * @param string $phone_number New phone number of the user {@min 4}
 * @param int $height {@from body}
 * @param int $weight {@from body}
 * @param int $eyes_color {@from body}
 * @param int $hair_color {@from body}
 * @param string $avatar {@from body}
 * @param string $description {@from body}
 * @return bool
 * @throws \Luracast\Restler\RestException
 */
public function settings($name, $surname, $sex, $email, $emailing, $phone_number,
$height = "", $weight = "", $eyes_color = "", $hair_color = "", $avatar = "",
$description = ""){

问题是当我决定仅在可选参数中发送“头像”时,我的服务将其放入$ height并返回

Bad Request: invalid value specified for `height`. Expecting integer value

如果Restler不是第一个可选参数,它是否可以捕获唯一好的可选值?

当有太多相互重叠的路由时,很难分辨出哪个值映射到哪个参数

Restler 3尝试按类型匹配参数,因为身高,体重,eyes_color,hair_color被键入为整数,因此在给定字符串值时它们不会干扰,因此头像可以将其作为第一个输入

但是由于您是通过将字符串参数分配给身高,体重等来弄乱类型的,因此Restler现在将它们视为字符串,因此最终会遇到上述问题

尝试将零指定为int值的默认值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM