{"action":"created","issue":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1627","repository_url":"https://api.github.com/repos/OpenAPITools/openapi-generator","labels_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1627/labels{/name}","comments_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1627/comments","events_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1627/events","html_url":"https://github.com/OpenAPITools/openapi-generator/issues/1627","id":388302967,"node_id":"MDU6SXNzdWUzODgzMDI5Njc=","number":1627,"title":"[java] Referenced schema is not generated properly","user":{"login":"padamstx","id":26463020,"node_id":"MDQ6VXNlcjI2NDYzMDIw","avatar_url":"https://avatars0.githubusercontent.com/u/26463020?v=4","gravatar_id":"","url":"https://api.github.com/users/padamstx","html_url":"https://github.com/padamstx","followers_url":"https://api.github.com/users/padamstx/followers","following_url":"https://api.github.com/users/padamstx/following{/other_user}","gists_url":"https://api.github.com/users/padamstx/gists{/gist_id}","starred_url":"https://api.github.com/users/padamstx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/padamstx/subscriptions","organizations_url":"https://api.github.com/users/padamstx/orgs","repos_url":"https://api.github.com/users/padamstx/repos","events_url":"https://api.github.com/users/padamstx/events{/privacy}","received_events_url":"https://api.github.com/users/padamstx/received_events","type":"User","site_admin":false},"labels":[{"id":931403269,"node_id":"MDU6TGFiZWw5MzE0MDMyNjk=","url":"https://api.github.com/repos/OpenAPITools/openapi-generator/labels/Feature:%20Generator","name":"Feature: Generator","color":"eeccff","default":false},{"id":931403399,"node_id":"MDU6TGFiZWw5MzE0MDMzOTk=","url":"https://api.github.com/repos/OpenAPITools/openapi-generator/labels/Issue:%20Bug","name":"Issue: Bug","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/milestones/4","html_url":"https://github.com/OpenAPITools/openapi-generator/milestone/4","labels_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/milestones/4/labels","id":3392269,"node_id":"MDk6TWlsZXN0b25lMzM5MjI2OQ==","number":4,"title":"4.0.0","description":"4.0.0-beta will be released on Dec 20th, 2018","creator":{"login":"wing328","id":934260,"node_id":"MDQ6VXNlcjkzNDI2MA==","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":47,"closed_issues":56,"state":"open","created_at":"2018-06-01T03:35:57Z","updated_at":"2018-12-10T04:22:59Z","due_on":"2019-01-31T08:00:00Z","closed_at":null},"comments":6,"created_at":"2018-12-06T16:51:18Z","updated_at":"2018-12-10T06:06:23Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"##### Description\r\nAfter applying the fix for issue #1624 (PR #1625), the attached schema results in incorrect code generation for the \"java\" generator, although I suspect other generators would suffer from the same fate.\r\nPrior to applying the fix for #1624, the generator throws an NPE :)\r\n\r\nThe crux of the problem is that the java generator will generate the \"Message\" class as expected, with the \"context\" field being declared as a \"Context\" object.   Unfortunately, the Context model is not generated because it is apparently considered to be a top-level map.   \r\n\r\nOne might think that a possible solution would be to generate the Message.context field so that it is of type Map<String, Object> since the Context model is optimized away after being interpreted as a top-level map.   But in my opinion, since Context is a referenced schema, we should not be optimizing that away.   It is a distinct model defined in the apispec as an object that can have arbitrary properties set on it and is referenced from a schema property belonging to the Message schema.   Therefore, it should be rendered as such...  i.e. we should generate a class called Context which is a subclass of Map<String, Object>.   At the very least, there should probably be a configuration property that can enable/disable the feature introduced by issue #1296.\r\n\r\nI could see this schema flattening being done if the Message.context schema property's schema was an inline schema, but not in the case where Message.context's schema is a reference to another named schema.\r\n\r\n##### openapi-generator version\r\nmaster (latest)\r\n\r\n##### OpenAPI declaration file content or url\r\n\r\nHere's the apispec which exhibits the problem:\r\n[testcase.zip](https://github.com/OpenAPITools/openapi-generator/files/2653970/testcase.zip)\r\n\r\n##### Command line used for generation\r\nUsing latest master code + fix for issue #1624:\r\n```\r\njava -jar <location-of-jar>/openapi-generator-cli.jar generate -i testcase.json -g java -o ./java/testcase\r\n```\r\n##### Steps to reproduce\r\n1) Process the apispec using the command above\r\n1) Observe the emitted Message.java class; the \"context\" field is of type Context, but the Context model did not get generated.\r\nNote: if the fix for #1624 is not applied, then the result will be an NPE\r\n\r\n##### Related issues/PRs\r\n#1296 \r\n\r\n##### Suggest a fix/enhancement\r\nEither revert the changes in #1296 or support a configuration property that can disable that feature.\r\n"},"comment":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/comments/445698213","html_url":"https://github.com/OpenAPITools/openapi-generator/issues/1627#issuecomment-445698213","issue_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1627","id":445698213,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTY5ODIxMw==","user":{"login":"wing328","id":934260,"node_id":"MDQ6VXNlcjkzNDI2MA==","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},"created_at":"2018-12-10T06:06:23Z","updated_at":"2018-12-10T06:06:23Z","author_association":"MEMBER","body":"> Our goal is to provide a set of SDKs for each IBM Watson service on the IBM Cloud such that a client programmer (user of one or more services) could easily switch between languages when using a particular service without needing to learn a whole new SDK\r\n\r\nUnderstood. I had the same goal when started contributing to the code base a few years back but later I got feedback from developers with different preferences when using a SDK of a particular programming language (e.g. returning an ApiResponse object vs returning a list containing response payload, headers and status code). We still want to achieve that as we've been providing many different options to meet different developer's preferences and we hope your team will be able to deliver a consistent developer experience using OpenAPI Generator.\r\n\r\nAs @jmini has pointed out, we'll probably add a switch/flag to allow users to control the behaviour (subclassing map vs alias to map). I've filed #1638 to fix the alias to map and will submit another PR to add the switch later before the 4.0.0 release. "}}
{"actor":{"display_login":"wing328"}}