【发布时间】:2023-12-28 07:41:01
【问题描述】:
我的 hydra vocab 类似于Markus-lanthaler Vocab。这是我在用户类上检索用户集合的操作之一。
{
"@id": "payu:retrieve_users",
"@type": "hydra:Operation",
"method": "GET",
"label": "Retrieve users",
"description": "Retrieves Users",
"expects": null,
"returns": "hydra:Collection",
"IriTemplate" : {
"@type" : "IriTemplate",
"template" : "{?userIds,firstName,lastName}",
"variableRepresentation": "BasicRepresentation",
"mapping" : [
{
"@type" : "IriTemplateMapping",
"variable" : "userIds",
"property" : "hydra:property",
"required" : false
},
{
"@type" : "IriTemplateMapping",
"variable" : "firstName",
"property" : "hydra:property",
"required" : false
},
{
"@type" : "IriTemplateMapping",
"variable" : "lastName",
"property" : "hydra:property",
"required" : false
}
]
}
}
正如你在 IRItemplate 中看到的那样
"template" : "{?userIds,firstName,lastName}"
所以我想控制检索,第三人将能够通过 (userIds) 或 (firstName,lastName) 检索。
我是否应该使用 IRItemplate 进行两个单独的 hydra 操作:
在第一次操作中:
"template" : "{?userIds}"
在第二次行动中:
"template" : "{?firstName,lastName}"
或者在 Hydra 规范中是否有任何现有的方法可以使用单一操作来做到这一点?
【问题讨论】:
标签: rest json-ld hydra-core