From edf2642e739f75debcc40bf454c8ee9513215f80 Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 8 Oct 2015 21:18:11 +0800 Subject: [PATCH 1/9] Support model name like "List" in Java clients Support generating model files with name like "List", "Map" and "Date" by using full qualified names when using them from the java.util package. --- .../io/swagger/codegen/DefaultCodegen.java | 31 ++++++++---------- .../codegen/languages/JavaClientCodegen.java | 32 +++++++++++-------- .../src/main/resources/Java/api.mustache | 14 ++------ .../Java/libraries/jersey2/api.mustache | 12 ++----- .../Java/libraries/okhttp-gson/api.mustache | 12 ++----- .../Java/libraries/retrofit/api.mustache | 11 +++---- 6 files changed, 46 insertions(+), 66 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index efc0aa31dbc8..55868c0acaff 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -311,15 +311,14 @@ public class DefaultCodegen { ); typeMapping = new HashMap(); - typeMapping.put("array", "List"); - typeMapping.put("map", "Map"); - typeMapping.put("List", "List"); + typeMapping.put("array", "java.util.List"); + typeMapping.put("map", "java.util.Map"); typeMapping.put("boolean", "Boolean"); typeMapping.put("string", "String"); typeMapping.put("int", "Integer"); typeMapping.put("float", "Float"); typeMapping.put("number", "BigDecimal"); - typeMapping.put("DateTime", "Date"); + typeMapping.put("DateTime", "java.util.Date"); typeMapping.put("long", "Long"); typeMapping.put("short", "Short"); typeMapping.put("char", "String"); @@ -337,15 +336,7 @@ public class DefaultCodegen { importMapping.put("BigDecimal", "java.math.BigDecimal"); importMapping.put("UUID", "java.util.UUID"); importMapping.put("File", "java.io.File"); - importMapping.put("Date", "java.util.Date"); importMapping.put("Timestamp", "java.sql.Timestamp"); - importMapping.put("Map", "java.util.Map"); - importMapping.put("HashMap", "java.util.HashMap"); - importMapping.put("Array", "java.util.List"); - importMapping.put("ArrayList", "java.util.ArrayList"); - importMapping.put("List", "java.util.*"); - importMapping.put("Set", "java.util.*"); - importMapping.put("DateTime", "org.joda.time.*"); importMapping.put("LocalDateTime", "org.joda.time.*"); importMapping.put("LocalDate", "org.joda.time.*"); importMapping.put("LocalTime", "org.joda.time.*"); @@ -1038,7 +1029,7 @@ public class DefaultCodegen { } } for (String i : imports) { - if (!defaultIncludes.contains(i) && !languageSpecificPrimitives.contains(i)) { + if (needToImport(i)) { op.imports.add(i); } } @@ -1311,6 +1302,12 @@ public class DefaultCodegen { return secs; } + protected boolean needToImport(String type) { + return !defaultIncludes.contains(type) + && !languageSpecificPrimitives.contains(type) + && type.indexOf(".") < 0; + } + protected List> toExamples(Map examples) { if (examples == null) { return null; @@ -1414,7 +1411,7 @@ public class DefaultCodegen { } private void addImport(CodegenModel m, String type) { - if (type != null && !languageSpecificPrimitives.contains(type) && !defaultIncludes.contains(type)) { + if (type != null && needToImport(type)) { m.imports.add(type); } } @@ -1593,8 +1590,8 @@ public class DefaultCodegen { * @return sanitized string */ public String sanitizeName(String name) { - // NOTE: performance wise, we should have written with 2 replaceAll to replace desired - // character with _ or empty character. Below aims to spell out different cases we've + // NOTE: performance wise, we should have written with 2 replaceAll to replace desired + // character with _ or empty character. Below aims to spell out different cases we've // encountered so far and hopefully make it easier for others to add more special // cases in the future. @@ -1617,7 +1614,7 @@ public class DefaultCodegen { // input name and age => input_name_and_age name = name.replaceAll(" ", "_"); - + // remove everything else other than word, number and _ // $php_variable => php_variable return name.replaceAll("[^a-zA-Z0-9_]", ""); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 360dc9c0f2f0..1276c2dde6c5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -71,8 +71,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { "Object", "byte[]") ); - instantiationTypes.put("array", "ArrayList"); - instantiationTypes.put("map", "HashMap"); + instantiationTypes.put("array", "java.util.ArrayList"); + instantiationTypes.put("map", "java.util.HashMap"); cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); @@ -107,7 +107,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public void processOpts() { super.processOpts(); - + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } else { @@ -158,7 +158,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); - + final String authFolder = (sourceFolder + File.separator + invokerPackage + ".auth").replace(".", File.separator); supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java")); supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java")); @@ -172,7 +172,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java")); supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java")); } - + // library-specific files if ("okhttp-gson".equals(getLibrary())) { // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call @@ -189,25 +189,25 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } private void sanitizeConfig() { - // Sanitize any config options here. We also have to update the additionalProperties because + // Sanitize any config options here. We also have to update the additionalProperties because // the whole additionalProperties object is injected into the main object passed to the mustache layer - + this.setApiPackage(sanitizePackageName(apiPackage)); if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { this.additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); } - + this.setModelPackage(sanitizePackageName(modelPackage)); if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { this.additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); } - + this.setInvokerPackage(sanitizePackageName(invokerPackage)); if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } } - + @Override public String escapeReservedWord(String name) { return "_" + name; @@ -294,10 +294,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public String toDefaultValue(Property p) { if (p instanceof ArrayProperty) { final ArrayProperty ap = (ArrayProperty) p; - return String.format("new ArrayList<%s>()", getTypeDeclaration(ap.getItems())); + return String.format("new java.util.ArrayList<%s>()", getTypeDeclaration(ap.getItems())); } else if (p instanceof MapProperty) { final MapProperty ap = (MapProperty) p; - return String.format("new HashMap()", getTypeDeclaration(ap.getAdditionalProperties())); + return String.format("new java.util.HashMap()", getTypeDeclaration(ap.getAdditionalProperties())); } return super.toDefaultValue(p); } @@ -308,7 +308,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { String type = null; if (typeMapping.containsKey(swaggerType)) { type = typeMapping.get(swaggerType); - if (languageSpecificPrimitives.contains(type)) { + if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0) { return type; } } else { @@ -394,7 +394,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } return objs; } - + public Map postProcessOperations(Map objs) { if("retrofit".equals(getLibrary())) { Map operations = (Map) objs.get("operations"); @@ -418,6 +418,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return objs; } + protected boolean needToImport(String type) { + return super.needToImport(type) && type.indexOf(".") < 0; + } + private String findCommonPrefixOfVars(List vars) { String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()])); // exclude trailing characters that should be part of a valid variable diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index ad957261f2a4..38ebc1c54abd 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -6,17 +6,9 @@ import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; import {{invokerPackage}}.TypeRef; -import {{modelPackage}}.*; - -import java.util.*; - {{#imports}}import {{import}}; {{/imports}} -import java.io.File; -import java.util.Map; -import java.util.HashMap; - {{>generatedAnnotation}} {{#operations}} public class {{classname}} { @@ -59,9 +51,9 @@ public class {{classname}} { .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; // query params - List {{localVariablePrefix}}queryParams = new ArrayList(); - Map {{localVariablePrefix}}headerParams = new HashMap(); - Map {{localVariablePrefix}}formParams = new HashMap(); + java.util.List {{localVariablePrefix}}queryParams = new java.util.ArrayList(); + java.util.Map {{localVariablePrefix}}headerParams = new java.util.HashMap(); + java.util.Map {{localVariablePrefix}}formParams = new java.util.HashMap(); {{#queryParams}} {{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache index d525db8a28d0..532f1ef78cf1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache @@ -8,15 +8,9 @@ import {{invokerPackage}}.TypeRef; import {{modelPackage}}.*; -import java.util.*; - {{#imports}}import {{import}}; {{/imports}} -import java.io.File; -import java.util.Map; -import java.util.HashMap; - {{>generatedAnnotation}} {{#operations}} public class {{classname}} { @@ -58,9 +52,9 @@ public class {{classname}} { .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; // query params - List {{localVariablePrefix}}queryParams = new ArrayList(); - Map {{localVariablePrefix}}headerParams = new HashMap(); - Map {{localVariablePrefix}}formParams = new HashMap(); + java.util.List {{localVariablePrefix}}queryParams = new java.util.ArrayList(); + java.util.Map {{localVariablePrefix}}headerParams = new java.util.HashMap(); + java.util.Map {{localVariablePrefix}}formParams = new java.util.HashMap(); {{#queryParams}} {{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache index b272687c7fde..d1f38f0ac358 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -14,15 +14,9 @@ import com.squareup.okhttp.Call; import java.lang.reflect.Type; -import java.util.*; - {{#imports}}import {{import}}; {{/imports}} -import java.io.File; -import java.util.Map; -import java.util.HashMap; - {{#operations}} public class {{classname}} { private ApiClient {{localVariablePrefix}}apiClient; @@ -58,15 +52,15 @@ public class {{classname}} { String {{localVariablePrefix}}path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; - List {{localVariablePrefix}}queryParams = new ArrayList();{{#queryParams}} + java.util.List {{localVariablePrefix}}queryParams = new java.util.ArrayList();{{#queryParams}} if ({{paramName}} != null) {{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));{{/queryParams}} - Map {{localVariablePrefix}}headerParams = new HashMap();{{#headerParams}} + java.util.Map {{localVariablePrefix}}headerParams = new java.util.HashMap();{{#headerParams}} if ({{paramName}} != null) {{localVariablePrefix}}headerParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));{{/headerParams}} - Map {{localVariablePrefix}}formParams = new HashMap();{{#formParams}} + java.util.Map {{localVariablePrefix}}formParams = new java.util.HashMap();{{#formParams}} if ({{paramName}} != null) {{localVariablePrefix}}formParams.put("{{baseName}}", {{paramName}});{{/formParams}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache index 89850d92bdc1..28d2d29f8d1a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache @@ -5,7 +5,6 @@ import {{modelPackage}}.*; import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; -import java.util.*; {{#imports}}import {{import}}; {{/imports}} @@ -22,7 +21,7 @@ public interface {{classname}} { */ {{#formParams}}{{#-first}} {{#isMultipart}}@Multipart{{/isMultipart}}{{^isMultipart}}@FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}} - @{{httpMethod}}("{{path}}") + @{{httpMethod}}("{{path}}") {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}} {{nickname}}({{^allParams}});{{/allParams}} {{#allParams}}{{>libraries/retrofit/queryParams}}{{>libraries/retrofit/pathParams}}{{>libraries/retrofit/headerParams}}{{>libraries/retrofit/bodyParams}}{{>libraries/retrofit/formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}} );{{/hasMore}}{{/allParams}} @@ -31,15 +30,15 @@ public interface {{classname}} { * {{summary}} * Async method {{#allParams}} * @param {{paramName}} {{description}} -{{/allParams}} * @param cb callback method +{{/allParams}} * @param cb callback method * @return void */ {{#formParams}}{{#-first}} {{#isMultipart}}@Multipart{{/isMultipart}}{{^isMultipart}}@FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}} - @{{httpMethod}}("{{path}}") + @{{httpMethod}}("{{path}}") void {{nickname}}( {{#allParams}}{{>libraries/retrofit/queryParams}}{{>libraries/retrofit/pathParams}}{{>libraries/retrofit/headerParams}}{{>libraries/retrofit/bodyParams}}{{>libraries/retrofit/formParams}}, {{/allParams}}Callback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> cb - ); + ); {{/operation}} } -{{/operations}} \ No newline at end of file +{{/operations}} From ab34dc56979b2acc2ecad697169e6a2ca0ccceee Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 8 Oct 2015 21:21:43 +0800 Subject: [PATCH 2/9] Rebuild Java cilents of the Petstore sample --- .../java/io/swagger/client/api/PetApi.java | 72 ++++++++--------- .../java/io/swagger/client/api/StoreApi.java | 41 ++++------ .../java/io/swagger/client/api/UserApi.java | 63 +++++++-------- .../java/io/swagger/client/model/Order.java | 9 +-- .../java/io/swagger/client/model/Pet.java | 15 ++-- .../java/io/swagger/client/api/PetApi.java | 68 +++++++--------- .../java/io/swagger/client/api/StoreApi.java | 39 ++++----- .../java/io/swagger/client/api/UserApi.java | 61 +++++++------- .../java/io/swagger/client/model/Order.java | 13 +-- .../java/io/swagger/client/model/Pet.java | 19 ++--- .../java/io/swagger/client/api/PetApi.java | 78 +++++++++--------- .../java/io/swagger/client/api/StoreApi.java | 41 ++++------ .../java/io/swagger/client/api/UserApi.java | 67 +++++++-------- .../java/io/swagger/client/model/Order.java | 7 +- .../java/io/swagger/client/model/Pet.java | 13 ++- .../java/io/swagger/client/api/PetApi.java | 81 +++++++++---------- .../java/io/swagger/client/api/StoreApi.java | 40 +++++---- .../java/io/swagger/client/api/UserApi.java | 74 +++++++++-------- .../java/io/swagger/client/model/Order.java | 7 +- .../java/io/swagger/client/model/Pet.java | 13 ++- 20 files changed, 373 insertions(+), 448 deletions(-) diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index ca9111f41764..4f503f934cbd 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -6,18 +6,10 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; -import io.swagger.client.model.*; - -import java.util.*; - import io.swagger.client.model.Pet; import java.io.File; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-30T16:27:52.437+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") public class PetApi { private ApiClient apiClient; @@ -52,9 +44,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -99,9 +91,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -136,9 +128,9 @@ public class PetApi { * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return List + * @return java.util.List */ - public List findPetsByStatus (List status) throws ApiException { + public java.util.List findPetsByStatus (java.util.List status) throws ApiException { Object postBody = null; byte[] postBinaryBody = null; @@ -146,9 +138,9 @@ public class PetApi { String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); @@ -174,7 +166,7 @@ public class PetApi { - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType); @@ -186,9 +178,9 @@ public class PetApi { * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return List + * @return java.util.List */ - public List findPetsByTags (List tags) throws ApiException { + public java.util.List findPetsByTags (java.util.List tags) throws ApiException { Object postBody = null; byte[] postBinaryBody = null; @@ -196,9 +188,9 @@ public class PetApi { String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); @@ -224,7 +216,7 @@ public class PetApi { - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType); @@ -252,9 +244,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -272,7 +264,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key", "petstore_auth" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; @@ -308,9 +300,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -366,9 +358,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -423,9 +415,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index f0628c595c98..4d861dcb5d8b 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -6,18 +6,9 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; -import io.swagger.client.model.*; - -import java.util.*; - -import java.util.Map; import io.swagger.client.model.Order; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-30T16:27:52.437+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") public class StoreApi { private ApiClient apiClient; @@ -41,9 +32,9 @@ public class StoreApi { /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return Map + * @return java.util.Map */ - public Map getInventory () throws ApiException { + public java.util.Map getInventory () throws ApiException { Object postBody = null; byte[] postBinaryBody = null; @@ -51,9 +42,9 @@ public class StoreApi { String path = "/store/inventory".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -77,7 +68,7 @@ public class StoreApi { - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType); @@ -99,9 +90,9 @@ public class StoreApi { String path = "/store/order".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -153,9 +144,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -207,9 +198,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index 3412c565b376..e2e0e90b18d6 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -6,18 +6,9 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; -import io.swagger.client.model.*; - -import java.util.*; - import io.swagger.client.model.User; -import java.util.*; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-30T16:27:52.437+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") public class UserApi { private ApiClient apiClient; @@ -52,9 +43,9 @@ public class UserApi { String path = "/user".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -91,7 +82,7 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithArrayInput (List body) throws ApiException { + public void createUsersWithArrayInput (java.util.List body) throws ApiException { Object postBody = body; byte[] postBinaryBody = null; @@ -99,9 +90,9 @@ public class UserApi { String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -138,7 +129,7 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithListInput (List body) throws ApiException { + public void createUsersWithListInput (java.util.List body) throws ApiException { Object postBody = body; byte[] postBinaryBody = null; @@ -146,9 +137,9 @@ public class UserApi { String path = "/user/createWithList".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -194,9 +185,9 @@ public class UserApi { String path = "/user/login".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); queryParams.addAll(apiClient.parameterToPairs("", "username", username)); @@ -245,9 +236,9 @@ public class UserApi { String path = "/user/logout".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -298,9 +289,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -353,9 +344,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -406,9 +397,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index b51be0c52e03..22320fbb39b2 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -1,7 +1,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; -import java.util.Date; @@ -10,13 +9,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-30T16:27:52.437+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; - private Date shipDate = null; + private java.util.Date shipDate = null; public enum StatusEnum { PLACED("placed"), @@ -79,10 +78,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("shipDate") - public Date getShipDate() { + public java.util.Date getShipDate() { return shipDate; } - public void setShipDate(Date shipDate) { + public void setShipDate(java.util.Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index aca4848ff988..fc0db631e60f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -3,7 +3,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; import io.swagger.client.model.Tag; -import java.util.*; @@ -12,14 +11,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-30T16:27:52.437+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") public class Pet { private Long id = null; private Category category = null; private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); + private java.util.List photoUrls = new java.util.ArrayList(); + private java.util.List tags = new java.util.ArrayList(); public enum StatusEnum { AVAILABLE("available"), @@ -81,10 +80,10 @@ public enum StatusEnum { **/ @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") - public List getPhotoUrls() { + public java.util.List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(List photoUrls) { + public void setPhotoUrls(java.util.List photoUrls) { this.photoUrls = photoUrls; } @@ -93,10 +92,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("tags") - public List getTags() { + public java.util.List getTags() { return tags; } - public void setTags(List tags) { + public void setTags(java.util.List tags) { this.tags = tags; } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index 26e0f275c8e2..56c0b1e173ce 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -8,16 +8,10 @@ import io.swagger.client.TypeRef; import io.swagger.client.model.*; -import java.util.*; - import io.swagger.client.model.Pet; import java.io.File; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") public class PetApi { private ApiClient apiClient; @@ -51,9 +45,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -91,9 +85,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -122,18 +116,18 @@ public class PetApi { * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return List + * @return java.util.List */ - public List findPetsByStatus (List status) throws ApiException { + public java.util.List findPetsByStatus (java.util.List status) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); @@ -156,7 +150,7 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } @@ -165,18 +159,18 @@ public class PetApi { * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return List + * @return java.util.List */ - public List findPetsByTags (List tags) throws ApiException { + public java.util.List findPetsByTags (java.util.List tags) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); @@ -199,7 +193,7 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } @@ -223,9 +217,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -272,9 +266,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -323,9 +317,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -373,9 +367,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index c95256c69aae..5f8a9fb13d8e 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -8,16 +8,9 @@ import io.swagger.client.TypeRef; import io.swagger.client.model.*; -import java.util.*; - -import java.util.Map; import io.swagger.client.model.Order; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") public class StoreApi { private ApiClient apiClient; @@ -41,18 +34,18 @@ public class StoreApi { /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return Map + * @return java.util.Map */ - public Map getInventory () throws ApiException { + public java.util.Map getInventory () throws ApiException { Object postBody = null; // create path and map variables String path = "/store/inventory".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -73,7 +66,7 @@ public class StoreApi { String[] authNames = new String[] { "api_key" }; - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } @@ -91,9 +84,9 @@ public class StoreApi { String path = "/store/order".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -138,9 +131,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -185,9 +178,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index 26c8d4b035f6..36199161b160 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -8,16 +8,9 @@ import io.swagger.client.TypeRef; import io.swagger.client.model.*; -import java.util.*; - import io.swagger.client.model.User; -import java.util.*; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") public class UserApi { private ApiClient apiClient; @@ -51,9 +44,9 @@ public class UserApi { String path = "/user".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -84,16 +77,16 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithArrayInput (List body) throws ApiException { + public void createUsersWithArrayInput (java.util.List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -124,16 +117,16 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithListInput (List body) throws ApiException { + public void createUsersWithListInput (java.util.List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -172,9 +165,9 @@ public class UserApi { String path = "/user/login".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); queryParams.addAll(apiClient.parameterToPairs("", "username", username)); @@ -216,9 +209,9 @@ public class UserApi { String path = "/user/logout".replaceAll("\\{format\\}","json"); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -262,9 +255,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -310,9 +303,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); @@ -356,9 +349,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - List queryParams = new ArrayList(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); + java.util.List queryParams = new java.util.ArrayList(); + java.util.Map headerParams = new java.util.HashMap(); + java.util.Map formParams = new java.util.HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 868c59a783d8..5b952459ddeb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -1,7 +1,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; -import java.util.Date; @@ -10,16 +9,18 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; - private Date shipDate = null; + private java.util.Date shipDate = null; public enum StatusEnum { - PLACED("placed"), APPROVED("approved"), DELIVERED("delivered"); + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); private String value; @@ -77,10 +78,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("shipDate") - public Date getShipDate() { + public java.util.Date getShipDate() { return shipDate; } - public void setShipDate(Date shipDate) { + public void setShipDate(java.util.Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 2a4a0b6c93d9..1e205686fd45 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; @@ -12,17 +11,19 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") public class Pet { private Long id = null; private Category category = null; private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); + private java.util.List photoUrls = new java.util.ArrayList(); + private java.util.List tags = new java.util.ArrayList(); public enum StatusEnum { - AVAILABLE("available"), PENDING("pending"), SOLD("sold"); + AVAILABLE("available"), + PENDING("pending"), + SOLD("sold"); private String value; @@ -79,10 +80,10 @@ public enum StatusEnum { **/ @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") - public List getPhotoUrls() { + public java.util.List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(List photoUrls) { + public void setPhotoUrls(java.util.List photoUrls) { this.photoUrls = photoUrls; } @@ -91,10 +92,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("tags") - public List getTags() { + public java.util.List getTags() { return tags; } - public void setTags(List tags) { + public void setTags(java.util.List tags) { this.tags = tags; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index debe576dc9dc..78bde8330796 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -14,15 +14,9 @@ import com.squareup.okhttp.Call; import java.lang.reflect.Type; -import java.util.*; - import io.swagger.client.model.Pet; import java.io.File; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - public class PetApi { private ApiClient apiClient; @@ -51,11 +45,11 @@ public class PetApi { // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -104,11 +98,11 @@ public class PetApi { // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -150,20 +144,20 @@ public class PetApi { } /* Build call for findPetsByStatus */ - private Call findPetsByStatusCall(List status) throws ApiException { + private Call findPetsByStatusCall(java.util.List status) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); if (status != null) queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -185,11 +179,11 @@ public class PetApi { * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return List + * @return java.util.List */ - public List findPetsByStatus(List status) throws ApiException { + public java.util.List findPetsByStatus(java.util.List status) throws ApiException { Call call = findPetsByStatusCall(status); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -200,28 +194,28 @@ public class PetApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call findPetsByStatusAsync(List status, ApiCallback> callback) throws ApiException { + public Call findPetsByStatusAsync(java.util.List status, ApiCallback> callback) throws ApiException { Call call = findPetsByStatusCall(status); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } /* Build call for findPetsByTags */ - private Call findPetsByTagsCall(List tags) throws ApiException { + private Call findPetsByTagsCall(java.util.List tags) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); if (tags != null) queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -243,11 +237,11 @@ public class PetApi { * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return List + * @return java.util.List */ - public List findPetsByTags(List tags) throws ApiException { + public java.util.List findPetsByTags(java.util.List tags) throws ApiException { Call call = findPetsByTagsCall(tags); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -258,9 +252,9 @@ public class PetApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call findPetsByTagsAsync(List tags, ApiCallback> callback) throws ApiException { + public Call findPetsByTagsAsync(java.util.List tags, ApiCallback> callback) throws ApiException { Call call = findPetsByTagsCall(tags); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } @@ -279,11 +273,11 @@ public class PetApi { String path = "/pet/{petId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -341,11 +335,11 @@ public class PetApi { String path = "/pet/{petId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); if (name != null) formParams.put("name", name); if (status != null) @@ -408,13 +402,13 @@ public class PetApi { String path = "/pet/{petId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); if (apiKey != null) headerParams.put("api_key", apiClient.parameterToString(apiKey)); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -471,11 +465,11 @@ public class PetApi { String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); if (additionalMetadata != null) formParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index a3fb14bb5210..ff7f02ecf562 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,15 +14,8 @@ import com.squareup.okhttp.Call; import java.lang.reflect.Type; -import java.util.*; - -import java.util.Map; import io.swagger.client.model.Order; -import java.io.File; -import java.util.Map; -import java.util.HashMap; - public class StoreApi { private ApiClient apiClient; @@ -51,11 +44,11 @@ public class StoreApi { // create path and map variables String path = "/store/inventory".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -76,11 +69,11 @@ public class StoreApi { /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return Map + * @return java.util.Map */ - public Map getInventory() throws ApiException { + public java.util.Map getInventory() throws ApiException { Call call = getInventoryCall(); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -90,9 +83,9 @@ public class StoreApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call getInventoryAsync(ApiCallback> callback) throws ApiException { + public Call getInventoryAsync(ApiCallback> callback) throws ApiException { Call call = getInventoryCall(); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } @@ -105,11 +98,11 @@ public class StoreApi { // create path and map variables String path = "/store/order".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -167,11 +160,11 @@ public class StoreApi { String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -229,11 +222,11 @@ public class StoreApi { String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index ce1bae64a46e..dccd7003b2b7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -14,14 +14,7 @@ import com.squareup.okhttp.Call; import java.lang.reflect.Type; -import java.util.*; - import io.swagger.client.model.User; -import java.util.*; - -import java.io.File; -import java.util.Map; -import java.util.HashMap; public class UserApi { private ApiClient apiClient; @@ -51,11 +44,11 @@ public class UserApi { // create path and map variables String path = "/user".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -97,18 +90,18 @@ public class UserApi { } /* Build call for createUsersWithArrayInput */ - private Call createUsersWithArrayInputCall(List body) throws ApiException { + private Call createUsersWithArrayInputCall(java.util.List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -131,7 +124,7 @@ public class UserApi { * * @param body List of user object */ - public void createUsersWithArrayInput(List body) throws ApiException { + public void createUsersWithArrayInput(java.util.List body) throws ApiException { Call call = createUsersWithArrayInputCall(body); apiClient.execute(call); } @@ -143,25 +136,25 @@ public class UserApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call createUsersWithArrayInputAsync(List body, ApiCallback callback) throws ApiException { + public Call createUsersWithArrayInputAsync(java.util.List body, ApiCallback callback) throws ApiException { Call call = createUsersWithArrayInputCall(body); apiClient.executeAsync(call, callback); return call; } /* Build call for createUsersWithListInput */ - private Call createUsersWithListInputCall(List body) throws ApiException { + private Call createUsersWithListInputCall(java.util.List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -184,7 +177,7 @@ public class UserApi { * * @param body List of user object */ - public void createUsersWithListInput(List body) throws ApiException { + public void createUsersWithListInput(java.util.List body) throws ApiException { Call call = createUsersWithListInputCall(body); apiClient.execute(call); } @@ -196,7 +189,7 @@ public class UserApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call createUsersWithListInputAsync(List body, ApiCallback callback) throws ApiException { + public Call createUsersWithListInputAsync(java.util.List body, ApiCallback callback) throws ApiException { Call call = createUsersWithListInputCall(body); apiClient.executeAsync(call, callback); return call; @@ -210,15 +203,15 @@ public class UserApi { // create path and map variables String path = "/user/login".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); if (username != null) queryParams.addAll(apiClient.parameterToPairs("", "username", username)); if (password != null) queryParams.addAll(apiClient.parameterToPairs("", "password", password)); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -272,11 +265,11 @@ public class UserApi { // create path and map variables String path = "/user/logout".replaceAll("\\{format\\}","json"); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -329,11 +322,11 @@ public class UserApi { String path = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -391,11 +384,11 @@ public class UserApi { String path = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -452,11 +445,11 @@ public class UserApi { String path = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - List queryParams = new ArrayList(); + java.util.List queryParams = new java.util.ArrayList(); - Map headerParams = new HashMap(); + java.util.Map headerParams = new java.util.HashMap(); - Map formParams = new HashMap(); + java.util.Map formParams = new java.util.HashMap(); final String[] accepts = { "application/json", "application/xml" diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java index df8e77b6fb35..57c9f791e97c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java @@ -1,7 +1,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; -import java.util.Date; import com.google.gson.annotations.SerializedName; @@ -24,7 +23,7 @@ public class Order { private Integer quantity = null; @SerializedName("shipDate") - private Date shipDate = null; + private java.util.Date shipDate = null; public enum StatusEnum { @@ -93,10 +92,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public Date getShipDate() { + public java.util.Date getShipDate() { return shipDate; } - public void setShipDate(Date shipDate) { + public void setShipDate(java.util.Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java index 9ab5457e26ac..4b214d56c01e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; import com.google.gson.annotations.SerializedName; @@ -26,10 +25,10 @@ public class Pet { private String name = null; @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); + private java.util.List photoUrls = new java.util.ArrayList(); @SerializedName("tags") - private List tags = new ArrayList(); + private java.util.List tags = new java.util.ArrayList(); public enum StatusEnum { @@ -95,10 +94,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(required = true, value = "") - public List getPhotoUrls() { + public java.util.List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(List photoUrls) { + public void setPhotoUrls(java.util.List photoUrls) { this.photoUrls = photoUrls; } @@ -106,10 +105,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public List getTags() { + public java.util.List getTags() { return tags; } - public void setTags(List tags) { + public void setTags(java.util.List tags) { this.tags = tags; } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index cd4dbe866a51..568e17b6cfc0 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -5,7 +5,6 @@ import io.swagger.client.model.*; import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; -import java.util.*; import io.swagger.client.model.Pet; import java.io.File; @@ -20,7 +19,7 @@ public interface PetApi { * @return Void */ - @PUT("/pet") + @PUT("/pet") Void updatePet( @Body Pet body ); @@ -29,14 +28,14 @@ public interface PetApi { * Update an existing pet * Async method * @param body Pet object that needs to be added to the store - * @param cb callback method + * @param cb callback method * @return void */ - @PUT("/pet") + @PUT("/pet") void updatePet( @Body Pet body, Callback cb - ); + ); /** * Add a new pet to the store @@ -46,7 +45,7 @@ public interface PetApi { * @return Void */ - @POST("/pet") + @POST("/pet") Void addPet( @Body Pet body ); @@ -55,66 +54,66 @@ public interface PetApi { * Add a new pet to the store * Async method * @param body Pet object that needs to be added to the store - * @param cb callback method + * @param cb callback method * @return void */ - @POST("/pet") + @POST("/pet") void addPet( @Body Pet body, Callback cb - ); + ); /** * Finds Pets by status * Sync method * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return List + * @return java.util.List */ - @GET("/pet/findByStatus") - List findPetsByStatus( - @Query("status") List status + @GET("/pet/findByStatus") + java.util.List findPetsByStatus( + @Query("status") java.util.List status ); /** * Finds Pets by status * Async method * @param status Status values that need to be considered for filter - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/pet/findByStatus") + @GET("/pet/findByStatus") void findPetsByStatus( - @Query("status") List status, Callback> cb - ); + @Query("status") java.util.List status, Callback> cb + ); /** * Finds Pets by tags * Sync method * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return List + * @return java.util.List */ - @GET("/pet/findByTags") - List findPetsByTags( - @Query("tags") List tags + @GET("/pet/findByTags") + java.util.List findPetsByTags( + @Query("tags") java.util.List tags ); /** * Finds Pets by tags * Async method * @param tags Tags to filter by - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/pet/findByTags") + @GET("/pet/findByTags") void findPetsByTags( - @Query("tags") List tags, Callback> cb - ); + @Query("tags") java.util.List tags, Callback> cb + ); /** * Find pet by ID @@ -124,7 +123,7 @@ public interface PetApi { * @return Pet */ - @GET("/pet/{petId}") + @GET("/pet/{petId}") Pet getPetById( @Path("petId") Long petId ); @@ -133,14 +132,14 @@ public interface PetApi { * Find pet by ID * Async method * @param petId ID of pet that needs to be fetched - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/pet/{petId}") + @GET("/pet/{petId}") void getPetById( @Path("petId") Long petId, Callback cb - ); + ); /** * Updates a pet in the store with form data @@ -153,7 +152,7 @@ public interface PetApi { */ @FormUrlEncoded - @POST("/pet/{petId}") + @POST("/pet/{petId}") Void updatePetWithForm( @Path("petId") String petId, @Field("name") String name, @Field("status") String status ); @@ -164,15 +163,15 @@ public interface PetApi { * @param petId ID of pet that needs to be updated * @param name Updated name of the pet * @param status Updated status of the pet - * @param cb callback method + * @param cb callback method * @return void */ @FormUrlEncoded - @POST("/pet/{petId}") + @POST("/pet/{petId}") void updatePetWithForm( @Path("petId") String petId, @Field("name") String name, @Field("status") String status, Callback cb - ); + ); /** * Deletes a pet @@ -183,7 +182,7 @@ public interface PetApi { * @return Void */ - @DELETE("/pet/{petId}") + @DELETE("/pet/{petId}") Void deletePet( @Path("petId") Long petId, @Header("api_key") String apiKey ); @@ -193,14 +192,14 @@ public interface PetApi { * Async method * @param petId Pet id to delete * @param apiKey - * @param cb callback method + * @param cb callback method * @return void */ - @DELETE("/pet/{petId}") + @DELETE("/pet/{petId}") void deletePet( @Path("petId") Long petId, @Header("api_key") String apiKey, Callback cb - ); + ); /** * uploads an image @@ -213,7 +212,7 @@ public interface PetApi { */ @Multipart - @POST("/pet/{petId}/uploadImage") + @POST("/pet/{petId}/uploadImage") Void uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file ); @@ -224,14 +223,14 @@ public interface PetApi { * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload - * @param cb callback method + * @param cb callback method * @return void */ @Multipart - @POST("/pet/{petId}/uploadImage") + @POST("/pet/{petId}/uploadImage") void uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file, Callback cb - ); + ); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index 1c0a8291d020..ce9e9456859f 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -5,9 +5,7 @@ import io.swagger.client.model.*; import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; -import java.util.*; -import java.util.Map; import io.swagger.client.model.Order; public interface StoreApi { @@ -16,24 +14,24 @@ public interface StoreApi { * Returns pet inventories by status * Sync method * Returns a map of status codes to quantities - * @return Map + * @return java.util.Map */ - @GET("/store/inventory") - Map getInventory(); + @GET("/store/inventory") + java.util.Map getInventory(); /** * Returns pet inventories by status * Async method - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/store/inventory") + @GET("/store/inventory") void getInventory( - Callback> cb - ); + Callback> cb + ); /** * Place an order for a pet @@ -43,7 +41,7 @@ public interface StoreApi { * @return Order */ - @POST("/store/order") + @POST("/store/order") Order placeOrder( @Body Order body ); @@ -52,14 +50,14 @@ public interface StoreApi { * Place an order for a pet * Async method * @param body order placed for purchasing the pet - * @param cb callback method + * @param cb callback method * @return void */ - @POST("/store/order") + @POST("/store/order") void placeOrder( @Body Order body, Callback cb - ); + ); /** * Find purchase order by ID @@ -69,7 +67,7 @@ public interface StoreApi { * @return Order */ - @GET("/store/order/{orderId}") + @GET("/store/order/{orderId}") Order getOrderById( @Path("orderId") String orderId ); @@ -78,14 +76,14 @@ public interface StoreApi { * Find purchase order by ID * Async method * @param orderId ID of pet that needs to be fetched - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/store/order/{orderId}") + @GET("/store/order/{orderId}") void getOrderById( @Path("orderId") String orderId, Callback cb - ); + ); /** * Delete purchase order by ID @@ -95,7 +93,7 @@ public interface StoreApi { * @return Void */ - @DELETE("/store/order/{orderId}") + @DELETE("/store/order/{orderId}") Void deleteOrder( @Path("orderId") String orderId ); @@ -104,13 +102,13 @@ public interface StoreApi { * Delete purchase order by ID * Async method * @param orderId ID of the order that needs to be deleted - * @param cb callback method + * @param cb callback method * @return void */ - @DELETE("/store/order/{orderId}") + @DELETE("/store/order/{orderId}") void deleteOrder( @Path("orderId") String orderId, Callback cb - ); + ); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java index 162222bc0f1b..57b8f66f4277 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java @@ -5,10 +5,8 @@ import io.swagger.client.model.*; import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; -import java.util.*; import io.swagger.client.model.User; -import java.util.*; public interface UserApi { @@ -20,7 +18,7 @@ public interface UserApi { * @return Void */ - @POST("/user") + @POST("/user") Void createUser( @Body User body ); @@ -29,14 +27,14 @@ public interface UserApi { * Create user * Async method * @param body Created user object - * @param cb callback method + * @param cb callback method * @return void */ - @POST("/user") + @POST("/user") void createUser( @Body User body, Callback cb - ); + ); /** * Creates list of users with given input array @@ -46,23 +44,23 @@ public interface UserApi { * @return Void */ - @POST("/user/createWithArray") + @POST("/user/createWithArray") Void createUsersWithArrayInput( - @Body List body + @Body java.util.List body ); /** * Creates list of users with given input array * Async method * @param body List of user object - * @param cb callback method + * @param cb callback method * @return void */ - @POST("/user/createWithArray") + @POST("/user/createWithArray") void createUsersWithArrayInput( - @Body List body, Callback cb - ); + @Body java.util.List body, Callback cb + ); /** * Creates list of users with given input array @@ -72,23 +70,23 @@ public interface UserApi { * @return Void */ - @POST("/user/createWithList") + @POST("/user/createWithList") Void createUsersWithListInput( - @Body List body + @Body java.util.List body ); /** * Creates list of users with given input array * Async method * @param body List of user object - * @param cb callback method + * @param cb callback method * @return void */ - @POST("/user/createWithList") + @POST("/user/createWithList") void createUsersWithListInput( - @Body List body, Callback cb - ); + @Body java.util.List body, Callback cb + ); /** * Logs user into the system @@ -99,7 +97,7 @@ public interface UserApi { * @return String */ - @GET("/user/login") + @GET("/user/login") String loginUser( @Query("username") String username, @Query("password") String password ); @@ -109,14 +107,14 @@ public interface UserApi { * Async method * @param username The user name for login * @param password The password for login in clear text - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/user/login") + @GET("/user/login") void loginUser( @Query("username") String username, @Query("password") String password, Callback cb - ); + ); /** * Logs out current logged in user session @@ -125,21 +123,21 @@ public interface UserApi { * @return Void */ - @GET("/user/logout") + @GET("/user/logout") Void logoutUser(); /** * Logs out current logged in user session * Async method - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/user/logout") + @GET("/user/logout") void logoutUser( Callback cb - ); + ); /** * Get user by user name @@ -149,7 +147,7 @@ public interface UserApi { * @return User */ - @GET("/user/{username}") + @GET("/user/{username}") User getUserByName( @Path("username") String username ); @@ -158,14 +156,14 @@ public interface UserApi { * Get user by user name * Async method * @param username The name that needs to be fetched. Use user1 for testing. - * @param cb callback method + * @param cb callback method * @return void */ - @GET("/user/{username}") + @GET("/user/{username}") void getUserByName( @Path("username") String username, Callback cb - ); + ); /** * Updated user @@ -176,7 +174,7 @@ public interface UserApi { * @return Void */ - @PUT("/user/{username}") + @PUT("/user/{username}") Void updateUser( @Path("username") String username, @Body User body ); @@ -186,14 +184,14 @@ public interface UserApi { * Async method * @param username name that need to be deleted * @param body Updated user object - * @param cb callback method + * @param cb callback method * @return void */ - @PUT("/user/{username}") + @PUT("/user/{username}") void updateUser( @Path("username") String username, @Body User body, Callback cb - ); + ); /** * Delete user @@ -203,7 +201,7 @@ public interface UserApi { * @return Void */ - @DELETE("/user/{username}") + @DELETE("/user/{username}") Void deleteUser( @Path("username") String username ); @@ -212,13 +210,13 @@ public interface UserApi { * Delete user * Async method * @param username The name that needs to be deleted - * @param cb callback method + * @param cb callback method * @return void */ - @DELETE("/user/{username}") + @DELETE("/user/{username}") void deleteUser( @Path("username") String username, Callback cb - ); + ); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java index df8e77b6fb35..57c9f791e97c 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java @@ -1,7 +1,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; -import java.util.Date; import com.google.gson.annotations.SerializedName; @@ -24,7 +23,7 @@ public class Order { private Integer quantity = null; @SerializedName("shipDate") - private Date shipDate = null; + private java.util.Date shipDate = null; public enum StatusEnum { @@ -93,10 +92,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public Date getShipDate() { + public java.util.Date getShipDate() { return shipDate; } - public void setShipDate(Date shipDate) { + public void setShipDate(java.util.Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java index 9ab5457e26ac..4b214d56c01e 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; import com.google.gson.annotations.SerializedName; @@ -26,10 +25,10 @@ public class Pet { private String name = null; @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); + private java.util.List photoUrls = new java.util.ArrayList(); @SerializedName("tags") - private List tags = new ArrayList(); + private java.util.List tags = new java.util.ArrayList(); public enum StatusEnum { @@ -95,10 +94,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(required = true, value = "") - public List getPhotoUrls() { + public java.util.List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(List photoUrls) { + public void setPhotoUrls(java.util.List photoUrls) { this.photoUrls = photoUrls; } @@ -106,10 +105,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public List getTags() { + public java.util.List getTags() { return tags; } - public void setTags(List tags) { + public void setTags(java.util.List tags) { this.tags = tags; } From aa0fbada0737839c7e62f8043d59b323be00bc1d Mon Sep 17 00:00:00 2001 From: xhh Date: Fri, 9 Oct 2015 22:07:43 +0800 Subject: [PATCH 3/9] Add a "fullJavaUtil" option to Java clients to toggle whether to use full qualified name (with full package prefix) for classes under java.util --- .../io/swagger/codegen/DefaultCodegen.java | 15 +++- .../codegen/languages/JavaClientCodegen.java | 49 +++++++++++- .../src/main/resources/Java/api.mustache | 10 ++- .../Java/libraries/jersey2/api.mustache | 12 +-- .../Java/libraries/okhttp-gson/api.mustache | 15 ++-- .../Java/libraries/retrofit/api.mustache | 6 +- .../java/io/swagger/client/api/PetApi.java | 64 +++++++-------- .../java/io/swagger/client/api/StoreApi.java | 35 ++++---- .../java/io/swagger/client/api/UserApi.java | 57 ++++++------- .../java/io/swagger/client/model/Order.java | 9 ++- .../java/io/swagger/client/model/Pet.java | 15 ++-- .../java/io/swagger/client/api/PetApi.java | 66 ++++++++-------- .../java/io/swagger/client/api/StoreApi.java | 37 ++++----- .../java/io/swagger/client/api/UserApi.java | 59 +++++++------- .../java/io/swagger/client/model/Order.java | 9 ++- .../java/io/swagger/client/model/Pet.java | 15 ++-- .../java/io/swagger/client/api/PetApi.java | 79 +++++++++---------- .../java/io/swagger/client/api/StoreApi.java | 42 +++++----- .../java/io/swagger/client/api/UserApi.java | 68 ++++++++-------- .../java/io/swagger/client/model/Order.java | 7 +- .../java/io/swagger/client/model/Pet.java | 13 +-- .../java/io/swagger/client/api/PetApi.java | 20 ++--- .../java/io/swagger/client/api/StoreApi.java | 11 +-- .../java/io/swagger/client/api/UserApi.java | 13 +-- .../java/io/swagger/client/model/Order.java | 7 +- .../java/io/swagger/client/model/Pet.java | 13 +-- 26 files changed, 412 insertions(+), 334 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 55868c0acaff..b5f544a749b5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -311,14 +311,15 @@ public class DefaultCodegen { ); typeMapping = new HashMap(); - typeMapping.put("array", "java.util.List"); - typeMapping.put("map", "java.util.Map"); + typeMapping.put("array", "List"); + typeMapping.put("map", "Map"); + typeMapping.put("List", "List"); typeMapping.put("boolean", "Boolean"); typeMapping.put("string", "String"); typeMapping.put("int", "Integer"); typeMapping.put("float", "Float"); typeMapping.put("number", "BigDecimal"); - typeMapping.put("DateTime", "java.util.Date"); + typeMapping.put("DateTime", "Date"); typeMapping.put("long", "Long"); typeMapping.put("short", "Short"); typeMapping.put("char", "String"); @@ -336,7 +337,15 @@ public class DefaultCodegen { importMapping.put("BigDecimal", "java.math.BigDecimal"); importMapping.put("UUID", "java.util.UUID"); importMapping.put("File", "java.io.File"); + importMapping.put("Date", "java.util.Date"); importMapping.put("Timestamp", "java.sql.Timestamp"); + importMapping.put("Map", "java.util.Map"); + importMapping.put("HashMap", "java.util.HashMap"); + importMapping.put("Array", "java.util.List"); + importMapping.put("ArrayList", "java.util.ArrayList"); + importMapping.put("List", "java.util.*"); + importMapping.put("Set", "java.util.*"); + importMapping.put("DateTime", "org.joda.time.*"); importMapping.put("LocalDateTime", "org.joda.time.*"); importMapping.put("LocalDate", "org.joda.time.*"); importMapping.put("LocalTime", "org.joda.time.*"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 1276c2dde6c5..5d61f1b59324 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -37,6 +37,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/java"; protected String localVariablePrefix = ""; + protected boolean fullJavaUtil = false; + protected String javaUtilPrefix = ""; protected Boolean serializableModel = false; public JavaClientCodegen() { @@ -71,8 +73,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { "Object", "byte[]") ); - instantiationTypes.put("array", "java.util.ArrayList"); - instantiationTypes.put("map", "java.util.HashMap"); + instantiationTypes.put("array", "ArrayList"); + instantiationTypes.put("map", "HashMap"); cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); @@ -81,6 +83,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC)); cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC)); + cliOptions.add(new CliOption("fullJavaUtil", "whether to use full qualified name for classes under java.util (default to false)")); supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6"); @@ -152,6 +155,32 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); + if (additionalProperties.containsKey("fullJavaUtil")) { + fullJavaUtil = Boolean.valueOf(additionalProperties.get("fullJavaUtil").toString()); + } + if (fullJavaUtil) { + javaUtilPrefix = "java.util."; + } + additionalProperties.put("fullJavaUtil", fullJavaUtil); + additionalProperties.put("javaUtilPrefix", javaUtilPrefix); + + if (fullJavaUtil) { + typeMapping.put("array", "java.util.List"); + typeMapping.put("map", "java.util.Map"); + typeMapping.put("DateTime", "java.util.Date"); + typeMapping.remove("List"); + importMapping.remove("Date"); + importMapping.remove("Map"); + importMapping.remove("HashMap"); + importMapping.remove("Array"); + importMapping.remove("ArrayList"); + importMapping.remove("List"); + importMapping.remove("Set"); + importMapping.remove("DateTime"); + instantiationTypes.put("array", "java.util.ArrayList"); + instantiationTypes.put("map", "java.util.HashMap"); + } + this.sanitizeConfig(); final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); @@ -294,10 +323,22 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public String toDefaultValue(Property p) { if (p instanceof ArrayProperty) { final ArrayProperty ap = (ArrayProperty) p; - return String.format("new java.util.ArrayList<%s>()", getTypeDeclaration(ap.getItems())); + final String pattern; + if (fullJavaUtil) { + pattern = "new java.util.ArrayList<%s>()"; + } else { + pattern = "new ArrayList<%s>()"; + } + return String.format(pattern, getTypeDeclaration(ap.getItems())); } else if (p instanceof MapProperty) { final MapProperty ap = (MapProperty) p; - return String.format("new java.util.HashMap()", getTypeDeclaration(ap.getAdditionalProperties())); + final String pattern; + if (fullJavaUtil) { + pattern = "new java.util.HashMap()"; + } else { + pattern = "new HashMap()"; + } + return String.format(pattern, getTypeDeclaration(ap.getAdditionalProperties())); } return super.toDefaultValue(p); } diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index 38ebc1c54abd..08d28ebd51b1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -9,6 +9,10 @@ import {{invokerPackage}}.TypeRef; {{#imports}}import {{import}}; {{/imports}} +{{^fullJavaUtil}} +import java.util.*; +{{/fullJavaUtil}} + {{>generatedAnnotation}} {{#operations}} public class {{classname}} { @@ -51,9 +55,9 @@ public class {{classname}} { .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; // query params - java.util.List {{localVariablePrefix}}queryParams = new java.util.ArrayList(); - java.util.Map {{localVariablePrefix}}headerParams = new java.util.HashMap(); - java.util.Map {{localVariablePrefix}}formParams = new java.util.HashMap(); + {{javaUtilPrefix}}List {{localVariablePrefix}}queryParams = new {{javaUtilPrefix}}ArrayList(); + {{javaUtilPrefix}}Map {{localVariablePrefix}}headerParams = new {{javaUtilPrefix}}HashMap(); + {{javaUtilPrefix}}Map {{localVariablePrefix}}formParams = new {{javaUtilPrefix}}HashMap(); {{#queryParams}} {{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache index 532f1ef78cf1..10f2fa2f7446 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache @@ -6,11 +6,13 @@ import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; import {{invokerPackage}}.TypeRef; -import {{modelPackage}}.*; - {{#imports}}import {{import}}; {{/imports}} +{{^fullJavaUtil}} +import java.util.*; +{{/fullJavaUtil}} + {{>generatedAnnotation}} {{#operations}} public class {{classname}} { @@ -52,9 +54,9 @@ public class {{classname}} { .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; // query params - java.util.List {{localVariablePrefix}}queryParams = new java.util.ArrayList(); - java.util.Map {{localVariablePrefix}}headerParams = new java.util.HashMap(); - java.util.Map {{localVariablePrefix}}formParams = new java.util.HashMap(); + {{javaUtilPrefix}}List {{localVariablePrefix}}queryParams = new {{javaUtilPrefix}}ArrayList(); + {{javaUtilPrefix}}Map {{localVariablePrefix}}headerParams = new {{javaUtilPrefix}}HashMap(); + {{javaUtilPrefix}}Map {{localVariablePrefix}}formParams = new {{javaUtilPrefix}}HashMap(); {{#queryParams}} {{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache index d1f38f0ac358..efb1a14f27d7 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -6,17 +6,18 @@ import {{invokerPackage}}.ApiException; import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; -import {{modelPackage}}.*; - import com.google.gson.reflect.TypeToken; import com.squareup.okhttp.Call; -import java.lang.reflect.Type; - {{#imports}}import {{import}}; {{/imports}} +import java.lang.reflect.Type; +{{^fullJavaUtil}} +import java.util.*; +{{/fullJavaUtil}} + {{#operations}} public class {{classname}} { private ApiClient {{localVariablePrefix}}apiClient; @@ -52,15 +53,15 @@ public class {{classname}} { String {{localVariablePrefix}}path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; - java.util.List {{localVariablePrefix}}queryParams = new java.util.ArrayList();{{#queryParams}} + {{javaUtilPrefix}}List {{localVariablePrefix}}queryParams = new {{javaUtilPrefix}}ArrayList();{{#queryParams}} if ({{paramName}} != null) {{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));{{/queryParams}} - java.util.Map {{localVariablePrefix}}headerParams = new java.util.HashMap();{{#headerParams}} + {{javaUtilPrefix}}Map {{localVariablePrefix}}headerParams = new {{javaUtilPrefix}}HashMap();{{#headerParams}} if ({{paramName}} != null) {{localVariablePrefix}}headerParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));{{/headerParams}} - java.util.Map {{localVariablePrefix}}formParams = new java.util.HashMap();{{#formParams}} + {{javaUtilPrefix}}Map {{localVariablePrefix}}formParams = new {{javaUtilPrefix}}HashMap();{{#formParams}} if ({{paramName}} != null) {{localVariablePrefix}}formParams.put("{{baseName}}", {{paramName}});{{/formParams}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache index 28d2d29f8d1a..b41e18aff47c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api.mustache @@ -1,7 +1,5 @@ package {{package}}; -import {{modelPackage}}.*; - import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; @@ -9,6 +7,10 @@ import retrofit.mime.*; {{#imports}}import {{import}}; {{/imports}} +{{^fullJavaUtil}} +import java.util.*; +{{/fullJavaUtil}} + {{#operations}} public interface {{classname}} { {{#operation}} diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index 4f503f934cbd..8715238ae148 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -9,7 +9,9 @@ import io.swagger.client.TypeRef; import io.swagger.client.model.Pet; import java.io.File; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00") public class PetApi { private ApiClient apiClient; @@ -44,9 +46,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -91,9 +93,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -128,9 +130,9 @@ public class PetApi { * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return java.util.List + * @return List */ - public java.util.List findPetsByStatus (java.util.List status) throws ApiException { + public List findPetsByStatus (List status) throws ApiException { Object postBody = null; byte[] postBinaryBody = null; @@ -138,9 +140,9 @@ public class PetApi { String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); @@ -166,7 +168,7 @@ public class PetApi { - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType); @@ -178,9 +180,9 @@ public class PetApi { * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return java.util.List + * @return List */ - public java.util.List findPetsByTags (java.util.List tags) throws ApiException { + public List findPetsByTags (List tags) throws ApiException { Object postBody = null; byte[] postBinaryBody = null; @@ -188,9 +190,9 @@ public class PetApi { String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); @@ -216,7 +218,7 @@ public class PetApi { - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType); @@ -244,9 +246,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -300,9 +302,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -358,9 +360,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -415,9 +417,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 4d861dcb5d8b..916b16e17ff1 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -6,9 +6,12 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; +import java.util.Map; import io.swagger.client.model.Order; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00") public class StoreApi { private ApiClient apiClient; @@ -32,9 +35,9 @@ public class StoreApi { /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return java.util.Map + * @return Map */ - public java.util.Map getInventory () throws ApiException { + public Map getInventory () throws ApiException { Object postBody = null; byte[] postBinaryBody = null; @@ -42,9 +45,9 @@ public class StoreApi { String path = "/store/inventory".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -68,7 +71,7 @@ public class StoreApi { - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType); @@ -90,9 +93,9 @@ public class StoreApi { String path = "/store/order".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -144,9 +147,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -198,9 +201,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index e2e0e90b18d6..80ee07041f76 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -7,8 +7,11 @@ import io.swagger.client.Pair; import io.swagger.client.TypeRef; import io.swagger.client.model.User; +import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00") public class UserApi { private ApiClient apiClient; @@ -43,9 +46,9 @@ public class UserApi { String path = "/user".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -82,7 +85,7 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithArrayInput (java.util.List body) throws ApiException { + public void createUsersWithArrayInput (List body) throws ApiException { Object postBody = body; byte[] postBinaryBody = null; @@ -90,9 +93,9 @@ public class UserApi { String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -129,7 +132,7 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithListInput (java.util.List body) throws ApiException { + public void createUsersWithListInput (List body) throws ApiException { Object postBody = body; byte[] postBinaryBody = null; @@ -137,9 +140,9 @@ public class UserApi { String path = "/user/createWithList".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -185,9 +188,9 @@ public class UserApi { String path = "/user/login".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("", "username", username)); @@ -236,9 +239,9 @@ public class UserApi { String path = "/user/logout".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -289,9 +292,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -344,9 +347,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -397,9 +400,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 22320fbb39b2..84582f973200 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -1,6 +1,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; +import java.util.Date; @@ -9,13 +10,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00") public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; - private java.util.Date shipDate = null; + private Date shipDate = null; public enum StatusEnum { PLACED("placed"), @@ -78,10 +79,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("shipDate") - public java.util.Date getShipDate() { + public Date getShipDate() { return shipDate; } - public void setShipDate(java.util.Date shipDate) { + public void setShipDate(Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index fc0db631e60f..3076f4a5be90 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -2,6 +2,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; +import java.util.*; import io.swagger.client.model.Tag; @@ -11,14 +12,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:43.997+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00") public class Pet { private Long id = null; private Category category = null; private String name = null; - private java.util.List photoUrls = new java.util.ArrayList(); - private java.util.List tags = new java.util.ArrayList(); + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { AVAILABLE("available"), @@ -80,10 +81,10 @@ public enum StatusEnum { **/ @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") - public java.util.List getPhotoUrls() { + public List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(java.util.List photoUrls) { + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } @@ -92,10 +93,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("tags") - public java.util.List getTags() { + public List getTags() { return tags; } - public void setTags(java.util.List tags) { + public void setTags(List tags) { this.tags = tags; } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index 56c0b1e173ce..b979fd081340 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -6,12 +6,12 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; -import io.swagger.client.model.*; - import io.swagger.client.model.Pet; import java.io.File; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00") public class PetApi { private ApiClient apiClient; @@ -45,9 +45,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -85,9 +85,9 @@ public class PetApi { String path = "/pet".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -116,18 +116,18 @@ public class PetApi { * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return java.util.List + * @return List */ - public java.util.List findPetsByStatus (java.util.List status) throws ApiException { + public List findPetsByStatus (List status) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); @@ -150,7 +150,7 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } @@ -159,18 +159,18 @@ public class PetApi { * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return java.util.List + * @return List */ - public java.util.List findPetsByTags (java.util.List tags) throws ApiException { + public List findPetsByTags (List tags) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); @@ -193,7 +193,7 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } @@ -217,9 +217,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -266,9 +266,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -317,9 +317,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -367,9 +367,9 @@ public class PetApi { .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 5f8a9fb13d8e..d011bca14175 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -6,11 +6,12 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; -import io.swagger.client.model.*; - +import java.util.Map; import io.swagger.client.model.Order; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00") public class StoreApi { private ApiClient apiClient; @@ -34,18 +35,18 @@ public class StoreApi { /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return java.util.Map + * @return Map */ - public java.util.Map getInventory () throws ApiException { + public Map getInventory () throws ApiException { Object postBody = null; // create path and map variables String path = "/store/inventory".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -66,7 +67,7 @@ public class StoreApi { String[] authNames = new String[] { "api_key" }; - TypeRef returnType = new TypeRef>() {}; + TypeRef returnType = new TypeRef>() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } @@ -84,9 +85,9 @@ public class StoreApi { String path = "/store/order".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -131,9 +132,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -178,9 +179,9 @@ public class StoreApi { .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index 36199161b160..1c811a06a3b2 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -6,11 +6,12 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.TypeRef; -import io.swagger.client.model.*; - import io.swagger.client.model.User; +import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00") public class UserApi { private ApiClient apiClient; @@ -44,9 +45,9 @@ public class UserApi { String path = "/user".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -77,16 +78,16 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithArrayInput (java.util.List body) throws ApiException { + public void createUsersWithArrayInput (List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -117,16 +118,16 @@ public class UserApi { * @param body List of user object * @return void */ - public void createUsersWithListInput (java.util.List body) throws ApiException { + public void createUsersWithListInput (List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -165,9 +166,9 @@ public class UserApi { String path = "/user/login".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("", "username", username)); @@ -209,9 +210,9 @@ public class UserApi { String path = "/user/logout".replaceAll("\\{format\\}","json"); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -255,9 +256,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -303,9 +304,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); @@ -349,9 +350,9 @@ public class UserApi { .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); // query params - java.util.List queryParams = new java.util.ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); - java.util.Map formParams = new java.util.HashMap(); + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 5b952459ddeb..2f091e480853 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -1,6 +1,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; +import java.util.Date; @@ -9,13 +10,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00") public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; - private java.util.Date shipDate = null; + private Date shipDate = null; public enum StatusEnum { PLACED("placed"), @@ -78,10 +79,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("shipDate") - public java.util.Date getShipDate() { + public Date getShipDate() { return shipDate; } - public void setShipDate(java.util.Date shipDate) { + public void setShipDate(Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 1e205686fd45..784478c84f94 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -2,6 +2,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; +import java.util.*; import io.swagger.client.model.Tag; @@ -11,14 +12,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-08T20:57:48.684+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00") public class Pet { private Long id = null; private Category category = null; private String name = null; - private java.util.List photoUrls = new java.util.ArrayList(); - private java.util.List tags = new java.util.ArrayList(); + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { AVAILABLE("available"), @@ -80,10 +81,10 @@ public enum StatusEnum { **/ @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") - public java.util.List getPhotoUrls() { + public List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(java.util.List photoUrls) { + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } @@ -92,10 +93,10 @@ public enum StatusEnum { **/ @ApiModelProperty(value = "") @JsonProperty("tags") - public java.util.List getTags() { + public List getTags() { return tags; } - public void setTags(java.util.List tags) { + public void setTags(List tags) { this.tags = tags; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index 78bde8330796..596596b935ac 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -6,17 +6,16 @@ import io.swagger.client.ApiException; import io.swagger.client.Configuration; import io.swagger.client.Pair; -import io.swagger.client.model.*; - import com.google.gson.reflect.TypeToken; import com.squareup.okhttp.Call; -import java.lang.reflect.Type; - import io.swagger.client.model.Pet; import java.io.File; +import java.lang.reflect.Type; +import java.util.*; + public class PetApi { private ApiClient apiClient; @@ -45,11 +44,11 @@ public class PetApi { // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -98,11 +97,11 @@ public class PetApi { // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -144,20 +143,20 @@ public class PetApi { } /* Build call for findPetsByStatus */ - private Call findPetsByStatusCall(java.util.List status) throws ApiException { + private Call findPetsByStatusCall(List status) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); if (status != null) queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -179,11 +178,11 @@ public class PetApi { * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return java.util.List + * @return List */ - public java.util.List findPetsByStatus(java.util.List status) throws ApiException { + public List findPetsByStatus(List status) throws ApiException { Call call = findPetsByStatusCall(status); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -194,28 +193,28 @@ public class PetApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call findPetsByStatusAsync(java.util.List status, ApiCallback> callback) throws ApiException { + public Call findPetsByStatusAsync(List status, ApiCallback> callback) throws ApiException { Call call = findPetsByStatusCall(status); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } /* Build call for findPetsByTags */ - private Call findPetsByTagsCall(java.util.List tags) throws ApiException { + private Call findPetsByTagsCall(List tags) throws ApiException { Object postBody = null; // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); if (tags != null) queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -237,11 +236,11 @@ public class PetApi { * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return java.util.List + * @return List */ - public java.util.List findPetsByTags(java.util.List tags) throws ApiException { + public List findPetsByTags(List tags) throws ApiException { Call call = findPetsByTagsCall(tags); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -252,9 +251,9 @@ public class PetApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call findPetsByTagsAsync(java.util.List tags, ApiCallback> callback) throws ApiException { + public Call findPetsByTagsAsync(List tags, ApiCallback> callback) throws ApiException { Call call = findPetsByTagsCall(tags); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } @@ -273,11 +272,11 @@ public class PetApi { String path = "/pet/{petId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -335,11 +334,11 @@ public class PetApi { String path = "/pet/{petId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); if (name != null) formParams.put("name", name); if (status != null) @@ -402,13 +401,13 @@ public class PetApi { String path = "/pet/{petId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); if (apiKey != null) headerParams.put("api_key", apiClient.parameterToString(apiKey)); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -465,11 +464,11 @@ public class PetApi { String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); if (additionalMetadata != null) formParams.put("additionalMetadata", additionalMetadata); if (file != null) diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index ff7f02ecf562..cb780538e18d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -6,16 +6,16 @@ import io.swagger.client.ApiException; import io.swagger.client.Configuration; import io.swagger.client.Pair; -import io.swagger.client.model.*; - import com.google.gson.reflect.TypeToken; import com.squareup.okhttp.Call; -import java.lang.reflect.Type; - +import java.util.Map; import io.swagger.client.model.Order; +import java.lang.reflect.Type; +import java.util.*; + public class StoreApi { private ApiClient apiClient; @@ -44,11 +44,11 @@ public class StoreApi { // create path and map variables String path = "/store/inventory".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -69,11 +69,11 @@ public class StoreApi { /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return java.util.Map + * @return Map */ - public java.util.Map getInventory() throws ApiException { + public Map getInventory() throws ApiException { Call call = getInventoryCall(); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -83,9 +83,9 @@ public class StoreApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call getInventoryAsync(ApiCallback> callback) throws ApiException { + public Call getInventoryAsync(ApiCallback> callback) throws ApiException { Call call = getInventoryCall(); - Type returnType = new TypeToken>(){}.getType(); + Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } @@ -98,11 +98,11 @@ public class StoreApi { // create path and map variables String path = "/store/order".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -160,11 +160,11 @@ public class StoreApi { String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -222,11 +222,11 @@ public class StoreApi { String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index dccd7003b2b7..a04470b3b405 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -6,15 +6,15 @@ import io.swagger.client.ApiException; import io.swagger.client.Configuration; import io.swagger.client.Pair; -import io.swagger.client.model.*; - import com.google.gson.reflect.TypeToken; import com.squareup.okhttp.Call; -import java.lang.reflect.Type; - import io.swagger.client.model.User; +import java.util.*; + +import java.lang.reflect.Type; +import java.util.*; public class UserApi { private ApiClient apiClient; @@ -44,11 +44,11 @@ public class UserApi { // create path and map variables String path = "/user".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -90,18 +90,18 @@ public class UserApi { } /* Build call for createUsersWithArrayInput */ - private Call createUsersWithArrayInputCall(java.util.List body) throws ApiException { + private Call createUsersWithArrayInputCall(List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -124,7 +124,7 @@ public class UserApi { * * @param body List of user object */ - public void createUsersWithArrayInput(java.util.List body) throws ApiException { + public void createUsersWithArrayInput(List body) throws ApiException { Call call = createUsersWithArrayInputCall(body); apiClient.execute(call); } @@ -136,25 +136,25 @@ public class UserApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call createUsersWithArrayInputAsync(java.util.List body, ApiCallback callback) throws ApiException { + public Call createUsersWithArrayInputAsync(List body, ApiCallback callback) throws ApiException { Call call = createUsersWithArrayInputCall(body); apiClient.executeAsync(call, callback); return call; } /* Build call for createUsersWithListInput */ - private Call createUsersWithListInputCall(java.util.List body) throws ApiException { + private Call createUsersWithListInputCall(List body) throws ApiException { Object postBody = body; // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -177,7 +177,7 @@ public class UserApi { * * @param body List of user object */ - public void createUsersWithListInput(java.util.List body) throws ApiException { + public void createUsersWithListInput(List body) throws ApiException { Call call = createUsersWithListInputCall(body); apiClient.execute(call); } @@ -189,7 +189,7 @@ public class UserApi { * @param callback The callback to be executed when the API call finishes * @return The request call */ - public Call createUsersWithListInputAsync(java.util.List body, ApiCallback callback) throws ApiException { + public Call createUsersWithListInputAsync(List body, ApiCallback callback) throws ApiException { Call call = createUsersWithListInputCall(body); apiClient.executeAsync(call, callback); return call; @@ -203,15 +203,15 @@ public class UserApi { // create path and map variables String path = "/user/login".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); if (username != null) queryParams.addAll(apiClient.parameterToPairs("", "username", username)); if (password != null) queryParams.addAll(apiClient.parameterToPairs("", "password", password)); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -265,11 +265,11 @@ public class UserApi { // create path and map variables String path = "/user/logout".replaceAll("\\{format\\}","json"); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -322,11 +322,11 @@ public class UserApi { String path = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -384,11 +384,11 @@ public class UserApi { String path = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" @@ -445,11 +445,11 @@ public class UserApi { String path = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - java.util.List queryParams = new java.util.ArrayList(); + List queryParams = new ArrayList(); - java.util.Map headerParams = new java.util.HashMap(); + Map headerParams = new HashMap(); - java.util.Map formParams = new java.util.HashMap(); + Map formParams = new HashMap(); final String[] accepts = { "application/json", "application/xml" diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java index 57c9f791e97c..df8e77b6fb35 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java @@ -1,6 +1,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; +import java.util.Date; import com.google.gson.annotations.SerializedName; @@ -23,7 +24,7 @@ public class Order { private Integer quantity = null; @SerializedName("shipDate") - private java.util.Date shipDate = null; + private Date shipDate = null; public enum StatusEnum { @@ -92,10 +93,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public java.util.Date getShipDate() { + public Date getShipDate() { return shipDate; } - public void setShipDate(java.util.Date shipDate) { + public void setShipDate(Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java index 4b214d56c01e..9ab5457e26ac 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java @@ -2,6 +2,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; +import java.util.*; import io.swagger.client.model.Tag; import com.google.gson.annotations.SerializedName; @@ -25,10 +26,10 @@ public class Pet { private String name = null; @SerializedName("photoUrls") - private java.util.List photoUrls = new java.util.ArrayList(); + private List photoUrls = new ArrayList(); @SerializedName("tags") - private java.util.List tags = new java.util.ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { @@ -94,10 +95,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(required = true, value = "") - public java.util.List getPhotoUrls() { + public List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(java.util.List photoUrls) { + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } @@ -105,10 +106,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public java.util.List getTags() { + public List getTags() { return tags; } - public void setTags(java.util.List tags) { + public void setTags(List tags) { this.tags = tags; } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index 568e17b6cfc0..f6b29f11a2af 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -1,7 +1,5 @@ package io.swagger.client.api; -import io.swagger.client.model.*; - import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; @@ -9,6 +7,8 @@ import retrofit.mime.*; import io.swagger.client.model.Pet; import java.io.File; +import java.util.*; + public interface PetApi { /** @@ -68,12 +68,12 @@ public interface PetApi { * Sync method * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter - * @return java.util.List + * @return List */ @GET("/pet/findByStatus") - java.util.List findPetsByStatus( - @Query("status") java.util.List status + List findPetsByStatus( + @Query("status") List status ); /** @@ -86,7 +86,7 @@ public interface PetApi { @GET("/pet/findByStatus") void findPetsByStatus( - @Query("status") java.util.List status, Callback> cb + @Query("status") List status, Callback> cb ); /** @@ -94,12 +94,12 @@ public interface PetApi { * Sync method * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return java.util.List + * @return List */ @GET("/pet/findByTags") - java.util.List findPetsByTags( - @Query("tags") java.util.List tags + List findPetsByTags( + @Query("tags") List tags ); /** @@ -112,7 +112,7 @@ public interface PetApi { @GET("/pet/findByTags") void findPetsByTags( - @Query("tags") java.util.List tags, Callback> cb + @Query("tags") List tags, Callback> cb ); /** diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index ce9e9456859f..16819d04a94d 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -1,24 +1,25 @@ package io.swagger.client.api; -import io.swagger.client.model.*; - import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; +import java.util.Map; import io.swagger.client.model.Order; +import java.util.*; + public interface StoreApi { /** * Returns pet inventories by status * Sync method * Returns a map of status codes to quantities - * @return java.util.Map + * @return Map */ @GET("/store/inventory") - java.util.Map getInventory(); + Map getInventory(); /** @@ -30,7 +31,7 @@ public interface StoreApi { @GET("/store/inventory") void getInventory( - Callback> cb + Callback> cb ); /** diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java index 57b8f66f4277..a5bc4d03477d 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java @@ -1,12 +1,13 @@ package io.swagger.client.api; -import io.swagger.client.model.*; - import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; import io.swagger.client.model.User; +import java.util.*; + +import java.util.*; public interface UserApi { @@ -46,7 +47,7 @@ public interface UserApi { @POST("/user/createWithArray") Void createUsersWithArrayInput( - @Body java.util.List body + @Body List body ); /** @@ -59,7 +60,7 @@ public interface UserApi { @POST("/user/createWithArray") void createUsersWithArrayInput( - @Body java.util.List body, Callback cb + @Body List body, Callback cb ); /** @@ -72,7 +73,7 @@ public interface UserApi { @POST("/user/createWithList") Void createUsersWithListInput( - @Body java.util.List body + @Body List body ); /** @@ -85,7 +86,7 @@ public interface UserApi { @POST("/user/createWithList") void createUsersWithListInput( - @Body java.util.List body, Callback cb + @Body List body, Callback cb ); /** diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java index 57c9f791e97c..df8e77b6fb35 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java @@ -1,6 +1,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; +import java.util.Date; import com.google.gson.annotations.SerializedName; @@ -23,7 +24,7 @@ public class Order { private Integer quantity = null; @SerializedName("shipDate") - private java.util.Date shipDate = null; + private Date shipDate = null; public enum StatusEnum { @@ -92,10 +93,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public java.util.Date getShipDate() { + public Date getShipDate() { return shipDate; } - public void setShipDate(java.util.Date shipDate) { + public void setShipDate(Date shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java index 4b214d56c01e..9ab5457e26ac 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java @@ -2,6 +2,7 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; +import java.util.*; import io.swagger.client.model.Tag; import com.google.gson.annotations.SerializedName; @@ -25,10 +26,10 @@ public class Pet { private String name = null; @SerializedName("photoUrls") - private java.util.List photoUrls = new java.util.ArrayList(); + private List photoUrls = new ArrayList(); @SerializedName("tags") - private java.util.List tags = new java.util.ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { @@ -94,10 +95,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(required = true, value = "") - public java.util.List getPhotoUrls() { + public List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(java.util.List photoUrls) { + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } @@ -105,10 +106,10 @@ public enum StatusEnum { /** **/ @ApiModelProperty(value = "") - public java.util.List getTags() { + public List getTags() { return tags; } - public void setTags(java.util.List tags) { + public void setTags(List tags) { this.tags = tags; } From 5ed52b3e1d2b04d3d55a3f18280dabee9f7215c3 Mon Sep 17 00:00:00 2001 From: cbornet Date: Mon, 12 Oct 2015 16:16:38 +0200 Subject: [PATCH 4/9] add gradle files with android support --- .../codegen/languages/JavaClientCodegen.java | 5 +- .../main/resources/Java/build.gradle.mustache | 107 ++++++++++++++++++ .../resources/Java/gradle.properties.mustache | 2 + .../libraries/jersey2/build.gradle.mustache | 107 ++++++++++++++++++ .../okhttp-gson/build.gradle.mustache | 102 +++++++++++++---- .../libraries/retrofit/build.gradle.mustache | 103 +++++++++++++++++ .../resources/Java/settings.gradle.mustache | 1 + .../client/petstore/java/default/build.gradle | 107 ++++++++++++++++++ .../petstore/java/default/gradle.properties | 2 + .../petstore/java/default/settings.gradle | 1 + .../client/petstore/java/jersey2/build.gradle | 107 ++++++++++++++++++ .../petstore/java/jersey2/gradle.properties | 2 + .../petstore/java/jersey2/settings.gradle | 1 + .../petstore/java/okhttp-gson/build.gradle | 102 +++++++++++++---- .../java/okhttp-gson/gradle.properties | 2 + .../petstore/java/okhttp-gson/settings.gradle | 1 + .../petstore/java/retrofit/build.gradle | 103 +++++++++++++++++ .../petstore/java/retrofit/gradle.properties | 2 + .../petstore/java/retrofit/settings.gradle | 1 + 19 files changed, 818 insertions(+), 40 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/gradle.properties.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/settings.gradle.mustache create mode 100644 samples/client/petstore/java/default/build.gradle create mode 100644 samples/client/petstore/java/default/gradle.properties create mode 100644 samples/client/petstore/java/default/settings.gradle create mode 100644 samples/client/petstore/java/jersey2/build.gradle create mode 100644 samples/client/petstore/java/jersey2/gradle.properties create mode 100644 samples/client/petstore/java/jersey2/settings.gradle create mode 100644 samples/client/petstore/java/okhttp-gson/gradle.properties create mode 100644 samples/client/petstore/java/okhttp-gson/settings.gradle create mode 100644 samples/client/petstore/java/retrofit/build.gradle create mode 100644 samples/client/petstore/java/retrofit/gradle.properties create mode 100644 samples/client/petstore/java/retrofit/settings.gradle diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 360dc9c0f2f0..1d56c340dea4 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -156,6 +156,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); + supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle")); + supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); + supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); @@ -177,8 +180,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if ("okhttp-gson".equals(getLibrary())) { // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java")); - // "build.gradle" is for development with Gradle - supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle")); // "build.sbt" is for development with SBT supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); } else if ("retrofit".equals(getLibrary())) { diff --git a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache new file mode 100644 index 000000000000..971dcd816a49 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache @@ -0,0 +1,107 @@ +group = '{{groupId}}' +version = '{{artifactVersion}}' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = '{{artifactId}}' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + swagger_annotations_version = "1.5.0" + jackson_version = "2.4.2" + jersey_version = "1.18" + jodatime_version = "2.3" + junit_version = "4.8.1" +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.sun.jersey:jersey-client:$jersey_version" + compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile "joda-time:joda-time:$jodatime_version" + testCompile "junit:junit:$junit_version" +} diff --git a/modules/swagger-codegen/src/main/resources/Java/gradle.properties.mustache b/modules/swagger-codegen/src/main/resources/Java/gradle.properties.mustache new file mode 100644 index 000000000000..05644f0754af --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/gradle.properties.mustache @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache new file mode 100644 index 000000000000..548c1854e5e1 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache @@ -0,0 +1,107 @@ +group = '{{groupId}}' +version = '{{artifactVersion}}' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = '{{artifactId}}' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + swagger_annotations_version = "1.5.0" + jackson_version = "2.4.2" + jersey_version = "2.6" + jodatime_version = "2.3" + junit_version = "4.8.1" +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "org.glassfish.jersey.core:jersey-client:$jersey_version" + compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile "joda-time:joda-time:$jodatime_version" + testCompile "junit:junit:$junit_version" +} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache index 02e1caa673af..289f9a6df722 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache @@ -1,11 +1,89 @@ -apply plugin: 'java' -apply plugin: 'maven' +group = '{{groupId}}' +version = '{{artifactVersion}}' -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} repositories { - mavenCentral() + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = '{{artifactId}}' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } } dependencies { @@ -15,17 +93,3 @@ dependencies { compile 'com.brsanthu:migbase64:2.2' testCompile 'junit:junit:4.8.1' } - -group = '{{groupId}}' -version = '{{artifactVersion}}' - -install { - repositories.mavenInstaller { - pom.artifactId = '{{artifactId}}' - } -} - -task execute(type:JavaExec) { - main = System.getProperty('mainClass') - classpath = sourceSets.main.runtimeClasspath -} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache new file mode 100644 index 000000000000..a285745505ac --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache @@ -0,0 +1,103 @@ +group = '{{groupId}}' +version = '{{artifactVersion}}' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = '{{artifactId}}' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + okhttp_version = "2.3.0" + oltu_version = "1.0.0" + retrofit_version = "1.9.0" + swagger_annotations_version = "1.5.0" + junit_version = "4.12" +} + +dependencies { + compile "com.squareup.okhttp:okhttp:$okhttp_version" + compile "com.squareup.retrofit:retrofit:$retrofit_version" + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" + testCompile "junit:junit:$junit_version" +} diff --git a/modules/swagger-codegen/src/main/resources/Java/settings.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/settings.gradle.mustache new file mode 100644 index 000000000000..b8fd6c4c41f9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/settings.gradle.mustache @@ -0,0 +1 @@ +rootProject.name = "{{artifactId}}" \ No newline at end of file diff --git a/samples/client/petstore/java/default/build.gradle b/samples/client/petstore/java/default/build.gradle new file mode 100644 index 000000000000..baa5ce97b015 --- /dev/null +++ b/samples/client/petstore/java/default/build.gradle @@ -0,0 +1,107 @@ +group = 'io.swagger' +version = '1.0.0' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = 'swagger-java-client' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + swagger_annotations_version = "1.5.0" + jackson_version = "2.4.2" + jersey_version = "1.18" + jodatime_version = "2.3" + junit_version = "4.8.1" +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.sun.jersey:jersey-client:$jersey_version" + compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile "joda-time:joda-time:$jodatime_version" + testCompile "junit:junit:$junit_version" +} diff --git a/samples/client/petstore/java/default/gradle.properties b/samples/client/petstore/java/default/gradle.properties new file mode 100644 index 000000000000..05644f0754af --- /dev/null +++ b/samples/client/petstore/java/default/gradle.properties @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/samples/client/petstore/java/default/settings.gradle b/samples/client/petstore/java/default/settings.gradle new file mode 100644 index 000000000000..55640f75122e --- /dev/null +++ b/samples/client/petstore/java/default/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "swagger-java-client" \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle new file mode 100644 index 000000000000..9727e5693e6d --- /dev/null +++ b/samples/client/petstore/java/jersey2/build.gradle @@ -0,0 +1,107 @@ +group = 'io.swagger' +version = '1.0.0' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = 'swagger-petstore-jersey2' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + swagger_annotations_version = "1.5.0" + jackson_version = "2.4.2" + jersey_version = "2.6" + jodatime_version = "2.3" + junit_version = "4.8.1" +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "org.glassfish.jersey.core:jersey-client:$jersey_version" + compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile "joda-time:joda-time:$jodatime_version" + testCompile "junit:junit:$junit_version" +} diff --git a/samples/client/petstore/java/jersey2/gradle.properties b/samples/client/petstore/java/jersey2/gradle.properties new file mode 100644 index 000000000000..05644f0754af --- /dev/null +++ b/samples/client/petstore/java/jersey2/gradle.properties @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2/settings.gradle b/samples/client/petstore/java/jersey2/settings.gradle new file mode 100644 index 000000000000..498d426abeeb --- /dev/null +++ b/samples/client/petstore/java/jersey2/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "swagger-petstore-jersey2" \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson/build.gradle b/samples/client/petstore/java/okhttp-gson/build.gradle index ada6a992573a..eea46b819d02 100644 --- a/samples/client/petstore/java/okhttp-gson/build.gradle +++ b/samples/client/petstore/java/okhttp-gson/build.gradle @@ -1,11 +1,89 @@ -apply plugin: 'java' -apply plugin: 'maven' +group = 'io.swagger' +version = '1.0.0' -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} repositories { - mavenCentral() + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = 'swagger-petstore-okhttp-gson' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } } dependencies { @@ -15,17 +93,3 @@ dependencies { compile 'com.brsanthu:migbase64:2.2' testCompile 'junit:junit:4.8.1' } - -group = 'io.swagger' -version = '1.0.0' - -install { - repositories.mavenInstaller { - pom.artifactId = 'swagger-petstore-okhttp-gson' - } -} - -task execute(type:JavaExec) { - main = System.getProperty('mainClass') - classpath = sourceSets.main.runtimeClasspath -} diff --git a/samples/client/petstore/java/okhttp-gson/gradle.properties b/samples/client/petstore/java/okhttp-gson/gradle.properties new file mode 100644 index 000000000000..05644f0754af --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/gradle.properties @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson/settings.gradle b/samples/client/petstore/java/okhttp-gson/settings.gradle new file mode 100644 index 000000000000..b73eec845910 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "swagger-petstore-okhttp-gson" \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit/build.gradle b/samples/client/petstore/java/retrofit/build.gradle new file mode 100644 index 000000000000..710d9da9a54c --- /dev/null +++ b/samples/client/petstore/java/retrofit/build.gradle @@ -0,0 +1,103 @@ +group = 'io.swagger' +version = '1.0.0' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.github.dcendents:android-maven-plugin:1.2' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 22 + buildToolsVersion '22.0.0' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 + + install { + repositories.mavenInstaller { + pom.artifactId = 'swagger-petstore-retrofit' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + okhttp_version = "2.3.0" + oltu_version = "1.0.0" + retrofit_version = "1.9.0" + swagger_annotations_version = "1.5.0" + junit_version = "4.12" +} + +dependencies { + compile "com.squareup.okhttp:okhttp:$okhttp_version" + compile "com.squareup.retrofit:retrofit:$retrofit_version" + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" + testCompile "junit:junit:$junit_version" +} diff --git a/samples/client/petstore/java/retrofit/gradle.properties b/samples/client/petstore/java/retrofit/gradle.properties new file mode 100644 index 000000000000..05644f0754af --- /dev/null +++ b/samples/client/petstore/java/retrofit/gradle.properties @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit/settings.gradle b/samples/client/petstore/java/retrofit/settings.gradle new file mode 100644 index 000000000000..7e540c099de9 --- /dev/null +++ b/samples/client/petstore/java/retrofit/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "swagger-petstore-retrofit" \ No newline at end of file From 17545e959ac3edf1bd5bca87821b72e16399e9c5 Mon Sep 17 00:00:00 2001 From: xhh Date: Tue, 13 Oct 2015 10:32:07 +0800 Subject: [PATCH 5/9] Handle enum names starting with number in Java client --- .../io/swagger/codegen/languages/JavaClientCodegen.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 360dc9c0f2f0..df4f07e25e6a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -426,7 +426,12 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } private String toEnumVarName(String value) { - return value.replaceAll("\\W+", "_").toUpperCase(); + String var = value.replaceAll("\\W+", "_").toUpperCase(); + if (var.matches("\\d.*")) { + return "_" + var; + } else { + return var; + } } private CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) { From 4e7d893a8e637d1072791a8422d4465412fce657 Mon Sep 17 00:00:00 2001 From: aersamkull Date: Tue, 13 Oct 2015 12:01:34 +0200 Subject: [PATCH 6/9] Updates to TypeScript Templates --- .../resources/TypeScript-Angular/api.mustache | 14 +++++++------- .../resources/TypeScript-Angular/model.mustache | 6 +++--- .../main/resources/TypeScript-node/api.mustache | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache index 233ead8bee48..2045dd353826 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache @@ -3,7 +3,7 @@ /* tslint:disable:no-unused-variable member-ordering */ {{#operations}} -module {{package}} { +namespace {{package}} { 'use strict'; {{#description}} @@ -24,16 +24,16 @@ module {{package}} { {{#operation}} public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { - var path = this.basePath + '{{path}}'; + let path = this.basePath + '{{path}}'; {{#pathParams}} path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}})); {{/pathParams}} - var queryParameters: any = {}; - var headerParams: any = {}; + let queryParameters: any = {}; + let headerParams: any = {}; {{#hasFormParams}} - var formParams: any = {}; + let formParams: any = {}; {{/hasFormParams}} {{#allParams}} @@ -63,7 +63,7 @@ module {{package}} { formParams['{{baseName}}'] = {{paramName}}; {{/formParams}} - var httpRequestParams: any = { + let httpRequestParams: any = { method: '{{httpMethod}}', url: path, json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}}, @@ -76,7 +76,7 @@ module {{package}} { }; if (extraHttpRequestParams) { - for (var k in extraHttpRequestParams) { + for (let k in extraHttpRequestParams) { if (extraHttpRequestParams.hasOwnProperty(k)) { httpRequestParams[k] = extraHttpRequestParams[k]; } diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache index b425d14d5e43..5b57ed4dc94f 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache @@ -1,6 +1,6 @@ /// -module {{package}} { +namespace {{package}} { 'use strict'; {{#models}} @@ -10,7 +10,7 @@ module {{package}} { * {{{description}}} */ {{/description}} - export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ + export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{#vars}} {{#description}} @@ -23,7 +23,7 @@ module {{package}} { } {{#hasEnums}} - export module {{classname}} { + export namespace {{classname}} { {{#vars}} {{#isEnum}} diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache index 6528a5d3a22c..4d03ae0f4248 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache @@ -27,7 +27,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ } {{#hasEnums}} -export module {{classname}} { +export namespace {{classname}} { {{#vars}} {{#isEnum}} export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} @@ -157,15 +157,15 @@ export class {{classname}} { {{#operation}} public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> { - var path = this.url + this.basePath + '{{path}}'; + let path = this.url + this.basePath + '{{path}}'; {{#pathParams}} path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}})); {{/pathParams}} - var queryParameters: any = {}; - var headerParams: any = {}; - var formParams: any = {}; + let queryParameters: any = {}; + let headerParams: any = {}; + let formParams: any = {}; {{#allParams}}{{#required}} // verify required parameter '{{paramName}}' is set @@ -183,7 +183,7 @@ export class {{classname}} { headerParams['{{baseName}}'] = {{paramName}}; {{/headerParams}} - var useFormData = false; + let useFormData = false; {{#formParams}} if ({{paramName}} !== undefined) { @@ -194,9 +194,9 @@ export class {{classname}} { {{/isFile}} {{/formParams}} - var deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>(); + let deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>(); - var requestOptions: request.Options = { + let requestOptions: request.Options = { method: '{{httpMethod}}', qs: queryParameters, headers: headerParams, From f603efc419e79dab5b0840f634c8581b5b01dbb2 Mon Sep 17 00:00:00 2001 From: cbornet Date: Tue, 13 Oct 2015 12:18:32 +0200 Subject: [PATCH 7/9] add retrofit to CI verified samples --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index d2cbadb394fd..27ce57442785 100644 --- a/pom.xml +++ b/pom.xml @@ -426,6 +426,7 @@ samples/client/petstore/java/default samples/client/petstore/java/jersey2 samples/client/petstore/java/okhttp-gson + samples/client/petstore/java/retrofit samples/client/petstore/scala samples/server/petstore/spring-mvc From 988de07c1798890d0468ecfdcfe32db5a246b119 Mon Sep 17 00:00:00 2001 From: aersamkull Date: Tue, 13 Oct 2015 13:32:01 +0200 Subject: [PATCH 8/9] Fixes noImplicitAny Error --- .../src/main/resources/TypeScript-Angular/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache index 2045dd353826..9681634a765a 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache @@ -16,7 +16,7 @@ namespace {{package}} { static $inject: string[] = ['$http', '$httpParamSerializer']; - constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (any) => any) { + constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (d: any) => any) { if (basePath) { this.basePath = basePath; } From 6d50ce6a774f1545234b7f8244921226824a6aca Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 15 Oct 2015 10:34:45 +0800 Subject: [PATCH 9/9] Fix a typo --- .../java/io/swagger/codegen/languages/JavaClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 5d61f1b59324..c559cf83f237 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -83,7 +83,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC)); cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC)); - cliOptions.add(new CliOption("fullJavaUtil", "whether to use full qualified name for classes under java.util (default to false)")); + cliOptions.add(new CliOption("fullJavaUtil", "whether to use fully qualified name for classes under java.util (default to false)")); supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");