{"action":"created","issue":{"url":"https://api.github.com/repos/katharsis-project/katharsis-framework/issues/10","repository_url":"https://api.github.com/repos/katharsis-project/katharsis-framework","labels_url":"https://api.github.com/repos/katharsis-project/katharsis-framework/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/katharsis-project/katharsis-framework/issues/10/comments","events_url":"https://api.github.com/repos/katharsis-project/katharsis-framework/issues/10/events","html_url":"https://github.com/katharsis-project/katharsis-framework/issues/10","id":168308585,"number":10,"title":"Katharis should automatically determine Entity/resource names and types","user":{"login":"masterspambot","id":581121,"avatar_url":"https://avatars.githubusercontent.com/u/581121?v=3","gravatar_id":"","url":"https://api.github.com/users/masterspambot","html_url":"https://github.com/masterspambot","followers_url":"https://api.github.com/users/masterspambot/followers","following_url":"https://api.github.com/users/masterspambot/following{/other_user}","gists_url":"https://api.github.com/users/masterspambot/gists{/gist_id}","starred_url":"https://api.github.com/users/masterspambot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masterspambot/subscriptions","organizations_url":"https://api.github.com/users/masterspambot/orgs","repos_url":"https://api.github.com/users/masterspambot/repos","events_url":"https://api.github.com/users/masterspambot/events{/privacy}","received_events_url":"https://api.github.com/users/masterspambot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/katharsis-project/katharsis-framework/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"masterspambot","id":581121,"avatar_url":"https://avatars.githubusercontent.com/u/581121?v=3","gravatar_id":"","url":"https://api.github.com/users/masterspambot","html_url":"https://github.com/masterspambot","followers_url":"https://api.github.com/users/masterspambot/followers","following_url":"https://api.github.com/users/masterspambot/following{/other_user}","gists_url":"https://api.github.com/users/masterspambot/gists{/gist_id}","starred_url":"https://api.github.com/users/masterspambot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masterspambot/subscriptions","organizations_url":"https://api.github.com/users/masterspambot/orgs","repos_url":"https://api.github.com/users/masterspambot/repos","events_url":"https://api.github.com/users/masterspambot/events{/privacy}","received_events_url":"https://api.github.com/users/masterspambot/received_events","type":"User","site_admin":false},"assignees":[{"login":"masterspambot","id":581121,"avatar_url":"https://avatars.githubusercontent.com/u/581121?v=3","gravatar_id":"","url":"https://api.github.com/users/masterspambot","html_url":"https://github.com/masterspambot","followers_url":"https://api.github.com/users/masterspambot/followers","following_url":"https://api.github.com/users/masterspambot/following{/other_user}","gists_url":"https://api.github.com/users/masterspambot/gists{/gist_id}","starred_url":"https://api.github.com/users/masterspambot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masterspambot/subscriptions","organizations_url":"https://api.github.com/users/masterspambot/orgs","repos_url":"https://api.github.com/users/masterspambot/repos","events_url":"https://api.github.com/users/masterspambot/events{/privacy}","received_events_url":"https://api.github.com/users/masterspambot/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2016-07-29T11:52:17Z","updated_at":"2016-07-29T11:52:21Z","closed_at":null,"body":"_From @chb0github on July 14, 2016 20:53_\n\nconsider this example code\r\n\r\n```java\r\npublic static class Foo implements ResourceRepository<Location,Long>{\r\n        @Override\r\n        public Location findOne(Long aLong, QueryParams queryParams) {\r\n            return null;\r\n        }\r\n\r\n        @Override\r\n        public Iterable<Location> findAll(QueryParams queryParams) {\r\n            return null;\r\n        }\r\n\r\n        @Override\r\n        public Iterable<Location> findAll(Iterable<Long> iterable, QueryParams queryParams) {\r\n            return null;\r\n        }\r\n\r\n        @Override\r\n        public <S extends Location> S save(S s) {\r\n            return null;\r\n        }\r\n\r\n        @Override\r\n        public void delete(Long aLong) {\r\n\r\n        }\r\n    }\r\n\r\n   public static void main(String[] args) {\r\n        Foo foo = new Foo();\r\n        Type[] ifaces = foo.getClass().getGenericInterfaces();\r\n        System.out.println(((ParameterizedTypeImpl)ifaces[0]).getActualTypeArguments()[0]);\r\n    }\r\n```\r\n\r\n> class com.mz.matrix.model.Location\r\n\r\nThe entity type can be determined simply by looking at the generics. From this, we can infer a resource by pluralizing and type by lowercasing:\r\n\r\n`http://host/locations`\r\n\r\nThe `@JsonApiResource(type = \"locations\")` is entirely unnecessary; it can be derived. We do, however, want to be able to override it as a type. \r\n\r\nWe are facing the scenario in 4 seperate places where we need:\r\n\r\n```java\r\n\r\npublic abstract class Location {\r\n   private Long id;\r\n   private String foo;\r\n}\r\n\r\n@JsonApiResource(type = \"locationtype1\")\r\npublic class LocationSubType1 extends Location {\r\n   private int age;\r\n}\r\n\r\n@JsonApiResource(type = \"locationtype2\")\r\npublic class LocationSubType2 extends Location {\r\n   private long something;\r\n}\r\n```\r\n\r\n```\r\nPOST http://host/locations\r\n{\r\n  \"type\" : \"locationtype1\"\r\n}\r\n\r\n\r\nPOST http://host/locations\r\n{\r\n  \"type\" : \"locationtype1\" \r\n\r\n}\r\n```\r\n\r\nwith mostly different attributes. Basically, without this change, polymorphic payloads become something between impossible and difficult.\r\n\r\nI can make the changes if there is no spec-specific reason not to do so\r\n\r\n\n\n_Copied from original issue: katharsis-project/katharsis-core#361_"},"comment":{"url":"https://api.github.com/repos/katharsis-project/katharsis-framework/issues/comments/236161447","html_url":"https://github.com/katharsis-project/katharsis-framework/issues/10#issuecomment-236161447","issue_url":"https://api.github.com/repos/katharsis-project/katharsis-framework/issues/10","id":236161447,"user":{"login":"masterspambot","id":581121,"avatar_url":"https://avatars.githubusercontent.com/u/581121?v=3","gravatar_id":"","url":"https://api.github.com/users/masterspambot","html_url":"https://github.com/masterspambot","followers_url":"https://api.github.com/users/masterspambot/followers","following_url":"https://api.github.com/users/masterspambot/following{/other_user}","gists_url":"https://api.github.com/users/masterspambot/gists{/gist_id}","starred_url":"https://api.github.com/users/masterspambot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masterspambot/subscriptions","organizations_url":"https://api.github.com/users/masterspambot/orgs","repos_url":"https://api.github.com/users/masterspambot/repos","events_url":"https://api.github.com/users/masterspambot/events{/privacy}","received_events_url":"https://api.github.com/users/masterspambot/received_events","type":"User","site_admin":false},"created_at":"2016-07-29T11:52:21Z","updated_at":"2016-07-29T11:52:21Z","body":"_From @chb0github on July 24, 2016 8:8_\n\nI think we have to allow them to vary. Some things are just not possible\notherwise. And per Błażej's comment 'the type can be singular or plural'\nthat does not mean the resource must be the same.\n\nSo:\n/balls\n\n\"type\":\"ball\"\n\nIs still find.\n\nAs for the trickiness of plural: we can use the EvoInflector for English\nand use service discovery for other languages  (even if not implemented).\nUsing English is going to get us very far.\n\nKatharsis is not a competitor to spring data. They have done a lot of\nthings we should do and they are doing it well. This ticket mimics that.\n\nThe resource and the type names must be allowed to vary\n\nOn Wed, Jul 20, 2016, 3:23 PM Błażej Krysiak <notifications@github.com>\nwrote:\n\n> According to spec json-api stays agnostic:\n>\n> Note: This spec is agnostic about inflection rules, so the value of type\n> can be either plural or singular.\n> However, the same value should be used consistently throughout an implementation.\n>\n> But if we want to implement this feature I'd recommend using singular form\n> due to many problems faced with pluralization that are dependent and vary\n> regarding to which language you use.\n>\n> On the other hand if we want to allow plural form we should allow to pass\n> custom name of resource.\n>\n> What guys do you think?\n>\n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/katharsis-project/katharsis-core/issues/361#issuecomment-234102231>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ABaI0BOYqcklvZLcpcZnztFTofBTarDYks5qXp_OgaJpZM4JM1vb>\n> .\n>\n"}}
{"actor":{"display_login":"masterspambot"}}