forked from loafle/openapi-generator-original
Update after merging
This commit is contained in:
@@ -9,11 +9,9 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
protected String dateLibrary = "default";
|
||||
protected String title = "Swagger Server";
|
||||
protected String implFolder = "src/main/java";
|
||||
|
||||
public static final String DATE_LIBRARY = "dateLibrary";
|
||||
public JaxRSServerCodegen() {
|
||||
super();
|
||||
|
||||
@@ -41,14 +39,6 @@ public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
|
||||
Map<String, String> dateOptions = new HashMap<String, String>();
|
||||
dateOptions.put("java8", "Java 8 native");
|
||||
dateOptions.put("joda", "Joda");
|
||||
dateLibrary.setEnum(dateOptions);
|
||||
|
||||
cliOptions.add(dateLibrary);
|
||||
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
|
||||
@@ -84,11 +74,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
if(additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) {
|
||||
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
||||
}
|
||||
|
||||
// if("jersey2".equals(getLibrary())) {
|
||||
// embeddedTemplateDir = templateDir = "JavaJaxRS" + File.separator + "jersey2";
|
||||
// }
|
||||
|
||||
|
||||
supportingFiles.clear();
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
@@ -111,25 +97,12 @@ public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
}
|
||||
|
||||
if("joda".equals(dateLibrary)) {
|
||||
typeMapping.put("date", "LocalDate");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
|
||||
importMapping.put("LocalDate", "org.joda.time.LocalDate");
|
||||
importMapping.put("DateTime", "org.joda.time.DateTime");
|
||||
|
||||
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache",
|
||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
||||
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache",
|
||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
|
||||
}
|
||||
else if ("java8".equals(dateLibrary)) {
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("javaVersion", "1.8");
|
||||
typeMapping.put("date", "LocalDate");
|
||||
typeMapping.put("DateTime", "LocalDateTime");
|
||||
importMapping.put("LocalDate", "java.time.LocalDate");
|
||||
importMapping.put("LocalDateTime", "java.time.LocalDateTime");
|
||||
|
||||
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache",
|
||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
|
||||
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache",
|
||||
@@ -180,7 +153,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
}
|
||||
}
|
||||
this.additionalProperties.put("serverPort", port);
|
||||
if( swagger.getPaths() != null) {
|
||||
if(swagger.getPaths() != null) {
|
||||
for(String pathname : swagger.getPaths().keySet()) {
|
||||
Path path = swagger.getPath(pathname);
|
||||
if(path.getOperations() != null) {
|
||||
@@ -256,7 +229,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
name = sanitizeName(name);
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@@ -291,8 +264,4 @@ public class JaxRSServerCodegen extends JavaClientCodegen {
|
||||
public boolean shouldOverwrite(String filename) {
|
||||
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
|
||||
}
|
||||
|
||||
public void setDateLibrary(String library) {
|
||||
this.dateLibrary = library;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user