diff --git a/.dockerignore b/.dockerignore index a0e39ffd165c..75ea5de6ca2f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -30,7 +30,7 @@ samples/client/petstore/qt5cpp/build-* samples/client/petstore/qt5cpp/PetStore/PetStore samples/client/petstore/qt5cpp/PetStore/Makefile samples/client/petstore/java/hello.txt -samples/client/petstore/android-java/hello.txt +samples/client/petstore/android/default/hello.txt samples/client/petstore/objc/Build samples/client/petstore/objc/Pods samples/server/petstore/nodejs/node_modules diff --git a/.gitignore b/.gitignore index 02ecb7220cdf..2aaad73c13f1 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ samples/client/petstore/qt5cpp/build-* samples/client/petstore/qt5cpp/PetStore/PetStore samples/client/petstore/qt5cpp/PetStore/Makefile samples/client/petstore/java/hello.txt -samples/client/petstore/android-java/hello.txt +samples/client/petstore/android/default/hello.txt samples/client/petstore/objc/SwaggerClientTests/Build samples/client/petstore/objc/SwaggerClientTests/Pods samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcworkspace diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index 7db8c7ec9161..5c171bb4039b 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -19,7 +19,7 @@ fi cd $APP_DIR ./bin/akka-scala-petstore.sh -./bin/android-java-petstore.sh +./bin/android-petstore.sh ./bin/clojure-petstore.sh ./bin/csharp-petstore.sh ./bin/dynamic-html.sh diff --git a/bin/android-petstore-volley.json b/bin/android-petstore-volley.json new file mode 100644 index 000000000000..913ef5c0139a --- /dev/null +++ b/bin/android-petstore-volley.json @@ -0,0 +1,4 @@ +{ + "library": "volley", + "artifactId": "swagger-petstore-android-volley" +} diff --git a/bin/android-volley-petstore.sh b/bin/android-petstore-volley.sh old mode 100644 new mode 100755 similarity index 72% rename from bin/android-volley-petstore.sh rename to bin/android-petstore-volley.sh index ab6ab7d9f084..6bd15b7f5715 --- a/bin/android-volley-petstore.sh +++ b/bin/android-petstore-volley.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t ../modules/swagger-codegen/src/main/resources/android-volley -i ../modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android-volley -o samples/client/petstore/android-volley" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -c bin/android-petstore-volley.json -o samples/client/petstore/android/volley" -java $JAVA_OPTS -jar $executable $ags \ No newline at end of file +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/android-java-petstore.sh b/bin/android-petstore.sh similarity index 85% rename from bin/android-java-petstore.sh rename to bin/android-petstore.sh index 29b43103dab2..72b12f92e55c 100755 --- a/bin/android-java-petstore.sh +++ b/bin/android-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/android-java -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android-java" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/android -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android/default" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/android-java-petstore.bat b/bin/windows/android-petstore.bat similarity index 71% rename from bin/windows/android-java-petstore.bat rename to bin/windows/android-petstore.bat index 73997ee789a8..03ee8a858361 100755 --- a/bin/windows/android-java-petstore.bat +++ b/bin/windows/android-petstore.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -set ags=generate -t modules\swagger-codegen\src\main\resources\android-java -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l android -o samples\client\petstore\android-java +set ags=generate -t modules\swagger-codegen\src\main\resources\android -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l android -o samples\client\petstore\android\default java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java index 636739c6b642..fec2c489b751 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java @@ -27,12 +27,16 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi protected String sourceFolder = projectFolder + "/java"; protected Boolean useAndroidMavenGradlePlugin = true; + // requestPackage and authPackage are used by the "volley" template/library + protected String requestPackage = "io.swagger.client.request"; + protected String authPackage = "io.swagger.client.auth"; + public AndroidClientCodegen() { super(); outputFolder = "generated-code/android"; modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); - embeddedTemplateDir = templateDir = "android-java"; + embeddedTemplateDir = templateDir = "android"; apiPackage = "io.swagger.client.api"; modelPackage = "io.swagger.client.model"; @@ -70,6 +74,12 @@ public AndroidClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); cliOptions.add(new CliOption(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.", BooleanProperty.TYPE).defaultValue(Boolean.TRUE.toString())); + + supportedLibraries.put("", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1"); + supportedLibraries.put("volley", "HTTP client: Volley 1.0.19"); + CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); + library.setEnum(supportedLibraries); + cliOptions.add(library); } @Override @@ -236,22 +246,67 @@ public void processOpts() { additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); } - supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); - additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); + if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) { + this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY)); + } + if (StringUtils.isEmpty(getLibrary())) { + addSupportingFilesForDefault(); + } else if ("volley".equals(getLibrary())) { + addSupportingFilesForVolley(); + } + } + + private void addSupportingFilesForDefault() { + supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); supportingFiles.add(new SupportingFile("apiInvoker.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java")); + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "ApiInvoker.java")); supportingFiles.add(new SupportingFile("httpPatch.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "HttpPatch.java")); + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "HttpPatch.java")); + supportingFiles.add(new SupportingFile("jsonUtil.mustache", + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "JsonUtil.java")); + supportingFiles.add(new SupportingFile("apiException.mustache", + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "ApiException.java")); + supportingFiles.add(new SupportingFile("Pair.mustache", + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "Pair.java")); + } + + private void addSupportingFilesForVolley() { + // supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); + // supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); + supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); + supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); + supportingFiles.add(new SupportingFile("apiInvoker.mustache", + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "ApiInvoker.java")); + supportingFiles.add(new SupportingFile("responses.mustache", + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "Responses.java")); + // supportingFiles.add(new SupportingFile("httpPatch.mustache", + // (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "HttpPatch.java")); supportingFiles.add(new SupportingFile("jsonUtil.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java")); + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "JsonUtil.java")); supportingFiles.add(new SupportingFile("apiException.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java")); + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "ApiException.java")); supportingFiles.add(new SupportingFile("Pair.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Pair.java")); + (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "Pair.java")); + supportingFiles.add(new SupportingFile("request/getrequest.mustache", + (sourceFolder + File.separator + requestPackage).replace(".", File.separator), "GetRequest.java")); + supportingFiles.add(new SupportingFile("request/postrequest.mustache", + (sourceFolder + File.separator + requestPackage).replace(".", File.separator), "PostRequest.java")); + supportingFiles.add(new SupportingFile("request/putrequest.mustache", + (sourceFolder + File.separator + requestPackage).replace(".", File.separator), "PutRequest.java")); + supportingFiles.add(new SupportingFile("request/deleterequest.mustache", + (sourceFolder + File.separator + requestPackage).replace(".", File.separator), "DeleteRequest.java")); + supportingFiles.add(new SupportingFile("request/patchrequest.mustache", + (sourceFolder + File.separator + requestPackage).replace(".", File.separator), "PatchRequest.java")); + supportingFiles.add(new SupportingFile("auth/apikeyauth.mustache", + (sourceFolder + File.separator + authPackage).replace(".", File.separator), "ApiKeyAuth.java")); + supportingFiles.add(new SupportingFile("auth/httpbasicauth.mustache", + (sourceFolder + File.separator + authPackage).replace(".", File.separator), "HttpBasicAuth.java")); + supportingFiles.add(new SupportingFile("auth/authentication.mustache", + (sourceFolder + File.separator + authPackage).replace(".", File.separator), "Authentication.java")); } public Boolean getUseAndroidMavenGradlePlugin() { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidVolleyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidVolleyClientCodegen.java deleted file mode 100644 index 9eeb9618b480..000000000000 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidVolleyClientCodegen.java +++ /dev/null @@ -1,299 +0,0 @@ -package io.swagger.codegen.languages; - -import io.swagger.codegen.CliOption; -import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.CodegenConstants; -import io.swagger.codegen.CodegenType; -import io.swagger.codegen.DefaultCodegen; -import io.swagger.codegen.SupportingFile; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; - -import java.io.File; -import java.util.Arrays; -import java.util.HashSet; - -import org.apache.commons.lang.StringUtils; - -public class AndroidVolleyClientCodegen extends DefaultCodegen implements CodegenConfig { - public static final String USE_ANDROID_MAVEN_GRADLE_PLUGIN = "useAndroidMavenGradlePlugin"; - protected String invokerPackage = "io.swagger.client"; - protected String groupId = "io.swagger"; - protected String artifactId = "swagger-android-volley-client"; - protected String artifactVersion = "1.0.0"; - protected String projectFolder = "src/main"; - protected String sourceFolder = projectFolder + "/java"; - protected Boolean useAndroidMavenGradlePlugin = true; - protected String requestPackage = "io.swagger.client.request"; - protected String authPackage = "io.swagger.client.auth"; - - public AndroidVolleyClientCodegen() { - super(); - outputFolder = "generated-code/android-volley"; - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); - embeddedTemplateDir = templateDir = "android-volley"; - apiPackage = "io.swagger.client.api"; - modelPackage = "io.swagger.client.model"; - - reservedWords = new HashSet( - Arrays.asList( - "abstract", "continue", "for", "new", "switch", "assert", - "default", "if", "package", "synchronized", "boolean", "do", "goto", "private", - "this", "break", "double", "implements", "protected", "throw", "byte", "else", - "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", - "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", - "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", - "native", "super", "while") - ); - - languageSpecificPrimitives = new HashSet( - Arrays.asList( - "String", - "boolean", - "Boolean", - "Double", - "Integer", - "Long", - "Float", - "Object") - ); - instantiationTypes.put("array", "ArrayList"); - instantiationTypes.put("map", "HashMap"); - - cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); - cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); - cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); - cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, "groupId for use in the generated build.gradle and pom.xml")); - cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "artifactId for use in the generated build.gradle and pom.xml")); - cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "artifact version for use in the generated build.gradle and pom.xml")); - cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); - cliOptions.add(new CliOption(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin. Default is true.")); - } - - public CodegenType getTag() { - return CodegenType.CLIENT; - } - - public String getName() { - return "android-volley"; - } - - public String getHelp() { - return "Generates an Android client library."; - } - - @Override - public String escapeReservedWord(String name) { - return "_" + name; - } - - @Override - public String apiFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); - } - - public String modelFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); - } - - @Override - public String getTypeDeclaration(Property p) { - if (p instanceof ArrayProperty) { - ArrayProperty ap = (ArrayProperty) p; - Property inner = ap.getItems(); - return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">"; - } else if (p instanceof MapProperty) { - MapProperty mp = (MapProperty) p; - Property inner = mp.getAdditionalProperties(); - - return getSwaggerType(p) + ""; - } - return super.getTypeDeclaration(p); - } - - @Override - public String getSwaggerType(Property p) { - String swaggerType = super.getSwaggerType(p); - String type = null; - if (typeMapping.containsKey(swaggerType)) { - type = typeMapping.get(swaggerType); - if (languageSpecificPrimitives.contains(type)) { - return toModelName(type); - } - } else { - type = swaggerType; - } - return toModelName(type); - } - - @Override - public String toVarName(String name) { - // replace - with _ e.g. created-at => created_at - name = name.replaceAll("-", "_"); - - // if it's all uppper case, do nothing - if (name.matches("^[A-Z_]*$")) { - return name; - } - - // camelize (lower first character) the variable name - // pet_id => petId - name = camelize(name, true); - - // for reserved word or word starting with number, append _ - if (reservedWords.contains(name) || name.matches("^\\d.*")) { - name = escapeReservedWord(name); - } - - return name; - } - - @Override - public String toParamName(String name) { - // should be the same as variable name - return toVarName(name); - } - - @Override - public String toModelName(String name) { - // model name cannot use reserved keyword, e.g. return - if (reservedWords.contains(name)) { - throw new RuntimeException(name + " (reserved word) cannot be used as a model name"); - } - - // camelize the model name - // phone_number => PhoneNumber - return camelize(name); - } - - @Override - public String toModelFilename(String name) { - // should be the same as the model name - return toModelName(name); - } - - @Override - public String toOperationId(String operationId) { - // throw exception if method name is empty - if (StringUtils.isEmpty(operationId)) { - throw new RuntimeException("Empty method name (operationId) not allowed"); - } - - // method name cannot use reserved keyword, e.g. return - if (reservedWords.contains(operationId)) { - throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); - } - - return camelize(operationId, true); - } - - @Override - public void processOpts() { - super.processOpts(); - - if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { - this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); - } else { - //not set, use default to be passed to template - additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); - } - - if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) { - this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID)); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.GROUP_ID, groupId); - } - - if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_ID)) { - this.setArtifactId((String) additionalProperties.get(CodegenConstants.ARTIFACT_ID)); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); - } - - if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { - this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); - } - - if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { - this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); - } - - if (additionalProperties.containsKey(USE_ANDROID_MAVEN_GRADLE_PLUGIN)) { - this.setUseAndroidMavenGradlePlugin(Boolean.valueOf((String) additionalProperties - .get(USE_ANDROID_MAVEN_GRADLE_PLUGIN))); - } else { - additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); - } - -// supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); - additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); - -// supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); - supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); - supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); - supportingFiles.add(new SupportingFile("apiInvoker.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java")); - supportingFiles.add(new SupportingFile("responses.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Responses.java")); -// supportingFiles.add(new SupportingFile("httpPatch.mustache", -// (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "HttpPatch.java")); - supportingFiles.add(new SupportingFile("jsonUtil.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java")); - supportingFiles.add(new SupportingFile("apiException.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java")); - supportingFiles.add(new SupportingFile("Pair.mustache", - (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Pair.java")); - supportingFiles.add(new SupportingFile("request/getrequest.mustache", - (sourceFolder + File.separator + requestPackage).replace(".", java.io.File.separator), "GetRequest.java")); - supportingFiles.add(new SupportingFile("request/postrequest.mustache", - (sourceFolder + File.separator + requestPackage).replace(".", java.io.File.separator), "PostRequest.java")); - supportingFiles.add(new SupportingFile("request/putrequest.mustache", - (sourceFolder + File.separator + requestPackage).replace(".", java.io.File.separator), "PutRequest.java")); - supportingFiles.add(new SupportingFile("request/deleterequest.mustache", - (sourceFolder + File.separator + requestPackage).replace(".", java.io.File.separator), "DeleteRequest.java")); - supportingFiles.add(new SupportingFile("request/patchrequest.mustache", - (sourceFolder + File.separator + requestPackage).replace(".", java.io.File.separator), "PatchRequest.java")); - supportingFiles.add(new SupportingFile("auth/apikeyauth.mustache", - (sourceFolder + File.separator + authPackage).replace(".", java.io.File.separator), "ApiKeyAuth.java")); - supportingFiles.add(new SupportingFile("auth/httpbasicauth.mustache", - (sourceFolder + File.separator + authPackage).replace(".", java.io.File.separator), "HttpBasicAuth.java")); - supportingFiles.add(new SupportingFile("auth/authentication.mustache", - (sourceFolder + File.separator + authPackage).replace(".", java.io.File.separator), "Authentication.java")); - } - - public Boolean getUseAndroidMavenGradlePlugin() { - return useAndroidMavenGradlePlugin; - } - - public void setUseAndroidMavenGradlePlugin(Boolean useAndroidMavenGradlePlugin) { - this.useAndroidMavenGradlePlugin = useAndroidMavenGradlePlugin; - } - - public void setInvokerPackage(String invokerPackage) { - this.invokerPackage = invokerPackage; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public void setSourceFolder(String sourceFolder) { - this.sourceFolder = sourceFolder; - } - -} 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 13cf4d7112db..5d8a4f0fc6bf 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 @@ -1,5 +1,4 @@ io.swagger.codegen.languages.AndroidClientCodegen -io.swagger.codegen.languages.AndroidVolleyClientCodegen io.swagger.codegen.languages.AsyncScalaClientCodegen io.swagger.codegen.languages.CSharpClientCodegen io.swagger.codegen.languages.DartClientCodegen diff --git a/modules/swagger-codegen/src/main/resources/android-java/Pair.mustache b/modules/swagger-codegen/src/main/resources/android/Pair.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/Pair.mustache rename to modules/swagger-codegen/src/main/resources/android/Pair.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/api.mustache b/modules/swagger-codegen/src/main/resources/android/api.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/api.mustache rename to modules/swagger-codegen/src/main/resources/android/api.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/apiException.mustache b/modules/swagger-codegen/src/main/resources/android/apiException.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/apiException.mustache rename to modules/swagger-codegen/src/main/resources/android/apiException.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/apiInvoker.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache rename to modules/swagger-codegen/src/main/resources/android/apiInvoker.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/build.mustache b/modules/swagger-codegen/src/main/resources/android/build.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/build.mustache rename to modules/swagger-codegen/src/main/resources/android/build.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/httpPatch.mustache b/modules/swagger-codegen/src/main/resources/android/httpPatch.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/httpPatch.mustache rename to modules/swagger-codegen/src/main/resources/android/httpPatch.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/jsonUtil.mustache b/modules/swagger-codegen/src/main/resources/android/jsonUtil.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/jsonUtil.mustache rename to modules/swagger-codegen/src/main/resources/android/jsonUtil.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/Pair.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/Pair.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/Pair.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/Pair.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/api.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/api.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/apiException.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/apiException.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/apiInvoker.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/auth/apikeyauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/auth/apikeyauth.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/auth/authentication.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/authentication.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/auth/authentication.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/authentication.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/auth/httpbasicauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/httpbasicauth.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/auth/httpbasicauth.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/httpbasicauth.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/build.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/build.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/jsonUtil.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/jsonUtil.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/jsonUtil.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/jsonUtil.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/manifest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/manifest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/manifest.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/manifest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/model.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/model.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/model.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/model.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/request/deleterequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/request/deleterequest.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/request/getrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/getrequest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/request/getrequest.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/request/getrequest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/request/patchrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/request/patchrequest.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/request/postrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/request/postrequest.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/request/putrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/request/putrequest.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/responses.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/responses.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/responses.mustache rename to modules/swagger-codegen/src/main/resources/android/libraries/volley/responses.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/manifest.mustache b/modules/swagger-codegen/src/main/resources/android/manifest.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/manifest.mustache rename to modules/swagger-codegen/src/main/resources/android/manifest.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-volley/model.mustache b/modules/swagger-codegen/src/main/resources/android/model.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-volley/model.mustache rename to modules/swagger-codegen/src/main/resources/android/model.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/pom.mustache b/modules/swagger-codegen/src/main/resources/android/pom.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/pom.mustache rename to modules/swagger-codegen/src/main/resources/android/pom.mustache diff --git a/modules/swagger-codegen/src/main/resources/android-java/settings.gradle.mustache b/modules/swagger-codegen/src/main/resources/android/settings.gradle.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/android-java/settings.gradle.mustache rename to modules/swagger-codegen/src/main/resources/android/settings.gradle.mustache diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java index c36c5453d983..26d55d7e9b2f 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java @@ -43,6 +43,8 @@ protected void setExpectations() { times = 1; clientCodegen.setUseAndroidMavenGradlePlugin(Boolean.valueOf(AndroidClientOptionsProvider.ANDROID_MAVEN_GRADLE_PLUGIN_VALUE)); times = 1; + clientCodegen.setLibrary(AndroidClientOptionsProvider.LIBRARY_VALUE); + times = 1; }}; } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/androidvolley/AndroidVolleyClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/androidvolley/AndroidVolleyClientOptionsTest.java deleted file mode 100644 index 58711d9a3f81..000000000000 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/androidvolley/AndroidVolleyClientOptionsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.swagger.codegen.androidvolley; - -import io.swagger.codegen.AbstractOptionsTest; -import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.languages.AndroidVolleyClientCodegen; -import io.swagger.codegen.options.AndroidClientOptionsProvider; -import io.swagger.codegen.options.AndroidVolleyClientOptionsProvider; -import mockit.Expectations; -import mockit.Tested; - -public class AndroidVolleyClientOptionsTest extends AbstractOptionsTest { - - @Tested - private AndroidVolleyClientCodegen clientCodegen; - - public AndroidVolleyClientOptionsTest() { - super(new AndroidVolleyClientOptionsProvider()); - } - - @Override - protected CodegenConfig getCodegenConfig() { - return clientCodegen; - } - - @Override - protected void setExpectations() { - new Expectations(clientCodegen) {{ - clientCodegen.setModelPackage(AndroidVolleyClientOptionsProvider.MODEL_PACKAGE_VALUE); - times = 1; - clientCodegen.setApiPackage(AndroidVolleyClientOptionsProvider.API_PACKAGE_VALUE); - times = 1; - clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(AndroidVolleyClientOptionsProvider.SORT_PARAMS_VALUE)); - times = 1; - clientCodegen.setInvokerPackage(AndroidVolleyClientOptionsProvider.INVOKER_PACKAGE_VALUE); - times = 1; - clientCodegen.setGroupId(AndroidVolleyClientOptionsProvider.GROUP_ID_VALUE); - times = 1; - clientCodegen.setArtifactId(AndroidVolleyClientOptionsProvider.ARTIFACT_ID_VALUE); - times = 1; - clientCodegen.setArtifactVersion(AndroidVolleyClientOptionsProvider.ARTIFACT_VERSION_VALUE); - times = 1; - clientCodegen.setSourceFolder(AndroidVolleyClientOptionsProvider.SOURCE_FOLDER_VALUE); - times = 1; - clientCodegen.setUseAndroidMavenGradlePlugin(Boolean.valueOf(AndroidVolleyClientOptionsProvider.ANDROID_MAVEN_GRADLE_PLUGIN_VALUE)); - times = 1; - }}; - } -} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java index c677e5caa7b8..82bb13029e51 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java @@ -18,6 +18,7 @@ public class AndroidClientOptionsProvider implements OptionsProvider { public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT"; public static final String SOURCE_FOLDER_VALUE = "src/main/java/test"; public static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true"; + public static final String LIBRARY_VALUE = "volley"; @Override public String getLanguage() { @@ -37,6 +38,7 @@ public Map createOptions() { .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE) .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE) .put(AndroidClientCodegen.USE_ANDROID_MAVEN_GRADLE_PLUGIN, ANDROID_MAVEN_GRADLE_PLUGIN_VALUE) + .put(CodegenConstants.LIBRARY, LIBRARY_VALUE) .build(); } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidVolleyClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidVolleyClientOptionsProvider.java deleted file mode 100644 index e67948935cc2..000000000000 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidVolleyClientOptionsProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.swagger.codegen.options; - -import io.swagger.codegen.CodegenConstants; -import io.swagger.codegen.languages.AndroidVolleyClientCodegen; - -import com.google.common.collect.ImmutableMap; - -import java.util.Map; - -public class AndroidVolleyClientOptionsProvider implements OptionsProvider { - public static final String ARTIFACT_ID_VALUE = "swagger-java-client-test"; - public static final String MODEL_PACKAGE_VALUE = "package"; - public static final String API_PACKAGE_VALUE = "apiPackage"; - public static final String INVOKER_PACKAGE_VALUE = "io.swagger.client.test"; - public static final String SORT_PARAMS_VALUE = "false"; - public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; - public static final String GROUP_ID_VALUE = "io.swagger.test"; - public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT"; - public static final String SOURCE_FOLDER_VALUE = "src/main/java/test"; - public static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true"; - - @Override - public String getLanguage() { - return "android-volley"; - } - - @Override - public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE) - .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE) - .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) - .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) - .put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE) - .put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE) - .put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE) - .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE) - .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE) - .put(AndroidVolleyClientCodegen.USE_ANDROID_MAVEN_GRADLE_PLUGIN, ANDROID_MAVEN_GRADLE_PLUGIN_VALUE) - .build(); - } - - @Override - public boolean isServer() { - return false; - } -} diff --git a/pom.xml b/pom.xml index ab883eb16f0b..77586cc1990a 100644 --- a/pom.xml +++ b/pom.xml @@ -278,7 +278,7 @@ - samples/client/petstore/android-java + samples/client/petstore/android/default @@ -446,7 +446,7 @@ - samples/client/petstore/android-java + samples/client/petstore/android/default samples/client/petstore/clojure samples/client/petstore/java/default samples/client/petstore/java/jersey2 diff --git a/samples/client/petstore/android-java/src/main/java/AndroidManifest.xml b/samples/client/petstore/android-java/src/main/java/AndroidManifest.xml deleted file mode 100644 index 1850229fc177..000000000000 --- a/samples/client/petstore/android-java/src/main/java/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/samples/client/petstore/android-java/build.gradle b/samples/client/petstore/android/default/build.gradle similarity index 100% rename from samples/client/petstore/android-java/build.gradle rename to samples/client/petstore/android/default/build.gradle diff --git a/samples/client/petstore/android/default/hello.txt b/samples/client/petstore/android/default/hello.txt new file mode 100644 index 000000000000..6769dd60bdf5 --- /dev/null +++ b/samples/client/petstore/android/default/hello.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/samples/client/petstore/android-java/pom.xml b/samples/client/petstore/android/default/pom.xml similarity index 100% rename from samples/client/petstore/android-java/pom.xml rename to samples/client/petstore/android/default/pom.xml diff --git a/samples/client/petstore/android-java/settings.gradle b/samples/client/petstore/android/default/settings.gradle similarity index 100% rename from samples/client/petstore/android-java/settings.gradle rename to samples/client/petstore/android/default/settings.gradle diff --git a/samples/client/petstore/android-java/src/main/AndroidManifest.xml b/samples/client/petstore/android/default/src/main/AndroidManifest.xml similarity index 100% rename from samples/client/petstore/android-java/src/main/AndroidManifest.xml rename to samples/client/petstore/android/default/src/main/AndroidManifest.xml diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiException.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiException.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiException.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiInvoker.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiInvoker.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/HttpPatch.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/HttpPatch.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/HttpPatch.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/HttpPatch.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/Pair.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/Pair.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/Pair.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Category.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Category.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Order.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Order.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Pet.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Pet.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Tag.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Tag.java diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/User.java similarity index 100% rename from samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java rename to samples/client/petstore/android/default/src/main/java/io/swagger/client/model/User.java diff --git a/samples/client/petstore/android-java/src/test/java/io/swagger/client/ApiInvokerTest.java b/samples/client/petstore/android/default/src/test/java/io/swagger/client/ApiInvokerTest.java similarity index 100% rename from samples/client/petstore/android-java/src/test/java/io/swagger/client/ApiInvokerTest.java rename to samples/client/petstore/android/default/src/test/java/io/swagger/client/ApiInvokerTest.java diff --git a/samples/client/petstore/android-java/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/android/default/src/test/java/io/swagger/petstore/test/PetApiTest.java similarity index 100% rename from samples/client/petstore/android-java/src/test/java/io/swagger/petstore/test/PetApiTest.java rename to samples/client/petstore/android/default/src/test/java/io/swagger/petstore/test/PetApiTest.java diff --git a/samples/client/petstore/android-java/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/android/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java similarity index 100% rename from samples/client/petstore/android-java/src/test/java/io/swagger/petstore/test/StoreApiTest.java rename to samples/client/petstore/android/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java diff --git a/samples/client/petstore/android-java/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/android/default/src/test/java/io/swagger/petstore/test/UserApiTest.java similarity index 100% rename from samples/client/petstore/android-java/src/test/java/io/swagger/petstore/test/UserApiTest.java rename to samples/client/petstore/android/default/src/test/java/io/swagger/petstore/test/UserApiTest.java diff --git a/samples/client/petstore/android-volley/build.gradle b/samples/client/petstore/android/volley/build.gradle similarity index 92% rename from samples/client/petstore/android-volley/build.gradle rename to samples/client/petstore/android/volley/build.gradle index 13edc8fdab2a..581f89479ac0 100644 --- a/samples/client/petstore/android-volley/build.gradle +++ b/samples/client/petstore/android/volley/build.gradle @@ -1,8 +1,6 @@ - group = 'io.swagger' project.version = '1.0.0' - buildscript { repositories { jcenter() @@ -23,16 +21,14 @@ allprojects { apply plugin: 'com.android.library' - apply plugin: 'com.github.dcendents.android-maven' - android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 22 + buildToolsVersion '22.0.0' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 22 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 @@ -57,7 +53,6 @@ ext { gson_version = "2.3.1" httpclient_version = "4.3.3" junit_version = "4.8.1" - volley_version = "1.0.19" } dependencies { @@ -65,7 +60,6 @@ dependencies { compile "com.google.code.gson:gson:$gson_version" compile "org.apache.httpcomponents:httpcore:$httpclient_version" compile "org.apache.httpcomponents:httpmime:$httpclient_version" - compile "com.mcxiaoke.volley:library:${volley_version}@aar" testCompile "junit:junit:$junit_version" } @@ -81,7 +75,6 @@ afterEvaluate { } } - task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' @@ -90,4 +83,3 @@ task sourcesJar(type: Jar) { artifacts { archives sourcesJar } - diff --git a/samples/client/petstore/android-volley/src/main/AndroidManifest.xml b/samples/client/petstore/android/volley/src/main/AndroidManifest.xml similarity index 100% rename from samples/client/petstore/android-volley/src/main/AndroidManifest.xml rename to samples/client/petstore/android/volley/src/main/AndroidManifest.xml diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiException.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/ApiException.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiException.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/ApiInvoker.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/JsonUtil.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/JsonUtil.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/JsonUtil.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Pair.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/Pair.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/Pair.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/Responses.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Responses.java similarity index 84% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/Responses.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/Responses.java index c0de417b616a..bc17fec1e853 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/Responses.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Responses.java @@ -50,4 +50,11 @@ public static interface OrderListResponse { } + public static interface StringResponse { + public void onResponse(String response); + } + + public static interface StringListResponse { + public void onResponse(List stringList); + } } \ No newline at end of file diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java similarity index 97% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/PetApi.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java index 927c96c15b0e..248704b21c13 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java @@ -15,7 +15,6 @@ import io.swagger.client.model.Pet; import java.io.File; - import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -23,7 +22,6 @@ import java.util.HashMap; import java.io.File; - public class PetApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -51,7 +49,7 @@ public String getBasePath() { * @param body Pet object that needs to be added to the store * @return void */ - public void updatePet (Pet body, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void updatePet (Pet body, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = body; @@ -117,7 +115,7 @@ public void onErrorResponse(VolleyError error) { * @param body Pet object that needs to be added to the store * @return void */ - public void addPet (Pet body, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void addPet (Pet body, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = body; @@ -408,7 +406,7 @@ public void onErrorResponse(VolleyError error) { * @param status Updated status of the pet * @return void */ - public void updatePetWithForm (String petId, String name, String status, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void updatePetWithForm (String petId, String name, String status, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = null; @@ -491,7 +489,7 @@ public void onErrorResponse(VolleyError error) { * @param apiKey * @return void */ - public void deletePet (Long petId, String apiKey, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void deletePet (Long petId, String apiKey, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = null; @@ -567,7 +565,7 @@ public void onErrorResponse(VolleyError error) { * @param file file to upload * @return void */ - public void uploadFile (Long petId, String additionalMetadata, File file, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void uploadFile (Long petId, String additionalMetadata, File file, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = null; @@ -644,4 +642,3 @@ public void onErrorResponse(VolleyError error) { } } - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java similarity index 98% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/StoreApi.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java index 5a74a4ddad3f..09ea8be7b3a8 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java @@ -15,7 +15,6 @@ import java.util.Map; import io.swagger.client.model.Order; - import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -23,7 +22,6 @@ import java.util.HashMap; import java.io.File; - public class StoreApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -269,7 +267,7 @@ public void onErrorResponse(VolleyError error) { * @param orderId ID of the order that needs to be deleted * @return void */ - public void deleteOrder (String orderId, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void deleteOrder (String orderId, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = null; @@ -336,4 +334,3 @@ public void onErrorResponse(VolleyError error) { } } - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java similarity index 96% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/UserApi.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java index 14351e3fd0ca..5730a282ad99 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java @@ -15,7 +15,6 @@ import io.swagger.client.model.User; import java.util.*; - import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -23,7 +22,6 @@ import java.util.HashMap; import java.io.File; - public class UserApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -51,7 +49,7 @@ public String getBasePath() { * @param body Created user object * @return void */ - public void createUser (User body, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void createUser (User body, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = body; @@ -117,7 +115,7 @@ public void onErrorResponse(VolleyError error) { * @param body List of user object * @return void */ - public void createUsersWithArrayInput (List body, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void createUsersWithArrayInput (List body, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = body; @@ -183,7 +181,7 @@ public void onErrorResponse(VolleyError error) { * @param body List of user object * @return void */ - public void createUsersWithListInput (List body, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void createUsersWithListInput (List body, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = body; @@ -324,7 +322,7 @@ public void onErrorResponse(VolleyError error) { * * @return void */ - public void logoutUser (final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void logoutUser (final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = null; @@ -468,7 +466,7 @@ public void onErrorResponse(VolleyError error) { * @param body Updated user object * @return void */ - public void updateUser (String username, User body, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void updateUser (String username, User body, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = body; @@ -540,7 +538,7 @@ public void onErrorResponse(VolleyError error) { * @param username The name that needs to be deleted * @return void */ - public void deleteUser (String username, final Response.Listener responseListener, final Response.ErrorListener errorListener) { + public void deleteUser (String username, final Responses.StringResponse responseListener, final Response.ErrorListener errorListener) { Object postBody = null; @@ -607,4 +605,3 @@ public void onErrorResponse(VolleyError error) { } } - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/Authentication.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/auth/Authentication.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/Authentication.java diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java new file mode 100644 index 000000000000..c203adfbd2e3 --- /dev/null +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -0,0 +1,35 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import android.util.Base64; + +import java.util.Map; +import java.util.List; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes(), Base64.DEFAULT)); + } +} diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Category.java similarity index 99% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Category.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Category.java index 98e5c25c80f9..44c71e8a6208 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Category.java @@ -1,12 +1,10 @@ package io.swagger.client.model; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Category { @@ -50,5 +48,3 @@ public String toString() { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Order.java similarity index 99% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Order.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Order.java index 4ef664deba2d..f3f42db615c5 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Order.java @@ -2,12 +2,10 @@ import java.util.Date; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Order { @@ -111,5 +109,3 @@ public String toString() { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Pet.java similarity index 99% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Pet.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Pet.java index cf7eb877b2ab..20865ad54340 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Pet.java @@ -1,15 +1,13 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; - +import java.util.*; import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Pet { @@ -113,5 +111,3 @@ public String toString() { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Tag.java similarity index 99% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Tag.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Tag.java index e87a002a1447..7c9651b1ba8e 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Tag.java @@ -1,12 +1,10 @@ package io.swagger.client.model; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Tag { @@ -50,5 +48,3 @@ public String toString() { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/User.java similarity index 99% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/User.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/User.java index fabdab0b4e37..dc022697eb0f 100644 --- a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/User.java @@ -1,12 +1,10 @@ package io.swagger.client.model; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class User { @@ -135,5 +133,3 @@ public String toString() { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/DeleteRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/DeleteRequest.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/GetRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/GetRequest.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/GetRequest.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/GetRequest.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/PatchRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/PatchRequest.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/PostRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/PostRequest.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java diff --git a/samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/PutRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java similarity index 100% rename from samples/client/petstore/android-volley/src/main/java/io/swagger/client/request/PutRequest.java rename to samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java