Jim
Jim

Reputation: 1986

Loopback explorer inline Model want Model Schema

I'm stuck with my remoteMethods not showing the defaults in Loopback Explorer. The post will create if I enter a JSON object but typically there is a sample labled "Model Schema". Here is just says Inline Model.

Any ideas?

Model definition:

{
  "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": {}
}

The remote method definition:

 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()
  });

Loopback Explorer

Upvotes: 1

Views: 694

Answers (1)

Njain
Njain

Reputation: 46

use type of parameter to model type instead object, see in below example

 accepts: [{
     description : 'The request to create an PICKLIST',
     arg: 'request',
     type: 'Picklist', // *** give model reference here
     required : true,
     http: {
         source : 'body'
     },
     default: {
         key: '',
         value: ''
     }
 }]

Upvotes: 1

Related Questions