{"action":"created","issue":{"url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo/issues/582","repository_url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo","labels_url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo/issues/582/labels{/name}","comments_url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo/issues/582/comments","events_url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo/issues/582/events","html_url":"https://github.com/joelittlejohn/jsonschema2pojo/issues/582","id":159538255,"number":582,"title":"Is it possible to use a property with JavaType HashMap and generics -> Maven plugin","user":{"login":"yveszoundi","id":5206067,"avatar_url":"https://avatars.githubusercontent.com/u/5206067?v=3","gravatar_id":"","url":"https://api.github.com/users/yveszoundi","html_url":"https://github.com/yveszoundi","followers_url":"https://api.github.com/users/yveszoundi/followers","following_url":"https://api.github.com/users/yveszoundi/following{/other_user}","gists_url":"https://api.github.com/users/yveszoundi/gists{/gist_id}","starred_url":"https://api.github.com/users/yveszoundi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yveszoundi/subscriptions","organizations_url":"https://api.github.com/users/yveszoundi/orgs","repos_url":"https://api.github.com/users/yveszoundi/repos","events_url":"https://api.github.com/users/yveszoundi/events{/privacy}","received_events_url":"https://api.github.com/users/yveszoundi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-06-10T00:40:31Z","updated_at":"2016-07-16T18:45:01Z","closed_at":null,"body":"It seems that jsonschema2pojo cannot generate complex classes (Maven plugin) with a mix of Map(generics), Collections(generics).\r\n\r\n# Issue\r\nI have a moderately complex schema, not that complex though with Collections(generics), Maps(generics), reference to definitions. The schema itself  is roughly 200 lines.\r\n\r\nThe code generation fails when attempting to perform java imports of a property defined as \r\n```\"aProperty\": { \"javaType\": \"java.util.Map<String, Integer>\" }```. I just get a compilation error.\r\nThe maven plugin (stable or git master), generates code with an import  of```java.util.Map<String, Integer>``` in this case. I'd even be happy if the _javaType_ was take as is, nevermind typing fully qualified class names.\r\n\r\nIf I check against http://www.jsonschema2pojo.org/ with my full \"real\" example, code generation seems to work as expected. I'm not referencing any external classes at this time.\r\nThe problem is like specific to the Maven plugin, but I could be wrong...\r\n\r\n# Workaround\r\nIt consists into not using generics for collections or maps specified within ```javaType```, just plain \"java.util.Map\".\r\n\r\n# Example:\r\nBelow is a simple example of what I'm trying to achieve with simplifications.\r\nThe real code has about 35 properties, 5 references to definitions, 4 enums, 10 collection types via javatype, 6 hashmaps(generics).\r\n\r\n```json\r\n{\r\n    \"id\": \"http://some.site.somewhere/entry-schema#\",\r\n    \"$schema\": \"http://json-schema.org/draft-04/schema#\",\r\n    \"description\": \"schema for whatever\",\r\n    \"type\": \"object\",\r\n    \"additionalProperties\": false,\r\n\"definitions\": {\r\n        \"aDef\": {\r\n            \"type\": \"object\",\r\n            \"additionalProperties\": false,\r\n            \"properties\": {\r\n                \"aDefProp\": {\r\n                    \"javaType\": \"java.lang.Integer\"\r\n                }\r\n            }\r\n        },\r\n  \"bDef\": {\r\n            \"type\": \"object\",\r\n            \"additionalProperties\": false,\r\n            \"properties\": {\r\n                \"bDefProp\": {\r\n                    \"javaType\": \"java.lang.Integer\"\r\n                }\r\n            }\r\n        }\r\n    },\r\n    \"properties\": {\r\n        \"aMapAppearsFewTimesWithDifferentNames\": {\r\n            \"javaType\": \"java.util.HashMap<String, Integer>\"\r\n        },\r\n          \"aListAppearsCoupleOfTimesWithDifferentNames\": {\r\n            \"javaType\": \"java.util.ArrayList<String>\"\r\n        },\r\n        \"anotherElementAppearsFewTimesWithDifferentNames\": {\r\n            \"$ref\": \"#/definitions/aDef\"\r\n        },\r\n      \"anotherElementAppearsFewTimesWithDifferentNames\": {\r\n            \"$ref\": \"#/definitions/bDef\"\r\n        },\r\n\"mainlyCoupleofStringsProperties\": {\r\n            \"type\":\"string\"\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo/issues/comments/233144911","html_url":"https://github.com/joelittlejohn/jsonschema2pojo/issues/582#issuecomment-233144911","issue_url":"https://api.github.com/repos/joelittlejohn/jsonschema2pojo/issues/582","id":233144911,"user":{"login":"joelittlejohn","id":686384,"avatar_url":"https://avatars.githubusercontent.com/u/686384?v=3","gravatar_id":"","url":"https://api.github.com/users/joelittlejohn","html_url":"https://github.com/joelittlejohn","followers_url":"https://api.github.com/users/joelittlejohn/followers","following_url":"https://api.github.com/users/joelittlejohn/following{/other_user}","gists_url":"https://api.github.com/users/joelittlejohn/gists{/gist_id}","starred_url":"https://api.github.com/users/joelittlejohn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelittlejohn/subscriptions","organizations_url":"https://api.github.com/users/joelittlejohn/orgs","repos_url":"https://api.github.com/users/joelittlejohn/repos","events_url":"https://api.github.com/users/joelittlejohn/events{/privacy}","received_events_url":"https://api.github.com/users/joelittlejohn/received_events","type":"User","site_admin":false},"created_at":"2016-07-16T18:45:01Z","updated_at":"2016-07-16T18:45:01Z","body":"So, it looks like this happens when you specify this:\r\n\r\n```json\r\n        \"aMapAppearsFewTimesWithDifferentNames\": {\r\n            \"javaType\": \"java.util.HashMap<String, Integer>\"\r\n        }\r\n```\r\n\r\ninstead of this:\r\n\r\n```json\r\n        \"aMapAppearsFewTimesWithDifferentNames\": {\r\n            \"type\": \"object\",\r\n            \"javaType\": \"java.util.HashMap<String, Integer>\"\r\n        }\r\n```\r\n\r\nIn the case of wanting a Java list, you can simply specify:\r\n\r\n```json\r\n        \"aMapAppearsFewTimesWithDifferentNames\": {\r\n            \"type\": \"array\",\r\n            \"items\": {\r\n                \"type\": \"string\"\r\n            }\r\n        }\r\n```\r\n"}}
{"actor":{"display_login":"joelittlejohn"}}