This commit is contained in:
William Cheng 2021-03-06 21:01:52 +08:00
commit 4ab17cfd96

View File

@ -349,8 +349,12 @@ public class GoClientCodegen extends AbstractGoCodegen {
public String toDefaultValue(Schema p) { public String toDefaultValue(Schema p) {
p = ModelUtils.getReferencedSchema(this.openAPI, p); p = ModelUtils.getReferencedSchema(this.openAPI, p);
if (ModelUtils.isStringSchema(p)) { if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) { Object defaultObj = p.getDefault();
return "\"" + escapeText((String) p.getDefault()) + "\""; if (defaultObj != null) {
if (defaultObj instanceof java.lang.String) {
return "\"" + escapeText((String) defaultObj) + "\"";
}
return "\"" + escapeText(defaultObj.toString()) + "\"";
} }
return null; return null;
} }