{"action":"created","issue":{"url":"https://api.github.com/repos/NSwag/NSwag/issues/447","repository_url":"https://api.github.com/repos/NSwag/NSwag","labels_url":"https://api.github.com/repos/NSwag/NSwag/issues/447/labels{/name}","comments_url":"https://api.github.com/repos/NSwag/NSwag/issues/447/comments","events_url":"https://api.github.com/repos/NSwag/NSwag/issues/447/events","html_url":"https://github.com/NSwag/NSwag/issues/447","id":191412238,"number":447,"title":"Typescript Template","user":{"login":"BringerOD","id":7971305,"avatar_url":"https://avatars.githubusercontent.com/u/7971305?v=3","gravatar_id":"","url":"https://api.github.com/users/BringerOD","html_url":"https://github.com/BringerOD","followers_url":"https://api.github.com/users/BringerOD/followers","following_url":"https://api.github.com/users/BringerOD/following{/other_user}","gists_url":"https://api.github.com/users/BringerOD/gists{/gist_id}","starred_url":"https://api.github.com/users/BringerOD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BringerOD/subscriptions","organizations_url":"https://api.github.com/users/BringerOD/orgs","repos_url":"https://api.github.com/users/BringerOD/repos","events_url":"https://api.github.com/users/BringerOD/events{/privacy}","received_events_url":"https://api.github.com/users/BringerOD/received_events","type":"User","site_admin":false},"labels":[{"id":255705718,"url":"https://api.github.com/repos/NSwag/NSwag/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2016-11-24T01:06:46Z","updated_at":"2016-11-28T20:34:45Z","closed_at":null,"body":"First of all thanks for all of your hard work.\r\n\r\nI am attempting to use the TypeScript Fetch generated code.\r\n\r\nI guess I am a confused on whether the generated code is design to be edited after the fact and never be generated again or not.  \r\n\r\nThe API call below produces a CompanyUser object when everything goes right and a list of errors ( string[] ) when its a bad request or status 400.  The promise on the template is of typed to return a  CompanyUser regardless of its an string[] or not .  Is this by design?  I guess I am not sure how to deal with it.  \r\n\r\nWas the idea with the template generation that we should generate it and then the modify it?  I was hoping to generate it every time the API changes instead of generating it once then modify it.  \r\n\r\nOne way to solve this would be to return a object with the response object and all the object results,  something like this.  \r\n\r\n```javascript\r\n    class GetUserResult {\r\n      response: Response\r\n      result200: CompanyUser;\r\n      result400: string[];\r\n    }\r\n```\r\n\r\nthen the function declaration could be.\r\n```javascript\r\ngetUser(companyId: string, id: string):  Promise<GetUserResult > {}\r\n```\r\n\r\nThis would allow the developer to import this code and then deal with all of the response types.\r\n\r\nHere is the typescript that is produced and the json swagger below.\r\n```javascript\r\n  getUser(companyId: string, id: string):  Promise<CompanyUser> {\r\n        let url_ = this.baseUrl + \"/api/companies/{companyId}/users/{id}\"; \r\n        if (companyId === undefined || companyId === null)\r\n            throw new Error(\"The parameter 'companyId' must be defined.\");\r\n        url_ = url_.replace(\"{companyId}\", encodeURIComponent(\"\" + companyId)); \r\n        if (id === undefined || id === null)\r\n            throw new Error(\"The parameter 'id' must be defined.\");\r\n        url_ = url_.replace(\"{id}\", encodeURIComponent(\"\" + id));\r\n\r\n        return this.http.fetch(url_, {\r\n            method: \"GET\",\r\n            headers: {\r\n                \"Content-Type\": \"application/json; charset=UTF-8\"\r\n            }\r\n        }).then((response) => {\r\n            return this.processGetUser(response);\r\n        });\r\n    }\r\n\r\n    private processGetUser(response: Response) {\r\n        return response.text().then((data) => {\r\n            const status = response.status.toString(); \r\n\r\n            if (status === \"204\") {\r\n            }\r\n            else\r\n            if (status === \"200\") {\r\n                let result200: CompanyUser = null; \r\n                let resultData200 = data === \"\" ? null : JSON.parse(data, this.jsonParseReviver);\r\n                result200 = resultData200 ? CompanyUser.fromJS(resultData200) : new CompanyUser();\r\n                return result200; \r\n            }\r\n            else\r\n            if (status === \"400\") {\r\n                let result400: string[] = null; \r\n                let resultData400 = data === \"\" ? null : JSON.parse(data, this.jsonParseReviver);\r\n                if (resultData400 && resultData400.constructor === Array) {\r\n                    result400 = [];\r\n                    for (let item of resultData400)\r\n                        result400.push(item);\r\n                }\r\n                throw result400; \r\n            }\r\n            else\r\n            if (status === \"404\") {\r\n            }\r\n            else\r\n            if (status === \"500\") {\r\n            }\r\n            else\r\n            {\r\n                throw new Error(\"error_no_callback_for_the_received_http_status\"); \r\n            }\r\n        });\r\n    }\r\n\r\n    /**\r\n```\r\nHere is the swagger json \r\n```javascript\r\n\"/api/companies/{companyId}/users/{id}\": {\r\n      \"get\": {\r\n        \"tags\": [\r\n          \"Users\"\r\n        ],\r\n        \"operationId\": \"GetUser\",\r\n        \"consumes\": [],\r\n        \"produces\": [],\r\n        \"parameters\": [\r\n          {\r\n            \"name\": \"companyId\",\r\n            \"in\": \"path\",\r\n            \"required\": true,\r\n            \"type\": \"string\",\r\n            \"format\": \"uuid\"\r\n          },\r\n          {\r\n            \"name\": \"id\",\r\n            \"in\": \"path\",\r\n            \"required\": true,\r\n            \"type\": \"string\",\r\n            \"format\": \"uuid\"\r\n          }\r\n        ],\r\n        \"responses\": {\r\n          \"204\": {\r\n            \"description\": \"No Content\"\r\n          },\r\n          \"200\": {\r\n            \"description\": \"OK\",\r\n            \"schema\": {\r\n              \"$ref\": \"#/definitions/CompanyUser\"\r\n            }\r\n          },\r\n          \"400\": {\r\n            \"description\": \"BadRequest\",\r\n            \"schema\": {\r\n              \"type\": \"array\",\r\n              \"items\": {\r\n                \"type\": \"string\"\r\n              }\r\n            }\r\n          },\r\n          \"404\": {\r\n            \"description\": \"NotFound\"\r\n          },\r\n          \"500\": {\r\n            \"description\": \"InternalServerError\"\r\n          }\r\n        },\r\n        \"deprecated\": false\r\n      },\r\n```"},"comment":{"url":"https://api.github.com/repos/NSwag/NSwag/issues/comments/263386203","html_url":"https://github.com/NSwag/NSwag/issues/447#issuecomment-263386203","issue_url":"https://api.github.com/repos/NSwag/NSwag/issues/447","id":263386203,"user":{"login":"BringerOD","id":7971305,"avatar_url":"https://avatars.githubusercontent.com/u/7971305?v=3","gravatar_id":"","url":"https://api.github.com/users/BringerOD","html_url":"https://github.com/BringerOD","followers_url":"https://api.github.com/users/BringerOD/followers","following_url":"https://api.github.com/users/BringerOD/following{/other_user}","gists_url":"https://api.github.com/users/BringerOD/gists{/gist_id}","starred_url":"https://api.github.com/users/BringerOD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BringerOD/subscriptions","organizations_url":"https://api.github.com/users/BringerOD/orgs","repos_url":"https://api.github.com/users/BringerOD/repos","events_url":"https://api.github.com/users/BringerOD/events{/privacy}","received_events_url":"https://api.github.com/users/BringerOD/received_events","type":"User","site_admin":false},"created_at":"2016-11-28T20:34:45Z","updated_at":"2016-11-28T20:34:45Z","body":"All good.  Thanks again."}}
{"actor":{"display_login":"BringerOD"}}