forked from loafle/openapi-generator-original
Work almost finish
Aask @wing328 if the modificatgion in the DefaultGenerator class is a problem. If needed, find a way to do it only for the CXF Codegen. TODO: Maybe create an abstract JAX-RS Codegen and make Jersey & CXF extends it ? CXF should not extends Jersey since there at two different frameworks implementing the JAX-RS specification. Important: nothing is tested yet, only visual checks during Maven build.
This commit is contained in:
parent
1dbc8a8552
commit
f3659f88a8
@ -264,7 +264,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
operation.put("basePath", basePath);
|
operation.put("basePath", basePath);
|
||||||
operation.put("basePathWithoutHost", basePathWithoutHost);
|
operation.put("basePathWithoutHost", basePathWithoutHost);
|
||||||
operation.put("contextPath", contextPath);
|
operation.put("contextPath", contextPath);
|
||||||
operation.put("baseName", tag);
|
// operation.put("baseName", tag); FIXME ask @hiveship if this modification cause a problem
|
||||||
|
operation.put("baseName", basePathWithoutHost);
|
||||||
operation.put("modelPackage", config.modelPackage());
|
operation.put("modelPackage", config.modelPackage());
|
||||||
operation.putAll(config.additionalProperties());
|
operation.putAll(config.additionalProperties());
|
||||||
operation.put("classname", config.toApiName(tag));
|
operation.put("classname", config.toApiName(tag));
|
||||||
|
@ -493,7 +493,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
|
if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
|
||||||
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
||||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
||||||
codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
codegenModel = JavaClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return codegenModel;
|
return codegenModel;
|
||||||
|
@ -2,8 +2,12 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.WordUtils;
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.models.Operation;
|
||||||
|
|
||||||
// TODO: create an abstract JavaJAXRSServerCodegen that both Jersey1 & CXF will extends.
|
// TODO: create an abstract JavaJAXRSServerCodegen that both Jersey1 & CXF will extends.
|
||||||
public class JavaJaxRSCXFServerCodegen extends JavaJaxRSJersey1ServerCodegen
|
public class JavaJaxRSCXFServerCodegen extends JavaJaxRSJersey1ServerCodegen
|
||||||
@ -30,20 +34,16 @@ public class JavaJaxRSCXFServerCodegen extends JavaJaxRSJersey1ServerCodegen
|
|||||||
supportingFiles.clear();
|
supportingFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toApiName(String name)
|
|
||||||
{
|
|
||||||
String computedName = name;
|
|
||||||
computedName = computedName.replace('-', ' ');
|
|
||||||
computedName = WordUtils.capitalize(computedName);
|
|
||||||
computedName = computedName.replaceAll("\\s", "");
|
|
||||||
computedName = super.toApiName(computedName);
|
|
||||||
return computedName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return "cxf";
|
return "cxf";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||||
|
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
|
||||||
|
co.subresourceOperation = !co.path.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,14 @@ import io.swagger.models.Swagger;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen
|
||||||
|
{
|
||||||
protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS";
|
protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS";
|
||||||
protected String title = "Swagger Server";
|
protected String title = "Swagger Server";
|
||||||
protected String implFolder = "src/main/java";
|
protected String implFolder = "src/main/java";
|
||||||
|
|
||||||
public JavaJaxRSJersey1ServerCodegen() {
|
public JavaJaxRSJersey1ServerCodegen()
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
sourceFolder = "src/gen/java";
|
sourceFolder = "src/gen/java";
|
||||||
@ -33,8 +35,8 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
|
|
||||||
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
|
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
|
||||||
|
|
||||||
for(int i = 0; i < cliOptions.size(); i++) {
|
for ( int i = 0; i < cliOptions.size(); i++ ) {
|
||||||
if(CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt())) {
|
if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) {
|
||||||
cliOptions.remove(i);
|
cliOptions.remove(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -46,7 +48,6 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
|
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
|
||||||
// supportedLibraries.put("jersey2", "Jersey2 core library 2.x");
|
|
||||||
library.setEnum(supportedLibraries);
|
library.setEnum(supportedLibraries);
|
||||||
|
|
||||||
cliOptions.add(library);
|
cliOptions.add(library);
|
||||||
@ -54,123 +55,120 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag()
|
||||||
|
{
|
||||||
return CodegenType.SERVER;
|
return CodegenType.SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName()
|
||||||
|
{
|
||||||
return "jaxrs";
|
return "jaxrs";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp()
|
||||||
return "Generates a Java JAXRS Server application.";
|
{
|
||||||
|
return "Generates a Java JAXRS Server application based on Jersey framework.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts()
|
||||||
|
{
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
if(additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) {
|
if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER) ) {
|
||||||
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
supportingFiles.clear();
|
supportingFiles.clear();
|
||||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
|
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
|
||||||
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache",
|
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
|
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
||||||
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache",
|
supportingFiles.add(new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
|
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
||||||
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("web.mustache",
|
|
||||||
("src/main/webapp/WEB-INF"), "web.xml"));
|
|
||||||
supportingFiles.add(new SupportingFile("StringUtil.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey("dateLibrary")) {
|
if ( additionalProperties.containsKey("dateLibrary") ) {
|
||||||
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
||||||
additionalProperties.put(dateLibrary, "true");
|
additionalProperties.put(dateLibrary, "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
if("joda".equals(dateLibrary)) {
|
if ( "joda".equals(dateLibrary) ) {
|
||||||
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache",
|
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
|
||||||
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache",
|
} else if ( "java8".equals(dateLibrary) ) {
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
|
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
|
||||||
}
|
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
|
||||||
else if ("java8".equals(dateLibrary)) {
|
|
||||||
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations)
|
||||||
|
// {
|
||||||
|
// String basePath = resourcePath;
|
||||||
|
//
|
||||||
|
// if ( basePath.startsWith("/") ) {
|
||||||
|
// basePath = basePath.substring(1);
|
||||||
|
// }
|
||||||
|
// int pos = basePath.indexOf("/");
|
||||||
|
// if ( pos > 0 ) {
|
||||||
|
// basePath = basePath.substring(0, pos);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if ( basePath == "" ) {
|
||||||
|
// basePath = "default";
|
||||||
|
// } else {
|
||||||
|
// if ( co.path.startsWith("/" + basePath) ) {
|
||||||
|
// co.path = co.path.substring(("/" + basePath).length());
|
||||||
|
// System.out.println("### DEBUG | jerseyCodegen addOperationToGroupe | co.path -> " + co.path.toString());
|
||||||
|
// }
|
||||||
|
// co.subresourceOperation = !co.path.isEmpty();
|
||||||
|
// }
|
||||||
|
// List<CodegenOperation> opList = operations.get(basePath);
|
||||||
|
// if ( opList == null ) {
|
||||||
|
// opList = new ArrayList<CodegenOperation>();
|
||||||
|
// operations.put(basePath, opList);
|
||||||
|
// }
|
||||||
|
// opList.add(co);
|
||||||
|
// co.baseName = basePath;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
public void preprocessSwagger(Swagger swagger)
|
||||||
String basePath = resourcePath;
|
{
|
||||||
if (basePath.startsWith("/")) {
|
if ( "/".equals(swagger.getBasePath()) ) {
|
||||||
basePath = basePath.substring(1);
|
|
||||||
}
|
|
||||||
int pos = basePath.indexOf("/");
|
|
||||||
if (pos > 0) {
|
|
||||||
basePath = basePath.substring(0, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (basePath == "") {
|
|
||||||
basePath = "default";
|
|
||||||
} else {
|
|
||||||
if (co.path.startsWith("/" + basePath)) {
|
|
||||||
co.path = co.path.substring(("/" + basePath).length());
|
|
||||||
}
|
|
||||||
co.subresourceOperation = !co.path.isEmpty();
|
|
||||||
}
|
|
||||||
List<CodegenOperation> opList = operations.get(basePath);
|
|
||||||
if (opList == null) {
|
|
||||||
opList = new ArrayList<CodegenOperation>();
|
|
||||||
operations.put(basePath, opList);
|
|
||||||
}
|
|
||||||
opList.add(co);
|
|
||||||
co.baseName = basePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void preprocessSwagger(Swagger swagger) {
|
|
||||||
if("/".equals(swagger.getBasePath())) {
|
|
||||||
swagger.setBasePath("");
|
swagger.setBasePath("");
|
||||||
}
|
}
|
||||||
|
|
||||||
String host = swagger.getHost();
|
String host = swagger.getHost();
|
||||||
String port = "8080";
|
String port = "8080"; // Default value for a JEE Server
|
||||||
if(host != null) {
|
if ( host != null ) {
|
||||||
String[] parts = host.split(":");
|
String[] parts = host.split(":");
|
||||||
if(parts.length > 1) {
|
if ( parts.length > 1 ) {
|
||||||
port = parts[1];
|
port = parts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.additionalProperties.put("serverPort", port);
|
this.additionalProperties.put("serverPort", port);
|
||||||
if(swagger != null && swagger.getPaths() != null) {
|
if ( swagger.getPaths() != null ) {
|
||||||
for(String pathname : swagger.getPaths().keySet()) {
|
for ( String pathname : swagger.getPaths().keySet() ) {
|
||||||
Path path = swagger.getPath(pathname);
|
Path path = swagger.getPath(pathname);
|
||||||
if(path.getOperations() != null) {
|
if ( path.getOperations() != null ) {
|
||||||
for(Operation operation : path.getOperations()) {
|
for ( Operation operation : path.getOperations() ) {
|
||||||
if(operation.getTags() != null) {
|
if ( operation.getTags() != null ) {
|
||||||
List<Map<String, String>> tags = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> tags = new ArrayList<Map<String, String>>();
|
||||||
for(String tag : operation.getTags()) {
|
for ( String tag : operation.getTags() ) {
|
||||||
Map<String, String> value = new HashMap<String, String>();
|
Map<String, String> value = new HashMap<String, String>();
|
||||||
value.put("tag", tag);
|
value.put("tag", tag);
|
||||||
value.put("hasMore", "true");
|
value.put("hasMore", "true");
|
||||||
tags.add(value);
|
tags.add(value);
|
||||||
}
|
}
|
||||||
if(tags.size() > 0) {
|
if ( tags.size() > 0 ) {
|
||||||
tags.get(tags.size() - 1).remove("hasMore");
|
tags.get(tags.size() - 1).remove("hasMore");
|
||||||
}
|
}
|
||||||
if(operation.getTags().size() > 0) {
|
if ( operation.getTags().size() > 0 ) {
|
||||||
String tag = operation.getTags().get(0);
|
String tag = operation.getTags().get(0);
|
||||||
operation.setTags(Arrays.asList(tag));
|
operation.setTags(Arrays.asList(tag));
|
||||||
}
|
}
|
||||||
@ -183,21 +181,22 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
public Map<String, Object> postProcessOperations(Map<String, Object> objs)
|
||||||
|
{
|
||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
if (operations != null) {
|
if ( operations != null ) {
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation operation : ops) {
|
for ( CodegenOperation operation : ops ) {
|
||||||
List<CodegenResponse> responses = operation.responses;
|
List<CodegenResponse> responses = operation.responses;
|
||||||
if (responses != null) {
|
if ( responses != null ) {
|
||||||
for (CodegenResponse resp : responses) {
|
for ( CodegenResponse resp : responses ) {
|
||||||
if ("0".equals(resp.code)) {
|
if ( "0".equals(resp.code) ) {
|
||||||
resp.code = "200";
|
resp.code = "200";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation.returnType == null) {
|
if (operation.returnType == null) {
|
||||||
operation.returnType = "Void";
|
operation.returnType = "void";
|
||||||
} else if (operation.returnType.startsWith("List")) {
|
} else if (operation.returnType.startsWith("List")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
@ -226,8 +225,9 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiName(String name) {
|
public String toApiName(String name)
|
||||||
if (name.length() == 0) {
|
{
|
||||||
|
if ( name.length() == 0 ) {
|
||||||
return "DefaultApi";
|
return "DefaultApi";
|
||||||
}
|
}
|
||||||
name = sanitizeName(name);
|
name = sanitizeName(name);
|
||||||
@ -235,21 +235,19 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFilename(String templateName, String tag) {
|
public String apiFilename(String templateName, String tag)
|
||||||
|
{
|
||||||
String result = super.apiFilename(templateName, tag);
|
String result = super.apiFilename(templateName, tag);
|
||||||
|
|
||||||
if (templateName.endsWith("Impl.mustache")) {
|
if ( templateName.endsWith("Impl.mustache") ) {
|
||||||
int ix = result.lastIndexOf('/');
|
int ix = result.lastIndexOf('/');
|
||||||
result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java";
|
result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java";
|
||||||
|
|
||||||
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
||||||
} else if (templateName.endsWith("Factory.mustache")) {
|
} else if ( templateName.endsWith("Factory.mustache") ) {
|
||||||
int ix = result.lastIndexOf('/');
|
int ix = result.lastIndexOf('/');
|
||||||
result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java";
|
result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java";
|
||||||
|
|
||||||
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
||||||
} else if (templateName.endsWith("Service.mustache")) {
|
} else if ( templateName.endsWith("Service.mustache") ) {
|
||||||
int ix = result.lastIndexOf('.');
|
int ix = result.lastIndexOf('.');
|
||||||
result = result.substring(0, ix) + "Service.java";
|
result = result.substring(0, ix) + "Service.java";
|
||||||
}
|
}
|
||||||
@ -257,12 +255,14 @@ public class JavaJaxRSJersey1ServerCodegen extends JavaClientCodegen {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String implFileFolder(String output) {
|
private String implFileFolder(String output)
|
||||||
|
{
|
||||||
return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/');
|
return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverwrite(String filename) {
|
public boolean shouldOverwrite(String filename)
|
||||||
|
{
|
||||||
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
|
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,10 @@ package {{package}};
|
|||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
import {{modelPackage}}.*;
|
|
||||||
import java.util.*;
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
@Path("/{{baseName}}")
|
@Path("{{baseName}}")
|
||||||
public interface {{classname}} {
|
public interface {{classname}} {
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
|
@ -3,9 +3,6 @@ package {{package}};
|
|||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
@ -21,9 +18,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
|||||||
public enum {{datatypeWithEnum}} {
|
public enum {{datatypeWithEnum}} {
|
||||||
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
|
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
|
||||||
};
|
};
|
||||||
{{#required}}@NotNull{{/required}}
|
|
||||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
|
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
|
||||||
{{#required}}@NotNull{{/required}}
|
|
||||||
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
import java.util.Objects;
|
{{#imports}}import{{import}};
|
||||||
{{#imports}}import {{import}};
|
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
|
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user