From 20ced771ba745232aad3349e7ddaf7f6ea6978a3 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Thu, 7 May 2015 01:09:25 -0700 Subject: [PATCH] Restoring the pom.xml so integration tests work --- .../languages/AndroidClientCodegen.java | 1 + .../resources/android-java/jsonUtil.mustache | 34 ++-- .../main/resources/android-java/pom.mustache | 155 ++++++++++++++++++ samples/client/petstore/android-java/pom.xml | 155 ++++++++++++++++++ .../main/java/io/swagger/client/JsonUtil.java | 98 +++++------ 5 files changed, 367 insertions(+), 76 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/android-java/pom.mustache create mode 100644 samples/client/petstore/android-java/pom.xml diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AndroidClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AndroidClientCodegen.java index df9e289297..3da9c6344a 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AndroidClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AndroidClientCodegen.java @@ -51,6 +51,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi additionalProperties.put("artifactId", artifactId); additionalProperties.put("artifactVersion", artifactVersion); + supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); supportingFiles.add(new SupportingFile("apiInvoker.mustache", diff --git a/modules/swagger-codegen/src/main/resources/android-java/jsonUtil.mustache b/modules/swagger-codegen/src/main/resources/android-java/jsonUtil.mustache index 0680f35c94..3a6ff4111d 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/jsonUtil.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/jsonUtil.mustache @@ -33,33 +33,23 @@ public class JsonUtil { } public static Type getListTypeForDeserialization(Class cls) { - Type type = null; - switch (cls.getSimpleName()) { - {{#models}}{{#model}} - case "{{classname}}": - type = new TypeToken>(){}.getType(); - break; - {{/model}}{{/models}} - default: - type = new TypeToken>(){}.getType(); - break; + String className = cls.getSimpleName(); + {{#models}}{{#model}} + if ("{{classname}}".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } - return type; + {{/model}}{{/models}} + return new TypeToken>(){}.getType(); } public static Type getTypeForDeserialization(Class cls) { - Type type = null; - switch (cls.getSimpleName()) { - {{#models}}{{#model}} - case "{{classname}}": - type = new TypeToken<{{classname}}>(){}.getType(); - break; - {{/model}}{{/models}} - default: - type = new TypeToken(){}.getType(); - break; + String className = cls.getSimpleName(); + {{#models}}{{#model}} + if ("{{classname}}".equalsIgnoreCase(className)) { + return new TypeToken<{{classname}}>(){}.getType(); } - return type; + {{/model}}{{/models}} + return new TypeToken(){}.getType(); } }; diff --git a/modules/swagger-codegen/src/main/resources/android-java/pom.mustache b/modules/swagger-codegen/src/main/resources/android-java/pom.mustache new file mode 100644 index 0000000000..807df48234 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/android-java/pom.mustache @@ -0,0 +1,155 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + + scm:git:git@github.com:wordnik/swagger-mustache.git + scm:git:git@github.com:wordnik/swagger-codegen.git + https://github.com/wordnik/swagger-codegen + + + 2.2.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + com.wordnik + swagger-annotations + ${swagger-annotations-version} + + + com.google.code.gson + gson + ${gson-version} + + + org.apache.httpcomponents + httpclient + ${httpclient-version} + compile + + + org.apache.httpcomponents + httpmime + ${httpclient-version} + compile + + + + + junit + junit + ${junit-version} + test + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + + 1.5.1-M1 + 2.3.1 + 4.8.1 + 1.0.0 + 4.8.1 + 4.3.6 + + \ No newline at end of file diff --git a/samples/client/petstore/android-java/pom.xml b/samples/client/petstore/android-java/pom.xml new file mode 100644 index 0000000000..fd961c04d0 --- /dev/null +++ b/samples/client/petstore/android-java/pom.xml @@ -0,0 +1,155 @@ + + 4.0.0 + io.swagger + swagger-android-client + jar + swagger-android-client + 1.0.0 + + scm:git:git@github.com:wordnik/swagger-mustache.git + scm:git:git@github.com:wordnik/swagger-codegen.git + https://github.com/wordnik/swagger-codegen + + + 2.2.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + com.wordnik + swagger-annotations + ${swagger-annotations-version} + + + com.google.code.gson + gson + ${gson-version} + + + org.apache.httpcomponents + httpclient + ${httpclient-version} + compile + + + org.apache.httpcomponents + httpmime + ${httpclient-version} + compile + + + + + junit + junit + ${junit-version} + test + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + + 1.5.1-M1 + 2.3.1 + 4.8.1 + 1.0.0 + 4.8.1 + 4.3.6 + + \ No newline at end of file diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java index 962fae63cb..5aa10d3ea8 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java @@ -33,65 +33,55 @@ public class JsonUtil { } public static Type getListTypeForDeserialization(Class cls) { - Type type = null; - switch (cls.getSimpleName()) { - - case "User": - type = new TypeToken>(){}.getType(); - break; - - case "Category": - type = new TypeToken>(){}.getType(); - break; - - case "Pet": - type = new TypeToken>(){}.getType(); - break; - - case "Tag": - type = new TypeToken>(){}.getType(); - break; - - case "Order": - type = new TypeToken>(){}.getType(); - break; - - default: - type = new TypeToken>(){}.getType(); - break; + String className = cls.getSimpleName(); + + if ("User".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } - return type; + + if ("Category".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("Pet".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("Tag".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + return new TypeToken>(){}.getType(); } public static Type getTypeForDeserialization(Class cls) { - Type type = null; - switch (cls.getSimpleName()) { - - case "User": - type = new TypeToken(){}.getType(); - break; - - case "Category": - type = new TypeToken(){}.getType(); - break; - - case "Pet": - type = new TypeToken(){}.getType(); - break; - - case "Tag": - type = new TypeToken(){}.getType(); - break; - - case "Order": - type = new TypeToken(){}.getType(); - break; - - default: - type = new TypeToken(){}.getType(); - break; + String className = cls.getSimpleName(); + + if ("User".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); } - return type; + + if ("Category".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Pet".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Tag".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + return new TypeToken(){}.getType(); } };