{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/2143","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/2143/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/2143/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/2143/events","html_url":"https://github.com/swagger-api/swagger-codegen/pull/2143","id":133868158,"number":2143,"title":"Do not create empty objects in model constructors","user":{"login":"delenius","id":7936653,"avatar_url":"https://avatars.githubusercontent.com/u/7936653?v=3","gravatar_id":"","url":"https://api.github.com/users/delenius","html_url":"https://github.com/delenius","followers_url":"https://api.github.com/users/delenius/followers","following_url":"https://api.github.com/users/delenius/following{/other_user}","gists_url":"https://api.github.com/users/delenius/gists{/gist_id}","starred_url":"https://api.github.com/users/delenius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delenius/subscriptions","organizations_url":"https://api.github.com/users/delenius/orgs","repos_url":"https://api.github.com/users/delenius/repos","events_url":"https://api.github.com/users/delenius/events{/privacy}","received_events_url":"https://api.github.com/users/delenius/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Client:%20Javascript","name":"Client: Javascript","color":"fad8c7"},{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Enhancement","name":"Enhancement","color":"e5ffe5"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/10","html_url":"https://github.com/swagger-api/swagger-codegen/milestones/v2.1.6","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/10/labels","id":1488305,"number":10,"title":"v2.1.6","description":"","creator":{"login":"fehguy","id":249413,"avatar_url":"https://avatars.githubusercontent.com/u/249413?v=3","gravatar_id":"","url":"https://api.github.com/users/fehguy","html_url":"https://github.com/fehguy","followers_url":"https://api.github.com/users/fehguy/followers","following_url":"https://api.github.com/users/fehguy/following{/other_user}","gists_url":"https://api.github.com/users/fehguy/gists{/gist_id}","starred_url":"https://api.github.com/users/fehguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fehguy/subscriptions","organizations_url":"https://api.github.com/users/fehguy/orgs","repos_url":"https://api.github.com/users/fehguy/repos","events_url":"https://api.github.com/users/fehguy/events{/privacy}","received_events_url":"https://api.github.com/users/fehguy/received_events","type":"User","site_admin":false},"open_issues":72,"closed_issues":213,"state":"open","created_at":"2016-01-06T20:41:39Z","updated_at":"2016-02-18T01:58:33Z","due_on":null,"closed_at":null},"comments":13,"created_at":"2016-02-16T02:42:41Z","updated_at":"2016-02-18T02:14:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/2143","html_url":"https://github.com/swagger-api/swagger-codegen/pull/2143","diff_url":"https://github.com/swagger-api/swagger-codegen/pull/2143.diff","patch_url":"https://github.com/swagger-api/swagger-codegen/pull/2143.patch"},"body":"Fixes #2142 \r\n\r\nThis removes the creation of empty instances\r\nfor optional parameters in the model constructors. The problem is that\r\nwhen the data for these fields is not present, we are left with \"empty\"\r\ninstances, which is not desirable, for several reasons:\r\n\r\n1. It means that we cannot check for the presence of a field using the\r\n   usual JS idiom `if (object.field) {...}`.\r\n2. It wastes memory with useless fields and objects.\r\n\r\nNote: This completely removes the creation of \"default\" values\r\nin the constructors. I don't know if there is some other case\r\nwhere this is a useful thing (are there other kinds of defaults\r\nbesides empty instances of model classes?)."},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/comments/185510420","html_url":"https://github.com/swagger-api/swagger-codegen/pull/2143#issuecomment-185510420","issue_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/2143","id":185510420,"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-02-18T02:14:54Z","updated_at":"2016-02-18T02:14:54Z","body":"Here is the `default` I used in `Order`'s `id`:\r\n```\r\n    \"Order\": {\r\n      \"properties\": {\r\n        \"id\": {\r\n          \"default\": 1234,\r\n          \"type\": \"integer\",\r\n          \"format\": \"int64\"\r\n        },\r\n        \"petId\": {\r\n          \"type\": \"integer\",\r\n          \"format\": \"int64\"\r\n        },\r\n        \"quantity\": {\r\n          \"type\": \"integer\",\r\n          \"format\": \"int32\"\r\n        },\r\n        \"shipDate\": {\r\n          \"type\": \"string\",\r\n          \"format\": \"date-time\"\r\n        },\r\n        \"status\": {\r\n          \"type\": \"string\",\r\n          \"description\": \"Order Status\",\r\n          \"enum\": [\r\n            \"placed\",\r\n            \"approved\",\r\n            \"delivered\"\r\n          ]\r\n        },\r\n        \"complete\": {\r\n          \"type\": \"boolean\"\r\n        }\r\n      },\r\n      \"xml\": {\r\n        \"name\": \"Order\"\r\n      }\r\n    }\r\n```"}}