title: How Can I Create a Loopback Remote Method with a Model Schema?
body: <p>I'm currently building a loopback application, which only has a single model named <code>Phone</code>. Here's my <code>common/models/phone.js</code> code:</p>
  
  <pre><code>module.exports = function(Phone) {
  
    // Return a random phone's data.
    Phone.random = function(callback) {
      return callback(null, {
        id: '12345',
        number: '+18182179222',
        name: 'Randall Degges'
      });
    };
  
    Phone.remoteMethod('random', {
      description: 'Return a random phone.',
      accepts: [],
      returns: [
        //{ type: 'object', root: true, description: 'return value' },
        { arg: 'id', type: 'string', description: 'phone id', required: true, root: true },
        { arg: 'number', type: 'string', description: 'phone number', required: true, root: true },
        { arg: 'name', type: 'string', description: 'phone name', required: false, root: true }
      ],
      http: {
        verb: 'get', path: '/random',
      }
    });
  
  };
  </code></pre>
  
  <p>When I pull up my API explorer on port 3000, and view my newly created <code>random</code> API call, I see the following:</p>
  
  <p><img src="https://i.stack.imgur.com/ev8xU.png" alt="Random API Call in Loopback Explorer"></p>
  
  <p>As you can see above, my "Model Schema" is empty. Booo!</p>
  
  <p>What I'd like to accomplish is something similar to the built-in API methods, which look something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/tEnf5.png" alt="Working API Call in Loopback Explorer"></p>
  
  <p>As you can see above, the "Model Schema" shows what the actual output of the API call will look like.</p>
  
  <p>I'm trying to figure out how to accomplish this with my remote endpoint, but so far have had no luck.</p>
  
  <p>Any suggestions are welcome.</p>
  
  <p><strong>BONUS POINTS</strong>: Is there a way to simply tell Loopback that my return value <em>is</em> just an already-defined model? In my case all I'm doing is returning an existing Phone model, so it would be nice to just let Loopback know that somehow and have it auto-generate the documentation accordingly.</p>
  
  <p>Thank you!</p>