{"action":"closed","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1341","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1341/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1341/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1341/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/1341","id":109983530,"number":1341,"title":"TypeScript generated bindings not mapping to JSON property names","user":{"login":"corruptmem","id":274923,"avatar_url":"https://avatars.githubusercontent.com/u/274923?v=3","gravatar_id":"","url":"https://api.github.com/users/corruptmem","html_url":"https://github.com/corruptmem","followers_url":"https://api.github.com/users/corruptmem/followers","following_url":"https://api.github.com/users/corruptmem/following{/other_user}","gists_url":"https://api.github.com/users/corruptmem/gists{/gist_id}","starred_url":"https://api.github.com/users/corruptmem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corruptmem/subscriptions","organizations_url":"https://api.github.com/users/corruptmem/orgs","repos_url":"https://api.github.com/users/corruptmem/repos","events_url":"https://api.github.com/users/corruptmem/events{/privacy}","received_events_url":"https://api.github.com/users/corruptmem/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Client:%20TypeScript","name":"Client: TypeScript","color":"fad8c7"},{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Need%20community%20contribution","name":"Need community contribution","color":"e3ff00"},{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/P2","name":"P2","color":"0052cc"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/5","html_url":"https://github.com/swagger-api/swagger-codegen/milestones/Future","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/5/labels","id":913962,"number":5,"title":"Future","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":42,"closed_issues":23,"state":"open","created_at":"2014-12-24T05:48:44Z","updated_at":"2016-01-27T03:16:02Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-10-06T10:55:00Z","updated_at":"2016-01-27T03:16:02Z","closed_at":"2016-01-27T03:16:02Z","body":"I'm using Swagger codegen to generate Angular Typescript bindings for a JSON web service. An example of one of my models from the Swagger definition is as follows:\r\n\r\n    NamePos:\r\n      type: object\r\n      properties:\r\n        Name:\r\n          type: string\r\n        Position:\r\n          type: string\r\n\r\nAnd this is sent over the wire as the following JSON object:\r\n\r\n    {\"Name\": \"x\", \"Position\": \"y\"}\r\n\r\nHowever, the TypeScript generator creates the following model:\r\n\r\n    export class CapitalStructure {\r\n        name: string;\r\n        position: string;\r\n    }\r\n\r\nThe API directly casts the returned JSON object into this model. What therefore happens, is that the obj.name is undefined, because the correct property name is actually obj.Name, but that's invalid according to to the generated TypeScript bindings.\r\n\r\nAs a workaround, I set it to use custom templates and in model.mustache, I changed this line:\r\n\r\n    {{name}}: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};\r\n\r\nInto\r\n\r\n    {{baseName}}: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};\r\n\r\nThis now generates models with property names that match the JSON (Name, Position), and the generated bindings work as expected.\r\n\r\nHowever, this would break if any of the properties contained a TypeScript reserved word, and also means the generated TypeScript doesn't follow general language conventions. The correct solution would likely to use some attribute maps from the name -> baseName and then perhaps getters/setters, as other language templates  do (e.g. Ruby, Python, PHP). An example from the Python generator can be seen here: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/python/model.mustache#L46"}}