如何在响应 composer-rest-server 中包含关系对象?

How to include relationship object in response composer-rest-server?

我们将Asset定义为:

asset PurchaseOrder identified by orderId {
  o String orderId
    --> SupplierChainParticipant createdBy
    --> SupplierChainParticipant assignedTo
  o String description    
  o String status
  o Integer quantity
  o String assetId    
}

Participant为:

participant SupplierChainParticipant  identified by participantId {
  o String participantId
  o String identity
  o String type     
}

现在,当我使用 composer-rest-server 的 REST API 获取 Asset 详细信息时,我收到的响应为:

{
  "orderId": "o5",
  "createdBy": "resource:com.supplychain-network.SupplierChainParticipant#p1",
  "assignedTo": "resource:com.supplychain-network.SupplierChainParticipant#p2",
  "description": "New Engine",
  "status": "created",
  "quantity": 1,
  "assetId": "a1"
}

由于目前它仅在获取 Asset 详细信息时返回 participantId,有没有办法获取参与者的详细信息以及 Asset 作为 JSON 响应?

如果您指定一个名为 include 的过滤键并将值设置为 resolve,则关系将被解析,相关资产也将被返回。

通过示例改进已接受的答案 -

1. 'http://localhost:3000/api/PurchaseOrder?filter={"where":{"orderId":"A01"},"include":"resolve"}'

2. 'http://localhost:3000/api/PurchaseOrder?filter={"include":"resolve"}'