[英]Symfony2 FOSRestBundle requirements of QueryParam
I have the following method with annotation: 我有以下带有注释的方法:
/**
* Search on players.
*
* @ApiDoc(
* output = "bbb\FrontendBundle\Entity\Player",
* statusCodes = {
* 200 = "Returned when successful",
* 404 = "Returned when no result was found"
* }
* )
*
* @Annotations\QueryParam(name="searchterm", requirements="[a-z]+", nullable=false, description="The term to search about in players.")
* @Annotations\QueryParam(name="limit", requirements="\d+", default="3", nullable=true, description="How many results to return.")
*
* @param Request $request the request object
* @param $searchterm
* @param $limit
* @return array
* @throws NotFoundHttpException when no result was found
*
* @Method("GET")
* @Route("/search", name="_api_player_search", options={"expose"=true})
*/
public function searchPlayerAction(Request $request, $searchterm, $limit)
{
}
The problem is, that if i give for example "Aaron" as searchterm ( api/player/search?searchterm=Aaron
) the variable $searchterm is null. 问题是,如果我给出“ Aaron”作为api/player/search?searchterm=Aaron
( api/player/search?searchterm=Aaron
),则变量$ searchterm为空。 if i try api/player/search?searchterm=aaron
everything works fine. 如果我尝试api/player/search?searchterm=aaron
一切正常。 I guess the problem is the requirements="[az]+"
property of the QueryParam annotation. 我想问题是QueryParam批注的requirements="[az]+"
属性。 How can i configure that uppercase charakters are also allowed? 如何配置还允许使用大写字符?
(The same with spaces etc..) (空格等也一样。)
Thank you for your help! 谢谢您的帮助!
尝试将requirements="[az]+"
更改requirements="[a-zA-Z]+"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.