Skip to content

Commit

Permalink
Properly generate email examples (#8035)
Browse files Browse the repository at this point in the history
Those are not primitive types, but not model either, they need to be
handled explicitely.
  • Loading branch information
therve authored Nov 30, 2020
1 parent 16e9011 commit a8fbcb0
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ private String constructExampleCode(CodegenParameter codegenParameter, HashMap<S
// look up the model
if (modelMaps.containsKey(codegenParameter.dataType)) {
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
} else if (codegenParameter.isEmail) { // email
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return "\"" + codegenParameter.example + "\"";
} else {
return "\"" + codegenParameter.paramName + "@example.com\"";
}
} else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date
processedModelMap.put("time.Time", 1);
return "time.Now()";
Expand Down Expand Up @@ -567,6 +573,12 @@ private String constructExampleCode(CodegenProperty codegenProperty, HashMap<Str
// look up the model
if (modelMaps.containsKey(codegenProperty.dataType)) {
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
} else if (codegenProperty.isEmail) { // email
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return "\"" + codegenProperty.example + "\"";
} else {
return "\"" + codegenProperty.name + "@example.com\"";
}
} else if (codegenProperty.isDateTime || codegenProperty.isDate) { // datetime or date
processedModelMap.put("time.Time", 1);
return "time.Now()";
Expand Down

0 comments on commit a8fbcb0

Please sign in to comment.