{"action":"created","issue":{"url":"https://api.github.com/repos/melrief/pureconfig/issues/69","repository_url":"https://api.github.com/repos/melrief/pureconfig","labels_url":"https://api.github.com/repos/melrief/pureconfig/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/melrief/pureconfig/issues/69/comments","events_url":"https://api.github.com/repos/melrief/pureconfig/issues/69/events","html_url":"https://github.com/melrief/pureconfig/pull/69","id":196227353,"number":69,"title":"Add CoproductHint for customization of sealed family conversions","user":{"login":"ruippeixotog","id":613493,"avatar_url":"https://avatars.githubusercontent.com/u/613493?v=3","gravatar_id":"","url":"https://api.github.com/users/ruippeixotog","html_url":"https://github.com/ruippeixotog","followers_url":"https://api.github.com/users/ruippeixotog/followers","following_url":"https://api.github.com/users/ruippeixotog/following{/other_user}","gists_url":"https://api.github.com/users/ruippeixotog/gists{/gist_id}","starred_url":"https://api.github.com/users/ruippeixotog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruippeixotog/subscriptions","organizations_url":"https://api.github.com/users/ruippeixotog/orgs","repos_url":"https://api.github.com/users/ruippeixotog/repos","events_url":"https://api.github.com/users/ruippeixotog/events{/privacy}","received_events_url":"https://api.github.com/users/ruippeixotog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-17T15:31:01Z","updated_at":"2016-12-19T01:11:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/melrief/pureconfig/pulls/69","html_url":"https://github.com/melrief/pureconfig/pull/69","diff_url":"https://github.com/melrief/pureconfig/pull/69.diff","patch_url":"https://github.com/melrief/pureconfig/pull/69.patch"},"body":"This pull request adds a new `CoproductHint` trait that allows easy customization of the serialization of sealed families. The general idea was taken from [spray-json-shapeless](https://github.com/fommil/spray-json-shapeless), with a handful of improvements and tweaks to better match the API patterns in pureconfig.\r\n\r\nA `CoproductHint` decides, for a given `Config` and the name of a coproduct option (such as the name of a subclass of the sealed trait), if the received config should be deserialized as an instance of the specific option. In most cases, it uses disambiguation information, such as an extra `type` field, to encode and decode the concrete instance to create.\r\n\r\nTwo implementations of `CoproductHint` are added. The most common in my view, and the default in spray-json-shapeless, is a `FieldCoproductHint`, which writes configs with an extra field (`type` by default) and reads it to instantiate concrete models. The name of the field and the mapping between class names and field values can be customized as described in the Scaladoc. I also added `FirstSuccessCoproductHint`, which doesn't encode any extra information and defines the current pureconfig behavior.\r\n\r\nI opted to change the default serialization of sealed families to use `FieldCoproductHint`. It's a breaking change, but the current behavior is arguably flawed (in fact, this fixes #13). People relying on the old behavior can easily put in scope an instance of `FirstSuccessCoproductHint`, though.\r\n\r\nWith this change, pureconfig stopped supporting pure `Coproduct` instances, as it now requires coproducts to be `LabelledGeneric` in order to retrieve the names of the various options. I don't think it is common for people to use `Coproducts`, particularly in configs; however, if you think otherwise I think I can rewrite this to keep support for non-labelled coproducts (at the cost of having some code duplicated, I guess).\r\n"},"comment":{"url":"https://api.github.com/repos/melrief/pureconfig/issues/comments/267861598","html_url":"https://github.com/melrief/pureconfig/pull/69#issuecomment-267861598","issue_url":"https://api.github.com/repos/melrief/pureconfig/issues/69","id":267861598,"user":{"login":"ruippeixotog","id":613493,"avatar_url":"https://avatars.githubusercontent.com/u/613493?v=3","gravatar_id":"","url":"https://api.github.com/users/ruippeixotog","html_url":"https://github.com/ruippeixotog","followers_url":"https://api.github.com/users/ruippeixotog/followers","following_url":"https://api.github.com/users/ruippeixotog/following{/other_user}","gists_url":"https://api.github.com/users/ruippeixotog/gists{/gist_id}","starred_url":"https://api.github.com/users/ruippeixotog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruippeixotog/subscriptions","organizations_url":"https://api.github.com/users/ruippeixotog/orgs","repos_url":"https://api.github.com/users/ruippeixotog/repos","events_url":"https://api.github.com/users/ruippeixotog/events{/privacy}","received_events_url":"https://api.github.com/users/ruippeixotog/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T01:11:25Z","updated_at":"2016-12-19T01:11:25Z","body":"Sure, no problem!"}}
{"actor":{"display_login":"ruippeixotog"}}