to set a default description if none is provided

This commit is contained in:
wing328
2016-07-19 16:55:39 +08:00
parent 207622a8f8
commit 37404909bf
7 changed files with 63 additions and 57 deletions

View File

@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import org.apache.commons.lang3.StringUtils;
public class DefaultGenerator extends AbstractGenerator implements Generator {
protected Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
@@ -149,10 +149,16 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (info.getVersion() != null) {
config.additionalProperties().put("appVersion", config.escapeText(info.getVersion()));
}
if (info.getDescription() != null) {
if (StringUtils.isEmpty(info.getDescription())) {
// set a default description if none if provided
config.additionalProperties().put("appDescription",
"No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
} else {
config.additionalProperties().put("appDescription",
config.escapeText(info.getDescription()));
}
if (info.getContact() != null) {
Contact contact = info.getContact();
config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl()));
@@ -522,7 +528,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (SupportingFile support : config.supportingFiles()) {
try {
String outputFolder = config.outputFolder();
if (isNotEmpty(support.folder)) {
if (StringUtils.isNotEmpty(support.folder)) {
outputFolder += File.separator + support.folder;
}
File of = new File(outputFolder);