Loopback Explorer 内联模型需要模型架构

Loopback explorer inline Model want Model Schema

我的 remoteMethods 在 Loopback Explorer 中没有显示默认值,这让我很困惑。 如果我输入 JSON 对象,post 将创建,但通常会有一个标记为 "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: ''
     }
 }]