无法通过 hyperledger rest 服务器访问数组中的资产

Unable to access assets from an array through hyperledger rest server

我正在尝试通过 hyperledger rest api 从另一个资产访问数组内的资产。

我的 .cto 的一部分如下所示:

asset AirSpaceZones identified by Id {
  o String Id 
  --> zone [] reqZones
  --> CTAzone [] CTA

}


abstract asset zone identified by Id {
  o String Id
  o String zoneName

}

asset CTAzone extends zone {
  o String upperLimit
  o String lowerLimit 
  o String type 
  o String zoneClass

} 

我的 Api 调用如下所示: http://localhost:3000/api/AirSpaceZones/PermanentAirspace

响应是:

$class  "org.example.nz.AirSpaceZones"
Id  "PermanentAirspace"
reqZones    
0   "resource:org.example.nz.CTAzone#NZA131"
1   "resource:org.example.nz.FIRzone#NZZC"
CTA 
0   "resource:org.example.nz.CTAzone#NZA131"

我需要 api 调用就像 http://localhost:3000/api/AirSpaceZones/PermanentAirspace/CTA/NZA131

解决方案是为模型定义关系,hyperledger rests 服务器使用环回连接器,因此:

  1. 针对您的 运行 业务网络创建环回连接器应用 参考:https://hyperledger.github.io/composer/latest/integrating/customizing-the-rest-server

  2. 定义关系,参考:https://loopback.io/doc/en/lb3/Creating-model-relations.html