环回资源管理器内联模型需要模型模式
问题描述:
我坚持使用我的remoteMethods不显示环回资源管理器中的默认值。 如果我输入一个JSON对象,那么这个帖子将会创建,但通常会有一个示例“Model Schema”。这里只是说内联模型。环回资源管理器内联模型需要模型模式
任何想法?
模型定义:
{
"name": "PicklistModel",
"plural": "PicklistModels",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"picklistId": {
"type": "string",
"id": true,
"generated": true
},
"key": {
"type": "string",
"required": false
},
"value": {
"type": "string",
"required": false
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
远程方法的定义:
Picklist.remoteMethod('create', {
description: 'Create an PICKLIST',
http: {
path: '/',
verb: 'POST'
},
accepts : [{
description : 'The request to create an PICKLIST',
arg : 'request',
type : 'object',
required : true,
http : {
source : 'body'
},
default: {
key: '',
value: ''
}
}
],
returns: RESTResponseStatic.loopbackAdapterCommonRestResponseDefinition()
});
答
使用类型的参数来模拟类型,而不是对象,请参见下面的示例
accepts: [{
description : 'The request to create an PICKLIST',
arg: 'request',
type: 'Picklist', // *** give model reference here
required : true,
http: {
source : 'body'
},
default: {
key: '',
value: ''
}
}]
像魅力一样工作!太好了,谢谢。 – Jim