{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/generator-loopback/issues/188","repository_url":"https://api.github.com/repos/strongloop/generator-loopback","labels_url":"https://api.github.com/repos/strongloop/generator-loopback/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/generator-loopback/issues/188/comments","events_url":"https://api.github.com/repos/strongloop/generator-loopback/issues/188/events","html_url":"https://github.com/strongloop/generator-loopback/pull/188","id":156435646,"number":188,"title":"remote-method: make prompts more descriptive","user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/generator-loopback/labels/%23review","name":"#review","color":"eeeeee"},{"url":"https://api.github.com/repos/strongloop/generator-loopback/labels/ease-of-use","name":"ease-of-use","color":"eeeeee"}],"state":"open","locked":false,"assignee":{"login":"jannyHou","id":12554153,"avatar_url":"https://avatars.githubusercontent.com/u/12554153?v=3","gravatar_id":"","url":"https://api.github.com/users/jannyHou","html_url":"https://github.com/jannyHou","followers_url":"https://api.github.com/users/jannyHou/followers","following_url":"https://api.github.com/users/jannyHou/following{/other_user}","gists_url":"https://api.github.com/users/jannyHou/gists{/gist_id}","starred_url":"https://api.github.com/users/jannyHou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jannyHou/subscriptions","organizations_url":"https://api.github.com/users/jannyHou/orgs","repos_url":"https://api.github.com/users/jannyHou/repos","events_url":"https://api.github.com/users/jannyHou/events{/privacy}","received_events_url":"https://api.github.com/users/jannyHou/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-05-24T07:16:17Z","updated_at":"2016-05-24T15:57:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/strongloop/generator-loopback/pulls/188","html_url":"https://github.com/strongloop/generator-loopback/pull/188","diff_url":"https://github.com/strongloop/generator-loopback/pull/188.diff","patch_url":"https://github.com/strongloop/generator-loopback/pull/188.patch"},"body":"I had a discussion with another IBMer, a newbie to LoopBack, about creating models with custom remote methods. He was adding accepts/returns arguments by manually editing JSON files, because he did not realise the generator prompts were asking for arguments.\r\n\r\nIn this patch, I have reworded prompts and added more explanatory texts to guide new developers.\r\n\r\n@richardpringle @crandmck @jannyHou please review\r\n\r\nHere is a copy of the new generator output:\r\n\r\n```\r\n$ yo loopback:remote-method\r\n? Select the model: Car\r\n? Enter the remote method name: honk\r\n? Is Static? Yes\r\n? Description for method: make some noise!\r\n\r\nLet's configure where to expose your new method in the public REST API.\r\nYou can provide multiple HTTP endpoints, enter an empty path when you are done.\r\n? Enter the path of this endpoint: /honk\r\n? HTTP verb: post\r\n\r\nLet's add another endpoint, enter an empty name when done.\r\n? Enter the path of this endpoint:\r\n\r\nNow it's time to describe input arguments of your remote method\r\nIn LoopBack, we call these arguments \"accepts\" arguments.\r\nOf course, you can define multiple input arguments.\r\nJust enter an empty name when all arguments were defined.\r\n? What is the name of this argument? mood\r\n? Select argument's type: string\r\n? Is this argument required? No\r\n? Please describe the argument: What is driver's mood?\r\n? Where to get the value from? (auto)\r\n\r\nLet's add another accept argument, enter an empty name when done.\r\n? What is the name of this argument?\r\n\r\nLet's describe output of the new method: the arguments passed  to the callback function.\r\nIn LoopBack, we call these arguments \"returns\" arguments.\r\nYou can define multiple callback arguments too.\r\nJust enter an empty name when all arguments were defined.\r\n? What is the name of this argument? sound\r\n? Select argument's type: buffer\r\n? Is this argument a full response body (root)? No\r\n? Please describe the argument: The sound in .wav format.\r\n\r\nLet's add another return argument. Enter empty name when done.\r\n? What is the name of this argument?\r\n\r\nWe have added strong-remoting metadata for your new method to common/models/car.json\r\nNow it's up to you to provide implementation in common/models/car.js\r\nHere is a sample code to get you started:\r\n\r\n/**\r\n * make some noise!\r\n * @param {string} mood What is driver's mood?\r\n * @param {Function(Error, buffer)} callback\r\n */\r\n\r\nCar.honk = function(mood, callback) {\r\n  var sound;\r\n  // TODO\r\n  callback(null, sound);\r\n};\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/generator-loopback/issues/comments/221318105","html_url":"https://github.com/strongloop/generator-loopback/pull/188#issuecomment-221318105","issue_url":"https://api.github.com/repos/strongloop/generator-loopback/issues/188","id":221318105,"user":{"login":"jannyHou","id":12554153,"avatar_url":"https://avatars.githubusercontent.com/u/12554153?v=3","gravatar_id":"","url":"https://api.github.com/users/jannyHou","html_url":"https://github.com/jannyHou","followers_url":"https://api.github.com/users/jannyHou/followers","following_url":"https://api.github.com/users/jannyHou/following{/other_user}","gists_url":"https://api.github.com/users/jannyHou/gists{/gist_id}","starred_url":"https://api.github.com/users/jannyHou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jannyHou/subscriptions","organizations_url":"https://api.github.com/users/jannyHou/orgs","repos_url":"https://api.github.com/users/jannyHou/repos","events_url":"https://api.github.com/users/jannyHou/events{/privacy}","received_events_url":"https://api.github.com/users/jannyHou/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T15:57:44Z","updated_at":"2016-05-24T15:57:44Z","body":"@bajtos I partly agree with @richardpringle that the prompt description might be better to keep concise. Think of the time that we don't have a remote-method generator, users still need to read doc to see the definition of each field (I mean like what is `endpoint`).\r\n\r\nFor a quick understanding of what is `accept` and `return`,\r\nhow about at the beginning when generator invoked, we add a dummy example to show how a remote-method Object looks like?\r\nFor example:\r\n```js\r\n/**\r\n * Description field of remote-method\r\n * @param {string} acceptArgName My first accept argument\r\n * @param {Function(Error, string)} callback\r\n */\r\n\r\nModelName.remoteMethodName = function(acceptArgName, callback) {\r\n  var returnArgName;\r\n  // TODO\r\n  callback(null, returnArgName);\r\n};\r\n```\r\nSo at the beginning we tell users what  `accept`, `return`, ect are and finally we show them what they create."}}
{"actor":{"display_login":"jannyHou"}}