Skip to content

Commit e15bbc9

Browse files
authored
Merge pull request #8999 from swagger-api/issue-4973
check if type declaration for ref property in order to fix regression…
2 parents c4c29d3 + 2fc3b94 commit e15bbc9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,12 @@ public void setModelPropertyNaming(String naming) {
655655

656656
@Override
657657
public String toDefaultValueWithParam(String name, Property p) {
658-
String type = normalizeType(getTypeDeclaration(p));
659-
if (p instanceof RefProperty) {
658+
String typeDeclaration = getTypeDeclaration(p);
659+
String type = normalizeType(typeDeclaration);
660+
if (p instanceof RefProperty && !isPrimitiveType(typeDeclaration.toLowerCase())) {
660661
return " = " + type + ".constructFromObject(data['" + name + "']);";
661-
} else {
662-
return " = ApiClient.convertToType(data['" + name + "'], " + type + ");";
663662
}
663+
return " = ApiClient.convertToType(data['" + name + "'], " + type + ");";
664664
}
665665

666666
@Override

0 commit comments

Comments
 (0)