#3908 make a copy of vendorExtensions map instead of copying the reference (#4093)

* #3908 make a copy of vendorExtensions map instead of copying the
reference

* using 4-space instead of tab.

* make a copy of vendorExtensions map instead of copying the reference
This commit is contained in:
RaphC 2016-11-18 09:52:42 +01:00 committed by wing328
parent cde24f1113
commit a260636a48
2 changed files with 21 additions and 2 deletions

View File

@ -122,7 +122,9 @@ public class CodegenParameter {
if (this.items != null) { if (this.items != null) {
output.items = this.items; output.items = this.items;
} }
output.vendorExtensions = this.vendorExtensions; if(this.vendorExtensions != null){
output.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions);
}
output.hasValidation = this.hasValidation; output.hasValidation = this.hasValidation;
output.isBinary = this.isBinary; output.isBinary = this.isBinary;
output.isByteArray = this.isByteArray; output.isByteArray = this.isByteArray;

View File

@ -1,5 +1,7 @@
package io.swagger.codegen; package io.swagger.codegen;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -283,9 +285,24 @@ public class CodegenProperty implements Cloneable {
@Override @Override
public CodegenProperty clone() { public CodegenProperty clone() {
try { try {
return (CodegenProperty) super.clone(); CodegenProperty cp = (CodegenProperty) super.clone();
if (this._enum != null) {
cp._enum = new ArrayList<String>(this._enum);
}
if (this.allowableValues != null) {
cp.allowableValues = new HashMap<String, Object>(this.allowableValues);
}
if (this.items != null) {
cp.items = this.items;
}
if(this.vendorExtensions != null){
cp.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions);
}
return cp;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }
} }