ValidationException:org.acme.shipping.perishable.AccelReading类型的意外属性

时间:2018-11-21 16:19:08

标签: hyperledger-fabric hyperledger-explorer

我跟随these instructions,运行setupdemo事务(它仅添加了一些示例数据),并成功添加了一个加速度计,可读取现有的运输到区块链。 装运数据包含加速度计读数:

{
  "$class": "org.acme.shipping.perishable.Shipment",
  "shipmentId": "320022000251363131363432",
  "type": "MEDICINE",
  "status": "IN_TRANSIT",
  "unitCount": 5000,
  "contract": "resource:org.acme.shipping.perishable.Contract#CON_002",
  "AccelReadings": [
    {
      "$class": "org.acme.shipping.perishable.AccelReading",
      "accel_x": 4,
      "accel_y": 4,
      "accel_z": 4,
      "latitude": "51",
      "longitude": "11",
      "readingTime": "2018-11-21T19:40:30.000Z",
      "shipment": "resource:org.acme.shipping.perishable.Shipment#320022000251363131363432",
      "transactionId": "01aed2c05c78cf638cc68e9bb4ab7428dc7bae212c6409c27049c372f5caee67",
      "timestamp": "2018-11-21T18:45:42.497Z"
    }
  ]
}

但是,在运行GET / AccelReading的资源管理器中出现错误。

{
  "error": {
    "statusCode": 500,
    "name": "ValidationException",
    "message": "Unexpected properties for type org.acme.shipping.perishable.AccelReading: accel_x, accel_y, accel_z, latitude, longitude, readingTime",
    "stack": "ValidationException: Unexpected properties for type org.acme.shipping.perishable.AccelReading: accel_x, accel_y, accel_z, latitude, longitude, readingTime\n    at validateProperties (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:60:15)\n    at JSONPopulator.visitClassDeclaration (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:118:9)\n    at JSONPopulator.visit (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:96:25)\n    at TransactionDeclaration.accept (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:65:24)\n    at Serializer.fromJSON (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer.js:180:26)\n    at resources.map (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-client/lib/registry.js:302:44)\n    at Array.map (<anonymous>)\n    at Util.queryChainCode.then.then (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-client/lib/registry.js:301:34)\n    at <anonymous>"
  }
}

1 个答案:

答案 0 :(得分:0)

将过滤器设置为{“ include”:“ resolve”}时,可以看到包括其AccelReading数据在内的货件