diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 09ea5fb73f..263adc05cf 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -264,8 +264,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { operation.put("basePath", basePath); operation.put("basePathWithoutHost", basePathWithoutHost); operation.put("contextPath", contextPath); - // operation.put("baseName", tag); FIXME ask @hiveship if this modification cause a problem - operation.put("baseName", basePathWithoutHost); + operation.put("baseName", tag); operation.put("modelPackage", config.modelPackage()); operation.putAll(config.additionalProperties()); operation.put("classname", config.toApiName(tag)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFCodegen.java deleted file mode 100644 index 0f063e485d..0000000000 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFCodegen.java +++ /dev/null @@ -1,73 +0,0 @@ - -package io.swagger.codegen.languages; - -import java.io.File; -import java.util.List; -import java.util.Map; - -import io.swagger.codegen.CliOption; -import io.swagger.codegen.CodegenConstants; -import io.swagger.codegen.CodegenOperation; -import io.swagger.models.Operation; - -public class JavaCXFCodegen extends AbstractJavaJAXRSServerCodegen -{ - public JavaCXFCodegen() - { - super(); - - sourceFolder = "src/gen/java"; - invokerPackage = "io.swagger.api"; - artifactId = "swagger-jaxrs-server"; - outputFolder = "generated-code/JavaJaxRS-CXF"; - - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); - apiPackage = "io.swagger.api"; - modelPackage = "io.swagger.model"; - - additionalProperties.put("title", title); - - super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; - - for ( int i = 0; i < cliOptions.size(); i++ ) { - if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) { - cliOptions.remove(i); - break; - } - } - - cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); - } - - @Override - public void processOpts() - { - super.processOpts(); - sourceFolder = "gen" + File.separator + "java"; - - modelTemplateFiles.clear(); - modelTemplateFiles.put("entityModel.mustache", ".java"); - - supportingFiles.clear(); - } - - @Override - public String getName() - { - return "jaxrs-cxf"; - } - - - @Override - public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { - super.addOperationToGroup(tag, resourcePath, operation, co, operations); - co.subresourceOperation = !co.path.isEmpty(); - } - - @Override - public String getHelp() - { - return "Generates a Java JAXRS Server application based on Apache CXF framework."; - } -} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyCodegen.java deleted file mode 100644 index 2e7d30842b..0000000000 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyCodegen.java +++ /dev/null @@ -1,124 +0,0 @@ -package io.swagger.codegen.languages; - -import io.swagger.codegen.*; -import io.swagger.models.Operation; - -import java.io.File; -import java.util.*; - -public class JavaJerseyCodegen extends AbstractJavaJAXRSServerCodegen -{ - - public JavaJerseyCodegen() - { - super(); - - sourceFolder = "src/gen/java"; - invokerPackage = "io.swagger.api"; - artifactId = "swagger-jaxrs-server"; - outputFolder = "generated-code/JavaJaxRS-Jersey"; - - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); - apiTemplateFiles.put("apiService.mustache", ".java"); - apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); - apiTemplateFiles.put("apiServiceFactory.mustache", ".java"); - apiPackage = "io.swagger.api"; - modelPackage = "io.swagger.model"; - - additionalProperties.put("title", title); - - embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18"; - - for ( int i = 0; i < cliOptions.size(); i++ ) { - if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) { - cliOptions.remove(i); - break; - } - } - - CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); - library.setDefault(DEFAULT_LIBRARY); - - Map supportedLibraries = new LinkedHashMap(); - - supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1"); - library.setEnum(supportedLibraries); - - cliOptions.add(library); - cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); - } - - @Override - public String getName() - { - return "jaxrs"; // TODO should be renamed as "jaxrs-jersey" - } - - @Override - public String getHelp() - { - return "Generates a Java JAXRS Server application based on Jersey framework."; - } - - @Override - public void processOpts() - { - super.processOpts(); - - if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER) ) { - implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); - } - - supportingFiles.clear(); - supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); - supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); - supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java")); - supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java")); - supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.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") ) { - setDateLibrary(additionalProperties.get("dateLibrary").toString()); - additionalProperties.put(dateLibrary, "true"); - } - - if ( "joda".equals(dateLibrary) ) { - 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) ) { - 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> 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()); - } - co.subresourceOperation = !co.path.isEmpty(); - } - List opList = operations.get(basePath); - if (opList == null) { - opList = new ArrayList(); - operations.put(basePath, opList); - } - opList.add(co); - co.baseName = basePath; - } -} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache index c49958f27b..869d1aa63d 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -6,7 +6,7 @@ package {{package}}; import javax.ws.rs.*; import javax.ws.rs.core.Response; -@Path("{{baseName}}") +@Path("{{contextPath}}") public interface {{classname}} { {{#operations}} {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 5a0d537220..18015a9328 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -6,11 +6,10 @@ io.swagger.codegen.languages.FlashClientCodegen io.swagger.codegen.languages.FlaskConnexionCodegen io.swagger.codegen.languages.GoClientCodegen io.swagger.codegen.languages.JavaClientCodegen -io.swagger.codegen.languages.JavascriptClientCodegen -io.swagger.codegen.languages.JavaClientCodegen -io.swagger.codegen.languages.JavaJerseyCodegen -io.swagger.codegen.languages.JavaCXFCodegen +io.swagger.codegen.languages.JavaJerseyServerCodegen +io.swagger.codegen.languages.JavaCXFServerCodegen io.swagger.codegen.languages.JavaInflectorServerCodegen +io.swagger.codegen.languages.JavascriptClientCodegen io.swagger.codegen.languages.JMeterCodegen io.swagger.codegen.languages.NodeJSServerCodegen io.swagger.codegen.languages.ObjcClientCodegen diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java index b2370aef8c..241846dbb8 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java @@ -2,7 +2,7 @@ package io.swagger.codegen.jaxrs; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.java.JavaClientOptionsTest; -import io.swagger.codegen.languages.JavaJerseyCodegen; +import io.swagger.codegen.languages.JavaJerseyServerCodegen; import io.swagger.codegen.options.JaxRSServerOptionsProvider; import mockit.Expectations; @@ -11,7 +11,7 @@ import mockit.Tested; public class JaxRSServerOptionsTest extends JavaClientOptionsTest { @Tested - private JavaJerseyCodegen clientCodegen; + private JavaJerseyServerCodegen clientCodegen; public JaxRSServerOptionsTest() { super(new JaxRSServerOptionsProvider()); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java index 3c74b570ec..34c91e2833 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java @@ -2,7 +2,7 @@ package io.swagger.codegen.jaxrs; import io.swagger.codegen.CodegenModel; -import io.swagger.codegen.languages.JavaJerseyCodegen; +import io.swagger.codegen.languages.JavaJerseyServerCodegen; import io.swagger.models.Model; import io.swagger.models.ModelImpl; import io.swagger.models.properties.DateProperty; @@ -26,7 +26,7 @@ public class JaxrsJava8ModelTest { .required("id") .required("name"); - final JavaJerseyCodegen codegen = new JavaJerseyCodegen(); + final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); codegen.setDateLibrary("java8"); codegen.processOpts(); final CodegenModel cm = codegen.fromModel("sample", model); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java index a133f2c366..8c71c51418 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java @@ -1,7 +1,7 @@ package io.swagger.codegen.jaxrs; import io.swagger.codegen.CodegenModel; -import io.swagger.codegen.languages.JavaJerseyCodegen; +import io.swagger.codegen.languages.JavaJerseyServerCodegen; import io.swagger.models.Model; import io.swagger.models.ModelImpl; import io.swagger.models.properties.DateProperty; @@ -25,7 +25,7 @@ public class JaxrsJodaModelTest { .required("id") .required("name"); - final JavaJerseyCodegen codegen = new JavaJerseyCodegen(); + final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); codegen.setDateLibrary("joda"); codegen.processOpts(); final CodegenModel cm = codegen.fromModel("sample", model);