问题描述
我写了一个服务操作看起来像
@DomainService(
nature = NatureOfService.VIEW_REST_ONLY,objectType = "rest.oneservice"
)
onepackage.Oneservice{
@Action(semantics = SemanticsOf.SAFE)
public List<Data> findDataByPerson(Person person,LocalDate start,LocalDate end){
...
}
}
在 SwaggerUI 中暴露为
get /services/rest.oneservice/actions/findDataByPerson/invoke
我找不到如何将域对象作为参数发送到rest api;
我该怎么做?
谢谢。
解决方法
对域对象的引用使用以下格式:
{
"person": {
"value": {
"href": "http://~/objects/person.Person/123"
}
}
}
其中 person.Person
是引用类型的对象类型(根据 @DomainObject(objectType=...))。
如果使用 PUT (@Action(semantics=IDEMPOTENT)) 或 POST (@Action(semantics=NON_IDEMPOTENT)) 调用操作,则上述内容将是正文。
如果使用 GET (@Action(semantics=SAFE)) 调用,那么该 json 将需要进行 URL 编码和附加。
规范第 2.10 节中的更多详细信息,也可在线获取here