{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3930","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3930/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3930/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3930/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3930","id":181211598,"number":3930,"title":"[JAVA] Support Javax injection for creation of API delegate instead of static factory pattern","user":{"login":"JLLeitschuh","id":1323708,"avatar_url":"https://avatars1.githubusercontent.com/u/1323708?v=3","gravatar_id":"","url":"https://api.github.com/users/JLLeitschuh","html_url":"https://github.com/JLLeitschuh","followers_url":"https://api.github.com/users/JLLeitschuh/followers","following_url":"https://api.github.com/users/JLLeitschuh/following{/other_user}","gists_url":"https://api.github.com/users/JLLeitschuh/gists{/gist_id}","starred_url":"https://api.github.com/users/JLLeitschuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JLLeitschuh/subscriptions","organizations_url":"https://api.github.com/users/JLLeitschuh/orgs","repos_url":"https://api.github.com/users/JLLeitschuh/repos","events_url":"https://api.github.com/users/JLLeitschuh/events{/privacy}","received_events_url":"https://api.github.com/users/JLLeitschuh/received_events","type":"User","site_admin":false},"labels":[{"id":64180619,"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Enhancement:%20Feature","name":"Enhancement: Feature","color":"e5ffe5","default":false},{"id":410531038,"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/General:%20Suggestion","name":"General: Suggestion","color":"66ccff","default":false},{"id":160482740,"url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels/Need%20community%20contribution","name":"Need community contribution","color":"e3ff00","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/5","html_url":"https://github.com/swagger-api/swagger-codegen/milestone/5","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones/5/labels","id":913962,"number":5,"title":"Future","description":"","creator":{"login":"fehguy","id":249413,"avatar_url":"https://avatars0.githubusercontent.com/u/249413?v=3","gravatar_id":"","url":"https://api.github.com/users/fehguy","html_url":"https://github.com/fehguy","followers_url":"https://api.github.com/users/fehguy/followers","following_url":"https://api.github.com/users/fehguy/following{/other_user}","gists_url":"https://api.github.com/users/fehguy/gists{/gist_id}","starred_url":"https://api.github.com/users/fehguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fehguy/subscriptions","organizations_url":"https://api.github.com/users/fehguy/orgs","repos_url":"https://api.github.com/users/fehguy/repos","events_url":"https://api.github.com/users/fehguy/events{/privacy}","received_events_url":"https://api.github.com/users/fehguy/received_events","type":"User","site_admin":false},"open_issues":325,"closed_issues":86,"state":"open","created_at":"2014-12-24T05:48:44Z","updated_at":"2017-03-13T07:24:22Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2016-10-05T17:03:59Z","updated_at":"2017-03-13T15:09:50Z","closed_at":null,"body":"<!--\nPlease follow the issue template below for bug reports and feature requests.\nAlso please indicate in the issue title which language/library is concerned. Eg:  [JAVA] Bug generating foo with bar \n-->\n##### Description\n\n**Replace/Complement static factory with DI injection**\n\nCurrently, the generator for jersey and rest-easy use the static factory pattern to create the delegate that gets called by the REST API.\n\n<!-- describe what is the question, suggestion or issue and why this is a problem for you. -->\n##### Swagger-codegen version\n\n<!-- which version of swagger-codegen are you using, is it a regression? -->\n\nWhatever version this [gradle plugin](https://github.com/thebignet/swagger-codegen-gradle-plugin) in using, (I think it's the current release).\n##### Swagger declaration file content or url\n\nUse the pet-store as an example.\n\n<!-- if it is a bug, a json or yaml that produces it.\n    If you post the code inline, please wrap it with\n    ```yaml\n    (here your code)\n    ```\n    (for YAML code) or\n    ```json\n    (here your code)\n    ```\n    (for JSON code), so it becomes more readable. If it is longer than about ten lines,\n    please create a Gist (https://gist.github.com) or upload it somewhere else and\n    link it here.\n  -->\n##### Command line used for generation\n\n``` groovy\nswagger {\n    inputSpec = \"${project.projectDir.path}/spec/swagger.yaml\"\n\n    output = 'build/swagger'\n    language = 'jaxrs-resteasy'\n\n    additionalProperties = [\n            'invokerPackage'   : 'edu.wpi.grip.web.swagger',\n            'modelPackage'     : 'edu.wpi.grip.web.swagger.model',\n            'apiPackage'       : 'edu.wpi.grip.web.swagger.api',\n            'serializableModel': 'true'\n    ]\n\n    apis = ''\n    models = ''\n    supportingFiles = ''\n}\n```\n##### Suggest a Fix\n\nI'm using a custom `api.mustache` file that replaces the delegate creation with constructor injection.\n\n``` java\nimport javax.inject.Inject;\n\npublic class {{classname}}  {\n    private final {{classname}}Service delegate;\n\n    @Inject\n    {{classname}}({{classname}}Service delegate) {\n        this.delegate = delegate;\n    }\n```\n\nIf a zero argument constructor is needed for other reasons and other frameworks both solutions could be implemented in parallel.\n\n``` java\nimport javax.inject.Inject;\n\npublic class {{classname}}  {\n    private final {{classname}}Service delegate;\n\n    {{classname}}() { // Zero argument constructor because some frameworks need this\n        this({{classname}}ServiceFactory.get{{classname}}(););\n    }\n\n    @Inject\n    {{classname}}({{classname}}Service delegate) {\n        this.delegate = delegate;\n    }\n```\n"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/comments/286136423","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3930#issuecomment-286136423","issue_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3930","id":286136423,"user":{"login":"JLLeitschuh","id":1323708,"avatar_url":"https://avatars1.githubusercontent.com/u/1323708?v=3","gravatar_id":"","url":"https://api.github.com/users/JLLeitschuh","html_url":"https://github.com/JLLeitschuh","followers_url":"https://api.github.com/users/JLLeitschuh/followers","following_url":"https://api.github.com/users/JLLeitschuh/following{/other_user}","gists_url":"https://api.github.com/users/JLLeitschuh/gists{/gist_id}","starred_url":"https://api.github.com/users/JLLeitschuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JLLeitschuh/subscriptions","organizations_url":"https://api.github.com/users/JLLeitschuh/orgs","repos_url":"https://api.github.com/users/JLLeitschuh/repos","events_url":"https://api.github.com/users/JLLeitschuh/events{/privacy}","received_events_url":"https://api.github.com/users/JLLeitschuh/received_events","type":"User","site_admin":false},"created_at":"2017-03-13T15:09:50Z","updated_at":"2017-03-13T15:09:50Z","body":"I agree with using `javax.inject` I use `javax.inject` myself. The thing is, the code generator is generating code for specific frameworks. The spring generator is generating for spring. There are other generators generating for other frameworks. I don't know if you can decouple that well."}}
{"actor":{"display_login":"JLLeitschuh"}}