{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3068","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3068/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3068/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3068/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3068","id":158836579,"number":3068,"title":"[Javascript] Return rejected Promise if required parameters are not set","user":{"login":"darylteo","id":1226920,"avatar_url":"https://avatars.githubusercontent.com/u/1226920?v=3","gravatar_id":"","url":"https://api.github.com/users/darylteo","html_url":"https://github.com/darylteo","followers_url":"https://api.github.com/users/darylteo/followers","following_url":"https://api.github.com/users/darylteo/following{/other_user}","gists_url":"https://api.github.com/users/darylteo/gists{/gist_id}","starred_url":"https://api.github.com/users/darylteo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darylteo/subscriptions","organizations_url":"https://api.github.com/users/darylteo/orgs","repos_url":"https://api.github.com/users/darylteo/repos","events_url":"https://api.github.com/users/darylteo/events{/privacy}","received_events_url":"https://api.github.com/users/darylteo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-07T04:36:02Z","updated_at":"2016-06-09T09:22:04Z","closed_at":null,"body":"##### Description\r\n\r\nWhen using the --promise version of javascript, when required parameters are not provided, it throws an exception. To maintain the consistency of the function, it could return a rejected Promise, so that we can simply write a failure handler at the end of the fluent chain.\r\n\r\n##### Swagger-codegen version\r\n\r\n2.1.6\r\n\r\n##### Swagger declaration file content or url\r\n\r\n##### Command line used for generation\r\n\r\n##### Steps to reproduce\r\n\r\n##### Related issues\r\n\r\n##### Suggest a Fix\r\n\r\nInstead of \r\n\r\n```javascript\r\n  // verify the required parameter 'count' is set\r\n  if (count == undefined || count == null) {\r\n    throw \"Missing the required parameter 'count' when calling resourceGet\";\r\n  }\r\n  ...\r\n  try {\r\n    api.resourceGet(...)\r\n      .then(res => {\r\n        ...\r\n      }, err => {\r\n        // error 1\r\n      });\r\n  } catch (e) {\r\n    // error 2\r\n  }\r\n```\r\n\r\nLet's do\r\n\r\n```javascript\r\n  // verify the required parameter 'count' is set\r\n  if (count == undefined || count == null) {\r\n    Promise.reject(new Error(\"Missing the required parameter 'count' when calling resourceGet\"));\r\n  }\r\n  ...\r\n  api.resourceGet(...)\r\n    .then(res => {\r\n      ...\r\n    }, err => {\r\n      // error 1\r\n    });\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/comments/224843265","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3068#issuecomment-224843265","issue_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3068","id":224843265,"user":{"login":"wing328","id":934260,"avatar_url":"https://avatars.githubusercontent.com/u/934260?v=3","gravatar_id":"","url":"https://api.github.com/users/wing328","html_url":"https://github.com/wing328","followers_url":"https://api.github.com/users/wing328/followers","following_url":"https://api.github.com/users/wing328/following{/other_user}","gists_url":"https://api.github.com/users/wing328/gists{/gist_id}","starred_url":"https://api.github.com/users/wing328/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wing328/subscriptions","organizations_url":"https://api.github.com/users/wing328/orgs","repos_url":"https://api.github.com/users/wing328/repos","events_url":"https://api.github.com/users/wing328/events{/privacy}","received_events_url":"https://api.github.com/users/wing328/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T09:22:04Z","updated_at":"2016-06-09T09:22:04Z","body":"@darylteo thanks for the suggestion and the code snippets to illustrate the difference.\r\n\r\ncc @delenius who added Promise support to the Javascript API client."}}
{"actor":{"display_login":"wing328"}}