{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/6672","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/6672/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/6672/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/6672/events","html_url":"https://github.com/swagger-api/swagger-codegen/pull/6672","id":265297558,"number":6672,"title":"[Swift4] Allow for custom dateformatter to be used","user":{"login":"DawidvanGraan","id":1670437,"avatar_url":"https://avatars0.githubusercontent.com/u/1670437?v=4","gravatar_id":"","url":"https://api.github.com/users/DawidvanGraan","html_url":"https://github.com/DawidvanGraan","followers_url":"https://api.github.com/users/DawidvanGraan/followers","following_url":"https://api.github.com/users/DawidvanGraan/following{/other_user}","gists_url":"https://api.github.com/users/DawidvanGraan/gists{/gist_id}","starred_url":"https://api.github.com/users/DawidvanGraan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DawidvanGraan/subscriptions","organizations_url":"https://api.github.com/users/DawidvanGraan/orgs","repos_url":"https://api.github.com/users/DawidvanGraan/repos","events_url":"https://api.github.com/users/DawidvanGraan/events{/privacy}","received_events_url":"https://api.github.com/users/DawidvanGraan/received_events","type":"User","site_admin":false},"labels":[{"id":165466244,"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Client:%20Swift","name":"Client: Swift","color":"fad8c7","default":false},{"id":317758118,"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Enhancement:%20General","name":"Enhancement: General","color":"e5ffe5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/12","html_url":"https://github.com/swagger-api/swagger-codegen/milestone/12","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/12/labels","id":1892261,"number":12,"title":"v2.3.0","description":"","creator":{"login":"wing328","id":934260,"avatar_url":"https://avatars2.githubusercontent.com/u/934260?v=4","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},"open_issues":232,"closed_issues":535,"state":"open","created_at":"2016-07-19T15:23:39Z","updated_at":"2017-10-18T13:38:47Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2017-10-13T13:54:49Z","updated_at":"2017-10-18T14:55:51Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/6672","html_url":"https://github.com/swagger-api/swagger-codegen/pull/6672","diff_url":"https://github.com/swagger-api/swagger-codegen/pull/6672.diff","patch_url":"https://github.com/swagger-api/swagger-codegen/pull/6672.patch"},"body":"### PR checklist\r\n\r\n- [x] Read the [contribution guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md).\r\n- [x] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\\bin\\windows\\`.\r\n- [x] Filed the PR against the correct branch: `3.0.0` branch for changes related to OpenAPI spec 3.0. Default: `master`.\r\n- [ ] Copied the [technical committee](https://github.com/swagger-api/swagger-codegen/#swagger-codegen-technical-committee) to review the pull request if your PR is targeting a particular programming langauge.\r\n\r\n### Description of the PR\r\n\r\nSetting a custom date format to be used on decoding. \r\n\r\nMy server response date uses the format `YYYY-MM-DD'T'HH:mm:ss.sssZ`, I needed a way to set DateFormatter on the decoding of the data models. Suggest allowing for a custom DateFormat to be used in `CodableHelper`. \r\n\r\nUsage:\r\n```\r\n// Custom Date\r\nlet dateFormat = DateFormatter()\r\ndateFormat.dateFormat = \"YYYY-MM-DD'T'HH:mm:ss.sssZ\" // \"2017-10-12T17:03:21.000Z\"\r\nCodableHelper.dateformatter = dateFormat\r\n```\r\nSuggested code change in `CodableHelper`\r\n```\r\n// Allow for custom date formatter to be used\r\nopen static var dateformatter: DateFormatter?\r\n\r\n// Check if formatter is set, else fallback to default values\r\nlet decoder = JSONDecoder()\r\nif let df = self.dateformatter {\r\n    decoder.dateDecodingStrategy = .formatted(df)\r\n} else {\r\n    decoder.dateDecodingStrategy = .deferredToDate\r\n    if #available(iOS 10.0, *) {\r\n        decoder.dateDecodingStrategy = .iso8601\r\n    }\r\n}\r\n```\r\n\r\nAlso changed the `dateDecodingStrategy` from '.base64' to '.deferredToDate` from issue #6576.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/comments/337619242","html_url":"https://github.com/swagger-api/swagger-codegen/pull/6672#issuecomment-337619242","issue_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/6672","id":337619242,"user":{"login":"DawidvanGraan","id":1670437,"avatar_url":"https://avatars0.githubusercontent.com/u/1670437?v=4","gravatar_id":"","url":"https://api.github.com/users/DawidvanGraan","html_url":"https://github.com/DawidvanGraan","followers_url":"https://api.github.com/users/DawidvanGraan/followers","following_url":"https://api.github.com/users/DawidvanGraan/following{/other_user}","gists_url":"https://api.github.com/users/DawidvanGraan/gists{/gist_id}","starred_url":"https://api.github.com/users/DawidvanGraan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DawidvanGraan/subscriptions","organizations_url":"https://api.github.com/users/DawidvanGraan/orgs","repos_url":"https://api.github.com/users/DawidvanGraan/repos","events_url":"https://api.github.com/users/DawidvanGraan/events{/privacy}","received_events_url":"https://api.github.com/users/DawidvanGraan/received_events","type":"User","site_admin":false},"created_at":"2017-10-18T14:55:51Z","updated_at":"2017-10-18T14:55:51Z","author_association":"NONE","body":"@ehyche Currently using `.iso8601` is not working for us. I agree that our dateformat is ISO8601, need to look deeper into how the date is decoded and see why it's falling.\r\n\r\nWill update the PR and set `decoder.dataDecodingStrategy = .base64` correctly. Sorry about this."}}
{"actor":{"display_login":"DawidvanGraan"}}