{"action":"opened","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3908","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3908/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3908/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3908/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3908","id":180333316,"number":3908,"title":"[JAVA] CodegenParameter instance copy is not safe","user":{"login":"RaphC","id":1260364,"avatar_url":"https://avatars.githubusercontent.com/u/1260364?v=3","gravatar_id":"","url":"https://api.github.com/users/RaphC","html_url":"https://github.com/RaphC","followers_url":"https://api.github.com/users/RaphC/followers","following_url":"https://api.github.com/users/RaphC/following{/other_user}","gists_url":"https://api.github.com/users/RaphC/gists{/gist_id}","starred_url":"https://api.github.com/users/RaphC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RaphC/subscriptions","organizations_url":"https://api.github.com/users/RaphC/orgs","repos_url":"https://api.github.com/users/RaphC/repos","events_url":"https://api.github.com/users/RaphC/events{/privacy}","received_events_url":"https://api.github.com/users/RaphC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-30T15:29:33Z","updated_at":"2016-09-30T15:29:33Z","closed_at":null,"body":"Hi,\r\n\r\n##### Description\r\n\r\nI'm using swagger codegen maven plugin to generate from swagger file our Java class with my own generator. I extended JavaJAXRSSpecServerCodegen to add some feature like ignoring some of parameters in the methods which are described in the swagger file. To do that, I set a vendor extensions and then when the plugin invokes fromOperation It ignores the parameters with these extension. In my code I have to make a copy of the CodegenParameter.\r\n\r\nList<CodegenParameter> printableParams = Lists.newLinkedList();\r\n\t\tfor (CodegenParameter p : op.allParams) {\r\n\t\t\t....\r\n\t\t\t\tprintableParams.add(p.copy());\r\n\t}\r\n\r\nUnfortunately when copying CodegenParameter instance, the attribute vendorExtensions is copied by reference.\r\n\r\noutput.vendorExtensions = this.vendorExtensions;\r\n\r\nSo If the current instance p modify its  vendorExtensions Map (add a new element for instance), my new cloned instance is affected by whereas it shouldn't be.\r\n\r\n##### Swagger-codegen version\r\n\r\n1.59\r\n\r\n##### Swagger declaration file content or url\r\n\r\n##### Command line used for generation\r\n\r\n##### Steps to reproduce\r\n\r\n##### Related issues\r\n\r\n##### Suggest a Fix\r\n\r\nJust make a copy of attribute vendorExtensions in the method copy() of CodegenParameter instead of  copying reference\r\n\r\n"}}
{"actor":{"display_login":"RaphC"}}