diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index b795f8e38e2..4f30cc01ccb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -30,6 +30,23 @@ public class CodegenOperation { public List> examples; public ExternalDocs externalDocs; + private boolean nonempty(List params) + { + return params != null && params.size() > 0; + } + public boolean getHasBodyParam() { + return nonempty(bodyParams); + } + public boolean getHasQueryParams() { + return nonempty(bodyParams); + } + public boolean getHasHeaderParams() { + return nonempty(bodyParams); + } + public boolean getHasPathParams() { + return nonempty(bodyParams); + } + // legacy support public String nickname; } 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 954c106bdfe..2f938a3c4c3 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 @@ -639,7 +639,9 @@ public class DefaultCodegen { if (np.getMaximum() != null) { allowableValues.put("max", np.getMaximum()); } - property.allowableValues = allowableValues; + if(allowableValues.size() > 0) { + property.allowableValues = allowableValues; + } } if (p instanceof StringProperty) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 3b484dc9fdf..aef8815955e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -17,6 +17,7 @@ import io.swagger.models.parameters.Parameter; import io.swagger.util.Json; import org.apache.commons.io.IOUtils; +import org.joda.time.DateTime; import java.io.File; import java.io.FileInputStream; @@ -63,6 +64,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { List files = new ArrayList(); try { config.processOpts(); + + config.additionalProperties().put("generatedDate", DateTime.now().toString()); + config.additionalProperties().put("generatorClass", config.getClass().toString()); + if (swagger.getInfo() != null) { Info info = swagger.getInfo(); if (info.getTitle() != null) { @@ -189,7 +194,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); - if (!config.shouldOverwrite(filename)) { + if (!config.shouldOverwrite(filename) && new File(filename).exists()) { continue; } 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 171753fc51e..6706ae344f8 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 @@ -96,7 +96,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public void processOpts() { super.processOpts(); - + if (additionalProperties.containsKey("invokerPackage")) { this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); } else { @@ -134,6 +134,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix")); } + this.sanitizeConfig(); + final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); @@ -151,7 +153,26 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java")); } - + private void sanitizeConfig() { + // 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("apiPackage")) { + this.additionalProperties.put("apiPackage", apiPackage); + } + + this.setModelPackage(sanitizePackageName(modelPackage)); + if (additionalProperties.containsKey("modelPackage")) { + this.additionalProperties.put("modelPackage", modelPackage); + } + + this.setInvokerPackage(sanitizePackageName(invokerPackage)); + if (additionalProperties.containsKey("invokerPackage")) { + this.additionalProperties.put("invokerPackage", invokerPackage); + } + } + @Override public String escapeReservedWord(String name) { return "_" + name; @@ -347,4 +368,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public void setLocalVariablePrefix(String localVariablePrefix) { this.localVariablePrefix = localVariablePrefix; } + + private String sanitizePackageName(String packageName) { + packageName = packageName.trim(); + packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_"); + if(Strings.isNullOrEmpty(packageName)) { + return "invalidPackageName"; + } + return packageName; + } + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index e0e1bdc07f8..61dc431b8a7 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -119,7 +119,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig @Override public String escapeReservedWord(String name) { - return name + "_"; + return "_" + name; } @Override @@ -179,14 +179,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig // petId => pet_id name = underscore(dropDots(name)); + // remove leading underscore + name = name.replaceAll("^_*", ""); + // for reserved word or word starting with number, append _ if (reservedWords.contains(name) || name.matches("^\\d.*")) { name = escapeReservedWord(name); } - // remove leading underscore - name = name.replaceAll("^_*", ""); - return name; } diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 5e87f9e1a5a..4e691c27493 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -38,6 +38,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth; import {{invokerPackage}}.auth.ApiKeyAuth; import {{invokerPackage}}.auth.OAuth; +{{>generatedAnnotation}} public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache b/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache index e936b423a91..4629c4e17be 100644 --- a/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache @@ -1,5 +1,6 @@ package {{invokerPackage}}; +{{>generatedAnnotation}} public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/modules/swagger-codegen/src/main/resources/Java/JSON.mustache b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache index 842920f2662..4f90c6190b2 100644 --- a/modules/swagger-codegen/src/main/resources/Java/JSON.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache @@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; +{{>generatedAnnotation}} public class JSON { private ObjectMapper mapper; diff --git a/modules/swagger-codegen/src/main/resources/Java/Pair.mustache b/modules/swagger-codegen/src/main/resources/Java/Pair.mustache index 9805c74903b..e2a47317afe 100644 --- a/modules/swagger-codegen/src/main/resources/Java/Pair.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/Pair.mustache @@ -1,5 +1,6 @@ package {{invokerPackage}}; +{{>generatedAnnotation}} public class Pair { private String name = ""; private String value = ""; diff --git a/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache b/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache index 035d6739dce..073966b0c21 100644 --- a/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache @@ -1,5 +1,6 @@ package {{invokerPackage}}; +{{>generatedAnnotation}} public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache b/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache index 5de0b840aa7..9e9ba5f8895 100644 --- a/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache @@ -3,6 +3,7 @@ package {{invokerPackage}}; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +{{>generatedAnnotation}} public class TypeRef { private final Type type; diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index a774816ca19..a4dc5e6f903 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { private ApiClient {{localVariablePrefix}}apiClient; diff --git a/modules/swagger-codegen/src/main/resources/Java/apiException.mustache b/modules/swagger-codegen/src/main/resources/Java/apiException.mustache index 9afe96c6ffb..bb3b53b0aeb 100644 --- a/modules/swagger-codegen/src/main/resources/Java/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/apiException.mustache @@ -3,6 +3,7 @@ package {{invokerPackage}}; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public class ApiException extends Exception { private int code = 0; private String message = null; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache index a1824b551ca..04be4812292 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache @@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache index 265c74cb76f..037ef58ab90 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache @@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache index 032ea57d4e8..63813e2504e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache @@ -8,6 +8,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; +{{>generatedAnnotation}} public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache index 66cf2ac8f0f..a1f1b6a827c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache @@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public class OAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { diff --git a/modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache new file mode 100644 index 00000000000..49110fc1ad9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache index 35a1cf24242..fb5f6b0d107 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -43,6 +43,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth; import {{invokerPackage}}.auth.ApiKeyAuth; import {{invokerPackage}}.auth.OAuth; +{{>generatedAnnotation}} public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index 0e12f514c48..39f0f0b6fa1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache index 5f5b5b1df9a..829a9daeabc 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache @@ -13,6 +13,7 @@ import {{modelPackage}}.*; {{#imports}}import {{import}}; {{/imports}} +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache new file mode 100644 index 00000000000..49110fc1ad9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache index 300d5e61dd9..db2480a8540 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache index ffab3b1088e..11b4036b832 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache index 68675432c64..5db3301b3d9 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache @@ -5,6 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +{{>generatedAnnotation}} public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache index 94711b26efb..2b9a2b1f8c5 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache @@ -3,6 +3,7 @@ package {{apiPackage}}; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +{{>generatedAnnotation}} public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache index 8ab2c99e4f8..1bd5e207d7b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache index 3216b60d516..9e1f808806e 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache @@ -26,6 +26,7 @@ import javax.ws.rs.*; {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API") +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache index 43e7cd8685c..a731da6c11c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +{{>generatedAnnotation}} {{#operations}} public abstract class {{classname}}Service { {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache index a434311d285..1bb63bc0775 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache @@ -3,6 +3,7 @@ package {{package}}.factories; import {{package}}.{{classname}}Service; import {{package}}.impl.{{classname}}ServiceImpl; +{{>generatedAnnotation}} public class {{classname}}ServiceFactory { private final static {{classname}}Service service = new {{classname}}ServiceImpl(); diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache index d49fa4952a2..0acd755745e 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +{{>generatedAnnotation}} {{#operations}} public class {{classname}}ServiceImpl extends {{classname}}Service { {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache new file mode 100644 index 00000000000..49110fc1ad9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache index 300d5e61dd9..db2480a8540 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache index d6a24b69311..e6e8d6fc04c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache @@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/{{baseName}}", description = "the {{baseName}} API") +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache index ffab3b1088e..11b4036b832 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache index 68675432c64..5db3301b3d9 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache @@ -5,6 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +{{>generatedAnnotation}} public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache index 94711b26efb..2b9a2b1f8c5 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache @@ -3,6 +3,7 @@ package {{apiPackage}}; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +{{>generatedAnnotation}} public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache new file mode 100644 index 00000000000..49110fc1ad9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache index 300d5e61dd9..db2480a8540 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache index 8ab2c99e4f8..1bd5e207d7b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache index b33ee7fc994..4a6e6879df3 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache @@ -18,6 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 //Loads the spring beans required by the framework @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) +{{>generatedAnnotation}} public class SwaggerConfig { @Bean ApiInfo apiInfo() { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache index 652dc310358..0b515fe2cc8 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache @@ -8,6 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc +{{>generatedAnnotation}} public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache index 6910ad11b76..426f831582e 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache @@ -2,6 +2,7 @@ package {{configPackage}}; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; +{{>generatedAnnotation}} public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { @Override diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache index 03904e51e79..d60c126316e 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache @@ -3,6 +3,7 @@ package {{configPackage}}; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +{{>generatedAnnotation}} public class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache index ce881084bc2..584db3b7a85 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache @@ -1,52 +1,158 @@ - + + + - - API Reference + {{{appName}}} + +

{{{appName}}}

-
{{{appDescription}}} for {{partner}}
+
{{{appDescription}}}
{{#infoUrl}}
More information: {{{infoUrl}}}
{{/infoUrl}} {{#infoEmail}}
Contact Info: {{{infoEmail}}}
{{/infoEmail}} {{#version}}
Version: {{{version}}}
{{/version}}
{{{licenseInfo}}}
{{{licenseUrl}}}

Access

-
Customize this message as you see fit!
-

Methods

+ {{access}} + +

Methods

+ [ Jump to Models ] + + {{! for the tables of content, I cheat and don't use CSS styles.... }} +

Table of Contents

+
{{access}}
+ {{#apiInfo}} +
    + {{#apis}} + {{#operations}} + {{#operation}} +
  1. {{httpMethod}} {{path}}
  2. + {{/operation}} + {{/operations}} + {{/apis}} +
+ {{/apiInfo}} + {{#apiInfo}} {{#apis}} - {{#operations}}{{#operation}} -
-
{{httpMethod}}: {{path}}
-
{{#tags}}{{this}}{{/tags}}
-
{{nickname}} {{summary}}
+ {{#operations}} + {{#operation}} +
+
+ Up +
{{httpMethod}} {{path}}
+
{{summary}} ({{nickname}})
+ {{! notes is operation.description. So why rename it and make it super confusing???? }}
{{notes}}
-

Parameters

+ {{#hasPathParams}} +

Path parameters

- {{#allParams}}{{>queryParam}}{{>pathParam}}{{>bodyParam}}{{>headerParam}}{{>formParam}} - {{/allParams}} + {{#pathParams}}{{>pathParam}}{{/pathParams}}
+ {{/hasPathParams}} + + {{#hasConsumes}} +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + {{#consumes}} +
  • {{mediaType}}
  • + {{/consumes}} +
+ {{/hasConsumes}} + + {{#hasBodyParam}} +

Request body

+
+ {{#bodyParams}}{{>bodyParam}}{{/bodyParams}} +
+ {{/hasBodyParam}} + + {{#hasHeaderParam}} +

Request headers

+
+ {{#headerParam}}{{>headerParam}}{{/headerParam}} +
+ {{/hasHeaderParam}} + + {{#hasQueryParams}} +

Query parameters

+
+ {{#queryParams}}{{>queryParam}}{{/queryParams}} +
+ {{/hasQueryParams}} + + + + {{#hasExamples}} + {{#examples}} +

Example data

+
Content-Type: {{{contentType}}}
+
{{{example}}}
+ {{/examples}} + {{/hasExamples}} + + {{#hasProduces}} +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + {{#produces}} +
  • {{mediaType}}
  • + {{/produces}} +
+ {{/hasProduces}} + +

Responses

+ {{#responses}} +

{{code}}

+ {{message}} {{#examples}}

Example data

Content-Type: {{{contentType}}}
{{example}}
{{/examples}} + {{/responses}}
-
- {{/operation}}{{/operations}} - {{/apis}}{{/apiInfo}} +
+ {{/operation}} + {{/operations}} + {{/apis}} + {{/apiInfo}} + + +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    + {{#models}} + {{#model}} +
  1. {{classname}}
  2. + {{/model}} + {{/models}} +
-

Models

{{#models}} {{#model}}
-

{{classname}}

+

{{classname}} Up

{{#vars}}
{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}
{{datatype}} {{description}}
{{/vars}} @@ -54,8 +160,5 @@
{{/model}} {{/models}} - \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache index 14ab06a7f7e..d69f0e7b161 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache @@ -57,6 +57,10 @@ pre { margin-bottom: 2px; } +.http-method { + text-transform: uppercase; +} + pre.get { background-color: #0f6ab4; } @@ -96,6 +100,10 @@ code { background-color: #0f6ab4; } +.up { + float:right; +} + .parameter { width: 500px; } diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index a7d290022f6..b7643de6ddd 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int); -(NSNumber*) requestWithCompletionBlock: (NSString*) path method: (NSString*) method + pathParams: (NSDictionary *) pathParams queryParams: (NSDictionary*) queryParams formParams: (NSDictionary *) formParams files: (NSDictionary *) files @@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int); self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + // sanitize parameters + pathParams = [self sanitizeForSerialization:pathParams]; + queryParams = [self sanitizeForSerialization:queryParams]; + headerParams = [self sanitizeForSerialization:headerParams]; + formParams = [self sanitizeForSerialization:formParams]; + body = [self sanitizeForSerialization:body]; + // auth setting [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; + NSMutableString *resourcePath = [NSMutableString stringWithString:path]; + [pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]] + withString:[SWGApiClient escape:obj]]; + }]; + NSMutableURLRequest * request = nil; - NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams]; + NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams]; if ([pathWithQueryParams hasPrefix:@"/"]) { pathWithQueryParams = [pathWithQueryParams substringFromIndex:1]; } @@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int); } } + // request cache BOOL hasHeaderParams = false; if(headerParams != nil && [headerParams count] > 0) { hasHeaderParams = true; } if(offlineState) { - NSLog(@"%@ cache forced", path); + NSLog(@"%@ cache forced", resourcePath); [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; } else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) { - NSLog(@"%@ cache enabled", path); + NSLog(@"%@ cache enabled", resourcePath); [request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; } else { - NSLog(@"%@ cache disabled", path); + NSLog(@"%@ cache disabled", resourcePath); [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; } @@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int); *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; } +- (id) sanitizeForSerialization:(id) object { + if (object == nil) { + return nil; + } + else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) { + return object; + } + else if ([object isKindOfClass:[NSDate class]]) { + return [object ISO8601String]; + } + else if ([object isKindOfClass:[NSArray class]]) { + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; + [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + if (obj) { + [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; + [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + if (obj) { + [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[SWGObject class]]) { + return [object toDictionary]; + } + else { + NSException *e = [NSException + exceptionWithName:@"InvalidObjectArgumentException" + reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object] + userInfo:nil]; + @throw e; + } +} + @end diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index 46d424d735f..eba62705879 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -168,6 +168,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; * * @param path Request url. * @param method Request method. + * @param pathParams Request path parameters. * @param queryParams Request query parameters. * @param body Request body. * @param headerParams Request header parameters. @@ -180,6 +181,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; */ -(NSNumber*) requestWithCompletionBlock:(NSString*) path method:(NSString*) method + pathParams:(NSDictionary *) pathParams queryParams:(NSDictionary*) queryParams formParams:(NSDictionary *) formParams files:(NSDictionary *) files @@ -191,4 +193,11 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; responseType:(NSString *) responseType completionBlock:(void (^)(id, NSError *))completionBlock; +/** + * Sanitize object for request + * + * @param object The query/path/header/form/body param to be sanitized. + */ +- (id) sanitizeForSerialization:(id) object; + @end diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache index 198c5a89fdf..534c887fe7b 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -88,8 +88,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - {{#pathParams}}[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"{{baseName}}", @"}"]] withString: [{{classPrefix}}ApiClient escape:{{paramName}}]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + {{#pathParams}}if ({{paramName}} != nil) { + pathParams[@"{{baseName}}"] = {{paramName}}; + } {{/pathParams}} NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -132,26 +135,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; {{#bodyParam}} bodyParam = {{paramName}}; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[({{classPrefix}}Object*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [({{classPrefix}}Object*)bodyParam toDictionary]; - } {{/bodyParam}}{{^bodyParam}} {{#formParams}} {{#notFile}} - formParams[@"{{paramName}}"] = {{paramName}}; + if ({{paramName}}) { + formParams[@"{{baseName}}"] = {{paramName}}; + } {{/notFile}}{{#isFile}} files[@"{{paramName}}"] = {{paramName}}; {{/isFile}} @@ -167,6 +156,7 @@ {{/requiredParamCount}} return [self.apiClient requestWithCompletionBlock: resourcePath method: @"{{httpMethod}}" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index ca9a3c05104..7493907d9e8 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -202,11 +202,9 @@ class ApiClient(object): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[key[1:]]: val - for key, val in iteritems(obj.__dict__) - if key != 'swagger_types' - and key != 'attribute_map' - and val is not None} + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} return {key: self.sanitize_for_serialization(val) for key, val in iteritems(obj_dict)} diff --git a/modules/swagger-codegen/src/main/resources/python/configuration.mustache b/modules/swagger-codegen/src/main/resources/python/configuration.mustache index 62633cdc4a1..d6d94ff5a50 100644 --- a/modules/swagger-codegen/src/main/resources/python/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/python/configuration.mustache @@ -23,9 +23,9 @@ import urllib3 try: import httplib except ImportError: - # python3 + # for python3 import http.client as httplib - + import sys import logging diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index c810655e382..4a93aeaf29d 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -86,18 +86,17 @@ class {{classname}}(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala index 81e252aa117..0043045a29d 100644 --- a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala +++ b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala @@ -2,6 +2,7 @@ package Java import io.swagger.codegen.languages.JavaClientCodegen import io.swagger.models._ +import io.swagger.models.parameters._ import io.swagger.models.properties._ import io.swagger.util.Json import org.junit.runner.RunWith @@ -382,7 +383,6 @@ class JavaModelTest2 extends FlatSpec with Matchers { cm.vars.size should be(1) val vars = cm.vars - Json.prettyPrint(vars.get(0)) vars.get(0).baseName should be("_") vars.get(0).getter should be("getU") vars.get(0).setter should be("setU") @@ -393,4 +393,17 @@ class JavaModelTest2 extends FlatSpec with Matchers { vars.get(0).hasMore should equal(null) vars.get(0).isNotContainer should equal(true) } + + it should "convert a parameter" in { + val parameter = new QueryParameter() + .property( + new IntegerProperty()) + .name("limit") + .required(true) + + val codegen = new JavaClientCodegen() + val cp = codegen.fromParameter(parameter, null) + + cp.allowableValues should be (null) + } } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java index c02c9877df4..52c99a5fb60 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java @@ -38,6 +38,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java index a39785eb47e..d42eb0dbf9d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java @@ -3,6 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class ApiException extends Exception { private int code = 0; private String message = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java index 04899a110f6..f2b95e96c5a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java @@ -1,5 +1,6 @@ package io.swagger.client; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java index 4c1fa53430b..0b9487b5858 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class JSON { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java index 4b7112f6db6..4c9c4041834 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java @@ -1,5 +1,6 @@ package io.swagger.client; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java index 5b5af2d5ce0..a27c220dbf3 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java @@ -1,5 +1,6 @@ package io.swagger.client; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java index 6081df1082f..3d68e7e5121 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java @@ -3,6 +3,7 @@ package io.swagger.client; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class TypeRef { private final Type type; 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 c1657233fdc..e6348cdc9e7 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 @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class PetApi { private ApiClient apiClient; 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 6a0c014f266..12b2e69f82f 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 @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class StoreApi { private ApiClient apiClient; 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 0d408637cea..b0e20a035bf 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 @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 0e5ca9c7c53..1ca97409c56 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,6 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java index 98b1a6900b9..892bf1c60ff 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java @@ -5,6 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index 980b24311be..d2161ee0ef1 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -8,6 +8,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java index 39fba5498c0..5c4242abcaf 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,6 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class OAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java index d43f6a9758f..19e0076e309 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class Category { private Long id = null; 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 25864d8c9cc..234b063eb27 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 @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class Order { private Long id = null; 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 f5cdc5fb71f..b680a4f8a50 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 @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java index 63a2ca3b739..ce6d0809265 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java index 0ace5b7e30a..9a75d96d761 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java index 52ce291a768..3ddf4621ae8 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java @@ -43,6 +43,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java index a39785eb47e..48b196e2af7 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -3,6 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class ApiException extends Exception { private int code = 0; private String message = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java index 04899a110f6..e94cd5c0aa3 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -1,5 +1,6 @@ package io.swagger.client; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 4c1fa53430b..0baddcd02c0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class JSON { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java index 4b7112f6db6..cb0e034bd63 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -1,5 +1,6 @@ package io.swagger.client; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java index 5b5af2d5ce0..50e37eb367a 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -1,5 +1,6 @@ package io.swagger.client; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java index 6081df1082f..1444bca5a06 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java @@ -3,6 +3,7 @@ package io.swagger.client; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class TypeRef { private final Type type; 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 c1657233fdc..ca72d88b130 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 @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class PetApi { private ApiClient apiClient; 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 6a0c014f266..2abbae3f714 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 @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class StoreApi { private ApiClient apiClient; 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 0d408637cea..7959290acd6 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 @@ -17,6 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 0e5ca9c7c53..87a4a90a49c 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,6 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java index 98b1a6900b9..b35133a0c94 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java @@ -5,6 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index 980b24311be..7d224efefbb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -8,6 +8,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java index 39fba5498c0..06debad62e4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,6 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class OAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index d43f6a9758f..f0dab47c7f7 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class Category { private Long id = null; 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 25864d8c9cc..671d8366be0 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 @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class Order { private Long id = null; 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 f5cdc5fb71f..036f694ffdd 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 @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 63a2ca3b739..3bf1b196e1d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 0ace5b7e30a..0d454ec95aa 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index 7802a5b46c0..84f28faa8c6 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -172,6 +172,7 @@ extern NSString *const SWGResponseObjectErrorKey; * * @param path Request url. * @param method Request method. + * @param pathParams Request path parameters. * @param queryParams Request query parameters. * @param body Request body. * @param headerParams Request header parameters. @@ -184,6 +185,7 @@ extern NSString *const SWGResponseObjectErrorKey; */ -(NSNumber*) requestWithCompletionBlock:(NSString*) path method:(NSString*) method + pathParams:(NSDictionary *) pathParams queryParams:(NSDictionary*) queryParams formParams:(NSDictionary *) formParams files:(NSDictionary *) files @@ -195,4 +197,11 @@ extern NSString *const SWGResponseObjectErrorKey; responseType:(NSString *) responseType completionBlock:(void (^)(id, NSError *))completionBlock; +/** + * Sanitize object for request + * + * @param object The query/path/header/form/body param to be sanitized. + */ +- (id) sanitizeForSerialization:(id) object; + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index 22b5c256402..906169f4d12 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int); -(NSNumber*) requestWithCompletionBlock: (NSString*) path method: (NSString*) method + pathParams: (NSDictionary *) pathParams queryParams: (NSDictionary*) queryParams formParams: (NSDictionary *) formParams files: (NSDictionary *) files @@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int); self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + // sanitize parameters + pathParams = [self sanitizeForSerialization:pathParams]; + queryParams = [self sanitizeForSerialization:queryParams]; + headerParams = [self sanitizeForSerialization:headerParams]; + formParams = [self sanitizeForSerialization:formParams]; + body = [self sanitizeForSerialization:body]; + // auth setting [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; + NSMutableString *resourcePath = [NSMutableString stringWithString:path]; + [pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]] + withString:[SWGApiClient escape:obj]]; + }]; + NSMutableURLRequest * request = nil; - NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams]; + NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams]; if ([pathWithQueryParams hasPrefix:@"/"]) { pathWithQueryParams = [pathWithQueryParams substringFromIndex:1]; } @@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int); } } + // request cache BOOL hasHeaderParams = false; if(headerParams != nil && [headerParams count] > 0) { hasHeaderParams = true; } if(offlineState) { - NSLog(@"%@ cache forced", path); + NSLog(@"%@ cache forced", resourcePath); [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; } else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) { - NSLog(@"%@ cache enabled", path); + NSLog(@"%@ cache enabled", resourcePath); [request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; } else { - NSLog(@"%@ cache disabled", path); + NSLog(@"%@ cache disabled", resourcePath); [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; } @@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int); *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; } +- (id) sanitizeForSerialization:(id) object { + if (object == nil) { + return nil; + } + else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) { + return object; + } + else if ([object isKindOfClass:[NSDate class]]) { + return [object ISO8601String]; + } + else if ([object isKindOfClass:[NSArray class]]) { + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; + [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + if (obj) { + [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; + [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + if (obj) { + [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[SWGObject class]]) { + return [object toDictionary]; + } + else { + NSException *e = [NSException + exceptionWithName:@"InvalidObjectArgumentException" + reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object] + userInfo:nil]; + @throw e; + } +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h index e340e0e2b86..84f10969e5b 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h @@ -7,8 +7,8 @@ * Do not edit the class manually. */ -#import "SWGTag.h" #import "SWGCategory.h" +#import "SWGTag.h" @protocol SWGPet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index f2e7fb64030..d79584f90bf 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -80,7 +80,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -115,27 +116,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"PUT" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -172,7 +158,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -207,27 +194,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -264,7 +236,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -310,6 +283,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -346,7 +320,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -392,6 +367,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -433,8 +409,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -462,7 +441,7 @@ NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + NSArray *authSettings = @[@"petstore_auth", @"api_key"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -474,6 +453,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -521,8 +501,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -558,11 +541,15 @@ - formParams[@"name"] = name; + if (name) { + formParams[@"name"] = name; + } - formParams[@"status"] = status; + if (status) { + formParams[@"status"] = status; + } @@ -570,6 +557,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -614,8 +602,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -657,6 +648,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"DELETE" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -704,8 +696,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -741,7 +736,9 @@ - formParams[@"additionalMetadata"] = additionalMetadata; + if (additionalMetadata) { + formParams[@"additionalMetadata"] = additionalMetadata; + } @@ -753,6 +750,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index ed792988597..792147ebed1 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -77,7 +77,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -117,6 +118,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -153,7 +155,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -188,27 +191,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -250,8 +238,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -291,6 +282,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -332,8 +324,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -373,6 +368,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"DELETE" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 46a76b35b57..92dd00fa28d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -80,7 +80,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -115,27 +116,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -172,7 +158,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -207,27 +194,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -264,7 +236,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -299,27 +272,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -359,7 +317,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -407,6 +366,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -440,7 +400,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -480,6 +441,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -521,8 +483,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -562,6 +527,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -606,8 +572,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -642,27 +611,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"PUT" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -704,8 +658,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -745,6 +702,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"DELETE" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index ca9a3c05104..7493907d9e8 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -202,11 +202,9 @@ class ApiClient(object): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[key[1:]]: val - for key, val in iteritems(obj.__dict__) - if key != 'swagger_types' - and key != 'attribute_map' - and val is not None} + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} return {key: self.sanitize_for_serialization(val) for key, val in iteritems(obj_dict)} diff --git a/samples/client/petstore/python/swagger_client/configuration.py b/samples/client/petstore/python/swagger_client/configuration.py index 8f469b72653..6bc58c90aea 100644 --- a/samples/client/petstore/python/swagger_client/configuration.py +++ b/samples/client/petstore/python/swagger_client/configuration.py @@ -23,9 +23,9 @@ import urllib3 try: import httplib except ImportError: - # python3 + # for python3 import http.client as httplib - + import sys import logging diff --git a/samples/client/petstore/python/swagger_client/models/category.py b/samples/client/petstore/python/swagger_client/models/category.py index 615e65ea839..bf70a7d10fd 100644 --- a/samples/client/petstore/python/swagger_client/models/category.py +++ b/samples/client/petstore/python/swagger_client/models/category.py @@ -97,18 +97,17 @@ class Category(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/order.py b/samples/client/petstore/python/swagger_client/models/order.py index a381853b91f..1a7612df190 100644 --- a/samples/client/petstore/python/swagger_client/models/order.py +++ b/samples/client/petstore/python/swagger_client/models/order.py @@ -203,18 +203,17 @@ class Order(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/pet.py b/samples/client/petstore/python/swagger_client/models/pet.py index 57dc93387a9..cda4fa1e8cd 100644 --- a/samples/client/petstore/python/swagger_client/models/pet.py +++ b/samples/client/petstore/python/swagger_client/models/pet.py @@ -203,18 +203,17 @@ class Pet(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/tag.py b/samples/client/petstore/python/swagger_client/models/tag.py index bfa389520a3..8108052aae3 100644 --- a/samples/client/petstore/python/swagger_client/models/tag.py +++ b/samples/client/petstore/python/swagger_client/models/tag.py @@ -97,18 +97,17 @@ class Tag(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/user.py b/samples/client/petstore/python/swagger_client/models/user.py index 7380bc94582..576473adcfa 100644 --- a/samples/client/petstore/python/swagger_client/models/user.py +++ b/samples/client/petstore/python/swagger_client/models/user.py @@ -247,18 +247,17 @@ class User(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result