我是Strongloop的新手,我找不到有关如何自定义响应类(我构建的对象的模型架构)的信息,我不知道如何在API资源管理器上显示带有自定义数据的对象.
例如,我有一个名为score的自定义远程方法
POST /Challenges/score
Run Code Online (Sandbox Code Playgroud)
我想为参数显示data一个自定义模型模式而不是单个参数,而不是模型模式用于挑战,正文上的数据具有所有参数并向用户显示数据类型:模型模式,这可能吗?
{
"id": "string",
"limit": 0,
"order": "string",
"userId": "string"
}
Run Code Online (Sandbox Code Playgroud)
另一方面,在Response Class中,我想显示响应对象的模式.像这样的东西:
{
"id":"string",
"userId":"string",
"user": {},
"totalScore":0,
"tags": []
}
Run Code Online (Sandbox Code Playgroud)
我看了不同的问题(这个和这个),但找不到解决这个问题的东西.
更新
这是远程方法的定义
Challenge.remoteMethod('score', {
accepts: { arg: 'data', type: 'object', http: { source: 'body' } },
returns: {arg: 'scores', type: 'array'},
http: {path: '/score', verb: 'post'}
});
Run Code Online (Sandbox Code Playgroud)