api-platform:我的过滤器出了什么问题?

时间:2019-09-06 13:48:36

标签: api-platform.com

我对此实体设置了此过滤器:

@ApiFilter(SearchFilter::class, properties={"shortName":"exact"})

当我在邮递员中对该网址进行测试时:

{{path}} / levels?shortName = TOTO

我得到了一些带有除whished过滤器之外的其他值的行。我的过滤器出了什么问题?

{
"@context": "/evaluation/api/contexts/Level",
"@id": "/evaluation/api/v1/levels",
"@type": "hydra:Collection",
"hydra:member": [
    {
        "@id": "/evaluation/api/v1/levels/524701de-448b-4380-875c-ff6debfafc8c",
        "@type": "Level",
        "id": "524701de-448b-4380-875c-ff6debfafc8c",
        "shortName": "IN_ACQUISITION",
        "position": 20,
        "priority": 20,

Merci Dom

1 个答案:

答案 0 :(得分:1)

{{path}}/levels?shortName[]=TOTO之类的过滤器(请注意方括号)用作described in the documentation。否则它将被忽略,并且您将获得返回的结果,就像URL的查询组件不存在一样。