Php 是否可能使用正则表达式进行PSR-7验证?(参数碰撞)
我目前正在通过Symfony(5.1)Routes和NelmioApiDocBundle生成OpenAPI注释 其中一条路线如下所示:Php 是否可能使用正则表达式进行PSR-7验证?(参数碰撞),php,symfony,openapi,nelmioapidocbundle,psr-7,Php,Symfony,Openapi,Nelmioapidocbundle,Psr 7,我目前正在通过Symfony(5.1)Routes和NelmioApiDocBundle生成OpenAPI注释 其中一条路线如下所示: * @Route("/users/{id}", methods={"GET"}, requirements={"id": "\d+"}) * @OA\Parameter(name="id", in="path", description=&
* @Route("/users/{id}", methods={"GET"}, requirements={"id": "\d+"})
* @OA\Parameter(name="id", in="path", description="The id of the user", required=true, @OA\Schema(type="integer"))
还有一个
* @Route("/users/followed", methods={"GET"})
我正在使用联盟的OpenAPI PSR-7消息验证器(),通过Symfony/PSR http消息桥
和nyholm/psr7
将Symfony请求转换为PSR-7请求。除了这两个端点之外,所有这些都工作得很好。我一直在
给定的请求与以下操作匹配:[/api/users/{id},get],/api/charter calculations/followerd,get]。但是,它与他们的模式不匹配。
是否可能
/后面的只能与/{id}
匹配?因此验证器会感到困惑吗?或者像我已经做过的那样为{id}
设置正则表达式是可能的吗?想出来了,所以回答我自己。这对我的问题有点特殊,但可能对其他人有帮助
我有额外的参数,比如
* @OA\Parameter(name="pageSize", in="query", @OA\Schema(type="integer"))
当我对一些验证进行单元测试以触发错误(例如,pageSize=test
)时,它会抛出League\openapividation\PSR7\Exception\Validation\InvalidQueryArgs
但是,当我添加“/users/follow”
端点时,之前的测试会抛出一个不同的错误:League\openapivalization\PSR7\Exception\MultipleOperationsMismatchForRequest
,因为现在的错误不是“嘿,我找到了端点,但查询是错误的!”而是“嘿,我找到了多个可能的端点,它们都错了!“