syntax, String definition) {
+ this.syntax = syntax;
+ this.definition = definition;
+ }
+
+ public abstract Boolean matches(String relativePath);
+
+ public String getDefinition() {
+ return this.definition;
+ }
+
+ protected String getPattern() {
+ if(syntax == null) return this.definition;
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < syntax.size(); i++) {
+ Part current = syntax.get(i);
+
+ switch(current.getToken()){
+ case MATCH_ALL:
+ case MATCH_ANY:
+ case ESCAPED_EXCLAMATION:
+ case ESCAPED_SPACE:
+ case PATH_DELIM:
+ case TEXT:
+ case DIRECTORY_MARKER:
+ sb.append(current.getValue());
+ break;
+ case NEGATE:
+ case ROOTED_MARKER:
+ case COMMENT:
+ break;
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Whether or not the rule should be negated. !foo means foo should be removed from previous matches.
+ * Example: **\/*.bak excludes all backup. Adding !/test.bak will include test.bak in the project root.
+ *
+ * NOTE: It is not possible to re-include a file if a parent directory of that file is excluded.
+ */
+ public Boolean getNegated() {
+ return this.syntax != null && this.syntax.size() > 0 && this.syntax.get(0).getToken() == IgnoreLineParser.Token.NEGATE;
+ }
+
+ public Operation evaluate(String relativePath) {
+ if (Boolean.TRUE.equals(matches(relativePath))) {
+ if(Boolean.TRUE.equals(this.getNegated())) {
+ return this.getIncludeOperation();
+ }
+ return this.getExcludeOperation();
+ }
+ return Operation.NOOP;
+ }
+
+ protected Operation getIncludeOperation(){ return Operation.INCLUDE; }
+ protected Operation getExcludeOperation(){ return Operation.EXCLUDE; }
+
+ public static Rule create(String definition) {
+ // NOTE: Comments that start with a : (e.g. //:) are pulled from git documentation for .gitignore
+ // see: https://github.com/git/git/blob/90f7b16b3adc78d4bbabbd426fb69aa78c714f71/Documentation/gitignore.txt
+ Rule rule = null;
+ if (definition.equals(".")) {
+ return new InvalidRule(null, definition, "Pattern '.' is invalid.");
+ } else if (definition.equals("!.")) {
+ return new InvalidRule(null, definition, "Pattern '!.' is invalid.");
+ } else if (definition.startsWith("..")) {
+ return new InvalidRule(null, definition, "Pattern '..' is invalid.");
+ }
+
+ try {
+ List result = IgnoreLineParser.parse(definition);
+
+ Boolean directoryOnly = null;
+ if (result.size() == 0) {
+ return rule;
+ } else if (result.size() == 1) {
+ // single-character filename only
+ Part part = result.get(0);
+ if (IgnoreLineParser.Token.MATCH_ANY.equals(part.getToken())) {
+ rule = new RootedFileRule(result, definition);
+ } else {
+ rule = new FileRule(result, definition);
+ }
+ } else {
+ IgnoreLineParser.Token head = result.get(0).getToken();
+
+ //: An optional prefix "`!`" which negates the pattern; any
+ //: matching file excluded by a previous pattern will become
+ //: included again. It is not possible to re-include a file if a parent
+ //: directory of that file is excluded. Git doesn't list excluded
+ //: directories for performance reasons, so any patterns on contained
+ //: files have no effect, no matter where they are defined.
+ //: Put a backslash ("`\`") in front of the first "`!`" for patterns
+ //: that begin with a literal "`!`", for example, "`\!important!.txt`".
+ // see this.getNegated();
+
+ //: If the pattern ends with a slash, it is removed for the
+ //: purpose of the following description, but it would only find
+ //: a match with a directory. In other words, `foo/` will match a
+ //: directory `foo` and paths underneath it, but will not match a
+ //: regular file or a symbolic link `foo` (this is consistent
+ //: with the way how pathspec works in general in Git).
+ directoryOnly = IgnoreLineParser.Token.DIRECTORY_MARKER.equals(result.get(result.size() - 1).getToken());
+
+ if (directoryOnly) {
+ rule = new DirectoryRule(result, definition);
+ } else if (IgnoreLineParser.Token.PATH_DELIM.equals(head)) {
+ //: A leading slash matches the beginning of the pathname.
+ //: For example, "/{asterisk}.c" matches "cat-file.c" but not
+ //: "mozilla-sha1/sha1.c".
+ rule = new RootedFileRule(result, definition);
+ } else {
+ // case 1
+ //: If the pattern does not contain a slash '/', Git treats it as
+ //: a shell glob pattern and checks for a match against the
+ //: pathname relative to the location of the `.gitignore` file
+ //: (relative to the toplevel of the work tree if not from a
+ //: `.gitignore` file).
+
+ // case 2
+ //: Otherwise, Git treats the pattern as a shell glob suitable
+ //: for consumption by fnmatch(3) with the FNM_PATHNAME flag:
+ //: wildcards in the pattern will not match a / in the pathname.
+ //: For example, "Documentation/{asterisk}.html" matches
+ //: "Documentation/git.html" but not "Documentation/ppc/ppc.html"
+ //: or "tools/perf/Documentation/perf.html".
+
+
+ // case 3
+ //: Two consecutive asterisks ("`**`") in patterns matched against
+ //: full pathname may have special meaning:
+ //:
+ //: - A leading "`**`" followed by a slash means match in all
+ //: directories. For example, "`**/foo`" matches file or directory
+ //: "`foo`" anywhere, the same as pattern "`foo`". "`**/foo/bar`"
+ //: matches file or directory "`bar`" anywhere that is directly
+ //: under directory "`foo`".
+ //:
+ //: - A trailing "`/**`" matches everything inside. For example,
+ //: "`abc/**`" matches all files inside directory "`abc`", relative
+ //: to the location of the `.gitignore` file, with infinite depth.
+ //:
+ //: - A slash followed by two consecutive asterisks then a slash
+ //: matches zero or more directories. For example, "`a/**/b`"
+ //: matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.
+ //:
+ //: - Other consecutive asterisks are considered invalid.
+ rule = new FileRule(result, definition);
+ }
+
+ }
+ } catch (ParserException e) {
+ e.printStackTrace();
+ return new InvalidRule(null, definition, e.getMessage());
+ }
+
+ return rule;
+ }
+}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java
index 99fab6e5444..c09b4ac3019 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java
@@ -23,6 +23,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
public AbstractJavaJAXRSServerCodegen()
{
super();
+ apiTestTemplateFiles.clear(); // TODO: add test template
}
@Override
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java
index 9e30ae657c8..cc41f3ea297 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java
@@ -1,62 +1,73 @@
package io.swagger.codegen.languages;
-import io.swagger.codegen.*;
-import io.swagger.models.properties.*;
-
-import java.util.*;
-import java.io.File;
-
import org.apache.commons.lang3.StringUtils;
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import io.swagger.codegen.CliOption;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.CodegenProperty;
+import io.swagger.codegen.CodegenType;
+import io.swagger.codegen.DefaultCodegen;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.FileProperty;
+import io.swagger.models.properties.MapProperty;
+import io.swagger.models.properties.Property;
+
public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String modelPropertyNaming= "camelCase";
protected Boolean supportsES6 = true;
- public AbstractTypeScriptClientCodegen() {
- super();
- supportsInheritance = true;
- setReservedWordsLowerCase(Arrays.asList(
- // local variable names used in API methods (endpoints)
- "varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
- "requestOptions",
- // Typescript reserved words
- "abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
+ public AbstractTypeScriptClientCodegen() {
+ super();
+ supportsInheritance = true;
+ setReservedWordsLowerCase(Arrays.asList(
+ // local variable names used in API methods (endpoints)
+ "varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
+ "requestOptions",
+ // Typescript reserved words
+ "abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
- languageSpecificPrimitives = new HashSet(Arrays.asList(
- "string",
- "String",
- "boolean",
- "Boolean",
- "Double",
- "Integer",
- "Long",
- "Float",
- "Object",
+ languageSpecificPrimitives = new HashSet(Arrays.asList(
+ "string",
+ "String",
+ "boolean",
+ "Boolean",
+ "Double",
+ "Integer",
+ "Long",
+ "Float",
+ "Object",
"Array",
"Date",
"number",
"any"
- ));
- instantiationTypes.put("array", "Array");
+ ));
+ instantiationTypes.put("array", "Array");
- typeMapping = new HashMap();
- typeMapping.put("Array", "Array");
- typeMapping.put("array", "Array");
- typeMapping.put("List", "Array");
- typeMapping.put("boolean", "boolean");
- typeMapping.put("string", "string");
- typeMapping.put("int", "number");
- typeMapping.put("float", "number");
- typeMapping.put("number", "number");
- typeMapping.put("long", "number");
- typeMapping.put("short", "number");
- typeMapping.put("char", "string");
- typeMapping.put("double", "number");
- typeMapping.put("object", "any");
- typeMapping.put("integer", "number");
- typeMapping.put("Map", "any");
- typeMapping.put("DateTime", "Date");
+ typeMapping = new HashMap();
+ typeMapping.put("Array", "Array");
+ typeMapping.put("array", "Array");
+ typeMapping.put("List", "Array");
+ typeMapping.put("boolean", "boolean");
+ typeMapping.put("string", "string");
+ typeMapping.put("int", "number");
+ typeMapping.put("float", "number");
+ typeMapping.put("number", "number");
+ typeMapping.put("long", "number");
+ typeMapping.put("short", "number");
+ typeMapping.put("char", "string");
+ typeMapping.put("double", "number");
+ typeMapping.put("object", "any");
+ typeMapping.put("integer", "number");
+ typeMapping.put("Map", "any");
+ typeMapping.put("DateTime", "Date");
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "string");
@@ -66,7 +77,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false"));
- }
+ }
@Override
public void processOpts() {
@@ -104,24 +115,24 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
}
@Override
- public String toParamName(String name) {
- // replace - with _ e.g. created-at => created_at
- name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
+ public String toParamName(String name) {
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
- // if it's all uppper case, do nothing
- if (name.matches("^[A-Z_]*$"))
- return name;
+ // if it's all uppper case, do nothing
+ if (name.matches("^[A-Z_]*$"))
+ return name;
- // camelize the variable name
- // pet_id => petId
- name = camelize(name, true);
+ // camelize the variable name
+ // pet_id => petId
+ name = camelize(name, true);
- // for reserved word or word starting with number, append _
- if (isReservedWord(name) || name.matches("^\\d.*"))
- name = escapeReservedWord(name);
+ // for reserved word or word starting with number, append _
+ if (isReservedWord(name) || name.matches("^\\d.*"))
+ name = escapeReservedWord(name);
- return name;
- }
+ return name;
+ }
@Override
public String toVarName(String name) {
@@ -130,70 +141,70 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
}
@Override
- public String toModelName(String name) {
- name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
+ public String toModelName(String name) {
+ name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
- if (!StringUtils.isEmpty(modelNamePrefix)) {
- name = modelNamePrefix + "_" + name;
+ if (!StringUtils.isEmpty(modelNamePrefix)) {
+ name = modelNamePrefix + "_" + name;
+ }
+
+ if (!StringUtils.isEmpty(modelNameSuffix)) {
+ name = name + "_" + modelNameSuffix;
+ }
+
+ // model name cannot use reserved keyword, e.g. return
+ if (isReservedWord(name)) {
+ String modelName = camelize("model_" + name);
+ LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ return modelName;
+ }
+
+ // model name starts with number
+ if (name.matches("^\\d.*")) {
+ String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
+ LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ return modelName;
+ }
+
+ // camelize the model name
+ // phone_number => PhoneNumber
+ return camelize(name);
}
- if (!StringUtils.isEmpty(modelNameSuffix)) {
- name = name + "_" + modelNameSuffix;
+ @Override
+ public String toModelFilename(String name) {
+ // should be the same as the model name
+ return toModelName(name);
+ }
+
+ @Override
+ public String getTypeDeclaration(Property p) {
+ if (p instanceof ArrayProperty) {
+ ArrayProperty ap = (ArrayProperty) p;
+ Property inner = ap.getItems();
+ return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
+ } else if (p instanceof MapProperty) {
+ MapProperty mp = (MapProperty) p;
+ Property inner = mp.getAdditionalProperties();
+ return "{ [key: string]: "+ getTypeDeclaration(inner) + "; }";
+ } else if (p instanceof FileProperty) {
+ return "any";
}
+ return super.getTypeDeclaration(p);
+ }
- // model name cannot use reserved keyword, e.g. return
- if (isReservedWord(name)) {
- String modelName = camelize("model_" + name);
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
- return modelName;
- }
-
- // model name starts with number
- if (name.matches("^\\d.*")) {
- String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
- return modelName;
- }
-
- // camelize the model name
- // phone_number => PhoneNumber
- return camelize(name);
- }
-
- @Override
- public String toModelFilename(String name) {
- // should be the same as the model name
- return toModelName(name);
- }
-
- @Override
- public String getTypeDeclaration(Property p) {
- if (p instanceof ArrayProperty) {
- ArrayProperty ap = (ArrayProperty) p;
- Property inner = ap.getItems();
- return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
- } else if (p instanceof MapProperty) {
- MapProperty mp = (MapProperty) p;
- Property inner = mp.getAdditionalProperties();
- return "{ [key: string]: "+ getTypeDeclaration(inner) + "; }";
- } else if (p instanceof FileProperty) {
- return "any";
- }
- return super.getTypeDeclaration(p);
- }
-
- @Override
- public String getSwaggerType(Property p) {
- String swaggerType = super.getSwaggerType(p);
- String type = null;
- if (typeMapping.containsKey(swaggerType)) {
- type = typeMapping.get(swaggerType);
- if (languageSpecificPrimitives.contains(type))
- return type;
- } else
- type = swaggerType;
- return toModelName(type);
- }
+ @Override
+ public String getSwaggerType(Property p) {
+ String swaggerType = super.getSwaggerType(p);
+ String type = null;
+ if (typeMapping.containsKey(swaggerType)) {
+ type = typeMapping.get(swaggerType);
+ if (languageSpecificPrimitives.contains(type))
+ return type;
+ } else
+ type = swaggerType;
+ return toModelName(type);
+ }
@Override
public String toOperationId(String operationId) {
@@ -217,8 +228,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
this.modelPropertyNaming = naming;
} else {
throw new IllegalArgumentException("Invalid model property naming '" +
- naming + "'. Must be 'original', 'camelCase', " +
- "'PascalCase' or 'snake_case'");
+ naming + "'. Must be 'original', 'camelCase', " +
+ "'PascalCase' or 'snake_case'");
}
}
@@ -232,9 +243,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case camelCase: return camelize(name, true);
case PascalCase: return camelize(name);
case snake_case: return underscore(name);
- default: throw new IllegalArgumentException("Invalid model property naming '" +
- name + "'. Must be 'original', 'camelCase', " +
- "'PascalCase' or 'snake_case'");
+ default: throw new IllegalArgumentException("Invalid model property naming '" +
+ name + "'. Must be 'original', 'camelCase', " +
+ "'PascalCase' or 'snake_case'");
}
}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java
index 282c4d88647..d11cc6ce0a3 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java
@@ -33,6 +33,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
// requestPackage and authPackage are used by the "volley" template/library
protected String requestPackage = "io.swagger.client.request";
protected String authPackage = "io.swagger.client.auth";
+ protected String gradleWrapperPackage = "gradle.wrapper";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
@@ -89,8 +90,8 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
cliOptions.add(CliOption.newBoolean(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.")
.defaultValue(Boolean.TRUE.toString()));
- supportedLibraries.put("", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1");
- supportedLibraries.put("volley", "HTTP client: Volley 1.0.19");
+ supportedLibraries.put("volley", "HTTP client: Volley 1.0.19 (default)");
+ supportedLibraries.put("httpclient", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be depecreated in the next major release.");
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setEnum(supportedLibraries);
cliOptions.add(library);
@@ -382,23 +383,26 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
additionalProperties.put( "modelDocPath", modelDocPath );
if (StringUtils.isEmpty(getLibrary())) {
- modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
- apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
- //supportingFiles.add(new SupportingFile("api_doc.mustache", apiDocPath, "api.md"));
- //supportingFiles.add(new SupportingFile("model_doc.mustache", modelDocPath, "model.md"));
- supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
- addSupportingFilesForDefault();
- } else if ("volley".equals(getLibrary())) {
- modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
- apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
- supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
- //supportingFiles.add(new SupportingFile("api_doc.mustache", apiDocPath, "api.md"));
- //supportingFiles.add(new SupportingFile("model_doc.mustache", modelDocPath, "model.md"));
- addSupportingFilesForVolley();
+ setLibrary("volley"); // set volley as the default library
}
+
+ // determine which file (mustache) to add based on library
+ if ("volley".equals(getLibrary())) {
+ addSupportingFilesForVolley();
+ } else if ("httpclient".equals(getLibrary())) {
+ addSupportingFilesForHttpClient();
+ } else {
+ throw new IllegalArgumentException("Invalid 'library' option specified: '" + getLibrary() + "'. Must be 'httpclient' or 'volley' (default)");
+ }
+
}
- private void addSupportingFilesForDefault() {
+ private void addSupportingFilesForHttpClient() {
+ // documentation files
+ modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
+ apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));
@@ -415,9 +419,25 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
(sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "Pair.java"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
+
+ // gradle wrapper files
+ supportingFiles.add(new SupportingFile( "gradlew.mustache", "", "gradlew" ));
+ supportingFiles.add(new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat" ));
+ supportingFiles.add(new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.properties" ));
+ supportingFiles.add(new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.jar" ));
+
}
private void addSupportingFilesForVolley() {
+ // documentation files
+ modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
+ apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+
+ supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
+ supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
// supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));
@@ -446,6 +466,14 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
(sourceFolder + File.separator + authPackage).replace(".", File.separator), "HttpBasicAuth.java"));
supportingFiles.add(new SupportingFile("auth/authentication.mustache",
(sourceFolder + File.separator + authPackage).replace(".", File.separator), "Authentication.java"));
+
+ // gradle wrapper files
+ supportingFiles.add(new SupportingFile( "gradlew.mustache", "", "gradlew" ));
+ supportingFiles.add(new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat" ));
+ supportingFiles.add(new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.properties" ));
+ supportingFiles.add(new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.jar" ));
}
public Boolean getUseAndroidMavenGradlePlugin() {
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java
index 2fc8738f067..4162ad1aeb4 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java
@@ -137,6 +137,11 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
@Override
public void processOpts() {
super.processOpts();
+ Boolean excludeTests = false;
+
+ if(additionalProperties.containsKey(CodegenConstants.EXCLUDE_TESTS)) {
+ excludeTests = Boolean.valueOf(additionalProperties.get(CodegenConstants.EXCLUDE_TESTS).toString());
+ }
apiPackage = "Api";
modelPackage = "Model";
@@ -218,6 +223,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
binRelativePath += "vendor";
additionalProperties.put("binRelativePath", binRelativePath);
+ supportingFiles.add(new SupportingFile("IApiAccessor.mustache",
+ clientPackageDir, "IApiAccessor.cs"));
supportingFiles.add(new SupportingFile("Configuration.mustache",
clientPackageDir, "Configuration.cs"));
supportingFiles.add(new SupportingFile("ApiClient.mustache",
@@ -232,7 +239,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
// copy package.config to nuget's standard location for project-level installs
supportingFiles.add(new SupportingFile("packages.config.mustache", packageFolder + File.separator, "packages.config"));
- supportingFiles.add(new SupportingFile("packages_test.config.mustache", testPackageFolder + File.separator, "packages.config"));
+
+ if(Boolean.FALSE.equals(excludeTests)) {
+ supportingFiles.add(new SupportingFile("packages_test.config.mustache", testPackageFolder + File.separator, "packages.config"));
+ }
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
@@ -245,11 +255,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, packageName + ".csproj"));
- // TODO: Check if test project output is enabled, partially related to #2506. Should have options for:
- // 1) No test project
- // 2) No model tests
- // 3) No api tests
- supportingFiles.add(new SupportingFile("TestProject.mustache", testPackageFolder, testPackageName + ".csproj"));
+ if(Boolean.FALSE.equals(excludeTests)) {
+ supportingFiles.add(new SupportingFile("TestProject.mustache", testPackageFolder, testPackageName + ".csproj"));
+ }
}
additionalProperties.put("apiDocPath", apiDocPath);
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java
index 4e34424eab7..f1c3db7c430 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java
@@ -146,6 +146,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go"));
supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.go"));
supportingFiles.add(new SupportingFile("api_response.mustache", "", "api_response.go"));
+ supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java
index 2812d2a301b..1ed9604fbf4 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java
@@ -19,6 +19,7 @@ public class GroovyClientCodegen extends JavaClientCodegen {
outputFolder = "generated-code/groovy";
modelTemplateFiles.put("model.mustache", ".groovy");
apiTemplateFiles.put(templateFileName, ".groovy");
+ apiTestTemplateFiles.clear(); // TODO: add test template
embeddedTemplateDir = templateDir = "Groovy";
apiPackage = "io.swagger.api";
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 bc839f07d18..1fba93891a4 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
@@ -36,7 +36,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String artifactId = "swagger-java-client";
protected String artifactVersion = "1.0.0";
protected String projectFolder = "src" + File.separator + "main";
+ protected String projectTestFolder = "src" + File.separator + "test";
protected String sourceFolder = projectFolder + File.separator + "java";
+ protected String testFolder = projectTestFolder + File.separator + "java";
+ protected String gradleWrapperPackage = "gradle.wrapper";
protected String localVariablePrefix = "";
protected boolean fullJavaUtil;
protected String javaUtilPrefix = "";
@@ -52,6 +55,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
outputFolder = "generated-code" + File.separator + "java";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
+ apiTestTemplateFiles.put("api_test.mustache", ".java");
embeddedTemplateDir = templateDir = "Java";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
@@ -107,12 +111,12 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
cliOptions.add(new CliOption("hideGenerationTimestamp", "hides the timestamp when files were generated"));
- supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
- supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1");
- supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
- supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
- supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
- supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.1). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.2)");
+ supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.19.1. JSON processing: Jackson 2.7.0");
+ supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.16.0. JSON processing: Jackson 2.7.0");
+ supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.22.2. JSON processing: Jackson 2.7.0");
+ supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.6.2");
+ supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
+ supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.2.0. JSON processing: Gson 2.6.1 (Retrofit 2.0.2). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.3)");
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY);
@@ -263,6 +267,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
final String authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/");
if ("feign".equals(getLibrary())) {
supportingFiles.add(new SupportingFile("FormAwareEncoder.mustache", invokerFolder, "FormAwareEncoder.java"));
+
+ //gradleWrapper files
+ supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") );
+ supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") );
}
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
@@ -281,6 +293,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
// generate markdown docs
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
+
+ //gradleWrapper files
+ supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") );
+ supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") );
} else if ("okhttp-gson".equals(getLibrary())) {
// generate markdown docs
modelDocTemplateFiles.put("model_doc.mustache", ".md");
@@ -293,14 +313,38 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java"));
// "build.sbt" is for development with SBT
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
+
+ //gradleWrapper files
+ supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") );
+ supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") );
} else if (usesAnyRetrofitLibrary()) {
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
+
+ //gradleWrapper files
+ supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") );
+ supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") );
} else if("jersey2".equals(getLibrary())) {
// generate markdown docs
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
+
+ //gradleWrapper files
+ supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") );
+ supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") );
+ supportingFiles.add( new SupportingFile( "gradle-wrapper.jar",
+ gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") );
}
if(additionalProperties.containsKey(DATE_LIBRARY)) {
@@ -366,6 +410,11 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', '/');
}
+ @Override
+ public String apiTestFileFolder() {
+ return outputFolder + "/" + testFolder + "/" + apiPackage().replace('.', '/');
+ }
+
@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', '/');
@@ -391,6 +440,11 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
return toModelName(name);
}
+ @Override
+ public String toApiTestFilename(String name) {
+ return toApiName(name) + "Test";
+ }
+
@Override
public String toVarName(String name) {
// sanitize name
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java
index 0cf59e5faa7..bb32ee9ab8d 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java
@@ -25,6 +25,7 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen {
sourceFolder = "src/gen/java";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
+ apiTestTemplateFiles.clear(); // TODO: add test template
embeddedTemplateDir = templateDir = "JavaInflector";
invokerPackage = "io.swagger.handler";
artifactId = "swagger-inflector-server";
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java
index b919430035d..5717c902740 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java
@@ -31,6 +31,7 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code
apiTemplateFiles.put("apiService.mustache", ".java");
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
apiTemplateFiles.put("apiServiceFactory.mustache", ".java");
+ apiTestTemplateFiles.clear(); // TODO: add test template
apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model";
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java
index 46b6083e2e4..1a9d0a80c24 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java
@@ -42,6 +42,9 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String[] specialWords = {"new", "copy"};
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
+ protected String modelFilesPath = "Model/";
+ protected String coreFilesPath = "Core/";
+ protected String apiFilesPath = "Api/";
protected Set advancedMapingTypes = new HashSet();
@@ -223,35 +226,35 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);
- String swaggerFolder = podName;
+ modelPackage = podName;
+ apiPackage = podName;
- modelPackage = swaggerFolder;
- apiPackage = swaggerFolder;
-
- supportingFiles.add(new SupportingFile("Object-header.mustache", swaggerFolder, classPrefix + "Object.h"));
- supportingFiles.add(new SupportingFile("Object-body.mustache", swaggerFolder, classPrefix + "Object.m"));
- supportingFiles.add(new SupportingFile("QueryParamCollection-header.mustache", swaggerFolder, classPrefix + "QueryParamCollection.h"));
- supportingFiles.add(new SupportingFile("QueryParamCollection-body.mustache", swaggerFolder, classPrefix + "QueryParamCollection.m"));
- supportingFiles.add(new SupportingFile("ApiClient-header.mustache", swaggerFolder, classPrefix + "ApiClient.h"));
- supportingFiles.add(new SupportingFile("ApiClient-body.mustache", swaggerFolder, classPrefix + "ApiClient.m"));
- supportingFiles.add(new SupportingFile("JSONResponseSerializer-header.mustache", swaggerFolder, classPrefix + "JSONResponseSerializer.h"));
- supportingFiles.add(new SupportingFile("JSONResponseSerializer-body.mustache", swaggerFolder, classPrefix + "JSONResponseSerializer.m"));
- supportingFiles.add(new SupportingFile("JSONRequestSerializer-body.mustache", swaggerFolder, classPrefix + "JSONRequestSerializer.m"));
- supportingFiles.add(new SupportingFile("JSONRequestSerializer-header.mustache", swaggerFolder, classPrefix + "JSONRequestSerializer.h"));
- supportingFiles.add(new SupportingFile("ResponseDeserializer-body.mustache", swaggerFolder, classPrefix + "ResponseDeserializer.m"));
- supportingFiles.add(new SupportingFile("ResponseDeserializer-header.mustache", swaggerFolder, classPrefix + "ResponseDeserializer.h"));
- supportingFiles.add(new SupportingFile("Sanitizer-body.mustache", swaggerFolder, classPrefix + "Sanitizer.m"));
- supportingFiles.add(new SupportingFile("Sanitizer-header.mustache", swaggerFolder, classPrefix + "Sanitizer.h"));
- supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", swaggerFolder, "JSONValueTransformer+ISO8601.m"));
- supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.h", swaggerFolder, "JSONValueTransformer+ISO8601.h"));
- supportingFiles.add(new SupportingFile("Configuration-body.mustache", swaggerFolder, classPrefix + "Configuration.m"));
- supportingFiles.add(new SupportingFile("Configuration-header.mustache", swaggerFolder, classPrefix + "Configuration.h"));
+ supportingFiles.add(new SupportingFile("Object-header.mustache", coreFileFolder(), classPrefix + "Object.h"));
+ supportingFiles.add(new SupportingFile("Object-body.mustache", coreFileFolder(), classPrefix + "Object.m"));
+ supportingFiles.add(new SupportingFile("QueryParamCollection-header.mustache", coreFileFolder(), classPrefix + "QueryParamCollection.h"));
+ supportingFiles.add(new SupportingFile("QueryParamCollection-body.mustache", coreFileFolder(), classPrefix + "QueryParamCollection.m"));
+ supportingFiles.add(new SupportingFile("ApiClient-header.mustache", coreFileFolder(), classPrefix + "ApiClient.h"));
+ supportingFiles.add(new SupportingFile("ApiClient-body.mustache", coreFileFolder(), classPrefix + "ApiClient.m"));
+ supportingFiles.add(new SupportingFile("JSONResponseSerializer-header.mustache", coreFileFolder(), classPrefix + "JSONResponseSerializer.h"));
+ supportingFiles.add(new SupportingFile("JSONResponseSerializer-body.mustache", coreFileFolder(), classPrefix + "JSONResponseSerializer.m"));
+ supportingFiles.add(new SupportingFile("JSONRequestSerializer-body.mustache", coreFileFolder(), classPrefix + "JSONRequestSerializer.m"));
+ supportingFiles.add(new SupportingFile("JSONRequestSerializer-header.mustache", coreFileFolder(), classPrefix + "JSONRequestSerializer.h"));
+ supportingFiles.add(new SupportingFile("ResponseDeserializer-body.mustache", coreFileFolder(), classPrefix + "ResponseDeserializer.m"));
+ supportingFiles.add(new SupportingFile("ResponseDeserializer-header.mustache", coreFileFolder(), classPrefix + "ResponseDeserializer.h"));
+ supportingFiles.add(new SupportingFile("Sanitizer-body.mustache", coreFileFolder(), classPrefix + "Sanitizer.m"));
+ supportingFiles.add(new SupportingFile("Sanitizer-header.mustache", coreFileFolder(), classPrefix + "Sanitizer.h"));
+ supportingFiles.add(new SupportingFile("Logger-body.mustache", coreFileFolder(), classPrefix + "Logger.m"));
+ supportingFiles.add(new SupportingFile("Logger-header.mustache", coreFileFolder(), classPrefix + "Logger.h"));
+ supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", coreFileFolder(), "JSONValueTransformer+ISO8601.m"));
+ supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.h", coreFileFolder(), "JSONValueTransformer+ISO8601.h"));
+ supportingFiles.add(new SupportingFile("Configuration-body.mustache", coreFileFolder(), classPrefix + "Configuration.m"));
+ supportingFiles.add(new SupportingFile("Configuration-header.mustache", coreFileFolder(), classPrefix + "Configuration.h"));
+ supportingFiles.add(new SupportingFile("api-protocol.mustache", coreFileFolder(), classPrefix + "Api.h"));
supportingFiles.add(new SupportingFile("podspec.mustache", "", podName + ".podspec"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
-
}
@Override
@@ -304,12 +307,12 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
if(innerTypeDeclaration.equalsIgnoreCase(BinaryDataType)) {
return "NSData*";
}
- // In this codition, type of property p is array of primitive,
+ // In this condition, type of property p is array of primitive,
// return container type with pointer, e.g. `NSArray**'
if (languageSpecificPrimitives.contains(innerTypeDeclaration)) {
return getSwaggerType(p) + "<" + innerTypeDeclaration + "*>*";
}
- // In this codition, type of property p is array of model,
+ // In this condition, type of property p is array of model,
// return container type combine inner type with pointer, e.g. `NSArray*'
else {
for (String sd : advancedMapingTypes) {
@@ -341,18 +344,18 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
} else {
String swaggerType = getSwaggerType(p);
- // In this codition, type of p is objective-c primitive type, e.g. `NSSNumber',
+ // In this condition, type of p is objective-c primitive type, e.g. `NSSNumber',
// return type of p with pointer, e.g. `NSNumber*'
if (languageSpecificPrimitives.contains(swaggerType) &&
foundationClasses.contains(swaggerType)) {
return swaggerType + "*";
}
- // In this codition, type of p is c primitive type, e.g. `bool',
+ // In this condition, type of p is c primitive type, e.g. `bool',
// return type of p, e.g. `bool'
else if (languageSpecificPrimitives.contains(swaggerType)) {
return swaggerType;
}
- // In this codition, type of p is objective-c object type, e.g. `SWGPet',
+ // In this condition, type of p is objective-c object type, e.g. `SWGPet',
// return type of p with pointer, e.g. `SWGPet*'
else {
return swaggerType + "*";
@@ -454,12 +457,16 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String apiFileFolder() {
- return outputFolder + File.separatorChar + apiPackage();
+ return (outputFolder + "/"+ apiPackage() + "/" + apiFilesPath).replace("/", File.separator);
}
@Override
public String modelFileFolder() {
- return outputFolder + File.separatorChar + modelPackage();
+ return (outputFolder + "/"+ modelPackage() + "/" + modelFilesPath).replace("/", File.separator);
+ }
+
+ public String coreFileFolder() {
+ return (apiPackage() + "/" + coreFilesPath).replace("/", File.separator);
}
@Override
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java
index 738ffd4e0d5..c89a7b4e5ba 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java
@@ -3,6 +3,7 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
@@ -13,6 +14,7 @@ import io.swagger.models.properties.*;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.HashSet;
import java.util.regex.Matcher;
@@ -32,10 +34,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
protected String invokerPackage = "Swagger\\Client";
- protected String composerVendorName = "swagger";
- protected String composerProjectName = "swagger-client";
+ protected String composerVendorName = null;
+ protected String composerProjectName = null;
protected String packagePath = "SwaggerClient-php";
- protected String artifactVersion = "1.0.0";
+ protected String artifactVersion = null;
protected String srcBasePath = "lib";
protected String testBasePath = "test";
protected String docsBasePath = "docs";
@@ -126,7 +128,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next swagger-codegen release"));
+ cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release"));
+ cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
}
@@ -214,12 +218,24 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
}
+ if (additionalProperties.containsKey(CodegenConstants.GIT_USER_ID)) {
+ this.setGitUserId((String) additionalProperties.get(CodegenConstants.GIT_USER_ID));
+ } else {
+ additionalProperties.put(CodegenConstants.GIT_USER_ID, gitUserId);
+ }
+
if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
} else {
additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
}
+ if (additionalProperties.containsKey(CodegenConstants.GIT_REPO_ID)) {
+ this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID));
+ } else {
+ additionalProperties.put(CodegenConstants.GIT_REPO_ID, gitRepoId);
+ }
+
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
} else {
@@ -626,4 +642,14 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
// process enum in models
return postProcessModelsEnum(objs);
}
+
+ @Override
+ public Map postProcessOperations(Map objs) {
+ Map operations = (Map) objs.get("operations");
+ List operationList = (List) operations.get("operation");
+ for (CodegenOperation op : operationList) {
+ op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
+ }
+ return objs;
+ }
}
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 113c6a6e1c1..8bc117120d6 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
@@ -116,6 +116,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public void processOpts() {
super.processOpts();
+ Boolean excludeTests = false;
+
+ if(additionalProperties.containsKey(CodegenConstants.EXCLUDE_TESTS)) {
+ excludeTests = Boolean.valueOf(additionalProperties.get(CodegenConstants.EXCLUDE_TESTS).toString());
+ }
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
@@ -145,13 +150,20 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py"));
+ supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini"));
+ supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
+ supportingFiles.add(new SupportingFile("requirements.mustache", "", "requirements.txt"));
+
supportingFiles.add(new SupportingFile("api_client.mustache", swaggerFolder, "api_client.py"));
supportingFiles.add(new SupportingFile("rest.mustache", swaggerFolder, "rest.py"));
supportingFiles.add(new SupportingFile("configuration.mustache", swaggerFolder, "configuration.py"));
supportingFiles.add(new SupportingFile("__init__package.mustache", swaggerFolder, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__api.mustache", apiPackage, "__init__.py"));
- supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
+
+ if(Boolean.FALSE.equals(excludeTests)) {
+ supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
+ }
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Rails5ServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Rails5ServerCodegen.java
new file mode 100644
index 00000000000..cbf77338ab3
--- /dev/null
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Rails5ServerCodegen.java
@@ -0,0 +1,323 @@
+package io.swagger.codegen.languages;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenType;
+import io.swagger.codegen.DefaultCodegen;
+import io.swagger.codegen.SupportingFile;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.MapProperty;
+import io.swagger.models.properties.Property;
+import io.swagger.models.Swagger;
+import io.swagger.util.Yaml;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Rails5ServerCodegen extends DefaultCodegen implements CodegenConfig {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Rails5ServerCodegen.class);
+
+ protected String gemName;
+ protected String moduleName;
+ protected String gemVersion = "1.0.0";
+ protected String appFolder = "app";
+ protected String channelsFolder = appFolder + File.separator + "channels";
+ protected String applicationCableFolder = channelsFolder + File.separator + "application_cable";
+ protected String controllersFolder = appFolder + File.separator + "controllers";
+ protected String jobsFolder = appFolder + File.separator + "jobs";
+ protected String mailersFolder = appFolder + File.separator + "mailers";
+ protected String modelsFolder = appFolder + File.separator + "models";
+ protected String viewsFolder = appFolder + File.separator + "views";
+ protected String layoutsFolder = viewsFolder + File.separator + "layouts";
+ protected String binFolder = "bin";
+ protected String configFolder = "config";
+ protected String environmentsFolder = configFolder + File.separator + "config";
+ protected String initializersFolder = configFolder + File.separator + "initializers";
+ protected String localesFolder = configFolder + File.separator + "locales";
+ protected String dbFolder = "db";
+ protected String migrateFolder = dbFolder + File.separator + "migrate";
+ protected String libFolder = "lib";
+ protected String tasksFolder = libFolder + File.separator + "tasks";
+ protected String logFolder = "log";
+ protected String publicFolder = "public";
+ protected String testFolder = "test";
+ protected String tmpFolder = "tmp";
+ protected String cacheFolder = tmpFolder + File.separator + "cache";
+ protected String pidFolder = tmpFolder + File.separator + "pids";
+ protected String socketsFolder = tmpFolder + File.separator + "sockets";
+ protected String vendorFolder = "vendor";
+
+ public Rails5ServerCodegen() {
+ super();
+ apiPackage = "app/controllers";
+ outputFolder = "generated-code" + File.separator + "rails5";
+
+ // no model
+ modelTemplateFiles.clear();
+ apiTemplateFiles.put("controller.mustache", ".rb");
+ embeddedTemplateDir = templateDir = "rails5";
+
+ typeMapping.clear();
+ languageSpecificPrimitives.clear();
+
+ setReservedWordsLowerCase(
+ Arrays.asList(
+ "__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
+ "begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
+ "break", "do", "false", "next", "rescue", "then", "when", "END", "case",
+ "else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
+ "if", "not", "return", "undef", "yield")
+ );
+
+ languageSpecificPrimitives.add("int");
+ languageSpecificPrimitives.add("array");
+ languageSpecificPrimitives.add("map");
+ languageSpecificPrimitives.add("string");
+ languageSpecificPrimitives.add("DateTime");
+
+ typeMapping.put("long", "int");
+ typeMapping.put("integer", "int");
+ typeMapping.put("Array", "array");
+ typeMapping.put("String", "string");
+ typeMapping.put("List", "array");
+ typeMapping.put("map", "map");
+ //TODO binary should be mapped to byte array
+ // mapped to String as a workaround
+ typeMapping.put("binary", "string");
+
+ // remove modelPackage and apiPackage added by default
+ cliOptions.clear();
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ // use constant model/api package (folder path)
+ //setModelPackage("models");
+ setApiPackage("app/controllers");
+
+ supportingFiles.add(new SupportingFile("Gemfile", "", "Gemfile"));
+ supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
+ supportingFiles.add(new SupportingFile("Rakefile", "", "Rakefile"));
+ supportingFiles.add(new SupportingFile("config.ru", "", "config.ru"));
+ supportingFiles.add(new SupportingFile("channel.rb", applicationCableFolder, "channel.rb"));
+ supportingFiles.add(new SupportingFile("connection.rb", applicationCableFolder, "connection.rb"));
+ supportingFiles.add(new SupportingFile("application_controller.rb", controllersFolder, "application_controller.rb"));
+ supportingFiles.add(new SupportingFile("application_job.rb", jobsFolder, "application_job.rb"));
+ supportingFiles.add(new SupportingFile("application_mailer.rb", mailersFolder, "application_mailer.rb"));
+ supportingFiles.add(new SupportingFile("application_record.rb", modelsFolder, "application_record.rb"));
+ supportingFiles.add(new SupportingFile("mailer.html.erb", layoutsFolder, "mailer.html.erb"));
+ supportingFiles.add(new SupportingFile("mailer.text.erb", layoutsFolder, "mailer.text.erb"));
+ supportingFiles.add(new SupportingFile("bundle", binFolder, "bundle"));
+ supportingFiles.add(new SupportingFile("rails", binFolder, "rails"));
+ supportingFiles.add(new SupportingFile("rake", binFolder, "rake"));
+ supportingFiles.add(new SupportingFile("setup", binFolder, "setup"));
+ supportingFiles.add(new SupportingFile("update", binFolder, "update"));
+ supportingFiles.add(new SupportingFile("development.rb", environmentsFolder, "development.rb"));
+ supportingFiles.add(new SupportingFile("production.rb", environmentsFolder, "production.rb"));
+ supportingFiles.add(new SupportingFile("active_record_belongs_to_required_by_default.rb", initializersFolder, "active_record_belongs_to_required_by_default.rb"));
+ supportingFiles.add(new SupportingFile("application_controller_renderer.rb", initializersFolder, "application_controller_renderer.rb"));
+ supportingFiles.add(new SupportingFile("backtrace_silencers.rb", initializersFolder, "backtrace_silencers.rb"));
+ supportingFiles.add(new SupportingFile("callback_terminator.rb", initializersFolder, "callback_terminator.rb"));
+ supportingFiles.add(new SupportingFile("cors.rb", initializersFolder, "cors.rb"));
+ supportingFiles.add(new SupportingFile("filter_parameter_logging.rb", initializersFolder, "filter_parameter_logging.rb"));
+ supportingFiles.add(new SupportingFile("inflections.rb", initializersFolder, "inflections.rb"));
+ supportingFiles.add(new SupportingFile("mime_types.rb", initializersFolder, "mime_types.rb"));
+ supportingFiles.add(new SupportingFile("ssl_options.rb", initializersFolder, "ssl_options.rb"));
+ supportingFiles.add(new SupportingFile("to_time_preserves_timezone.rb", initializersFolder, "to_time_preserves_timezone.rb"));
+ supportingFiles.add(new SupportingFile("en.yml", localesFolder, "en.yml"));
+ supportingFiles.add(new SupportingFile("application.rb", configFolder, "application.rb"));
+ supportingFiles.add(new SupportingFile("boot.rb", configFolder, "boot.rb"));
+ supportingFiles.add(new SupportingFile("cable.yml", configFolder, "cable.yml"));
+ supportingFiles.add(new SupportingFile("database.yml", configFolder, "database.yml"));
+ supportingFiles.add(new SupportingFile("environment.rb", configFolder, "environment.rb"));
+ supportingFiles.add(new SupportingFile("puma.rb", configFolder, "puma.rb"));
+ supportingFiles.add(new SupportingFile("routes.mustache", configFolder, "routes.rb"));
+ supportingFiles.add(new SupportingFile("secrets.yml", configFolder, "secrets.yml"));
+ supportingFiles.add(new SupportingFile("spring.rb", configFolder, "spring.rb"));
+ supportingFiles.add(new SupportingFile(".keep", migrateFolder, ".keep"));
+ supportingFiles.add(new SupportingFile("schema.rb", dbFolder, "schema.rb"));
+ supportingFiles.add(new SupportingFile("seeds.rb", dbFolder, "seeds.rb"));
+ supportingFiles.add(new SupportingFile(".keep", tasksFolder, ".keep"));
+ supportingFiles.add(new SupportingFile(".keep", logFolder, ".keep"));
+ supportingFiles.add(new SupportingFile("404.html", publicFolder, "404.html"));
+ supportingFiles.add(new SupportingFile("422.html", publicFolder, "422.html"));
+ supportingFiles.add(new SupportingFile("500.html", publicFolder, "500.html"));
+ supportingFiles.add(new SupportingFile("apple-touch-icon-precomposed.png", publicFolder, "apple-touch-icon-precomposed.png"));
+ supportingFiles.add(new SupportingFile("apple-touch-icon.png", publicFolder, "apple-touch-icon.png"));
+ supportingFiles.add(new SupportingFile("favicon.ico", publicFolder, "favicon.ico"));
+ supportingFiles.add(new SupportingFile("robots.txt", publicFolder, "robots.txt"));
+ supportingFiles.add(new SupportingFile("robots.txt", publicFolder, "robots.txt"));
+ supportingFiles.add(new SupportingFile("test_helper.rb", testFolder, "test_helper.rb"));
+ supportingFiles.add(new SupportingFile(".keep", cacheFolder, ".keep"));
+ supportingFiles.add(new SupportingFile(".keep", pidFolder, ".keep"));
+ supportingFiles.add(new SupportingFile(".keep", socketsFolder, ".keep"));
+ supportingFiles.add(new SupportingFile("restart.txt", tmpFolder, "restart.txt"));
+ supportingFiles.add(new SupportingFile(".keep", vendorFolder, ".keep"));
+ }
+
+ @Override
+ public CodegenType getTag() {
+ return CodegenType.SERVER;
+ }
+
+ @Override
+ public String getName() {
+ return "rails5";
+ }
+
+ @Override
+ public String getHelp() {
+ return "Generates a Rails5 server library.";
+ }
+
+ @Override
+ public String escapeReservedWord(String name) {
+ return "_" + name;
+ }
+
+ @Override
+ public String apiFileFolder() {
+ return outputFolder + File.separator + apiPackage.replace("/", File.separator);
+ }
+
+ @Override
+ public String getTypeDeclaration(Property p) {
+ if (p instanceof ArrayProperty) {
+ ArrayProperty ap = (ArrayProperty) p;
+ Property inner = ap.getItems();
+ return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
+ } else if (p instanceof MapProperty) {
+ MapProperty mp = (MapProperty) p;
+ Property inner = mp.getAdditionalProperties();
+ return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
+ }
+ return super.getTypeDeclaration(p);
+ }
+
+ @Override
+ public String getSwaggerType(Property p) {
+ String swaggerType = super.getSwaggerType(p);
+ String type = null;
+ if (typeMapping.containsKey(swaggerType)) {
+ type = typeMapping.get(swaggerType);
+ if (languageSpecificPrimitives.contains(type)) {
+ return type;
+ }
+ } else {
+ type = swaggerType;
+ }
+ if (type == null) {
+ return null;
+ }
+ return type;
+ }
+
+ @Override
+ public String toDefaultValue(Property p) {
+ return "null";
+ }
+
+ @Override
+ public String toVarName(String name) {
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
+
+ // if it's all uppper case, convert to lower case
+ if (name.matches("^[A-Z_]*$")) {
+ name = name.toLowerCase();
+ }
+
+ // camelize (lower first character) the variable name
+ // petId => pet_id
+ name = underscore(name);
+
+ // for reserved word or word starting with number, append _
+ if (isReservedWord(name) || name.matches("^\\d.*")) {
+ name = escapeReservedWord(name);
+ }
+
+ return name;
+ }
+
+ @Override
+ public String toParamName(String name) {
+ // should be the same as variable name
+ return toVarName(name);
+ }
+
+ @Override
+ public String toModelName(String name) {
+ // model name cannot use reserved keyword, e.g. return
+ if (isReservedWord(name)) {
+ throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
+ }
+
+ // camelize the model name
+ // phone_number => PhoneNumber
+ return camelize(name);
+ }
+
+ @Override
+ public String toModelFilename(String name) {
+ // model name cannot use reserved keyword, e.g. return
+ if (isReservedWord(name)) {
+ throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
+ }
+
+ // underscore the model file name
+ // PhoneNumber.rb => phone_number.rb
+ return underscore(name);
+ }
+
+ @Override
+ public String toApiFilename(String name) {
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
+
+ // e.g. PhoneNumberApi.rb => phone_number_api.rb
+ return underscore(name) + "_controllers";
+ }
+
+ @Override
+ public String toApiName(String name) {
+ if (name.length() == 0) {
+ return "ApiController";
+ }
+ // e.g. phone_number_api => PhoneNumberApi
+ return camelize(name) + "Controller";
+ }
+
+ @Override
+ public String toOperationId(String operationId) {
+ // method name cannot use reserved keyword, e.g. return
+ if (isReservedWord(operationId)) {
+ throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
+ }
+
+ return underscore(operationId);
+ }
+
+ @Override
+ public Map postProcessSupportingFileData(Map objs) {
+ Swagger swagger = (Swagger)objs.get("swagger");
+ if(swagger != null) {
+ try {
+ objs.put("swagger-yaml", Yaml.mapper().writeValueAsString(swagger));
+ } catch (JsonProcessingException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+ return super.postProcessSupportingFileData(objs);
+ }
+
+}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java
index 6655a28f1d5..70b3a32085a 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java
@@ -5,6 +5,7 @@ import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
+import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@@ -527,6 +528,57 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
return camelize(name) + "Api";
}
+ @Override
+ public String toEnumValue(String value, String datatype) {
+ if ("Integer".equals(datatype) || "Float".equals(datatype)) {
+ return value;
+ } else {
+ return "\"" + escapeText(value) + "\"";
+ }
+ }
+
+ @Override
+ public String toEnumVarName(String name, String datatype) {
+ // number
+ if ("Integer".equals(datatype) || "Float".equals(datatype)) {
+ String varName = new String(name);
+ varName = varName.replaceAll("-", "MINUS_");
+ varName = varName.replaceAll("\\+", "PLUS_");
+ varName = varName.replaceAll("\\.", "_DOT_");
+ return varName;
+ }
+
+ // string
+ String enumName = sanitizeName(underscore(name).toUpperCase());
+ enumName = enumName.replaceFirst("^_", "");
+ enumName = enumName.replaceFirst("_$", "");
+
+ if (enumName.matches("\\d.*")) { // starts with number
+ return "N" + enumName;
+ } else {
+ return enumName;
+ }
+ }
+
+ @Override
+ public String toEnumName(CodegenProperty property) {
+ String enumName = underscore(toModelName(property.name)).toUpperCase();
+ enumName = enumName.replaceFirst("^_", "");
+ enumName = enumName.replaceFirst("_$", "");
+
+ if (enumName.matches("\\d.*")) { // starts with number
+ return "N" + enumName;
+ } else {
+ return enumName;
+ }
+ }
+
+ @Override
+ public Map postProcessModels(Map objs) {
+ // process enum in models
+ return postProcessModelsEnum(objs);
+ }
+
@Override
public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java
index 070f5de6d03..7a487494a5b 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java
@@ -20,6 +20,7 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege
outputFolder = "generated-code/javaSpringBoot";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put(templateFileName, ".java");
+ apiTestTemplateFiles.clear(); // TODO: add test template
embeddedTemplateDir = templateDir = "JavaSpringBoot";
apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model";
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java
index 8bd7e3c1f8e..18b2f872d56 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java
@@ -18,6 +18,7 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
outputFolder = "generated-code/javaSpringMVC";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put(templateFileName, ".java");
+ apiTestTemplateFiles.clear(); // TODO: add test template
embeddedTemplateDir = templateDir = "JavaSpringMVC";
apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model";
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java
index ba846857cb9..6ec81c1c357 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java
@@ -342,7 +342,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
// Ensure that the enum type doesn't match a reserved word or
// the variable name doesn't match the generated enum type or the
// Swift compiler will generate an error
- if (isReservedWord(codegenProperty.datatypeWithEnum) || name.equals(codegenProperty.datatypeWithEnum)) {
+ if (isReservedWord(codegenProperty.datatypeWithEnum) || toVarName(name).equals(codegenProperty.datatypeWithEnum)) {
codegenProperty.datatypeWithEnum = codegenProperty.datatypeWithEnum + "Enum";
}
}
@@ -355,8 +355,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
if (value.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
return value;
}
- char[] separators = {'-', '_', ' '};
- return WordUtils.capitalizeFully(StringUtils.lowerCase(value), separators).replaceAll("[-_ ]", "");
+ char[] separators = {'-', '_', ' ', ':'};
+ return WordUtils.capitalizeFully(StringUtils.lowerCase(value), separators).replaceAll("[-_ :]", "");
}
@@ -502,6 +502,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumVarName(String name, String datatype) {
+ // TODO: this code is probably useless, because the var name is computed from the value in map.put("enum", toSwiftyEnumName(value));
// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = new String(name);
@@ -525,8 +526,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumName(CodegenProperty property) {
- String enumName = underscore(toModelName(property.name)).toUpperCase();
+ String enumName = toModelName(property.name);
+ // TODO: toModelName already does something for names starting with number, so this code is probably never called
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java
index a80e0f66ae0..6a945249af6 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java
@@ -5,12 +5,15 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import io.swagger.codegen.CliOption;
+import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.SupportingFile;
+import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.FileProperty;
import io.swagger.models.properties.MapProperty;
+import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.Property;
public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCodegen {
@@ -43,6 +46,12 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
}
+ @Override
+ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, ModelImpl swaggerModel) {
+ codegenModel.additionalPropertiesType = getSwaggerType(swaggerModel.getAdditionalProperties());
+ addImport(codegenModel, codegenModel.additionalPropertiesType);
+ }
+
@Override
public String getName() {
return "typescript-angular2";
@@ -106,14 +115,19 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
MapProperty mp = (MapProperty)p;
inner = mp.getAdditionalProperties();
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
+ } else if(p instanceof FileProperty || p instanceof ObjectProperty) {
+ return "any";
} else {
- return p instanceof FileProperty ? "any" : super.getTypeDeclaration(p);
+ return super.getTypeDeclaration(p);
}
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
+ if(languageSpecificPrimitives.contains(swaggerType)) {
+ return swaggerType;
+ }
return addModelPrefix(swaggerType);
}
@@ -121,13 +135,25 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
- if (languageSpecificPrimitives.contains(type))
- return type;
- } else
+ } else {
+ type = swaggerType;
+ }
+
+ if (!startsWithLanguageSpecificPrimitiv(type)) {
type = "models." + swaggerType;
+ }
return type;
}
+ private boolean startsWithLanguageSpecificPrimitiv(String type) {
+ for (String langPrimitive:languageSpecificPrimitives) {
+ if (type.startsWith(langPrimitive)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java
index c817162401e..90f778eae8e 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java
@@ -26,7 +26,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
super.processOpts();
supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
- supportingFiles.add(new SupportingFile("assign.ts", "", "assign.ts"));
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
supportingFiles.add(new SupportingFile("package.json.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("typings.json.mustache", "", "typings.json"));
diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache
index ad7b9051f05..4d54d84d337 100644
--- a/modules/swagger-codegen/src/main/resources/Java/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache
@@ -78,12 +78,12 @@ public class {{classname}} {
{{/formParams}}
final String[] {{localVariablePrefix}}localVarAccepts = {
- {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
+ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
};
final String {{localVariablePrefix}}localVarAccept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}localVarAccepts);
final String[] {{localVariablePrefix}}localVarContentTypes = {
- {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
+ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
};
final String {{localVariablePrefix}}localVarContentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}localVarContentTypes);
diff --git a/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache
index 93c5bc5b13a..bbb5b66f840 100644
--- a/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache
@@ -75,8 +75,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
{{/operation}}
{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/Java/api_test.mustache b/modules/swagger-codegen/src/main/resources/Java/api_test.mustache
new file mode 100644
index 00000000000..f9e00ef2979
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/api_test.mustache
@@ -0,0 +1,41 @@
+package {{package}};
+
+import {{invokerPackage}}.ApiException;
+{{#imports}}import {{import}};
+{{/imports}}
+import org.junit.Test;
+
+{{^fullJavaUtil}}
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+{{/fullJavaUtil}}
+
+/**
+ * API tests for {{classname}}
+ */
+public class {{classname}}Test {
+
+ private final {{classname}} api = new {{classname}}();
+
+ {{#operations}}{{#operation}}
+ /**
+ * {{summary}}
+ *
+ * {{notes}}
+ *
+ * @throws ApiException
+ * if the Api call fails
+ */
+ @Test
+ public void {{operationId}}Test() throws ApiException {
+ {{#allParams}}
+ {{{dataType}}} {{paramName}} = null;
+ {{/allParams}}
+ // {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+
+ // TODO: test validations
+ }
+ {{/operation}}{{/operations}}
+}
diff --git a/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache b/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache
index 32858aad3c3..7cf39af816c 100644
--- a/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache
@@ -8,5 +8,8 @@
*.war
*.ear
+# exclude jar for gradle wrapper
+!gradle/wrapper/*.jar
+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
diff --git a/modules/swagger-codegen/src/main/resources/Java/gradle-wrapper.jar b/modules/swagger-codegen/src/main/resources/Java/gradle-wrapper.jar
new file mode 100644
index 00000000000..2c6137b8789
Binary files /dev/null and b/modules/swagger-codegen/src/main/resources/Java/gradle-wrapper.jar differ
diff --git a/modules/swagger-codegen/src/main/resources/Java/gradle-wrapper.properties.mustache b/modules/swagger-codegen/src/main/resources/Java/gradle-wrapper.properties.mustache
new file mode 100644
index 00000000000..b7a36473955
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/gradle-wrapper.properties.mustache
@@ -0,0 +1,6 @@
+#Tue May 17 23:08:05 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
diff --git a/modules/swagger-codegen/src/main/resources/Java/gradlew.bat.mustache b/modules/swagger-codegen/src/main/resources/Java/gradlew.bat.mustache
new file mode 100644
index 00000000000..72d362dafd8
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/gradlew.bat.mustache
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/modules/swagger-codegen/src/main/resources/Java/gradlew.mustache b/modules/swagger-codegen/src/main/resources/Java/gradlew.mustache
new file mode 100755
index 00000000000..9d82f789151
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/gradlew.mustache
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache
new file mode 100644
index 00000000000..303fda344e9
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache
@@ -0,0 +1,44 @@
+package {{package}};
+
+import {{invokerPackage}}.ApiClient;
+{{#imports}}import {{import}};
+{{/imports}}
+import org.junit.Before;
+import org.junit.Test;
+
+{{^fullJavaUtil}}
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+{{/fullJavaUtil}}
+
+/**
+ * API tests for {{classname}}
+ */
+public class {{classname}}Test {
+
+ private {{classname}} api;
+
+ @Before
+ public void setup() {
+ api = new ApiClient().buildClient({{classname}}.class);
+ }
+
+ {{#operations}}{{#operation}}
+ /**
+ * {{summary}}
+ *
+ * {{notes}}
+ */
+ @Test
+ public void {{operationId}}Test() {
+ {{#allParams}}
+ {{{dataType}}} {{paramName}} = null;
+ {{/allParams}}
+ // {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+
+ // TODO: test validations
+ }
+ {{/operation}}{{/operations}}
+}
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/auth/OAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/auth/OAuth.mustache
index 74ff86ebd1b..1df88d403a2 100644
--- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/auth/OAuth.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/auth/OAuth.mustache
@@ -23,14 +23,17 @@ import feign.Request.Options;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import feign.Response;
+import feign.RetryableException;
import feign.Util;
import {{invokerPackage}}.StringUtil;
public class OAuth implements RequestInterceptor {
+ static final int MILLIS_PER_SECOND = 1000;
+
public interface AccessTokenListener {
- public void notify(BasicOAuthToken token);
+ void notify(BasicOAuthToken token);
}
private volatile String accessToken;
@@ -41,21 +44,13 @@ public class OAuth implements RequestInterceptor {
private AccessTokenListener accessTokenListener;
public OAuth(Client client, TokenRequestBuilder requestBuilder) {
- setOauthClient(client);
+ this.oauthClient = new OAuthClient(new OAuthFeignClient(client));
this.tokenRequestBuilder = requestBuilder;
}
public OAuth(Client client, OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
this(client, OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes));
- setFlow(flow);
- authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
- }
- public OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
- this(new Client.Default(null, null), flow, authorizationUrl, tokenUrl, scopes);
- }
-
- public void setFlow(OAuthFlow flow) {
switch(flow) {
case accessCode:
case implicit:
@@ -70,6 +65,11 @@ public class OAuth implements RequestInterceptor {
default:
break;
}
+ authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
+ }
+
+ public OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
+ this(new Client.Default(null, null), flow, authorizationUrl, tokenUrl, scopes);
}
@Override
@@ -80,34 +80,29 @@ public class OAuth implements RequestInterceptor {
}
// If first time, get the token
if (expirationTimeMillis == null || System.currentTimeMillis() >= expirationTimeMillis) {
- try {
- updateAccessToken();
- } catch (OAuthSystemException e) {
- e.printStackTrace();
- return;
- } catch (OAuthProblemException e) {
- e.printStackTrace();
- return;
- }
+ updateAccessToken();
}
if (getAccessToken() != null) {
template.header("Authorization", "Bearer " + getAccessToken());
}
}
- public synchronized void updateAccessToken() throws OAuthSystemException, OAuthProblemException {
- if (getAccessToken() == null) {
- OAuthJSONAccessTokenResponse accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage());
- if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
- setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn());
- if (accessTokenListener != null) {
- accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
- }
+ public synchronized void updateAccessToken() {
+ OAuthJSONAccessTokenResponse accessTokenResponse;
+ try {
+ accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage());
+ } catch (Exception e) {
+ throw new RetryableException(e.getMessage(), e,null);
+ }
+ if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
+ setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn());
+ if (accessTokenListener != null) {
+ accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
}
}
}
- public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
+ public synchronized void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
this.accessTokenListener = accessTokenListener;
}
@@ -117,7 +112,7 @@ public class OAuth implements RequestInterceptor {
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
this.accessToken = accessToken;
- this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * 1000;
+ this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
}
public TokenRequestBuilder getTokenRequestBuilder() {
@@ -148,7 +143,7 @@ public class OAuth implements RequestInterceptor {
this.oauthClient = new OAuthClient( new OAuthFeignClient(client));
}
- public class OAuthFeignClient implements HttpClient {
+ public static class OAuthFeignClient implements HttpClient {
private Client client;
@@ -198,6 +193,5 @@ public class OAuth implements RequestInterceptor {
public void shutdown() {
// Nothing to do here
}
-
}
}
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache
index 6c980b727fa..26cb9d7d946 100644
--- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache
@@ -76,12 +76,12 @@ public class {{classname}} {
{{/formParams}}
final String[] {{localVariablePrefix}}localVarAccepts = {
- {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
+ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
};
final String {{localVariablePrefix}}localVarAccept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}localVarAccepts);
final String[] {{localVariablePrefix}}localVarContentTypes = {
- {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
+ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
};
final String {{localVariablePrefix}}localVarContentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}localVarContentTypes);
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache
index 6c46a9aed9a..dd9141bd3dc 100644
--- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache
@@ -76,13 +76,13 @@ public class {{classname}} {
{{localVariablePrefix}}localVarFormParams.put("{{baseName}}", {{paramName}});{{/formParams}}
final String[] {{localVariablePrefix}}localVarAccepts = {
- {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
+ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
};
final String {{localVariablePrefix}}localVarAccept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}localVarAccepts);
if ({{localVariablePrefix}}localVarAccept != null) {{localVariablePrefix}}localVarHeaderParams.put("Accept", {{localVariablePrefix}}localVarAccept);
final String[] {{localVariablePrefix}}localVarContentTypes = {
- {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
+ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
};
final String {{localVariablePrefix}}localVarContentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}localVarContentTypes);
{{localVariablePrefix}}localVarHeaderParams.put("Content-Type", {{localVariablePrefix}}localVarContentType);
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api_test.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api_test.mustache
new file mode 100644
index 00000000000..a34cfe0e12b
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/api_test.mustache
@@ -0,0 +1,44 @@
+package {{package}};
+
+import {{invokerPackage}}.ApiClient;
+{{#imports}}import {{import}};
+{{/imports}}
+import org.junit.Before;
+import org.junit.Test;
+
+{{^fullJavaUtil}}
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+{{/fullJavaUtil}}
+
+/**
+ * API tests for {{classname}}
+ */
+public class {{classname}}Test {
+
+ private {{classname}} api;
+
+ @Before
+ public void setup() {
+ api = new ApiClient().createService({{classname}}.class);
+ }
+
+ {{#operations}}{{#operation}}
+ /**
+ * {{summary}}
+ *
+ * {{notes}}
+ */
+ @Test
+ public void {{operationId}}Test() {
+ {{#allParams}}
+ {{{dataType}}} {{paramName}} = null;
+ {{/allParams}}
+ // {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+
+ // TODO: test validations
+ }
+ {{/operation}}{{/operations}}
+}
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api_test.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api_test.mustache
new file mode 100644
index 00000000000..a34cfe0e12b
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api_test.mustache
@@ -0,0 +1,44 @@
+package {{package}};
+
+import {{invokerPackage}}.ApiClient;
+{{#imports}}import {{import}};
+{{/imports}}
+import org.junit.Before;
+import org.junit.Test;
+
+{{^fullJavaUtil}}
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+{{/fullJavaUtil}}
+
+/**
+ * API tests for {{classname}}
+ */
+public class {{classname}}Test {
+
+ private {{classname}} api;
+
+ @Before
+ public void setup() {
+ api = new ApiClient().createService({{classname}}.class);
+ }
+
+ {{#operations}}{{#operation}}
+ /**
+ * {{summary}}
+ *
+ * {{notes}}
+ */
+ @Test
+ public void {{operationId}}Test() {
+ {{#allParams}}
+ {{{dataType}}} {{paramName}} = null;
+ {{/allParams}}
+ // {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+
+ // TODO: test validations
+ }
+ {{/operation}}{{/operations}}
+}
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/auth/OAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/auth/OAuth.mustache
index 0997418a210..3b245597f21 100644
--- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/auth/OAuth.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/auth/OAuth.mustache
@@ -1,6 +1,7 @@
package {{invokerPackage}}.auth;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
+import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
import java.io.IOException;
import java.util.Map;
@@ -85,42 +86,55 @@ public class OAuth implements Interceptor {
updateAccessToken(null);
}
- // Build the request
- Builder rb = request.newBuilder();
+ if (getAccessToken() != null) {
+ // Build the request
+ Builder rb = request.newBuilder();
- String requestAccessToken = new String(getAccessToken());
- try {
- oAuthRequest = new OAuthBearerClientRequest(request.url().toString())
- .setAccessToken(requestAccessToken)
- .buildHeaderMessage();
- } catch (OAuthSystemException e) {
- throw new IOException(e);
+ String requestAccessToken = new String(getAccessToken());
+ try {
+ oAuthRequest = new OAuthBearerClientRequest(request.url().toString())
+ .setAccessToken(requestAccessToken)
+ .buildHeaderMessage();
+ } catch (OAuthSystemException e) {
+ throw new IOException(e);
+ }
+
+ for ( Map.Entry header : oAuthRequest.getHeaders().entrySet() ) {
+ rb.addHeader(header.getKey(), header.getValue());
+ }
+ rb.url( oAuthRequest.getLocationUri());
+
+ //Execute the request
+ Response response = chain.proceed(rb.build());
+
+ // 401 most likely indicates that access token has expired.
+ // Time to refresh and resend the request
+ if ( response != null && (response.code() == HTTP_UNAUTHORIZED | response.code() == HTTP_FORBIDDEN) ) {
+ if (updateAccessToken(requestAccessToken)) {
+ return intercept( chain );
+ }
+ }
+ return response;
+ } else {
+ return chain.proceed(chain.request());
}
-
- for ( Map.Entry header : oAuthRequest.getHeaders().entrySet() ) {
- rb.addHeader(header.getKey(), header.getValue());
- }
- rb.url( oAuthRequest.getLocationUri());
-
- //Execute the request
- Response response = chain.proceed(rb.build());
-
- // 401 most likely indicates that access token has expired.
- // Time to refresh and resend the request
- if ( response.code() == HTTP_UNAUTHORIZED ) {
- updateAccessToken(requestAccessToken);
- return intercept( chain );
- }
- return response;
}
- public synchronized void updateAccessToken(String requestAccessToken) throws IOException {
+ /*
+ * Returns true if the access token has been updated
+ */
+ public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
try {
OAuthJSONAccessTokenResponse accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage());
- setAccessToken(accessTokenResponse.getAccessToken());
- if (accessTokenListener != null) {
- accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
+ if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
+ setAccessToken(accessTokenResponse.getAccessToken());
+ if (accessTokenListener != null) {
+ accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
+ }
+ return getAccessToken().equals(requestAccessToken);
+ } else {
+ return false;
}
} catch (OAuthSystemException e) {
throw new IOException(e);
@@ -128,6 +142,7 @@ public class OAuth implements Interceptor {
throw new IOException(e);
}
}
+ return true;
}
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache
index 5d25496a1b3..7d57616610d 100644
--- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache
@@ -18,8 +18,8 @@ public interface {{classname}} {
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
- {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
- {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+ {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+ {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}});
{{/operation}}
}
diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/api.mustache
index 16f46ce0534..15442ad4748 100644
--- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/api.mustache
@@ -25,8 +25,8 @@ import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;
@Path("/{{baseName}}")
-{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
-{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
{{>generatedAnnotation}}
{{#operations}}
@@ -36,8 +36,8 @@ public class {{classname}} {
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
- {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
- {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+ {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+ {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#authMethods}}@io.swagger.annotations.Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
{{#scopes}}@io.swagger.annotations.AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}},
diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey2/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey2/api.mustache
index 4200f4aca6e..e1eb66091ae 100644
--- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey2/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey2/api.mustache
@@ -23,8 +23,8 @@ import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;
@Path("/{{baseName}}")
-{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
-{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
{{>generatedAnnotation}}
{{#operations}}
@@ -34,8 +34,8 @@ public class {{classname}} {
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
- {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
- {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+ {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+ {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#authMethods}}@io.swagger.annotations.Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
{{#scopes}}@io.swagger.annotations.AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}},
diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache
index d83facaf646..6354f755b8b 100644
--- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache
@@ -19,8 +19,8 @@ import javax.ws.rs.*;
{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
{{/isMultipart}}{{/operation}}{{/operations}}
@Path("/{{baseName}}")
-{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
-{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}} {
@@ -29,8 +29,8 @@ public class {{classname}} {
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
- {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
- {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+ {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+ {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{^isMultipart}}{{>formParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.{{nickname}}({{#isMultipart}}input,{{/isMultipart}}{{#allParams}}{{^isMultipart}}{{paramName}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{paramName}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}securityContext);
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache
index 126fbf61a2c..b214f376110 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache
@@ -41,8 +41,8 @@ public class {{classname}} {
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} })
@RequestMapping(value = "{{{path}}}",
- {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
- {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
+ {{#hasProduces}}produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
+ {{#hasConsumes}}consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
method = RequestMethod.{{httpMethod}})
public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}})
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api-j8-async.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api-j8-async.mustache
index b11e5c2db20..90cb04104f0 100755
--- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api-j8-async.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api-j8-async.mustache
@@ -49,8 +49,8 @@ public interface {{classname}} {
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},{{/hasMore}}{{/responses}} })
@RequestMapping(value = "{{path}}",
- {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
- {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
+ {{#hasProduces}}produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
+ {{#hasConsumes}}consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
method = RequestMethod.{{httpMethod}})
default CallablereturnTypes}}>> {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}})
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache
index ee02339909e..7fe7c5acf60 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache
@@ -46,8 +46,8 @@ public class {{classname}} {
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} })
@RequestMapping(value = "{{{path}}}",
- {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
- {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
+ {{#hasProduces}}produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
+ {{#hasConsumes}}consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
method = RequestMethod.{{httpMethod}})
public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}})
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache
index 257a4611db5..95c86d4bc0b 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache
@@ -163,10 +163,9 @@
9.2.9.v20150224
1.13
1.6.3
- 1.6.1
4.8.1
2.5
- 2.0.4-SNAPSHOT
- 4.0.9.RELEASE
+ 2.4.0
+ 4.2.5.RELEASE
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache
index f47085ad657..14abda4751c 100644
--- a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache
@@ -74,8 +74,8 @@
};
var authNames = [<#authMethods>''<#hasMore>, ];
- var contentTypes = [<#consumes>''<#hasMore>, ];
- var accepts = [<#produces>''<#hasMore>, ];
+ var contentTypes = [<#consumes>'<& mediaType>'<#hasMore>, ];
+ var accepts = [<#produces>'<& mediaType>'<#hasMore>, ];
var returnType = <#returnType><&returnType><^returnType>null;
return this.apiClient.callApi(
diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache
index f5aad995da5..0decb56e915 100644
--- a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache
@@ -82,8 +82,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
{{/operation}}
{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig
index c84abac129c..f0d0fde5e57 100644
--- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig
+++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig
@@ -27,6 +27,7 @@ io.swagger.codegen.languages.ScalaClientCodegen
io.swagger.codegen.languages.ScalatraServerCodegen
io.swagger.codegen.languages.SilexServerCodegen
io.swagger.codegen.languages.SinatraServerCodegen
+io.swagger.codegen.languages.Rails5ServerCodegen
io.swagger.codegen.languages.SlimFrameworkServerCodegen
io.swagger.codegen.languages.SpringBootServerCodegen
io.swagger.codegen.languages.SpringMVCServerCodegen
diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/README.md b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/README.md
index 8ec43e76497..db2dfccec36 100644
--- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/README.md
+++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/README.md
@@ -1,44 +1,54 @@
# TypeScript-Fetch
-This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The codegen Node module can be used in the following environments:
+This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
-* Node.JS
+Environment
+* Node.js
* Webpack
* Browserify
-It is usable in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `typings` in `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
+Language level
+* ES5 - you must have a Promises/A+ library installed
+* ES6
+
+Module system
+* CommonJS
+* ES6 module system
+
+It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
### Installation ###
-`swagger-codegen` does not generate JavaScript directly. The codegen Node module comes with `package.json` that bundles `typescript` and `typings` so it can self-compile. The self-compile is normally run automatically via the `npm` `postinstall` script of `npm install`.
+`swagger-codegen` does not generate JavaScript directly. The generated Node module comes with `package.json` that bundles `typescript` and `typings` so it can self-compile during `prepublish` stage. The should be run automatically during `npm install` or `npm publish`.
-CAVEAT: Due to [privilege implications](https://docs.npmjs.com/misc/scripts#user), `npm` may skip `postinstall` script if the user is `root`. You would need to manually invoke `npm install` or `npm run postinstall` for the codegen module if that's the case.
+CAVEAT: Due to [privilege implications](https://docs.npmjs.com/misc/scripts#user), `npm` would skip all scripts if the user is `root`. You would need to manually run it with `npm run prepublish` or run `npm install --unsafe-perm`.
-#### NPM repository ###
-If you remove `"private": true` from `package.json`, you may publish the module to NPM. In which case, you would be able to install the module as any other NPM module.
+#### NPM ####
+You may publish the module to NPM. In this case, you would be able to install the module as any other NPM module. It maybe useful to use [scoped packages](https://docs.npmjs.com/misc/scope).
-It maybe useful to use [scoped packages](https://docs.npmjs.com/misc/scope).
+You can also use `npm link` to link the module. However, this would not modify `package.json` of the installing project, as such you would need to relink everytime you deploy that project.
-#### NPM install local file ###
-You should be able to directly install the module using `npm install file:///codegen_path`.
+You can also directly install the module using `npm install file_path`. If you do `npm install file_path --save`, NPM will save relative path to `package.json`. In this case, `npm install` and `npm shrinkwrap` may misbehave. You would need to manually edit `package.json` and replace it with absolute path.
-NOTES: If you do `npm install file:///codegen_path --save` NPM might convert your path to relative path, maybe have adverse affect. `npm install` and `npm shrinkwrap` may misbehave if the installation path is not absolute.
-
-#### direct copy/symlink ###
-You may also simply copy or symlink the codegen into a directly under your project. The syntax of the usage would differ if you take this route. (See below)
-
-### Usage ###
-With ES6 module syntax, the following syntaxes are supported:
+Regardless of which method you deployed your NPM module, the ES6 module syntaxes are as follows:
```
import * as localName from 'npmName';
import {operationId} from 'npmName';
+```
+The CommonJS syntax is as follows:
+```
+import localName = require('npmName');
+```
+#### Direct copy/symlink ####
+You may also simply copy or symlink the generated module into a directory under your project. The syntax of this is as follows:
+
+With ES6 module syntax, the following syntaxes are supported:
+```
import * as localName from './symlinkDir';
import {operationId} from './symlinkDir';
```
-With CommonJS, the following syntaxes are supported:
+The CommonJS syntax is as follows:
```
-import localName = require('npmName');
-
import localName = require('./symlinkDir')';
-```
\ No newline at end of file
+```
diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache
index 67d61999aa0..20c303e40eb 100644
--- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache
@@ -1,7 +1,30 @@
-import * as querystring from 'querystring';
-import * as fetch from 'isomorphic-fetch';
-import {assign} from './assign';
+import * as querystring from "querystring";
+import * as url from "url";
+import * as isomorphicFetch from "isomorphic-fetch";
+{{^supportsES6}}
+import * as assign from "core-js/library/fn/object/assign";
+{{/supportsES6}}
+
+interface Dictionary { [index: string]: T; }
+export interface FetchAPI { (url: string, init?: any): Promise; }
+
+const BASE_PATH = "{{basePath}}";
+
+export interface FetchArgs {
+ url: string;
+ options: any;
+}
+
+export class BaseAPI {
+ basePath: string;
+ fetch: FetchAPI;
+
+ constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) {
+ this.basePath = basePath;
+ this.fetch = fetch;
+ }
+}
{{#models}}
{{#model}}
@@ -13,24 +36,20 @@ import {assign} from './assign';
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{#vars}}
{{#description}}
-
/**
* {{{description}}}
*/
{{/description}}
- "{{name}}"{{^required}}?{{/required}}: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
+ "{{name}}"{{^required}}?{{/required}}: {{#isEnum}}{{classname}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
{{/vars}}
}
{{#hasEnums}}
-export namespace {{classname}} {
{{#vars}}
{{#isEnum}}
-
-export type {{datatypeWithEnum}} = {{#allowableValues}}{{#values}}'{{.}}'{{^-last}} | {{/-last}}{{/values}}{{/allowableValues}};
+export type {{classname}}{{datatypeWithEnum}} = {{#allowableValues}}{{#values}}"{{.}}"{{^-last}} | {{/-last}}{{/values}}{{/allowableValues}};
{{/isEnum}}
{{/vars}}
-}
{{/hasEnums}}
{{/model}}
{{/models}}
@@ -38,96 +57,111 @@ export type {{datatypeWithEnum}} = {{#allowableValues}}{{#values}}'{{.}}'{{^-las
{{#apiInfo}}
{{#apis}}
{{#operations}}
-//export namespace {{package}} {
- 'use strict';
-
-{{#description}}
- /**
- * {{&description}}
- */
-{{/description}}
- export class {{classname}} {
- protected basePath = '{{basePath}}';
- public defaultHeaders : any = {};
-
- constructor(basePath?: string) {
- if (basePath) {
- this.basePath = basePath;
- }
- }
+/**
+ * {{classname}} - fetch parameter creator{{#description}}
+ * {{&description}}{{/description}}
+ */
+export const {{classname}}FetchParamCreactor = {
{{#operation}}
- /**
- * {{summary}}
- * {{notes}}
- {{#allParams}}* @param {{paramName}} {{description}}
- {{/allParams}}*/
- public {{nickname}} (params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }, extraQueryParams?: any, extraFetchParams?: any ) : Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
- const localVarPath = this.basePath + '{{path}}'{{#pathParams}}
- .replace('{' + '{{baseName}}' + '}', String(params.{{paramName}})){{/pathParams}};
-
- let queryParameters: any = assign({}, extraQueryParams);
- let headerParams: any = assign({}, this.defaultHeaders);
-{{#hasFormParams}}
- let formParams: any = {};
- headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
-
-{{/hasFormParams}}
-{{#hasBodyParam}}
- headerParams['Content-Type'] = 'application/json';
-
-{{/hasBodyParam}}
+ /** {{#summary}}
+ * {{summary}}{{/summary}}{{#notes}}
+ * {{notes}}{{/notes}}{{#allParams}}
+ * @param {{paramName}} {{description}}{{/allParams}}
+ */
+ {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}): FetchArgs {
{{#allParams}}
{{#required}}
- // verify required parameter '{{paramName}}' is set
- if (params.{{paramName}} == null) {
- throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}');
- }
+ // verify required parameter "{{paramName}}" is set
+ if (params["{{paramName}}"] == null) {
+ throw new Error("Missing required parameter {{paramName}} when calling {{nickname}}");
+ }
{{/required}}
{{/allParams}}
-{{#queryParams}}
- if (params.{{paramName}} !== undefined) {
- queryParameters['{{baseName}}'] = params.{{paramName}};
- }
+ const baseUrl = `{{path}}`{{#pathParams}}
+ .replace(`{${"{{baseName}}"}}`, `${ params.{{paramName}} }`){{/pathParams}};
+ let urlObj = url.parse(baseUrl, true);
+{{#hasQueryParams}}
+ urlObj.query = {{#supportsES6}}Object.{{/supportsES6}}assign({}, urlObj.query, { {{#queryParams}}
+ "{{baseName}}": params.{{paramName}},{{/queryParams}}
+ });
+{{/hasQueryParams}}
+ let fetchOptions: RequestInit = { method: "{{httpMethod}}" };
-{{/queryParams}}
-{{#headerParams}}
- headerParams['{{baseName}}'] = params.{{paramName}};
+ let contentTypeHeader: Dictionary;
+{{#hasFormParams}}
+ contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" };
+ fetchOptions.body = querystring.stringify({ {{#formParams}}
+ "{{baseName}}": params.{{paramName}},{{/formParams}}
+ });
+{{/hasFormParams}}
+{{#hasBodyParam}}
+ contentTypeHeader = { "Content-Type": "application/json" };{{#bodyParam}}
+ if (params["{{paramName}}"]) {
+ fetchOptions.body = JSON.stringify(params["{{paramName}}"] || {});
+ }{{/bodyParam}}
+{{/hasBodyParam}}
+{{#hasHeaderParam}}
+ fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({ {{#headerParams}}
+ "{{baseName}}": params.{{paramName}},{{/headerParams}}
+ }, contentTypeHeader);
+{{/hasHeaderParam}}
+{{^hasHeaderParam}}
+ if (contentTypeHeader) {
+ fetchOptions.headers = contentTypeHeader;
+ }
+{{/hasHeaderParam}}
+ return {
+ url: url.format(urlObj),
+ options: fetchOptions,
+ };
+ },
+{{/operation}}
+}
-{{/headerParams}}
-{{#formParams}}
- formParams['{{baseName}}'] = params.{{paramName}};
-
-{{/formParams}}
- let fetchParams = {
- method: '{{httpMethod}}',
- headers: headerParams,
- {{#bodyParam}}body: JSON.stringify(params.{{paramName}}),
- {{/bodyParam}}
- {{#hasFormParams}}body: querystring.stringify(formParams),
- {{/hasFormParams}}
-
- };
-
- if (extraFetchParams) {
- fetchParams = assign(fetchParams, extraFetchParams);
- }
-
- let localVarPathWithQueryParameters = localVarPath + (localVarPath.indexOf('?') !== -1 ? '&' : '?') + querystring.stringify(queryParameters);
-
- return fetch(localVarPathWithQueryParameters, fetchParams).then((response) => {
+/**
+ * {{classname}} - functional programming interface{{#description}}
+ * {{&description}}{{/description}}
+ */
+export const {{classname}}Fp = {
+{{#operation}}
+ /** {{#summary}}
+ * {{summary}}{{/summary}}{{#notes}}
+ * {{notes}}{{/notes}}{{#allParams}}
+ * @param {{paramName}} {{description}}{{/allParams}}
+ */
+ {{nickname}}({{#hasParams}}params: { {{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }{{/hasParams}}): (fetch: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> {
+ const fetchArgs = {{classname}}FetchParamCreactor.{{nickname}}({{#hasParams}}params{{/hasParams}});
+ return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
+ return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
- return response.json();
+ return response{{#returnType}}.json(){{/returnType}};
} else {
- let error = new Error(response.statusText);
- (error as any).response = response;
- throw error;
+ throw response;
}
});
- }
+ };
+ },
{{/operation}}
+};
+
+/**
+ * {{classname}} - object-oriented interface{{#description}}
+ * {{&description}}{{/description}}
+ */
+export class {{classname}} extends BaseAPI {
+{{#operation}}
+ /** {{#summary}}
+ * {{summary}}{{/summary}}{{#notes}}
+ * {{notes}}{{/notes}}{{#allParams}}
+ * @param {{paramName}} {{description}}{{/allParams}}
+ */
+ {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) {
+ return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(this.fetch, this.basePath);
}
-//}
+{{/operation}}
+}
+
{{/operations}}
{{/apis}}
{{/apiInfo}}
diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/assign.ts b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/assign.ts
deleted file mode 100644
index 23355144147..00000000000
--- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/assign.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export function assign (target: any, ...args: any[]) {
- 'use strict';
- if (target === undefined || target === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
-
- var output = Object(target);
- for (let source of args) {
- if (source !== undefined && source !== null) {
- for (var nextKey in source) {
- if (source.hasOwnProperty(nextKey)) {
- output[nextKey] = source[nextKey];
- }
- }
- }
- }
- return output;
-};
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache
index e6379434b80..62a598d536b 100644
--- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache
+++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache
@@ -1,15 +1,15 @@
{
"name": "{{#npmName}}{{{npmName}}}{{/npmName}}{{^npmName}}typescript-fetch-api{{/npmName}}",
"version": "{{#npmVersion}}{{{npmVersion}}}{{/npmVersion}}{{^npmVersion}}0.0.0{{/npmVersion}}",
- "private": true,
"main": "./dist/api.js",
"browser": "./dist/api.js",
"typings": "./dist/api.d.ts",
"dependencies": {
- "isomorphic-fetch": "^2.2.1"
+ {{^supportsES6}}"core-js": "^2.4.0",
+ {{/supportsES6}}"isomorphic-fetch": "^2.2.1"
},
"scripts" : {
- "install" : "typings install && tsc"
+ "prepublish" : "typings install && tsc"
},
"devDependencies": {
"typescript": "^1.8.10",
diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tsconfig.json.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tsconfig.json.mustache
index 06a057d7a49..25f414e9840 100644
--- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tsconfig.json.mustache
+++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tsconfig.json.mustache
@@ -4,7 +4,8 @@
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"module": "commonjs",
"noImplicitAny": true,
- "outDir": "dist"
+ "outDir": "dist",
+ "rootDir": "."
},
"exclude": [
"dist",
diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/typings.json.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/typings.json.mustache
index 38baf589fb9..3aca69ff648 100644
--- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/typings.json.mustache
+++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/typings.json.mustache
@@ -1,9 +1,9 @@
{
"version": false,
"dependencies": {},
- "ambientDependencies": {
-{{^supportsES6}} "es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304",
-{{/supportsES6}} "node": "registry:dt/node#4.0.0+20160423143914",
+ "ambientDependencies": { {{^supportsES6}}
+ "core-js": "registry:dt/core-js#0.0.0+20160317120654",{{/supportsES6}}
+ "node": "registry:dt/node#4.0.0+20160423143914",
"isomorphic-fetch": "registry:dt/isomorphic-fetch#0.0.0+20160505171433"
}
}
diff --git a/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore b/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore
new file mode 100644
index 00000000000..19d3377182e
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore
@@ -0,0 +1,23 @@
+# Swagger Codegen Ignore
+# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache
index 4d0e8c99675..7983a41edf6 100644
--- a/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache
@@ -20,7 +20,7 @@ object {{classname}} {
{{>javadoc}}
{{/javadocRenderer}}
def {{operationId}}({{>methodParameters}}): ApiRequest[{{>operationReturnType}}] =
- ApiRequest[{{>operationReturnType}}](ApiMethods.{{httpMethod.toUpperCase}}, "{{basePath}}", "{{path}}", {{#consumes.0}}"{{mediaType}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}})
+ ApiRequest[{{>operationReturnType}}](ApiMethods.{{httpMethod.toUpperCase}}, "{{basePath}}", "{{path}}", {{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}})
{{#authMethods}}{{#isApiKey}}.withApiKey(apiKey, "{{keyParamName}}", {{#isKeyInQuery}}QUERY{{/isKeyInQuery}}{{#isKeyInHeader}}HEADER{{/isKeyInHeader}})
{{/isApiKey}}{{#isBasic}}.withCredentials(basicAuth)
{{/isBasic}}{{/authMethods}}{{#bodyParam}}.withBody({{paramName}})
diff --git a/modules/swagger-codegen/src/main/resources/android/api.mustache b/modules/swagger-codegen/src/main/resources/android/api.mustache
index f3d0f7996de..5f786e503a0 100644
--- a/modules/swagger-codegen/src/main/resources/android/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/api.mustache
@@ -73,7 +73,7 @@ public class {{classname}} {
{{/headerParams}}
String[] localVarContentTypes = {
- {{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
+ {{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
};
String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json";
diff --git a/modules/swagger-codegen/src/main/resources/android/apiException.mustache b/modules/swagger-codegen/src/main/resources/android/apiException.mustache
index a6bcba75b7c..be5255e2568 100644
--- a/modules/swagger-codegen/src/main/resources/android/apiException.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/apiException.mustache
@@ -14,16 +14,16 @@ public class ApiException extends Exception {
public int getCode() {
return code;
}
-
+
public void setCode(int code) {
this.code = code;
}
-
+
public String getMessage() {
return message;
}
-
+
public void setMessage(String message) {
this.message = message;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/api_doc.mustache b/modules/swagger-codegen/src/main/resources/android/api_doc.mustache
index 2fdcab749ab..cd3888dfb06 100644
--- a/modules/swagger-codegen/src/main/resources/android/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/api_doc.mustache
@@ -53,8 +53,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
{{/operation}}
{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache
index e153ce23ecf..a9b0f28edfb 100755
--- a/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache
@@ -28,7 +28,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
diff --git a/modules/swagger-codegen/src/main/resources/android/gradle-wrapper.jar b/modules/swagger-codegen/src/main/resources/android/gradle-wrapper.jar
new file mode 100644
index 00000000000..2c6137b8789
Binary files /dev/null and b/modules/swagger-codegen/src/main/resources/android/gradle-wrapper.jar differ
diff --git a/modules/swagger-codegen/src/main/resources/android/gradle-wrapper.properties.mustache b/modules/swagger-codegen/src/main/resources/android/gradle-wrapper.properties.mustache
new file mode 100644
index 00000000000..fa452523ac0
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/android/gradle-wrapper.properties.mustache
@@ -0,0 +1,6 @@
+#Mon May 16 21:00:11 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
diff --git a/modules/swagger-codegen/src/main/resources/android/gradlew.bat.mustache b/modules/swagger-codegen/src/main/resources/android/gradlew.bat.mustache
new file mode 100644
index 00000000000..5f192121eb4
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/android/gradlew.bat.mustache
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/modules/swagger-codegen/src/main/resources/android/gradlew.mustache b/modules/swagger-codegen/src/main/resources/android/gradlew.mustache
new file mode 100644
index 00000000000..9d82f789151
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/android/gradlew.mustache
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/modules/swagger-codegen/src/main/resources/android/httpPatch.mustache b/modules/swagger-codegen/src/main/resources/android/httpPatch.mustache
index 55cec2f1279..08ce4409f7a 100644
--- a/modules/swagger-codegen/src/main/resources/android/httpPatch.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/httpPatch.mustache
@@ -13,4 +13,4 @@ public class HttpPatch extends HttpPost {
public String getMethod() {
return METHOD_PATCH;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache
index 38c7f00cdaa..5d9ecb32066 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache
@@ -81,7 +81,7 @@ public class {{classname}} {
{{/headerParams}}
String[] contentTypes = {
- {{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
+ {{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
@@ -167,7 +167,7 @@ public class {{classname}} {
{{/headerParams}}
String[] contentTypes = {
- {{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
+ {{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache
index a6bcba75b7c..be5255e2568 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache
@@ -14,16 +14,16 @@ public class ApiException extends Exception {
public int getCode() {
return code;
}
-
+
public void setCode(int code) {
this.code = code;
}
-
+
public String getMessage() {
return message;
}
-
+
public void setMessage(String message) {
this.message = message;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/git_push.sh.mustache
new file mode 100644
index 00000000000..b3c88d4be09
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/git_push.sh.mustache
@@ -0,0 +1,51 @@
+#!/bin/sh
+# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
+#
+# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
+
+git_user_id=$1
+git_repo_id=$2
+release_note=$3
+
+if [ "$git_user_id" = "" ]; then
+ git_user_id="{{{gitUserId}}}"
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
+fi
+
+if [ "$git_repo_id" = "" ]; then
+ git_repo_id="{{{gitRepoId}}}"
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
+fi
+
+if [ "$release_note" = "" ]; then
+ release_note="{{{releaseNote}}}"
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
+fi
+
+# Initialize the local directory as a Git repository
+git init
+
+# Adds the files in the local repository and stages them for commit.
+git add .
+
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
+git commit -m "$release_note"
+
+# Sets the new remote
+git_remote=`git remote`
+if [ "$git_remote" = "" ]; then # git remote not defined
+
+ if [ "$GIT_TOKEN" = "" ]; then
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ else
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ fi
+
+fi
+
+git pull origin master
+
+# Pushes (Forces) the changes in the local repository up to the remote repository
+echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/gitignore.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/gitignore.mustache
new file mode 100644
index 00000000000..a8368751267
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/gitignore.mustache
@@ -0,0 +1,39 @@
+# Built application files
+*.apk
+*.ap_
+
+# Files for the Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+
+# Keystore files
+*.jks
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/model.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/model.mustache
index d22bfa5693b..df99de87403 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/model.mustache
@@ -52,7 +52,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
return true;{{/hasVars}}
}
- @Override
+ @Override
public int hashCode() {
int result = 17;
{{#vars}}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/pom.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/pom.mustache
index 4036bb32afb..80ba5feacab 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/pom.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/pom.mustache
@@ -37,11 +37,24 @@
${android-platform-version}
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.6
+ 1.6
+
+
+
+
- 1.5.0
+ 1.5.8
4.4.4
4.5.2
- 2.3.1
+ 2.6.2
1.0.19
4.1.1.4
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache
index 0df3f6e4ac4..6b0600e77b9 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache
@@ -83,4 +83,4 @@ public class DeleteRequest extends Request {
return headers;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/getrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/getrequest.mustache
index 63803c3b481..ec225b5a46c 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/getrequest.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/getrequest.mustache
@@ -36,4 +36,4 @@ public class GetRequest extends StringRequest{
return headers;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache
index 87270b48ebf..188fc5edb41 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache
@@ -83,4 +83,4 @@ public class PatchRequest extends Request {
return headers;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache
index f11fddd25ef..02c7fdfb119 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache
@@ -83,4 +83,4 @@ public class PostRequest extends Request {
return headers;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache
index 9e54c7cfe9a..571a921e56a 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache
@@ -83,4 +83,4 @@ public class PutRequest extends Request {
return headers;
}
-}
\ No newline at end of file
+}
diff --git a/modules/swagger-codegen/src/main/resources/android/model.mustache b/modules/swagger-codegen/src/main/resources/android/model.mustache
index d22bfa5693b..df99de87403 100644
--- a/modules/swagger-codegen/src/main/resources/android/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/model.mustache
@@ -52,7 +52,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
return true;{{/hasVars}}
}
- @Override
+ @Override
public int hashCode() {
int result = 17;
{{#vars}}
diff --git a/modules/swagger-codegen/src/main/resources/android/pom.mustache b/modules/swagger-codegen/src/main/resources/android/pom.mustache
index 0c00c55de1f..bf11a6625c5 100644
--- a/modules/swagger-codegen/src/main/resources/android/pom.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/pom.mustache
@@ -152,4 +152,4 @@
4.8.1
4.3.6
-
\ No newline at end of file
+
diff --git a/modules/swagger-codegen/src/main/resources/android/settings.gradle.mustache b/modules/swagger-codegen/src/main/resources/android/settings.gradle.mustache
index b8fd6c4c41f..ba0114cb176 100644
--- a/modules/swagger-codegen/src/main/resources/android/settings.gradle.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/settings.gradle.mustache
@@ -1 +1 @@
-rootProject.name = "{{artifactId}}"
\ No newline at end of file
+rootProject.name = "{{artifactId}}"
diff --git a/modules/swagger-codegen/src/main/resources/clojure/api.mustache b/modules/swagger-codegen/src/main/resources/clojure/api.mustache
index a6b598fc610..cf821cfdd3c 100644
--- a/modules/swagger-codegen/src/main/resources/clojure/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/clojure/api.mustache
@@ -14,8 +14,8 @@
<#hasOptionalParams> :query-params {<#queryParams>"" <#collectionFormat>(with-collection-format :)<^collectionFormat> }
<#hasOptionalParams> :form-params {<#formParams>"" <#collectionFormat>(with-collection-format :)<^collectionFormat> }<#bodyParam>
<#hasOptionalParams> :body-param
- <#hasOptionalParams> :content-types [<#consumes>""<#hasMore> ]
- <#hasOptionalParams> :accepts [<#produces>""<#hasMore> ]
+ <#hasOptionalParams> :content-types [<#consumes>"<& mediaType>"<#hasMore> ]
+ <#hasOptionalParams> :accepts [<#produces>"<& mediaType>"<#hasMore> ]
<#hasOptionalParams> :auth-names [<#authMethods>"<&name>"<#hasMore> ]})<#hasOptionalParams>))
(defn
@@ -24,4 +24,4 @@
([<#allParams><#required><#isFile>^File ] (<#allParams><#required> nil))
<#hasOptionalParams>([<#allParams><#required><#isFile>^File <#hasOptionalParams>optional-params]
<#hasOptionalParams> (:data (-with-http-info<#allParams><#required> <#hasOptionalParams> optional-params))<#hasOptionalParams>))
-
\ No newline at end of file
+
diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
index 2c0f8f681e3..f9b9f766299 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
@@ -20,6 +20,11 @@ namespace {{packageName}}.Client
///
public class ApiClient
{
+ private JsonSerializerSettings serializerSettings = new JsonSerializerSettings
+ {
+ ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
+ };
+
///
/// Initializes a new instance of the class
/// with default configuration and base path ({{basePath}}).
@@ -305,7 +310,7 @@ namespace {{packageName}}.Client
// at this point, it must be a model (json)
try
{
- return JsonConvert.DeserializeObject(response.Content, type);
+ return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
}
catch (Exception e)
{
diff --git a/modules/swagger-codegen/src/main/resources/csharp/IApiAccessor.mustache b/modules/swagger-codegen/src/main/resources/csharp/IApiAccessor.mustache
new file mode 100644
index 00000000000..eecd5284493
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/csharp/IApiAccessor.mustache
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using RestSharp;
+
+namespace {{packageName}}.Client
+{
+ ///
+ /// Represents configuration aspects required to interact with the API endpoints.
+ ///
+ public interface IApiAccessor
+ {
+ ///
+ /// Gets or sets the configuration object
+ ///
+ /// An instance of the Configuration
+ Configuration Configuration {get; set;}
+
+ ///
+ /// Gets the base path of the API client.
+ ///
+ /// The base path
+ String GetBasePath();
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache b/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache
index 57f6201600f..763780f657e 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache
@@ -4,9 +4,9 @@ VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.csproj", "{{packageGuid}}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{testPackageName}}", "src\{{testPackageName}}\{{testPackageName}}.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
+{{^excludeTests}}Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{testPackageName}}", "src\{{testPackageName}}\{{testPackageName}}.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
EndProject
-Global
+{{/excludeTests}}Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
index 2b3f224cfc5..da1cee8caef 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
@@ -13,7 +13,7 @@ namespace {{packageName}}.Api
///
/// Represents a collection of functions to interact with the API endpoints
///
- public interface I{{classname}}
+ public interface I{{classname}} : IApiAccessor
{
#region Synchronous Operations
{{#operation}}
@@ -72,7 +72,7 @@ namespace {{packageName}}.Api
///
/// Represents a collection of functions to interact with the API endpoints
///
- public class {{classname}} : I{{classname}}
+ public partial class {{classname}} : I{{classname}}
{
///
/// Initializes a new instance of the class.
@@ -122,7 +122,7 @@ namespace {{packageName}}.Api
/// Sets the base path of the API client.
///
/// The base path
- [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
+ [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
public void SetBasePath(String basePath)
{
// do nothing
@@ -196,7 +196,7 @@ namespace {{packageName}}.Api
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
{{#consumes}}
- "{{mediaType}}"{{#hasMore}}, {{/hasMore}}
+ "{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}
{{/consumes}}
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
@@ -204,7 +204,7 @@ namespace {{packageName}}.Api
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
{{#produces}}
- "{{mediaType}}"{{#hasMore}}, {{/hasMore}}
+ "{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}
{{/produces}}
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
@@ -329,7 +329,7 @@ namespace {{packageName}}.Api
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
{{#consumes}}
- "{{mediaType}}"{{#hasMore}}, {{/hasMore}}
+ "{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}
{{/consumes}}
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
@@ -337,7 +337,7 @@ namespace {{packageName}}.Api
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
{{#produces}}
- "{{mediaType}}"{{#hasMore}}, {{/hasMore}}
+ "{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}
{{/produces}}
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
diff --git a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache
index 677ad3edbe1..c0a31d09377 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache
@@ -87,8 +87,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
diff --git a/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache b/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache
index cb345a93cc4..21471de3c27 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache
@@ -32,7 +32,7 @@ namespace {{packageName}}.Test
[SetUp]
public void Init()
{
- instance = new {{classname}}();
+ instance = new {{classname}}();
}
///
diff --git a/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache b/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache
index 4d4061a29fd..c8a00373ff2 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache
@@ -24,6 +24,13 @@
public {{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} { get; set; }
{{/isEnum}}
{{/vars}}
+ {{#hasRequired}}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected {{classname}}() { }
+ {{/hasRequired}}
///
/// Initializes a new instance of the class.
///
@@ -32,9 +39,12 @@
/// {{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.
{{/isReadOnly}}
{{/vars}}
- public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} = null{{/isReadOnly}}{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/vars}})
+ public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} = null{{^-last}}, {{/-last}}{{/readWriteVars}})
{
- {{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
+ {{#vars}}
+ {{^isReadOnly}}
+ {{#required}}
+ // to ensure "{{name}}" is required (not null)
if ({{name}} == null)
{
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
@@ -43,8 +53,12 @@
{
this.{{name}} = {{name}};
}
- {{/required}}{{/isReadOnly}}{{/vars}}
- {{#vars}}{{^isReadOnly}}{{^required}}
+ {{/required}}
+ {{/isReadOnly}}
+ {{/vars}}
+ {{#vars}}
+ {{^isReadOnly}}
+ {{^required}}
{{#defaultValue}}// use default value if no "{{name}}" provided
if ({{name}} == null)
{
@@ -56,9 +70,11 @@
}
{{/defaultValue}}
{{^defaultValue}}
- this.{{name}} = {{name}};
+this.{{name}} = {{name}};
{{/defaultValue}}
- {{/required}}{{/isReadOnly}}{{/vars}}
+ {{/required}}
+ {{/isReadOnly}}
+ {{/vars}}
}
{{#vars}}
@@ -79,7 +95,8 @@
{
var sb = new StringBuilder();
sb.Append("class {{classname}} {\n");
- {{#vars}}sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
+ {{#vars}}
+ sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
sb.Append("}\n");
return sb.ToString();
diff --git a/modules/swagger-codegen/src/main/resources/dart/api.mustache b/modules/swagger-codegen/src/main/resources/dart/api.mustache
index d8ee98569c1..cba12208b7d 100644
--- a/modules/swagger-codegen/src/main/resources/dart/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/dart/api.mustache
@@ -37,7 +37,7 @@ class {{classname}} {
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}};
{{/headerParams}}
- List contentTypes = [{{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}];
+ List contentTypes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}];
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
List authNames = [{{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
diff --git a/modules/swagger-codegen/src/main/resources/go/.travis.yml b/modules/swagger-codegen/src/main/resources/go/.travis.yml
new file mode 100644
index 00000000000..f5cb2ce9a5a
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/go/.travis.yml
@@ -0,0 +1,8 @@
+language: go
+
+install:
+ - go get -d -v .
+
+script:
+ - go build -v ./
+
diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache
index 480db023f6b..0209e8590c3 100644
--- a/modules/swagger-codegen/src/main/resources/go/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/go/api.mustache
@@ -5,6 +5,7 @@ import (
"strings"
"fmt"
"errors"
+ "net/url"
{{#imports}}"{{import}}"
{{/imports}}
)
@@ -50,7 +51,7 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
}{{/required}}{{/allParams}}
headerParams := make(map[string]string)
- queryParams := make(map[string]string)
+ queryParams := url.Values{}
formParams := make(map[string]string)
var postBody interface{}
var fileName string
@@ -75,13 +76,26 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
- }{{#hasQueryParams}}{{#queryParams}}
-
- queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
+ }
+ {{#hasQueryParams}}
+ {{#queryParams}}
+ {{#isListContainer}}
+ var collectionFormat = "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"
+ if collectionFormat == "multi" {
+ for _, value := range {{paramName}} {
+ queryParams.Add("{{paramName}}", value)
+ }
+ } else {
+ queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, collectionFormat))
+ }
+ {{/isListContainer}}
+ {{^isListContainer}}
+ queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, ""))
+ {{/isListContainer}}
{{/queryParams}}{{/hasQueryParams}}
// to determine the Content-Type header
- localVarHttpContentTypes := []string{ {{#consumes}}"{{mediaType}}", {{/consumes}} }
+ localVarHttpContentTypes := []string{ {{#consumes}}"{{{mediaType}}}", {{/consumes}} }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
@@ -90,7 +104,7 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
- {{#produces}}"{{mediaType}}",
+ {{#produces}}"{{{mediaType}}}",
{{/produces}} }
// set Accept header
diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache
index 88c5ce07e4e..2fa6d14ef2b 100644
--- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache
+++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache
@@ -6,7 +6,7 @@ import (
"path/filepath"
"reflect"
"strings"
-
+ "net/url"
"github.com/go-resty/resty"
)
@@ -47,7 +47,7 @@ func contains(source []string, containvalue string) bool {
func (c *APIClient) CallAPI(path string, method string,
postBody interface{},
headerParams map[string]string,
- queryParams map[string]string,
+ queryParams url.Values,
formParams map[string]string,
fileName string,
fileBytes []byte) (*resty.Response, error) {
@@ -79,17 +79,26 @@ func (c *APIClient) CallAPI(path string, method string,
return nil, fmt.Errorf("invalid method %v", method)
}
-func (c *APIClient) ParameterToString(obj interface{}) string {
+func (c *APIClient) ParameterToString(obj interface{},collectionFormat string) string {
if reflect.TypeOf(obj).String() == "[]string" {
- return strings.Join(obj.([]string), ",")
- } else {
- return obj.(string)
+ switch collectionFormat {
+ case "pipes":
+ return strings.Join(obj.([]string), "|")
+ case "ssv":
+ return strings.Join(obj.([]string), " ")
+ case "tsv":
+ return strings.Join(obj.([]string), "\t")
+ case "csv" :
+ return strings.Join(obj.([]string), ",")
+ }
}
+
+ return obj.(string)
}
func prepareRequest(postBody interface{},
headerParams map[string]string,
- queryParams map[string]string,
+ queryParams url.Values,
formParams map[string]string,
fileName string,
fileBytes []byte) *resty.Request {
@@ -104,7 +113,7 @@ func prepareRequest(postBody interface{},
// add query parameter, if any
if len(queryParams) > 0 {
- request.SetQueryParams(queryParams)
+ request.SetMultiValueQueryParams(queryParams)
}
// add form parameter, if any
diff --git a/modules/swagger-codegen/src/main/resources/go/api_doc.mustache b/modules/swagger-codegen/src/main/resources/go/api_doc.mustache
index e91082ffc99..3c3444474ee 100644
--- a/modules/swagger-codegen/src/main/resources/go/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/go/api_doc.mustache
@@ -35,8 +35,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache
index 60da5979a89..ad22284d4e4 100644
--- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache
+++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache
@@ -14,10 +14,17 @@
{{#infoUrl}}{{/infoUrl}}
{{#infoEmail}}{{/infoEmail}}
{{#version}}Version: {{{version}}}
{{/version}}
+ {{#basePathWithoutHost}}BasePath:{{basePathWithoutHost}}
{{/basePathWithoutHost}}
{{{licenseInfo}}}
{{{licenseUrl}}}
Access
- {{access}}
+ {{#hasAuthMethods}}
+
+ {{#authMethods}}
+ - {{#isBasic}}HTTP Basic Authentication{{/isBasic}}{{#isOAuth}}OAuth AuthorizationUrl:{{authorizationUrl}}TokenUrl:{{tokenUrl}}{{/isOAuth}}{{#isApiKey}}APIKey KeyParamName:{{keyParamName}} KeyInQuery:{{isKeyInQuery}} KeyInHeader:{{isKeyInHeader}}{{/isApiKey}}
+ {{/authMethods}}
+
+ {{/hasAuthMethods}}
[ Jump to Models ]
@@ -61,7 +68,7 @@
This API call consumes the following media types via the Content-Type request header:
{{#consumes}}
- {{mediaType}}
+ {{{mediaType}}}
{{/consumes}}
{{/hasConsumes}}
@@ -118,7 +125,7 @@
the media type will be conveyed by the Content-Type response header.
{{#produces}}
- {{mediaType}}
+ {{{mediaType}}}
{{/produces}}
{{/hasProduces}}
diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Http/routes.mustache b/modules/swagger-codegen/src/main/resources/lumen/app/Http/routes.mustache
index 3166f947935..4b904bf2f8e 100644
--- a/modules/swagger-codegen/src/main/resources/lumen/app/Http/routes.mustache
+++ b/modules/swagger-codegen/src/main/resources/lumen/app/Http/routes.mustache
@@ -13,7 +13,7 @@ $app->get('/', function () use ($app) {
* {{httpMethod}} {{nickname}}
* Summary: {{summary}}
* Notes: {{notes}}
-{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
+{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
*/
$app->{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}$null = null) use ($app) {
{{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}}
diff --git a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache
index be2fac8d86e..3d91b32c8e4 100644
--- a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache
+++ b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache
@@ -13,7 +13,7 @@ $app->get('/', function () use ($app) {
* {{httpMethod}} {{nickname}}
* Summary: {{summary}}
* Notes: {{notes}}
-{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
+{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
*/
Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}null) use ($app) {
{{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}}
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 5afc917e228..f0f99bc96e2 100644
--- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache
@@ -2,7 +2,7 @@
NSString *const {{classPrefix}}ResponseObjectErrorKey = @"{{classPrefix}}ResponseObject";
-static long requestId = 0;
+static NSUInteger requestId = 0;
static bool offlineState = false;
static NSMutableSet * queuedRequests = nil;
static bool cacheEnabled = false;
@@ -36,7 +36,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
@interface {{classPrefix}}ApiClient ()
-@property (readwrite, nonatomic) NSDictionary *HTTPResponseHeaders;
+@property (nonatomic, strong) NSDictionary* HTTPResponseHeaders;
@end
@@ -83,54 +83,10 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
reachabilityStatus = status;
}
-- (void)setHeaderValue:(NSString*) value
- forKey:(NSString*) forKey {
+- (void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey {
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
}
-#pragma mark - Log Methods
-
-+ (void)debugLog:(NSString *)method
- message:(NSString *)format, ... {
- {{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig];
- if (!config.debug) {
- return;
- }
-
- NSMutableString *message = [NSMutableString stringWithCapacity:1];
-
- if (method) {
- [message appendString:[NSString stringWithFormat:@"%@: ", method]];
- }
-
- va_list args;
- va_start(args, format);
-
- [message appendString:[[NSString alloc] initWithFormat:format arguments:args]];
-
- // If set logging file handler, log into file,
- // otherwise log into console.
- if (config.loggingFileHanlder) {
- [config.loggingFileHanlder seekToEndOfFile];
- [config.loggingFileHanlder writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];
- }
- else {
- NSLog(@"%@", message);
- }
-
- va_end(args);
-}
-
-- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error {
-
- NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\
- "[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n",
- [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding],
- responseObject];
-
- {{classPrefix}}DebugLog(message);
-}
-
#pragma mark - Cache Methods
+(void)clearCache {
@@ -151,86 +107,20 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
[NSURLCache setSharedURLCache:cache];
}
-#pragma mark - Utility Methods
-
-/*
- * Detect `Accept` from accepts
- */
-+ (NSString *) selectHeaderAccept:(NSArray *)accepts {
- if (accepts == nil || [accepts count] == 0) {
- return @"";
- }
-
- NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
- for (NSString *string in accepts) {
- NSString * lowerAccept = [string lowercaseString];
- // use rangeOfString instead of containsString for iOS 7 support
- if ([lowerAccept rangeOfString:@"application/json"].location != NSNotFound) {
- return @"application/json";
- }
- [lowerAccepts addObject:lowerAccept];
- }
-
- if (lowerAccepts.count == 1) {
- return [lowerAccepts firstObject];
- }
-
- return [lowerAccepts componentsJoinedByString:@", "];
-}
-
-/*
- * Detect `Content-Type` from contentTypes
- */
-+ (NSString *) selectHeaderContentType:(NSArray *)contentTypes
-{
- if (contentTypes == nil || [contentTypes count] == 0) {
- return @"application/json";
- }
-
- NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]];
- [contentTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- [lowerContentTypes addObject:[obj lowercaseString]];
- }];
-
- if ([lowerContentTypes containsObject:@"application/json"]) {
- return @"application/json";
- }
- else {
- return lowerContentTypes[0];
- }
-}
-
-+ (NSString*)escape:(id)unescaped {
- if ([unescaped isKindOfClass:[NSString class]]){
- return (NSString *)CFBridgingRelease
- (CFURLCreateStringByAddingPercentEscapes(
- NULL,
- (__bridge CFStringRef) unescaped,
- NULL,
- (CFStringRef)@"!*'();:@&=+$,/?%#[]",
- kCFStringEncodingUTF8));
- }
- else {
- return [NSString stringWithFormat:@"%@", unescaped];
- }
-}
-
#pragma mark - Request Methods
-+(unsigned long)requestQueueSize {
++(NSUInteger)requestQueueSize {
return [queuedRequests count];
}
+(NSNumber*) nextRequestId {
@synchronized(self) {
- long nextId = ++requestId;
- {{classPrefix}}DebugLog(@"got id %ld", nextId);
- return [NSNumber numberWithLong:nextId];
+ return @(++requestId);
}
}
+(NSNumber*) queueRequest {
- NSNumber* requestId = [{{classPrefix}}ApiClient nextRequestId];
+ NSNumber* requestId = [[self class] nextRequestId];
{{classPrefix}}DebugLog(@"added %@ to request queue", requestId);
[queuedRequests addObject:requestId];
return requestId;
@@ -294,7 +184,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
if (![strongSelf executeRequestWithId:requestId]) {
return;
}
- [strongSelf logResponse:response responseObject:responseObject request:request error:error];
+ {{classPrefix}}DebugLogResponse(response, responseObject,request,error);
strongSelf.HTTPResponseHeaders = {{classPrefix}}__headerFieldsForResponse(response);
if(!error) {
completionBlock(responseObject, nil);
@@ -321,7 +211,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
return;
}
strongSelf.HTTPResponseHeaders = {{classPrefix}}__headerFieldsForResponse(response);
- [strongSelf logResponse:response responseObject:responseObject request:request error:error];
+ {{classPrefix}}DebugLogResponse(response, responseObject,request,error);
if(error) {
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
if (responseObject) {
@@ -330,8 +220,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
completionBlock(nil, augmentedError);
}
- {{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig];
- NSString *directory = config.tempFolderPath ?: NSTemporaryDirectory();
+ NSString *directory = [self configuration].tempFolderPath ?: NSTemporaryDirectory();
NSString * filename = {{classPrefix}}__fileNameForResponse(response);
NSString *filepath = [directory stringByAppendingPathComponent:filename];
@@ -370,14 +259,13 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
self.requestSerializer = [AFHTTPRequestSerializer serializer];
}
else {
- NSAssert(false, @"unsupport request type %@", requestContentType);
+ NSAssert(NO, @"Unsupported request type %@", requestContentType);
}
// setting response serializer
if ([responseContentType isEqualToString:@"application/json"]) {
self.responseSerializer = [{{classPrefix}}JSONResponseSerializer serializer];
- }
- else {
+ } else {
self.responseSerializer = [AFHTTPResponseSerializer serializer];
}
@@ -393,8 +281,9 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
NSMutableString *resourcePath = [NSMutableString stringWithString:path];
[pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
- [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]]
- withString:[{{classPrefix}}ApiClient escape:obj]];
+ NSString * safeString = ([obj isKindOfClass:[NSString class]]) ? obj : [NSString stringWithFormat:@"%@", obj];
+ safeString = {{classPrefix}}PercentEscapedStringFromString(safeString);
+ [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"{%@}", key]] withString:safeString];
}];
NSMutableURLRequest * request = nil;
@@ -438,10 +327,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
}
// request cache
- BOOL hasHeaderParams = false;
- if (headerParams != nil && [headerParams count] > 0) {
- hasHeaderParams = true;
- }
+ BOOL hasHeaderParams = [headerParams count] > 0;
if (offlineState) {
{{classPrefix}}DebugLog(@"%@ cache forced", resourcePath);
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
@@ -462,9 +348,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
}
[self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"];
-
- // Always disable cookies!
- [request setHTTPShouldHandleCookies:NO];
+ [self postProcessRequest:request];
NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest];
if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) {
@@ -485,59 +369,66 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
return requestId;
}
+//Added for easier override to modify request
+-(void)postProcessRequest:(NSMutableURLRequest *)request {
+ // Always disable cookies!
+ [request setHTTPShouldHandleCookies:NO];
+}
+
#pragma mark -
- (NSString*) pathWithQueryParamsToString:(NSString*) path
queryParams:(NSDictionary*) queryParams {
+ if(queryParams.count == 0) {
+ return path;
+ }
NSString * separator = nil;
- int counter = 0;
+ NSUInteger counter = 0;
NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path];
- if (queryParams != nil){
- for(NSString * key in [queryParams keyEnumerator]){
- if (counter == 0) separator = @"?";
- else separator = @"&";
- id queryParam = [queryParams valueForKey:key];
- if ([queryParam isKindOfClass:[NSString class]]){
- [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
- [{{classPrefix}}ApiClient escape:key], [{{classPrefix}}ApiClient escape:[queryParams valueForKey:key]]]];
- }
- else if ([queryParam isKindOfClass:[{{classPrefix}}QueryParamCollection class]]){
- {{classPrefix}}QueryParamCollection * coll = ({{classPrefix}}QueryParamCollection*) queryParam;
- NSArray* values = [coll values];
- NSString* format = [coll format];
- if ([format isEqualToString:@"csv"]) {
- [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
- [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]];
-
- }
- else if ([format isEqualToString:@"tsv"]) {
- [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
- [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]];
-
- }
- else if ([format isEqualToString:@"pipes"]) {
- [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
- [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]];
-
- }
- else if ([format isEqualToString:@"multi"]) {
- for(id obj in values) {
- [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
- [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]];
- counter += 1;
- }
-
- }
- }
- else {
- [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
- [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]]];
- }
-
- counter += 1;
+ NSDictionary *separatorStyles = @{@"csv" : @",",
+ @"tsv" : @"\t",
+ @"pipes": @"|"
+ };
+ for(NSString * key in [queryParams keyEnumerator]){
+ if (counter == 0) {
+ separator = @"?";
+ } else {
+ separator = @"&";
}
+ id queryParam = [queryParams valueForKey:key];
+ if(!queryParam) {
+ continue;
+ }
+ NSString *safeKey = {{classPrefix}}PercentEscapedStringFromString(key);
+ if ([queryParam isKindOfClass:[NSString class]]){
+ [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, {{classPrefix}}PercentEscapedStringFromString(queryParam)]];
+
+ } else if ([queryParam isKindOfClass:[{{classPrefix}}QueryParamCollection class]]){
+ {{classPrefix}}QueryParamCollection * coll = ({{classPrefix}}QueryParamCollection*) queryParam;
+ NSArray* values = [coll values];
+ NSString* format = [coll format];
+
+ if([format isEqualToString:@"multi"]) {
+ for(id obj in values) {
+ if (counter > 0) {
+ separator = @"&";
+ }
+ NSString * safeValue = {{classPrefix}}PercentEscapedStringFromString([NSString stringWithFormat:@"%@",obj]);
+ [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]];
+ counter += 1;
+ }
+ continue;
+ }
+ NSString * separatorStyle = separatorStyles[format];
+ NSString * safeValue = {{classPrefix}}PercentEscapedStringFromString([values componentsJoinedByString:separatorStyle]);
+ [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]];
+ } else {
+ NSString * safeValue = {{classPrefix}}PercentEscapedStringFromString([NSString stringWithFormat:@"%@",queryParam]);
+ [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]];
+ }
+ counter += 1;
}
return requestUrl;
}
@@ -549,24 +440,26 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
queryParams:(NSDictionary *__autoreleasing *)querys
WithAuthSettings:(NSArray *)authSettings {
- if (!authSettings || [authSettings count] == 0) {
+ if ([authSettings count] == 0) {
return;
}
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
- {{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig];
+ NSDictionary* configurationAuthSettings = [[self configuration] authSettings];
for (NSString *auth in authSettings) {
- NSDictionary *authSetting = [[config authSettings] objectForKey:auth];
-
- if (authSetting) { // auth setting is set only if the key is non-empty
- if ([authSetting[@"in"] isEqualToString:@"header"] && [authSetting[@"key"] length] != 0) {
- [headersWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]];
- }
- else if ([authSetting[@"in"] isEqualToString:@"query"] && [authSetting[@"key"] length] != 0) {
- [querysWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]];
- }
+ NSDictionary *authSetting = configurationAuthSettings[auth];
+ if(!authSetting) { // auth setting is set only if the key is non-empty
+ continue;
+ }
+ NSString *type = authSetting[@"in"];
+ NSString *key = authSetting[@"key"];
+ NSString *value = authSetting[@"value"];
+ if ([type isEqualToString:@"header"] && [key length] > 0 ) {
+ headersWithAuth[key] = value;
+ } else if ([type isEqualToString:@"query"] && [key length] != 0) {
+ querysWithAuth[key] = value;
}
}
@@ -577,7 +470,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
- (AFSecurityPolicy *) customSecurityPolicy {
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
- {{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig];
+ {{classPrefix}}Configuration *config = [self configuration];
if (config.sslCaCert) {
NSData *certData = [NSData dataWithContentsOfFile:config.sslCaCert];
@@ -595,4 +488,8 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
return securityPolicy;
}
+- ({{classPrefix}}Configuration*) configuration {
+ return [{{classPrefix}}Configuration sharedConfig];
+}
+
@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 b08112ba445..db7df9b3407 100644
--- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache
@@ -7,6 +7,7 @@
#import "{{classPrefix}}Configuration.h"
#import "{{classPrefix}}ResponseDeserializer.h"
#import "{{classPrefix}}Sanitizer.h"
+#import "{{classPrefix}}Logger.h"
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
@@ -26,13 +27,6 @@
*/
extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
-/**
- * Log debug message macro
- */
-#ifndef {{classPrefix}}DebugLog
- #define {{classPrefix}}DebugLog(format, ...) [{{classPrefix}}ApiClient debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__];
-#endif
-
@interface {{classPrefix}}ApiClient : AFHTTPSessionManager
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
@@ -62,7 +56,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
*
* @return The size of `queuedRequests` static variable.
*/
-+(unsigned long)requestQueueSize;
++(NSUInteger)requestQueueSize;
/**
* Sets the client unreachable
@@ -113,15 +107,6 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
*/
+(void) cancelRequest:(NSNumber*)requestId;
-/**
- * Gets URL encoded NSString
- *
- * @param unescaped The string which will be escaped.
- *
- * @return The escaped string.
- */
-+(NSString*) escape:(id)unescaped;
-
/**
* Customizes the behavior when the reachability changed
*
@@ -134,24 +119,6 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
*/
- (void)configureCacheReachibility;
-/**
- * Detects Accept header from accepts NSArray
- *
- * @param accepts NSArray of header
- *
- * @return The Accept header
- */
-+(NSString *) selectHeaderAccept:(NSArray *)accepts;
-
-/**
- * Detects Content-Type header from contentTypes NSArray
- *
- * @param contentTypes NSArray of header
- *
- * @return The Content-Type header
- */
-+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
-
/**
* Sets header for request
*
@@ -172,19 +139,6 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
queryParams:(NSDictionary **)querys
WithAuthSettings:(NSArray *)authSettings;
-/**
- * Logs request and response
- *
- * @param response NSURLResponse for the HTTP request.
- * @param responseObject response object of the HTTP request.
- * @param request The HTTP request.
- * @param error The error of the HTTP request.
- */
-- (void)logResponse:(NSURLResponse *)response
- responseObject:(id)responseObject
- request:(NSURLRequest *)request
- error:(NSError *)error;
-
/**
* Performs request
*
@@ -223,8 +177,11 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
- (AFSecurityPolicy *) customSecurityPolicy;
/**
- * Log debug message
+ * {{classPrefix}}Configuration return sharedConfig
+ *
+ * @return {{classPrefix}}Configuration
*/
-+(void)debugLog:(NSString *)method message:(NSString *)format, ...;
+- ({{classPrefix}}Configuration*) configuration;
+
@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache
index 527e16c2b91..e37551bf8a1 100644
--- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache
@@ -2,8 +2,9 @@
@interface {{classPrefix}}Configuration ()
-@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKey;
-@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix;
+@property (nonatomic, strong) NSMutableDictionary *mutableDefaultHeaders;
+@property (nonatomic, strong) NSMutableDictionary *mutableApiKey;
+@property (nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix;
@end
@@ -30,12 +31,11 @@
self.username = @"";
self.password = @"";
self.accessToken= @"";
- self.tempFolderPath = nil;
- self.debug = NO;
self.verifySSL = YES;
- self.loggingFile = nil;
self.mutableApiKey = [NSMutableDictionary dictionary];
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
+ self.mutableDefaultHeaders = [NSMutableDictionary dictionary];
+ self.logger = [{{classPrefix}}Logger sharedLogger];
}
return self;
}
@@ -43,11 +43,13 @@
#pragma mark - Instance Methods
- (NSString *) getApiKeyWithPrefix:(NSString *)key {
- if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // both api key prefix and api key are set
- return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]];
+ NSString *prefix = self.apiKeyPrefix[key];
+ NSString *apiKey = self.apiKey[key];
+ if (prefix && apiKey != (id)[NSNull null] && apiKey.length > 0) { // both api key prefix and api key are set
+ return [NSString stringWithFormat:@"%@ %@", prefix, apiKey];
}
- else if ([self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // only api key, no api key prefix
- return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]];
+ else if (apiKey != (id)[NSNull null] && apiKey.length > 0) { // only api key, no api key prefix
+ return [NSString stringWithFormat:@"%@", self.apiKey[key]];
}
else { // return empty string if nothing is set
return @"";
@@ -70,8 +72,7 @@
- (NSString *) getAccessToken {
if (self.accessToken.length == 0) { // token not set, return empty string
return @"";
- }
- else {
+ } else {
return [NSString stringWithFormat:@"Bearer %@", self.accessToken];
}
}
@@ -94,20 +95,6 @@
[self.mutableApiKeyPrefix removeObjectForKey:identifier];
}
-- (void) setLoggingFile:(NSString *)loggingFile {
- // close old file handler
- if ([self.loggingFileHanlder isKindOfClass:[NSFileHandle class]]) {
- [self.loggingFileHanlder closeFile];
- }
-
- _loggingFile = loggingFile;
- _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile];
- if (_loggingFileHanlder == nil) {
- [[NSFileManager defaultManager] createFileAtPath:_loggingFile contents:nil attributes:nil];
- _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile];
- }
-}
-
#pragma mark - Getter Methods
- (NSDictionary *) apiKey {
@@ -154,4 +141,34 @@
};
}
+-(BOOL)debug {
+ return self.logger.isEnabled;
+}
+
+-(void)setDebug:(BOOL)debug {
+ self.logger.enabled = debug;
+}
+
+
+
+- (void)setDefaultHeaderValue:(NSString *)value forKey:(NSString *)key {
+ if(!value) {
+ [self.mutableDefaultHeaders removeObjectForKey:key];
+ return;
+ }
+ self.mutableDefaultHeaders[key] = value;
+}
+
+-(void) removeDefaultHeaderForKey:(NSString*)key {
+ [self.mutableDefaultHeaders removeObjectForKey:key];
+}
+
+- (NSString *)defaultHeaderForKey:(NSString *)key {
+ return self.mutableDefaultHeaders[key];
+}
+
+- (NSDictionary *)defaultHeaders {
+ return [self.mutableDefaultHeaders copy];
+}
+
@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache
index b77ddfe5dee..12807ca5411 100644
--- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache
@@ -1,5 +1,6 @@
#import
#import "{{classPrefix}}ApiClient.h"
+#import "{{classPrefix}}Logger.h"
/** The `{{classPrefix}}Configuration` class manages the configurations for the sdk.
*
@@ -12,6 +13,11 @@
@interface {{classPrefix}}Configuration : NSObject
+/**
+ * Default api logger
+ */
+@property (nonatomic, strong) {{classPrefix}}Logger * logger;
+
/**
* Default api client
*/
@@ -37,7 +43,7 @@
@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix;
/**
- * Usename for HTTP Basic Authentication
+ * Username for HTTP Basic Authentication
*/
@property (nonatomic) NSString *username;
@@ -56,25 +62,11 @@
*/
@property (nonatomic) NSString *tempFolderPath;
-/**
- * Logging Settings
- */
-
/**
* Debug switch, default false
*/
@property (nonatomic) BOOL debug;
-/**
- * Debug file location, default log in console
- */
-@property (nonatomic) NSString *loggingFile;
-
-/**
- * Log file handler, this property is used by sdk internally.
- */
-@property (nonatomic, readonly) NSFileHandle *loggingFileHanlder;
-
/**
* Gets configuration singleton instance
*/
@@ -113,8 +105,6 @@
/**
* Sets the prefix for API key
*
- * To remove a apiKeyPrefix for an identifier, just set the apiKeyPrefix to nil.
- *
* @param apiKeyPrefix API key prefix.
* @param identifier API key identifier.
*/
@@ -143,8 +133,33 @@
- (NSString *) getAccessToken;
/**
- * Gets Authentication Setings
+ * Gets Authentication Settings
*/
- (NSDictionary *) authSettings;
+/**
+* Default headers for all services
+*/
+@property (readonly, nonatomic, strong) NSDictionary *defaultHeaders;
+
+/**
+* Removes header from defaultHeaders
+*
+* @param Header name.
+*/
+-(void) removeDefaultHeaderForKey:(NSString*)key;
+
+/**
+* Sets the header for key
+*
+* @param value Value for header name
+* @param key Header name
+*/
+-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
+
+/**
+* @param Header key name.
+*/
+-(NSString*) defaultHeaderForKey:(NSString*)key;
+
@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/Logger-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Logger-body.mustache
new file mode 100644
index 00000000000..9a8f7de2418
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/objc/Logger-body.mustache
@@ -0,0 +1,74 @@
+#import "{{classPrefix}}Logger.h"
+
+@interface {{classPrefix}}Logger ()
+
+@end
+
+@implementation {{classPrefix}}Logger
+
++ (instancetype) sharedLogger {
+ static {{classPrefix}}Logger *shardLogger = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ shardLogger = [[self alloc] init];
+ });
+ return shardLogger;
+}
+
+#pragma mark - Log Methods
+
+- (void)debugLog:(NSString *)method
+ message:(NSString *)format, ... {
+ if (!self.isEnabled) {
+ return;
+ }
+
+ NSMutableString *message = [NSMutableString stringWithCapacity:1];
+
+ if (method) {
+ [message appendFormat:@"%@: ", method];
+ }
+
+ va_list args;
+ va_start(args, format);
+
+ [message appendString:[[NSString alloc] initWithFormat:format arguments:args]];
+
+ // If set logging file handler, log into file,
+ // otherwise log into console.
+ if (self.loggingFileHandler) {
+ [self.loggingFileHandler seekToEndOfFile];
+ [self.loggingFileHandler writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];
+ } else {
+ NSLog(@"%@", message);
+ }
+
+ va_end(args);
+}
+
+- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error {
+ NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\
+ "[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n",
+ [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding],
+ responseObject];
+
+ {{classPrefix}}DebugLog(message);
+}
+
+- (void) setLoggingFile:(NSString *)loggingFile {
+ if(_loggingFile == loggingFile) {
+ return;
+ }
+ // close old file handler
+ if ([self.loggingFileHandler isKindOfClass:[NSFileHandle class]]) {
+ [self.loggingFileHandler closeFile];
+ }
+ _loggingFile = loggingFile;
+ _loggingFileHandler = [NSFileHandle fileHandleForWritingAtPath:_loggingFile];
+ if (_loggingFileHandler == nil) {
+ [[NSFileManager defaultManager] createFileAtPath:_loggingFile contents:nil attributes:nil];
+ _loggingFileHandler = [NSFileHandle fileHandleForWritingAtPath:_loggingFile];
+ }
+}
+
+@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/Logger-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Logger-header.mustache
new file mode 100644
index 00000000000..2070f95ae9f
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/objc/Logger-header.mustache
@@ -0,0 +1,54 @@
+#import
+
+/**
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * Do not edit the class manually.
+ */
+
+#ifndef {{classPrefix}}DebugLogResponse
+#define {{classPrefix}}DebugLogResponse(response, responseObject,request, error) [[{{classPrefix}}Logger sharedLogger] logResponse:response responseObject:responseObject request:request error:error];
+#endif
+
+/**
+ * Log debug message macro
+ */
+#ifndef {{classPrefix}}DebugLog
+#define {{classPrefix}}DebugLog(format, ...) [[{{classPrefix}}Logger sharedLogger] debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__];
+#endif
+
+@interface {{classPrefix}}Logger : NSObject
+
++(instancetype)sharedLogger;
+
+/**
+ * Enabled switch, default NO - default set by {{classPrefix}}Configuration debug property
+ */
+@property (nonatomic, assign, getter=isEnabled) BOOL enabled;
+
+/**
+ * Debug file location, default log in console
+ */
+@property (nonatomic, strong) NSString *loggingFile;
+
+/**
+ * Log file handler, this property is used by sdk internally.
+ */
+@property (nonatomic, strong, readonly) NSFileHandle *loggingFileHandler;
+
+/**
+ * Log debug message
+ */
+-(void)debugLog:(NSString *)method message:(NSString *)format, ...;
+
+/**
+ * Logs request and response
+ *
+ * @param response NSURLResponse for the HTTP request.
+ * @param responseObject response object of the HTTP request.
+ * @param request The HTTP request.
+ * @param error The error of the HTTP request.
+ */
+- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error;
+
+@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/README.mustache b/modules/swagger-codegen/src/main/resources/objc/README.mustache
index ed48e239596..db56c1b4b77 100644
--- a/modules/swagger-codegen/src/main/resources/objc/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/README.mustache
@@ -42,6 +42,7 @@ pod '{{podName}}', :path => 'Vendor/{{podName}}'
### Usage
Import the following:
+
```objc
#import <{{podName}}/{{{classPrefix}}}ApiClient.h>
#import <{{podName}}/{{{classPrefix}}}Configuration.h>
@@ -81,12 +82,10 @@ Please follow the [installation procedure](#installation--usage) and then run th
{{#allParams}}{{{dataType}}} *{{paramName}} = {{{example}}}; // {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
{{/allParams}}
-@try
-{
- {{classname}} *apiInstance = [[{{classname}} alloc] init];
+{{classname}} *apiInstance = [[{{classname}} alloc] init];
{{#summary}} // {{{.}}}
-{{/summary}} [apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
+{{/summary}}[apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
{{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
{{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error)) {
{{#returnType}}
@@ -98,12 +97,6 @@ Please follow the [installation procedure](#installation--usage) and then run th
NSLog(@"Error: %@", error);
}
}];
-}
-@catch (NSException *exception)
-{
- NSLog(@"Exception when calling {{classname}}->{{operationId}}: %@ ", exception.name);
- NSLog(@"Reason: %@ ", exception.reason);
-}
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```
diff --git a/modules/swagger-codegen/src/main/resources/objc/Sanitizer-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Sanitizer-body.mustache
index 74b166d75e9..a111aad9cef 100644
--- a/modules/swagger-codegen/src/main/resources/objc/Sanitizer-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/Sanitizer-body.mustache
@@ -3,11 +3,57 @@
#import "{{classPrefix}}QueryParamCollection.h"
#import
-@interface {{classPrefix}}Sanitizer ()
+NSString * {{classPrefix}}PercentEscapedStringFromString(NSString *string) {
+ static NSString * const k{{classPrefix}}CharactersGeneralDelimitersToEncode = @":#[]@";
+ static NSString * const k{{classPrefix}}CharactersSubDelimitersToEncode = @"!$&'()*+,;=";
+
+ NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
+ [allowedCharacterSet removeCharactersInString:[k{{classPrefix}}CharactersGeneralDelimitersToEncode stringByAppendingString:k{{classPrefix}}CharactersSubDelimitersToEncode]];
+
+ static NSUInteger const batchSize = 50;
+
+ NSUInteger index = 0;
+ NSMutableString *escaped = @"".mutableCopy;
+
+ while (index < string.length) {
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wgnu"
+ NSUInteger length = MIN(string.length - index, batchSize);
+ #pragma GCC diagnostic pop
+ NSRange range = NSMakeRange(index, length);
+
+ // To avoid breaking up character sequences such as 👴🏻👮🏽
+ range = [string rangeOfComposedCharacterSequencesForRange:range];
+
+ NSString *substring = [string substringWithRange:range];
+ NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
+ [escaped appendString:encoded];
+
+ index += range.length;
+ }
+
+ return escaped;
+}
+
+@interface SWGSanitizer ()
+
+@property (nonatomic, strong) NSRegularExpression* jsonHeaderTypeExpression;
@end
-@implementation {{classPrefix}}Sanitizer
+@implementation SWGSanitizer
+
+static NSString * kApplicationJSONType = @"application/json";
+
+-(instancetype)init {
+ self = [super init];
+ if ( !self ) {
+ return nil;
+ }
+ _jsonHeaderTypeExpression = [NSRegularExpression regularExpressionWithPattern:@"(.*)application(.*)json(.*)" options:NSRegularExpressionCaseInsensitive error:nil];
+ return self;
+}
+
- (id) sanitizeForSerialization:(id) object {
if (object == nil) {
@@ -17,7 +63,7 @@
return object;
}
else if ([object isKindOfClass:[NSDate class]]) {
- return [object ISO8601String];
+ return [self dateParameterToString:object];
}
else if ([object isKindOfClass:[NSArray class]]) {
NSArray *objectArray = object;
@@ -61,7 +107,7 @@
return [param stringValue];
}
else if ([param isKindOfClass:[NSDate class]]) {
- return [param ISO8601String];
+ return [self dateParameterToString:param];
}
else if ([param isKindOfClass:[NSArray class]]) {
NSMutableArray *mutableParam = [NSMutableArray array];
@@ -79,4 +125,44 @@
}
}
+- (NSString *)dateParameterToString:(id)param {
+ return [param ISO8601String];
+}
+
+#pragma mark - Utility Methods
+
+/*
+ * Detect `Accept` from accepts
+ */
+- (NSString *) selectHeaderAccept:(NSArray *)accepts {
+ if (accepts.count == 0) {
+ return @"";
+ }
+ NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
+ for (NSString *string in accepts) {
+ if ([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0) {
+ return kApplicationJSONType;
+ }
+ [lowerAccepts addObject:[string lowercaseString]];
+ }
+ return [lowerAccepts componentsJoinedByString:@", "];
+}
+
+/*
+ * Detect `Content-Type` from contentTypes
+ */
+- (NSString *) selectHeaderContentType:(NSArray *)contentTypes {
+ if (contentTypes.count == 0) {
+ return kApplicationJSONType;
+ }
+ NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]];
+ for (NSString *string in contentTypes) {
+ if([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0){
+ return kApplicationJSONType;
+ }
+ [lowerContentTypes addObject:[string lowercaseString]];
+ }
+ return [lowerContentTypes firstObject];
+}
+
@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/Sanitizer-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Sanitizer-header.mustache
index 706a94c1d0e..cd946661615 100644
--- a/modules/swagger-codegen/src/main/resources/objc/Sanitizer-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/Sanitizer-header.mustache
@@ -6,6 +6,8 @@
* Do not edit the class manually.
*/
+extern NSString * {{classPrefix}}PercentEscapedStringFromString(NSString *string);
+
@protocol {{classPrefix}}Sanitizer
/**
@@ -20,6 +22,24 @@
*/
- (NSString *) parameterToString: (id) param;
+/**
+ * Detects Accept header from accepts NSArray
+ *
+ * @param accepts NSArray of header
+ *
+ * @return The Accept header
+ */
+-(NSString *) selectHeaderAccept:(NSArray *)accepts;
+
+/**
+ * Detects Content-Type header from contentTypes NSArray
+ *
+ * @param contentTypes NSArray of header
+ *
+ * @return The Content-Type header
+ */
+-(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
+
@end
@interface {{classPrefix}}Sanitizer : NSObject <{{classPrefix}}Sanitizer>
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 2a7880d8367..5c09f340b4d 100644
--- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache
@@ -6,24 +6,29 @@
{{newline}}
@interface {{classname}} ()
- @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
+
+@property (nonatomic, strong) NSMutableDictionary *defaultHeaders;
+
@end
@implementation {{classname}}
-static {{classname}}* singletonAPI = nil;
+NSString* k{{classname}}ErrorDomain = @"{{classname}}ErrorDomain";
+NSInteger k{{classname}}MissingParamErrorCode = 234513;
+
+@synthesize apiClient = _apiClient;
#pragma mark - Initialize methods
-- (id) init {
+- (instancetype) init {
self = [super init];
if (self) {
{{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig];
if (config.apiClient == nil) {
config.apiClient = [[{{classPrefix}}ApiClient alloc] init];
}
- self.apiClient = config.apiClient;
- self.defaultHeaders = [NSMutableDictionary dictionary];
+ _apiClient = config.apiClient;
+ _defaultHeaders = [NSMutableDictionary dictionary];
}
return self;
}
@@ -31,39 +36,36 @@ static {{classname}}* singletonAPI = nil;
- (id) initWithApiClient:({{classPrefix}}ApiClient *)apiClient {
self = [super init];
if (self) {
- self.apiClient = apiClient;
- self.defaultHeaders = [NSMutableDictionary dictionary];
+ _apiClient = apiClient;
+ _defaultHeaders = [NSMutableDictionary dictionary];
}
return self;
}
#pragma mark -
-+({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
- if (singletonAPI == nil) {
- singletonAPI = [[{{classname}} alloc] init];
- [singletonAPI addHeader:headerValue forKey:key];
- }
- return singletonAPI;
++ (instancetype)sharedAPI {
+ static {{classname}} *sharedAPI;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ sharedAPI = [[self alloc] init];
+ });
+ return sharedAPI;
}
-+({{classname}}*) sharedAPI {
- if (singletonAPI == nil) {
- singletonAPI = [[{{classname}} alloc] init];
- }
- return singletonAPI;
+-(NSString*) defaultHeaderForKey:(NSString*)key {
+ return self.defaultHeaders[key];
}
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
+ [self setDefaultHeaderValue:value forKey:key];
+}
+
+-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key];
}
--(void) setHeaderValue:(NSString*) value
- forKey:(NSString*)key {
- [self.defaultHeaders setValue:value forKey:key];
-}
-
--(unsigned long) requestQueueSize {
+-(NSUInteger) requestQueueSize {
return [{{classPrefix}}ApiClient requestQueueSize];
}
@@ -84,7 +86,13 @@ static {{classname}}* singletonAPI = nil;
{{#required}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == nil) {
- [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `{{paramName}}` when calling `{{nickname}}`"];
+ NSParameterAssert({{paramName}});
+ if(handler) {
+ NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"{{paramName}}"] };
+ NSError* error = [NSError errorWithDomain:k{{classname}}ErrorDomain code:k{{classname}}MissingParamErrorCode userInfo:userInfo];
+ handler({{#returnType}}nil, {{/returnType}}error);
+ }
+ return nil;
}
{{/required}}
@@ -92,9 +100,7 @@ static {{classname}}* singletonAPI = nil;
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"{{path}}"];
// remove format in URL if needed
- if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
- [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
- }
+ [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)];
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
{{#pathParams}}
@@ -112,31 +118,24 @@ static {{classname}}* singletonAPI = nil;
{{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}}
}
{{/queryParams}}
- NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
+ NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders];
+ [headerParams addEntriesFromDictionary:self.defaultHeaders];
{{#headerParams}}
-
if ({{paramName}} != nil) {
headerParams[@"{{baseName}}"] = {{paramName}};
}
-
{{/headerParams}}
// HTTP header `Accept`
- headerParams[@"Accept"] = [{{classPrefix}}ApiClient selectHeaderAccept:@[{{#produces}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]];
- if ([headerParams[@"Accept"] length] == 0) {
- [headerParams removeObjectForKey:@"Accept"];
+ NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[{{#produces}}@"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]];
+ if(acceptHeader.length > 0) {
+ headerParams[@"Accept"] = acceptHeader;
}
// response content type
- NSString *responseContentType;
- if ([headerParams objectForKey:@"Accept"]) {
- responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
- }
- else {
- responseContentType = @"";
- }
+ NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @"";
// request content type
- NSString *requestContentType = [{{classPrefix}}ApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]];
+ NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[{{#consumes}}@"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]];
// Authentication setting
NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
@@ -173,7 +172,9 @@ static {{classname}}* singletonAPI = nil;
responseContentType: responseContentType
responseType: {{^returnType}}nil{{/returnType}}{{#returnType}}@"{{{ returnType }}}"{{/returnType}}
completionBlock: ^(id data, NSError *error) {
- handler({{#returnType}}({{{ returnType }}})data, {{/returnType}}error);
+ if(handler) {
+ handler({{#returnType}}({{{ returnType }}})data, {{/returnType}}error);
+ }
}
];
}
diff --git a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache
index 7c5a9d335cf..67bb9045ec8 100644
--- a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache
@@ -1,10 +1,8 @@
#import
{{#imports}}#import "{{import}}.h"
{{/imports}}
-#import "{{classPrefix}}Object.h"
-#import "{{classPrefix}}ApiClient.h"
+#import "{{classPrefix}}Api.h"
{{newline}}
-
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
@@ -12,23 +10,21 @@
*/
{{#operations}}
-@interface {{classname}}: NSObject
-@property(nonatomic, assign){{classPrefix}}ApiClient *apiClient;
+@interface {{classname}}: NSObject <{{classPrefix}}Api>
+
+extern NSString* k{{classname}}ErrorDomain;
+extern NSInteger k{{classname}}MissingParamErrorCode;
+
++(instancetype) sharedAPI;
--(instancetype) initWithApiClient:({{classPrefix}}ApiClient *)apiClient;
--(void) addHeader:(NSString*)value forKey:(NSString*)key;
--(unsigned long) requestQueueSize;
-+({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
-+({{classname}}*) sharedAPI;
{{#operation}}
-///
-///
/// {{{summary}}}
/// {{#notes}}{{{notes}}}{{/notes}}
///
/// {{#allParams}}@param {{paramName}} {{description}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
-/// {{/allParams}}
+/// {{/allParams}}{{#responses}}
+/// code:{{{code}}} message:"{{{message}}}"{{#hasMore}},{{/hasMore}}{{/responses}}
///
/// @return {{{returnType}}}
-(NSNumber*) {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
diff --git a/modules/swagger-codegen/src/main/resources/objc/api-protocol.mustache b/modules/swagger-codegen/src/main/resources/objc/api-protocol.mustache
new file mode 100644
index 00000000000..142b75dabaa
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/objc/api-protocol.mustache
@@ -0,0 +1,24 @@
+#import
+#import "{{classPrefix}}Object.h"
+#import "{{classPrefix}}ApiClient.h"
+
+/**
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * Do not edit the class manually.
+ */
+
+@protocol {{classPrefix}}Api
+
+@property(nonatomic, assign) {{classPrefix}}ApiClient *apiClient;
+
+-(id) initWithApiClient:({{classPrefix}}ApiClient *)apiClient;
+
+-(void) addHeader:(NSString*)value forKey:(NSString*)key DEPRECATED_MSG_ATTRIBUTE("setDefaultHeaderValue:forKey:");
+
+-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
+-(NSString*) defaultHeaderForKey:(NSString*)key;
+
+-(NSUInteger) requestQueueSize;
+
+@end
diff --git a/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache b/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache
index c27f6425388..44fe31d6404 100644
--- a/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache
@@ -42,29 +42,21 @@ Method | HTTP request | Description
{{#allParams}}{{{dataType}}} {{paramName}} = {{{example}}}; // {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
{{/allParams}}
-@try
-{
- {{classname}} *apiInstance = [[{{classname}} alloc] init];
+{{classname}}*apiInstance = [[{{classname}} alloc] init];
-{{#summary}} // {{{.}}}
-{{/summary}} [apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
- {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
- {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) {
+{{#summary}}// {{{.}}}
+{{/summary}}[apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
+ {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
+ {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) {
{{#returnType}}
- if (output) {
- NSLog(@"%@", output);
- }
+ if (output) {
+ NSLog(@"%@", output);
+ }
{{/returnType}}
- if (error) {
- NSLog(@"Error: %@", error);
- }
- }];
-}
-@catch (NSException *exception)
-{
- NSLog(@"Exception when calling {{classname}}->{{operationId}}: %@ ", exception.name);
- NSLog(@"Reason: %@ ", exception.reason);
-}
+ if (error) {
+ NSLog(@"Error calling {{classname}}->{{operationId}}: %@", error);
+ }
+ }];
```
### Parameters
@@ -84,8 +76,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
diff --git a/modules/swagger-codegen/src/main/resources/objc/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/objc/git_push.sh.mustache
old mode 100755
new mode 100644
diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache
index 776cd55ccef..6f15d3b6c5b 100644
--- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache
@@ -7,7 +7,7 @@
- (instancetype)init {
self = [super init];
if (self) {
- // initalise property's default value, if any
+ // initialize property's default value, if any
{{#vars}}{{#defaultValue}}self.{{name}} = {{{defaultValue}}};
{{/defaultValue}}{{/vars}}
}
diff --git a/modules/swagger-codegen/src/main/resources/objc/podspec.mustache b/modules/swagger-codegen/src/main/resources/objc/podspec.mustache
index 338ded84e89..c308a399c0a 100644
--- a/modules/swagger-codegen/src/main/resources/objc/podspec.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/podspec.mustache
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
{{#apiInfo}}{{#apis}}{{^hasMore}}
s.summary = "{{appName}}"
s.description = <<-DESC
- {{appDescription}}
+ {{{appDescription}}}
DESC
{{/hasMore}}{{/apis}}{{/apiInfo}}
s.platform = :ios, '7.0'
@@ -29,8 +29,8 @@ Pod::Spec.new do |s|
s.source_files = '{{podName}}/**/*'
s.public_header_files = '{{podName}}/**/*.h'
- s.dependency 'AFNetworking', '~> 2.3'
- s.dependency 'JSONModel', '~> 1.1'
- s.dependency 'ISO8601', '~> 0.3'
+ s.dependency 'AFNetworking', '~> 3'
+ s.dependency 'JSONModel', '~> 1.2'
+ s.dependency 'ISO8601', '~> 0.5'
end
diff --git a/modules/swagger-codegen/src/main/resources/perl/api.mustache b/modules/swagger-codegen/src/main/resources/perl/api.mustache
index d96a2302a8a..d7ece2d1e65 100644
--- a/modules/swagger-codegen/src/main/resources/perl/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/api.mustache
@@ -100,11 +100,11 @@ sub {{operationId}} {
my $form_params = {};
# 'Accept' and 'Content-Type' header
- my $_header_accept = $self->{api_client}->select_header_accept({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}});
+ my $_header_accept = $self->{api_client}->select_header_accept({{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}});
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
- $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}});
+ $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}});
{{#queryParams}}
# query params
diff --git a/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache b/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache
index 17dc3903152..585a67c1ac1 100644
--- a/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache
@@ -67,8 +67,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
index 5b8b9b21632..bfd811b89f0 100644
--- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
@@ -55,18 +55,21 @@ class ApiClient
/**
* Configuration
+ *
* @var Configuration
*/
protected $config;
/**
* Object Serializer
+ *
* @var ObjectSerializer
*/
protected $serializer;
/**
* Constructor of the class
+ *
* @param Configuration $config config for this ApiClient
*/
public function __construct(\{{invokerPackage}}\Configuration $config = null)
@@ -81,6 +84,7 @@ class ApiClient
/**
* Get the config
+ *
* @return Configuration
*/
public function getConfig()
@@ -90,6 +94,7 @@ class ApiClient
/**
* Get the serializer
+ *
* @return ObjectSerializer
*/
public function getSerializer()
@@ -99,7 +104,9 @@ class ApiClient
/**
* Get API key (with prefix if set)
+ *
* @param string $apiKeyIdentifier name of apikey
+ *
* @return string API key with the prefix
*/
public function getApiKeyWithPrefix($apiKeyIdentifier)
@@ -122,12 +129,14 @@ class ApiClient
/**
* Make the HTTP call (Sync)
+ *
* @param string $resourcePath path to method endpoint
* @param string $method method to call
* @param array $queryParams parameters to be place in query URL
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @param string $responseType expected response type of the endpoint
+ *
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
* @return mixed
*/
@@ -160,7 +169,7 @@ class ApiClient
if ($this->config->getCurlTimeout() != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
}
- // return the result on success, rather than just true
+ // return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@@ -171,7 +180,7 @@ class ApiClient
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
}
- if (! empty($queryParams)) {
+ if (!empty($queryParams)) {
$url = ($url . '?' . http_build_query($queryParams));
}
@@ -216,7 +225,7 @@ class ApiClient
// Make the request
$response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
- $http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
+ $http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
@@ -228,7 +237,7 @@ class ApiClient
// Handle the response
if ($response_info['http_code'] == 0) {
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
- } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
+ } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) {
// return raw body if response is a file
if ($responseType == '\SplFileObject' || $responseType == 'string') {
return array($http_body, $response_info['http_code'], $http_header);
@@ -246,7 +255,9 @@ class ApiClient
throw new ApiException(
"[".$response_info['http_code']."] Error connecting to the API ($url)",
- $response_info['http_code'], $http_header, $data
+ $response_info['http_code'],
+ $http_header,
+ $data
);
}
return array($data, $response_info['http_code'], $http_header);
@@ -295,40 +306,35 @@ class ApiClient
*
* @return string[] Array of HTTP response heaers
*/
- protected function http_parse_headers($raw_headers)
+ protected function httpParseHeaders($raw_headers)
{
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();
$key = '';
-
- foreach(explode("\n", $raw_headers) as $h)
- {
+
+ foreach (explode("\n", $raw_headers) as $h) {
$h = explode(':', $h, 2);
-
- if (isset($h[1]))
- {
- if (!isset($headers[$h[0]]))
+
+ if (isset($h[1])) {
+ if (!isset($headers[$h[0]])) {
$headers[$h[0]] = trim($h[1]);
- elseif (is_array($headers[$h[0]]))
- {
+ } elseif (is_array($headers[$h[0]])) {
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
- }
- else
- {
+ } else {
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
}
-
+
$key = $h[0];
- }
- else
- {
- if (substr($h[0], 0, 1) == "\t")
- $headers[$key] .= "\r\n\t".trim($h[0]);
- elseif (!$key)
- $headers[0] = trim($h[0]);trim($h[0]);
+ } else {
+ if (substr($h[0], 0, 1) == "\t") {
+ $headers[$key] .= "\r\n\t".trim($h[0]);
+ } elseif (!$key) {
+ $headers[0] = trim($h[0]);
+ }
+ trim($h[0]);
}
}
-
+
return $headers;
}
}
diff --git a/modules/swagger-codegen/src/main/resources/php/ApiException.mustache b/modules/swagger-codegen/src/main/resources/php/ApiException.mustache
index eee688001ed..031e8cd995e 100644
--- a/modules/swagger-codegen/src/main/resources/php/ApiException.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ApiException.mustache
@@ -48,30 +48,34 @@ class ApiException extends Exception
/**
* The HTTP body of the server response either as Json or string.
+ *
* @var mixed
*/
protected $responseBody;
/**
* The HTTP header of the server response.
+ *
* @var string[]
*/
protected $responseHeaders;
/**
* The deserialized response object
+ *
* @var $responseObject;
*/
protected $responseObject;
/**
* Constructor
+ *
* @param string $message Error message
* @param int $code HTTP status code
* @param string $responseHeaders HTTP response header
* @param mixed $responseBody HTTP body of the server response either as Json or string
*/
- public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null)
+ public function __construct($message = "", $code = 0, $responseHeaders = null, $responseBody = null)
{
parent::__construct($message, $code);
$this->responseHeaders = $responseHeaders;
@@ -100,7 +104,9 @@ class ApiException extends Exception
/**
* Sets the deseralized response object (during deserialization)
+ *
* @param mixed $obj Deserialized response object
+ *
* @return void
*/
public function setResponseObject($obj)
diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
index 34d79b0ae39..7de8d9d085e 100644
--- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
@@ -1,6 +1,6 @@
getTempFolderPath() . sanitizeFilename($match[1]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
- error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
- return $deserialized;
+ if (Configuration::getDefaultConfiguration()->getDebug()) {
+ error_log("[DEBUG] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
+ }
+
+ return $deserialized;
} else {
// If a discriminator is defined and points to a valid subclass, use it.
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
@@ -282,11 +286,11 @@ class ObjectSerializer
$instance = new $class();
foreach ($instance::swaggerTypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
-
+
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
continue;
}
-
+
$propertyValue = $data->{$instance::attributeMap()[$property]};
if (isset($propertyValue)) {
$instance->$propertySetter(self::deserialize($propertyValue, $type, null, $discriminator));
diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache
index 3049d013ca5..1f96e378f1b 100644
--- a/modules/swagger-codegen/src/main/resources/php/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/README.mustache
@@ -27,11 +27,11 @@ To install the bindings via [Composer](http://getcomposer.org/), add the followi
"repositories": [
{
"type": "git",
- "url": "https://github.com/{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}{{composerVendorName}}{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{composerProjectName}}{{/gitRepoId}}.git"
+ "url": "https://github.com/{{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}.git"
}
],
"require": {
- "{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}{{composerVendorName}}{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{composerProjectName}}{{/gitRepoId}}": "*@dev"
+ "{{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}": "*@dev"
}
}
```
@@ -46,7 +46,7 @@ Download the files and include `autoload.php`:
require_once('/path/to/{{packagePath}}/autoload.php');
```
-## Tests
+## Tests
To run the unit tests:
@@ -108,7 +108,7 @@ Class | Method | HTTP request | Description
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
{{#authMethods}}## {{{name}}}
-{{#isApiKey}}- **Type**: API key
+{{#isApiKey}}- **Type**: API key
- **API key parameter name**: {{{keyParamName}}}
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
{{/isApiKey}}
diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache
index cc74dfd3a2a..26024ea4789 100644
--- a/modules/swagger-codegen/src/main/resources/php/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api.mustache
@@ -26,8 +26,8 @@
*/
/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
@@ -52,36 +52,41 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* API Client
+ *
* @var \{{invokerPackage}}\ApiClient instance of the ApiClient
*/
protected $apiClient;
-
+
/**
* Constructor
+ *
* @param \{{invokerPackage}}\ApiClient|null $apiClient The api client to use
*/
- function __construct(\{{invokerPackage}}\ApiClient $apiClient = null)
+ public function __construct(\{{invokerPackage}}\ApiClient $apiClient = null)
{
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('{{basePath}}');
}
-
+
$this->apiClient = $apiClient;
}
-
+
/**
* Get API client
+ *
* @return \{{invokerPackage}}\ApiClient get the API client
*/
public function getApiClient()
{
return $this->apiClient;
}
-
+
/**
* Set the API client
+ *
* @param \{{invokerPackage}}\ApiClient $apiClient set the API client
+ *
* @return {{classname}}
*/
public function setApiClient(\{{invokerPackage}}\ApiClient $apiClient)
@@ -89,31 +94,33 @@ use \{{invokerPackage}}\ObjectSerializer;
$this->apiClient = $apiClient;
return $this;
}
-
+
{{#operation}}
/**
- * {{{operationId}}}
+ * Operation {{{operationId}}}
*
- * {{{summary}}}
+ * {{{summary}}}.
*
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
- {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
+ {{/allParams}} *
+ * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
- list($response) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
- return $response;
+ list($response) = $this->{{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+ return $response;
}
/**
- * {{{operationId}}}WithHttpInfo
+ * Operation {{{operationId}}}WithHttpInfo
*
- * {{{summary}}}
+ * {{{summary}}}.
*
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
- {{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
+ {{/allParams}} *
+ * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
@@ -153,19 +160,19 @@ use \{{invokerPackage}}\ObjectSerializer;
{{/hasValidation}}
{{/allParams}}
-
+
// parse inputs
$resourcePath = "{{path}}";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
- $_header_accept = $this->apiClient->selectHeaderAccept(array({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}));
+ $_header_accept = $this->apiClient->selectHeaderAccept(array({{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
- $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}}));
-
+ $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array({{#consumes}}'{{{mediaType}}}'{{#hasMore}},{{/hasMore}}{{/consumes}}));
+
{{#queryParams}}// query params
{{#collectionFormat}}
if (is_array(${{paramName}})) {
@@ -208,7 +215,7 @@ use \{{invokerPackage}}\ObjectSerializer;
if (function_exists('curl_file_create')) {
$formParams['{{baseName}}'] = curl_file_create($this->apiClient->getSerializer()->toFormValue(${{paramName}}));
} else {
- $formParams['{{baseName}}'] = '@' . $this->apiClient->getSerializer()->toFormValue(${{paramName}});
+ $formParams['{{baseName}}'] = '@' . $this->apiClient->getSerializer()->toFormValue(${{paramName}});
}
{{/isFile}}
{{^isFile}}
@@ -220,7 +227,7 @@ use \{{invokerPackage}}\ObjectSerializer;
if (isset(${{paramName}})) {
$_tempBody = ${{paramName}};
}{{/bodyParams}}
-
+
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
@@ -244,9 +251,12 @@ use \{{invokerPackage}}\ObjectSerializer;
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
- $resourcePath, '{{httpMethod}}',
- $queryParams, $httpBody,
- $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
+ $resourcePath,
+ '{{httpMethod}}',
+ $queryParams,
+ $httpBody,
+ $headerParams{{#returnType}},
+ '{{returnType}}'{{/returnType}}
);
{{#returnType}}
if (!$response) {
@@ -254,17 +264,22 @@ use \{{invokerPackage}}\ObjectSerializer;
}
return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader);
- {{/returnType}}{{^returnType}}
+ {{/returnType}}
+ {{^returnType}}
return array(null, $statusCode, $httpHeader);
{{/returnType}}
} catch (ApiException $e) {
- switch ($e->getCode()) { {{#responses}}{{#dataType}}
- {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
- $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders());
- $e->setResponseObject($data);
- break;{{/dataType}}{{/responses}}
+ switch ($e->getCode()) {
+ {{#responses}}
+ {{#dataType}}
+ {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
+ $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders());
+ $e->setResponseObject($data);
+ break;
+ {{/dataType}}
+ {{/responses}}
}
-
+
throw $e;
}
}
diff --git a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache
index 4cf01aa510b..be2cb895fed 100644
--- a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache
@@ -17,7 +17,7 @@ Method | HTTP request | Description
{{{notes}}}{{/notes}}
-### Example
+### Example
```php
{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
print_r($result);{{/returnType}}
} catch (Exception $e) {
@@ -63,8 +63,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
diff --git a/modules/swagger-codegen/src/main/resources/php/api_test.mustache b/modules/swagger-codegen/src/main/resources/php/api_test.mustache
index fc07d338301..6a525223584 100644
--- a/modules/swagger-codegen/src/main/resources/php/api_test.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api_test.mustache
@@ -26,8 +26,8 @@
*/
/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
* Please update the test case below to test the endpoint.
*/
@@ -53,14 +53,16 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* Setup before running each test case
*/
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass()
+ {
}
/**
* Clean up after running each test case
*/
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass()
+ {
}
@@ -68,10 +70,11 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* Test case for {{{operationId}}}
*
- * {{{summary}}}
+ * {{{summary}}}.
*
*/
- public function test_{{operationId}}() {
+ public function test{{vendorExtensions.x-testOperationId}}()
+ {
}
{{/operation}}
diff --git a/modules/swagger-codegen/src/main/resources/php/autoload.mustache b/modules/swagger-codegen/src/main/resources/php/autoload.mustache
index 04be6e11992..0942715ce8d 100644
--- a/modules/swagger-codegen/src/main/resources/php/autoload.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/autoload.mustache
@@ -1,14 +1,15 @@
'{{{datatype}}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
- static function swaggerTypes() {
+ public static function swaggerTypes()
+ {
return self::$swaggerTypes{{#parentSchema}} + parent::swaggerTypes(){{/parentSchema}};
}
- /**
+ /**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
- static $attributeMap = array(
+ protected static $attributeMap = array(
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
- static function attributeMap() {
+ public static function attributeMap()
+ {
return {{#parentSchema}}parent::attributeMap() + {{/parentSchema}}self::$attributeMap;
}
@@ -85,12 +89,13 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
- static $setters = array(
+ protected static $setters = array(
{{#vars}}'{{name}}' => '{{setter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
- static function setters() {
+ public static function setters()
+ {
return {{#parentSchema}}parent::setters() + {{/parentSchema}}self::$setters;
}
@@ -98,12 +103,13 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
- static $getters = array(
+ protected static $getters = array(
{{#vars}}'{{name}}' => '{{getter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
-
- static function getters() {
+
+ public static function getters()
+ {
return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters;
}
@@ -115,7 +121,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
* Gets allowable values of the enum
* @return string[]
*/
- public function {{getter}}AllowableValues() {
+ public function {{getter}}AllowableValues()
+ {
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}
@@ -152,48 +159,48 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
/**
* show all the invalid properties with reasons.
- *
+ *
* @return array invalid properties with reasons
*/
- public function list_invalid_properties()
+ public function listInvalidProperties()
{
$invalid_properties = array();
{{#vars}}
{{#required}}
if ($this->container['{{name}}'] === null) {
- $invalid_properties[] = "'${{name}}' can't be null";
+ $invalid_properties[] = "'{{name}}' can't be null";
}
{{/required}}
{{#isEnum}}
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
if (!in_array($this->container['{{name}}'], $allowed_values)) {
- $invalid_properties[] = "invalid value for '${{name}}', must be one of #{allowed_values}.";
+ $invalid_properties[] = "invalid value for '{{name}}', must be one of #{allowed_values}.";
}
{{/isEnum}}
{{#hasValidation}}
{{#maxLength}}
if (strlen($this->container['{{name}}']) > {{maxLength}}) {
- $invalid_properties[] = "invalid value for '${{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
+ $invalid_properties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
}
{{/maxLength}}
{{#minLength}}
if (strlen($this->container['{{name}}']) < {{minLength}}) {
- $invalid_properties[] = "invalid value for '${{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
+ $invalid_properties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
}
{{/minLength}}
{{#maximum}}
if ($this->container['{{name}}'] > {{maximum}}) {
- $invalid_properties[] = "invalid value for '${{name}}', must be smaller than or equal to {{maximum}}.";
+ $invalid_properties[] = "invalid value for '{{name}}', must be smaller than or equal to {{maximum}}.";
}
{{/maximum}}
{{#minimum}}
if ($this->container['{{name}}'] < {{minimum}}) {
- $invalid_properties[] = "invalid value for '${{name}}', must be bigger than or equal to {{minimum}}.";
+ $invalid_properties[] = "invalid value for '{{name}}', must be bigger than or equal to {{minimum}}.";
}
{{/minimum}}
{{#pattern}}
if (!preg_match("{{pattern}}", $this->container['{{name}}'])) {
- $invalid_properties[] = "invalid value for '${{name}}', must be conform to the pattern {{pattern}}.";
+ $invalid_properties[] = "invalid value for '{{name}}', must be conform to the pattern {{pattern}}.";
}
{{/pattern}}
{{/hasValidation}}
@@ -204,8 +211,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
/**
* validate all the properties in the model
* return true if all passed
- *
- * @return bool True if all properteis are valid
+ *
+ * @return bool True if all properteis are valid
*/
public function valid()
{
@@ -265,7 +272,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
/**
* Sets {{name}}
- * @param {{datatype}} ${{name}} {{#description}}{{{description}}}{{/description}}
+ * @param {{datatype}} ${{name}}{{#description}} {{{description}}}{{/description}}
* @return $this
*/
public function {{setter}}(${{name}})
@@ -309,7 +316,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
{{/vars}}
/**
* Returns true if offset exists. False otherwise.
- * @param integer $offset Offset
+ * @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
@@ -319,17 +326,17 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
/**
* Gets offset.
- * @param integer $offset Offset
- * @return mixed
+ * @param integer $offset Offset
+ * @return mixed
*/
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
-
+
/**
* Sets value based on offset.
- * @param integer $offset Offset
+ * @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
@@ -341,17 +348,17 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
$this->container[$offset] = $value;
}
}
-
+
/**
* Unsets offset.
- * @param integer $offset Offset
+ * @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->container[$offset]);
}
-
+
/**
* Gets the string presentation of the object
* @return string
diff --git a/modules/swagger-codegen/src/main/resources/php/model_enum.mustache b/modules/swagger-codegen/src/main/resources/php/model_enum.mustache
index 4598f9fdff9..ffb268c6cb9 100644
--- a/modules/swagger-codegen/src/main/resources/php/model_enum.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/model_enum.mustache
@@ -7,7 +7,8 @@ class {{classname}} {
* Gets allowable values of the enum
* @return string[]
*/
- public function {{getter}}AllowableValues() {
+ public function {{getter}}AllowableValues()
+ {
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}
diff --git a/modules/swagger-codegen/src/main/resources/php/model_generic.mustache b/modules/swagger-codegen/src/main/resources/php/model_generic.mustache
index 006cd09c62a..22f97456e04 100644
--- a/modules/swagger-codegen/src/main/resources/php/model_generic.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/model_generic.mustache
@@ -1,19 +1,20 @@
class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayAccess
{
/**
- * Array of property to type mappings. Used for (de)serialization
+ * Array of property to type mappings. Used for (de)serialization
* @var string[]
*/
static $swaggerTypes = array(
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
-
- static function swaggerTypes() {
+
+ static function swaggerTypes()
+ {
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}};
}
- /**
+ /**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
@@ -21,8 +22,9 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
-
- static function attributeMap() {
+
+ static function attributeMap()
+ {
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap;
}
@@ -34,8 +36,9 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{#vars}}'{{name}}' => '{{setter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
-
- static function setters() {
+
+ static function setters()
+ {
return {{#parent}}parent::setters() + {{/parent}}self::$setters;
}
@@ -47,8 +50,9 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{#vars}}'{{name}}' => '{{getter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
-
- static function getters() {
+
+ static function getters()
+ {
return {{#parent}}parent::getters() + {{/parent}}self::$getters;
}
@@ -60,7 +64,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
* Gets allowable values of the enum
* @return string[]
*/
- public function {{getter}}AllowableValues() {
+ public function {{getter}}AllowableValues()
+ {
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}
@@ -115,7 +120,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/vars}}
/**
* Returns true if offset exists. False otherwise.
- * @param integer $offset Offset
+ * @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
@@ -125,17 +130,17 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
/**
* Gets offset.
- * @param integer $offset Offset
- * @return mixed
+ * @param integer $offset Offset
+ * @return mixed
*/
public function offsetGet($offset)
{
return $this->$offset;
}
-
+
/**
* Sets value based on offset.
- * @param integer $offset Offset
+ * @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
@@ -143,17 +148,17 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{
$this->$offset = $value;
}
-
+
/**
* Unsets offset.
- * @param integer $offset Offset
+ * @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->$offset);
}
-
+
/**
* Gets the string presentation of the object.
* @return string
diff --git a/modules/swagger-codegen/src/main/resources/php/model_test.mustache b/modules/swagger-codegen/src/main/resources/php/model_test.mustache
index 0d615eca102..3482629f917 100644
--- a/modules/swagger-codegen/src/main/resources/php/model_test.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/model_test.mustache
@@ -39,7 +39,7 @@ namespace {{modelPackage}};
* {{classname}}Test Class Doc Comment
*
* @category Class
- * @description {{description}}
+ * @description {{#description}}{{description}}{{/description}}{{^description}}{{classname}}{{/description}}
* @package {{invokerPackage}}
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
@@ -51,24 +51,26 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
/**
* Setup before running each test case
*/
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass()
+ {
}
/**
* Clean up after running each test case
*/
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass()
+ {
}
/**
- * Test {{classname}}
+ * Test "{{classname}}"
*/
- public function test{{classname}}() {
+ public function test{{classname}}()
+ {
}
-
}
{{/model}}
{{/models}}
diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache
index 94458e3f724..c9c94ad3e3e 100644
--- a/modules/swagger-codegen/src/main/resources/python/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/api.mustache
@@ -156,13 +156,13 @@ class {{classname}}(object):
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
- select_header_accept([{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}])
+ select_header_accept([{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
- select_header_content_type([{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}])
+ select_header_content_type([{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}])
# Authentication setting
auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
diff --git a/modules/swagger-codegen/src/main/resources/python/api_doc.mustache b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache
index 8eb25a87b06..98dec04a393 100644
--- a/modules/swagger-codegen/src/main/resources/python/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache
@@ -65,8 +65,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
diff --git a/modules/swagger-codegen/src/main/resources/python/requirements.mustache b/modules/swagger-codegen/src/main/resources/python/requirements.mustache
new file mode 100644
index 00000000000..f00e08fa339
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/requirements.mustache
@@ -0,0 +1,5 @@
+certifi >= 14.05.14
+six == 1.8.0
+python_dateutil >= 2.5.3
+setuptools >= 21.0.0
+urllib3 >= 1.15.1
diff --git a/modules/swagger-codegen/src/main/resources/python/test-requirements.mustache b/modules/swagger-codegen/src/main/resources/python/test-requirements.mustache
new file mode 100644
index 00000000000..2702246c0e6
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/test-requirements.mustache
@@ -0,0 +1,5 @@
+coverage>=4.0.3
+nose>=1.3.7
+pluggy>=0.3.1
+py>=1.4.31
+randomize>=0.13
diff --git a/modules/swagger-codegen/src/main/resources/python/tox.mustache b/modules/swagger-codegen/src/main/resources/python/tox.mustache
new file mode 100644
index 00000000000..d99517b76b6
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/tox.mustache
@@ -0,0 +1,10 @@
+[tox]
+envlist = py27, py34
+
+[testenv]
+deps=-r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
+
+commands=
+ nosetests \
+ []
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/rails5/.keep b/modules/swagger-codegen/src/main/resources/rails5/.keep
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/swagger-codegen/src/main/resources/rails5/404.html b/modules/swagger-codegen/src/main/resources/rails5/404.html
new file mode 100644
index 00000000000..b612547fc21
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/modules/swagger-codegen/src/main/resources/rails5/422.html b/modules/swagger-codegen/src/main/resources/rails5/422.html
new file mode 100644
index 00000000000..a21f82b3bdb
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/modules/swagger-codegen/src/main/resources/rails5/500.html b/modules/swagger-codegen/src/main/resources/rails5/500.html
new file mode 100644
index 00000000000..061abc587dc
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/modules/swagger-codegen/src/main/resources/rails5/Gemfile b/modules/swagger-codegen/src/main/resources/rails5/Gemfile
new file mode 100644
index 00000000000..b553bf7355d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/Gemfile
@@ -0,0 +1,36 @@
+source 'https://rubygems.org'
+
+
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '>= 5.0.0.racecar1', '< 5.1'
+# Use mysql as the database for Active Record
+gem 'mysql2', '>= 0.3.18', '< 0.5'
+# Use Puma as the app server
+gem 'puma', '~> 3.0'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.0'
+# Use Redis adapter to run Action Cable in production
+# gem 'redis', '~> 3.0'
+# Use ActiveModel has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use Capistrano for deployment
+# gem 'capistrano-rails', group: :development
+
+# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
+# gem 'rack-cors'
+
+group :development, :test do
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'byebug', platform: :mri
+end
+
+group :development do
+ gem 'listen', '~> 3.0.5'
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
+ gem 'spring'
+ gem 'spring-watcher-listen', '~> 2.0.0'
+end
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
diff --git a/modules/swagger-codegen/src/main/resources/rails5/README.md b/modules/swagger-codegen/src/main/resources/rails5/README.md
new file mode 100644
index 00000000000..c5cb90075a6
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/README.md
@@ -0,0 +1,25 @@
+# Swagger for Rails 5
+
+This is a project to provide Swagger support inside the [Sinatra](http://rubyonrails.org/) framework.
+
+## Prerequisites
+You need to install ruby >= 2.2.2 and run:
+
+```
+bundle install
+```
+
+## Getting started
+
+This sample was generated with the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project.
+
+```
+bin/rake db:create
+bin/rails s
+```
+
+To list all your routes, use:
+
+```
+bin/rake routes
+```
diff --git a/modules/swagger-codegen/src/main/resources/rails5/Rakefile b/modules/swagger-codegen/src/main/resources/rails5/Rakefile
new file mode 100644
index 00000000000..e85f913914b
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative 'config/application'
+
+Rails.application.load_tasks
diff --git a/modules/swagger-codegen/src/main/resources/rails5/active_record_belongs_to_required_by_default.rb b/modules/swagger-codegen/src/main/resources/rails5/active_record_belongs_to_required_by_default.rb
new file mode 100644
index 00000000000..f613b40f804
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/active_record_belongs_to_required_by_default.rb
@@ -0,0 +1,6 @@
+# Be sure to restart your server when you modify this file.
+
+# Require `belongs_to` associations by default. This is a new Rails 5.0
+# default, so it is introduced as a configuration option to ensure that apps
+# made on earlier versions of Rails are not affected when upgrading.
+Rails.application.config.active_record.belongs_to_required_by_default = true
diff --git a/modules/swagger-codegen/src/main/resources/rails5/apple-touch-icon-precomposed.png b/modules/swagger-codegen/src/main/resources/rails5/apple-touch-icon-precomposed.png
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/swagger-codegen/src/main/resources/rails5/apple-touch-icon.png b/modules/swagger-codegen/src/main/resources/rails5/apple-touch-icon.png
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/swagger-codegen/src/main/resources/rails5/application.rb b/modules/swagger-codegen/src/main/resources/rails5/application.rb
new file mode 100644
index 00000000000..70bea9ecf69
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/application.rb
@@ -0,0 +1,30 @@
+require_relative 'boot'
+
+require "rails"
+# Pick the frameworks you want:
+require "active_model/railtie"
+require "active_job/railtie"
+require "active_record/railtie"
+require "action_controller/railtie"
+require "action_mailer/railtie"
+require "action_view/railtie"
+require "action_cable/engine"
+# require "sprockets/railtie"
+require "rails/test_unit/railtie"
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module ApiDemo
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Only loads a smaller set of middleware suitable for API only apps.
+ # Middleware like session, flash, cookies can be added back manually.
+ # Skip views, helpers and assets when generating a new resource.
+ config.api_only = true
+ end
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/application_controller.rb b/modules/swagger-codegen/src/main/resources/rails5/application_controller.rb
new file mode 100644
index 00000000000..4ac8823b095
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::API
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/application_controller_renderer.rb b/modules/swagger-codegen/src/main/resources/rails5/application_controller_renderer.rb
new file mode 100644
index 00000000000..51639b67a00
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/application_controller_renderer.rb
@@ -0,0 +1,6 @@
+# Be sure to restart your server when you modify this file.
+
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
diff --git a/modules/swagger-codegen/src/main/resources/rails5/application_job.rb b/modules/swagger-codegen/src/main/resources/rails5/application_job.rb
new file mode 100644
index 00000000000..a009ace51cc
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/application_job.rb
@@ -0,0 +1,2 @@
+class ApplicationJob < ActiveJob::Base
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/application_mailer.rb b/modules/swagger-codegen/src/main/resources/rails5/application_mailer.rb
new file mode 100644
index 00000000000..286b2239d13
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: 'from@example.com'
+ layout 'mailer'
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/application_record.rb b/modules/swagger-codegen/src/main/resources/rails5/application_record.rb
new file mode 100644
index 00000000000..10a4cba84df
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ self.abstract_class = true
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/backtrace_silencers.rb b/modules/swagger-codegen/src/main/resources/rails5/backtrace_silencers.rb
new file mode 100644
index 00000000000..59385cdf379
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/modules/swagger-codegen/src/main/resources/rails5/boot.rb b/modules/swagger-codegen/src/main/resources/rails5/boot.rb
new file mode 100644
index 00000000000..30f5120df69
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/boot.rb
@@ -0,0 +1,3 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/modules/swagger-codegen/src/main/resources/rails5/bundle b/modules/swagger-codegen/src/main/resources/rails5/bundle
new file mode 100755
index 00000000000..66e9889e8b4
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/modules/swagger-codegen/src/main/resources/rails5/cable.yml b/modules/swagger-codegen/src/main/resources/rails5/cable.yml
new file mode 100644
index 00000000000..aa4e832748c
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/cable.yml
@@ -0,0 +1,10 @@
+# Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket.
+production:
+ adapter: redis
+ url: redis://localhost:6379/1
+
+development:
+ adapter: async
+
+test:
+ adapter: async
diff --git a/modules/swagger-codegen/src/main/resources/rails5/callback_terminator.rb b/modules/swagger-codegen/src/main/resources/rails5/callback_terminator.rb
new file mode 100644
index 00000000000..649e82280e1
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/callback_terminator.rb
@@ -0,0 +1,6 @@
+# Be sure to restart your server when you modify this file.
+
+# Do not halt callback chains when a callback returns false. This is a new
+# Rails 5.0 default, so it is introduced as a configuration option to ensure
+# that apps made with earlier versions of Rails are not affected when upgrading.
+ActiveSupport.halt_callback_chains_on_return_false = false
diff --git a/modules/swagger-codegen/src/main/resources/rails5/channel.rb b/modules/swagger-codegen/src/main/resources/rails5/channel.rb
new file mode 100644
index 00000000000..d56fa30f4d8
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/channel.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading.
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/config.ru b/modules/swagger-codegen/src/main/resources/rails5/config.ru
new file mode 100644
index 00000000000..f7ba0b527b1
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/modules/swagger-codegen/src/main/resources/rails5/connection.rb b/modules/swagger-codegen/src/main/resources/rails5/connection.rb
new file mode 100644
index 00000000000..b4f41389ad0
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/connection.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading.
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/controller.mustache b/modules/swagger-codegen/src/main/resources/rails5/controller.mustache
new file mode 100644
index 00000000000..321960875d8
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/controller.mustache
@@ -0,0 +1,49 @@
+class {{classname}} < ApplicationController
+{{#operations}}
+{{#operation}}
+
+{{#isRestfulIndex}}
+ def index
+ # Your code here
+
+ render json: {"message" => "yes, it worked"}
+ end
+{{/isRestfulIndex}}
+{{#isRestfulShow}}
+ def show
+ # Your code here
+
+ render json: {"message" => "yes, it worked"}
+ end
+{{/isRestfulShow}}
+{{#isRestfulCreate}}
+ def create
+ # Your code here
+
+ render json: {"message" => "yes, it worked"}
+ end
+{{/isRestfulCreate}}
+{{#isRestfulUpdate}}
+ def update
+ # Your code here
+
+ render json: {"message" => "yes, it worked"}
+ end
+{{/isRestfulUpdate}}
+{{#isRestfulDestroy}}
+ def destroy
+ # Your code here
+
+ render json: {"message" => "yes, it worked"}
+ end
+{{/isRestfulDestroy}}
+{{^isRestful}}
+ def {{nickname}}
+ # Your code here
+
+ render json: {"message" => "yes, it worked"}
+ end
+{{/isRestful}}
+{{/operation}}
+{{/operations}}
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/cors.rb b/modules/swagger-codegen/src/main/resources/rails5/cors.rb
new file mode 100644
index 00000000000..3b1c1b5ed14
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/cors.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Avoid CORS issues when API is called from the frontend app.
+# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
+
+# Read more: https://github.com/cyu/rack-cors
+
+# Rails.application.config.middleware.insert_before 0, Rack::Cors do
+# allow do
+# origins 'example.com'
+#
+# resource '*',
+# headers: :any,
+# methods: [:get, :post, :put, :patch, :delete, :options, :head]
+# end
+# end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/database.yml b/modules/swagger-codegen/src/main/resources/rails5/database.yml
new file mode 100644
index 00000000000..e536d9f37dc
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/database.yml
@@ -0,0 +1,54 @@
+# MySQL. Versions 5.0 and up are supported.
+#
+# Install the MySQL driver
+# gem install mysql2
+#
+# Ensure the MySQL gem is defined in your Gemfile
+# gem 'mysql2'
+#
+# And be sure to use new-style password hashing:
+# http://dev.mysql.com/doc/refman/5.7/en/old-client.html
+#
+default: &default
+ adapter: mysql2
+ encoding: utf8
+ pool: 5
+ username: root
+ password:
+ socket: /tmp/mysql.sock
+
+development:
+ <<: *default
+ database: api_demo_development
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: api_demo_test
+
+# As with config/secrets.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password as a unix environment variable when you boot
+# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full rundown on how to provide these environment variables in a
+# production deployment.
+#
+# On Heroku and other platform providers, you may have a full connection URL
+# available as an environment variable. For example:
+#
+# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
+#
+# You can use this database configuration with:
+#
+# production:
+# url: <%= ENV['DATABASE_URL'] %>
+#
+production:
+ <<: *default
+ database: api_demo_production
+ username: api_demo
+ password: <%= ENV['API_DEMO_DATABASE_PASSWORD'] %>
diff --git a/modules/swagger-codegen/src/main/resources/rails5/development.rb b/modules/swagger-codegen/src/main/resources/rails5/development.rb
new file mode 100644
index 00000000000..082a013ab36
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/development.rb
@@ -0,0 +1,47 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => 'public, max-age=172800'
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/en.yml b/modules/swagger-codegen/src/main/resources/rails5/en.yml
new file mode 100644
index 00000000000..0653957166e
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/en.yml
@@ -0,0 +1,23 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/modules/swagger-codegen/src/main/resources/rails5/environment.rb b/modules/swagger-codegen/src/main/resources/rails5/environment.rb
new file mode 100644
index 00000000000..426333bb469
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/modules/swagger-codegen/src/main/resources/rails5/favicon.ico b/modules/swagger-codegen/src/main/resources/rails5/favicon.ico
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/swagger-codegen/src/main/resources/rails5/filter_parameter_logging.rb b/modules/swagger-codegen/src/main/resources/rails5/filter_parameter_logging.rb
new file mode 100644
index 00000000000..4a994e1e7bb
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/modules/swagger-codegen/src/main/resources/rails5/inflections.rb b/modules/swagger-codegen/src/main/resources/rails5/inflections.rb
new file mode 100644
index 00000000000..ac033bf9dc8
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/mailer.html.erb b/modules/swagger-codegen/src/main/resources/rails5/mailer.html.erb
new file mode 100644
index 00000000000..cbd34d2e9dd
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/mailer.html.erb
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ <%= yield %>
+
+
diff --git a/modules/swagger-codegen/src/main/resources/rails5/mailer.text.erb b/modules/swagger-codegen/src/main/resources/rails5/mailer.text.erb
new file mode 100644
index 00000000000..37f0bddbd74
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/modules/swagger-codegen/src/main/resources/rails5/mime_types.rb b/modules/swagger-codegen/src/main/resources/rails5/mime_types.rb
new file mode 100644
index 00000000000..dc1899682b0
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/modules/swagger-codegen/src/main/resources/rails5/production.rb b/modules/swagger-codegen/src/main/resources/rails5/production.rb
new file mode 100644
index 00000000000..6cb0a8fe61c
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/production.rb
@@ -0,0 +1,80 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Action Cable endpoint configuration
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Don't mount Action Cable in the main server process.
+ # config.action_cable.mount_path = nil
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "api_demo_#{Rails.env}"
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/puma.rb b/modules/swagger-codegen/src/main/resources/rails5/puma.rb
new file mode 100644
index 00000000000..c7f311f8116
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/puma.rb
@@ -0,0 +1,47 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum, this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted this block will be run, if you are using `preload_app!`
+# option you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/modules/swagger-codegen/src/main/resources/rails5/rails b/modules/swagger-codegen/src/main/resources/rails5/rails
new file mode 100755
index 00000000000..07396602377
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/modules/swagger-codegen/src/main/resources/rails5/rake b/modules/swagger-codegen/src/main/resources/rails5/rake
new file mode 100755
index 00000000000..17240489f64
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/modules/swagger-codegen/src/main/resources/rails5/restart.txt b/modules/swagger-codegen/src/main/resources/rails5/restart.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/swagger-codegen/src/main/resources/rails5/robots.txt b/modules/swagger-codegen/src/main/resources/rails5/robots.txt
new file mode 100644
index 00000000000..3c9c7c01f30
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-agent: *
+# Disallow: /
diff --git a/modules/swagger-codegen/src/main/resources/rails5/routes.mustache b/modules/swagger-codegen/src/main/resources/rails5/routes.mustache
new file mode 100644
index 00000000000..6ebc0d4965d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/routes.mustache
@@ -0,0 +1,17 @@
+Rails.application.routes.draw do
+
+ def add_swagger_route http_method, path, opts = {}
+ full_path = path.gsub(/{(.*?)}/, ':\1')
+ match full_path, to: "#{opts.fetch(:controller_name)}##{opts[:action_name]}", via: http_method
+ end
+
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+{{#operation}}
+ add_swagger_route '{{httpMethod}}', '{{basePathWithoutHost}}{{path}}', controller_name: '{{classVarName}}', action_name: {{#isRestfulIndex}}'index'{{/isRestfulIndex}}{{#isRestfulCreate}}'create'{{/isRestfulCreate}}{{#isRestfulUpdate}}'update'{{/isRestfulUpdate}}{{#isRestfulShow}}'show'{{/isRestfulShow}}{{#isRestfulDestroy}}'destroy'{{/isRestfulDestroy}}{{^isRestful}}'{{nickname}}'{{/isRestful}}
+{{/operation}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/schema.rb b/modules/swagger-codegen/src/main/resources/rails5/schema.rb
new file mode 100644
index 00000000000..4dfbb16804e
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/schema.rb
@@ -0,0 +1,16 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 0) do
+
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/secrets.yml b/modules/swagger-codegen/src/main/resources/rails5/secrets.yml
new file mode 100644
index 00000000000..179b066b84d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/secrets.yml
@@ -0,0 +1,22 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rails secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+development:
+ secret_key_base: 2e13a003477a557ba3fcc6260c2ec69e411238b9b8b530c3c70e71f7cfc905b5f746f5c195a0282342a77ad6acd4e6ef8949106723200a99414fe83393d67344
+
+test:
+ secret_key_base: fedf54236a94882c00e2fa0af308a4135f50941396437b9fbc38dd340c0a8bcf38cfcf6264cc2abc2af5bda26252293fe48e9a3e90fbfc4d25d6886d6d14b300
+
+# Do not keep production secrets in the repository,
+# instead read values from the environment.
+production:
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
diff --git a/modules/swagger-codegen/src/main/resources/rails5/seeds.rb b/modules/swagger-codegen/src/main/resources/rails5/seeds.rb
new file mode 100644
index 00000000000..1beea2accd7
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
diff --git a/modules/swagger-codegen/src/main/resources/rails5/setup b/modules/swagger-codegen/src/main/resources/rails5/setup
new file mode 100755
index 00000000000..e620b4dadb2
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/setup
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/spring.rb b/modules/swagger-codegen/src/main/resources/rails5/spring.rb
new file mode 100644
index 00000000000..c9119b40c08
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/spring.rb
@@ -0,0 +1,6 @@
+%w(
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
diff --git a/modules/swagger-codegen/src/main/resources/rails5/ssl_options.rb b/modules/swagger-codegen/src/main/resources/rails5/ssl_options.rb
new file mode 100644
index 00000000000..1775dea1e76
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/ssl_options.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure SSL options to enable HSTS with subdomains.
+Rails.application.config.ssl_options = { hsts: { subdomains: true } }
diff --git a/modules/swagger-codegen/src/main/resources/rails5/test.rb b/modules/swagger-codegen/src/main/resources/rails5/test.rb
new file mode 100644
index 00000000000..30587ef6d5e
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/test.rb
@@ -0,0 +1,42 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => 'public, max-age=3600'
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/test_helper.rb b/modules/swagger-codegen/src/main/resources/rails5/test_helper.rb
new file mode 100644
index 00000000000..92e39b2d78c
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/test_helper.rb
@@ -0,0 +1,10 @@
+ENV['RAILS_ENV'] ||= 'test'
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/to_time_preserves_timezone.rb b/modules/swagger-codegen/src/main/resources/rails5/to_time_preserves_timezone.rb
new file mode 100644
index 00000000000..8674be3227e
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/to_time_preserves_timezone.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Preserve the timezone of the receiver when calling to `to_time`.
+# Ruby 2.4 will change the behavior of `to_time` to preserve the timezone
+# when converting to an instance of `Time` instead of the previous behavior
+# of converting to the local system timezone.
+#
+# Rails 5.0 introduced this config option so that apps made with earlier
+# versions of Rails are not affected when upgrading.
+ActiveSupport.to_time_preserves_timezone = true
diff --git a/modules/swagger-codegen/src/main/resources/rails5/update b/modules/swagger-codegen/src/main/resources/rails5/update
new file mode 100755
index 00000000000..a8e4462f203
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/modules/swagger-codegen/src/main/resources/rails5/wrap_parameters.rb b/modules/swagger-codegen/src/main/resources/rails5/wrap_parameters.rb
new file mode 100644
index 00000000000..bbfc3961bff
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/rails5/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache
index 20b6d4593e3..5201fd343ea 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache
@@ -98,11 +98,11 @@ module {{moduleName}}
header_params = {}
# HTTP header 'Accept' (if needed)
- local_header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
+ local_header_accept = [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
# HTTP header 'Content-Type'
- local_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
+ local_header_content_type = [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type){{#headerParams}}{{#required}}
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}{{/required}}{{/headerParams}}{{#headerParams}}{{^required}}
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if opts[:'{{{paramName}}}']{{/required}}{{/headerParams}}
diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache
index a2cee7f9361..02fd5f7f547 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache
@@ -22,7 +22,7 @@ Method | HTTP request | Description
# load the gem
require '{{{gemName}}}'
{{#hasAuthMethods}}
-# setup authorization
+# setup authorization
{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}
# Configure HTTP basic authorization: {{{name}}}
config.username = 'YOUR USERNAME'
@@ -70,8 +70,8 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
diff --git a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
index 87877d1763e..0c15a9929f3 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
@@ -86,7 +86,7 @@
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
- # @param [Object] value Any valid value
+ # @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
diff --git a/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache
index e153ce23ecf..a9b0f28edfb 100755
--- a/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache
@@ -28,7 +28,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache
index 14f26898d2b..33a5d134029 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache
@@ -4,239 +4,6 @@
require 'date'
-module {{moduleName}}{{#models}}{{#model}}{{#description}}
- # {{{description}}}{{/description}}
- class {{classname}}{{#vars}}{{#description}}
- # {{{description}}}{{/description}}
- attr_accessor :{{{name}}}
-{{/vars}}
-
- # Attribute mapping from ruby-style variable name to JSON key.
- def self.attribute_map
- {
- {{#vars}}
- :'{{{name}}}' => :'{{{baseName}}}'{{#hasMore}},{{/hasMore}}
- {{/vars}}
- }
- end
-
- # Attribute type mapping.
- def self.swagger_types
- {
- {{#vars}}
- :'{{{name}}}' => :'{{{datatype}}}'{{#hasMore}},{{/hasMore}}
- {{/vars}}
- }
- end
-
- # Initializes the object
- # @param [Hash] attributes Model attributes in the form of hash
- def initialize(attributes = {})
- return unless attributes.is_a?(Hash)
-
- # convert string to symbol for hash key
- attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
-
- {{#vars}}
- if attributes.has_key?(:'{{{baseName}}}')
- {{#isContainer}}
- if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
- self.{{{name}}} = value
- end
- {{/isContainer}}
- {{^isContainer}}
- self.{{{name}}} = attributes[:'{{{baseName}}}']
- {{/isContainer}}
- {{#defaultValue}}
- else
- self.{{{name}}} = {{{defaultValue}}}
- {{/defaultValue}}
- end
-
- {{/vars}}
- end
-
- # Show invalid properties with the reasons. Usually used together with valid?
- # @return Array for valid properies with the reasons
- def list_invalid_properties
- invalid_properties = Array.new
- {{#isEnum}}
- allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
- if @{{{name}}} && !allowed_values.include?({{{name}}})
- invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.")
- end
-
- {{/isEnum}}
- {{#hasValidation}}
- if @{{{name}}}.nil?
- fail ArgumentError, "{{{name}}} cannot be nil"
- end
-
- {{#minLength}}
- if @{{{name}}}.to_s.length > {{{maxLength}}}
- invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.")
- end
-
- {{/minLength}}
- {{#maxLength}}
- if @{{{name}}}.to_s.length < {{{minLength}}}
- invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.")
- end
-
- {{/maxLength}}
- {{#maximum}}
- if @{{{name}}} > {{{maximum}}}
- invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.")
- end
-
- {{/maximum}}
- {{#minimum}}
- if @{{{name}}} < {{{minimum}}}
- invalid_properties.push("invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}.")
- end
-
- {{/minimum}}
- {{#pattern}}
- if @{{{name}}} !~ Regexp.new({{{pattern}}})
- invalid_properties.push("invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}.")
- end
-
- {{/pattern}}
- {{/hasValidation}}
- return invalid_properties
- end
-
- # Check to see if the all the properties in the model are valid
- # @return true if the model is valid
- def valid?
- {{#vars}}
- {{#required}}
- if @{{{name}}}.nil?
- return false
- end
-
- {{/required}}
- {{#isEnum}}
- allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
- if @{{{name}}} && !allowed_values.include?(@{{{name}}})
- return false
- end
- {{/isEnum}}
- {{#hasValidation}}
- {{#minLength}}
- if @{{{name}}}.to_s.length > {{{maxLength}}}
- return false
- end
-
- {{/minLength}}
- {{#maxLength}}
- if @{{{name}}}.to_s.length < {{{minLength}}}
- return false
- end
-
- {{/maxLength}}
- {{#maximum}}
- if @{{{name}}} > {{{maximum}}}
- return false
- end
-
- {{/maximum}}
- {{#minimum}}
- if @{{{name}}} < {{{minimum}}}
- return false
- end
-
- {{/minimum}}
- {{#pattern}}
- if @{{{name}}} !~ Regexp.new({{{pattern}}})
- return false
- end
-
- {{/pattern}}
- {{/hasValidation}}
- {{/vars}}
- end
-
- {{#vars}}
- {{#isEnum}}
- # Custom attribute writer method checking allowed values (enum).
- # @param [Object] {{{name}}} Object to be assigned
- def {{{name}}}=({{{name}}})
- allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
- if {{{name}}} && !allowed_values.include?({{{name}}})
- fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}."
- end
- @{{{name}}} = {{{name}}}
- end
-
- {{/isEnum}}
- {{^isEnum}}
- {{#hasValidation}}
- # Custom attribute writer method with validation
- # @param [Object] {{{name}}} Value to be assigned
- def {{{name}}}=({{{name}}})
- if {{{name}}}.nil?
- fail ArgumentError, "{{{name}}} cannot be nil"
- end
-
- {{#minLength}}
- if {{{name}}}.to_s.length > {{{maxLength}}}
- fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}."
- end
-
- {{/minLength}}
- {{#maxLength}}
- if {{{name}}}.to_s.length < {{{minLength}}}
- fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}."
- end
-
- {{/maxLength}}
- {{#maximum}}
- if {{{name}}} > {{{maximum}}}
- fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}."
- end
-
- {{/maximum}}
- {{#minimum}}
- if {{{name}}} < {{{minimum}}}
- fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}."
- end
-
- {{/minimum}}
- {{#pattern}}
- if @{{{name}}} !~ Regexp.new({{{pattern}}})
- fail ArgumentError, "invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}."
- end
-
- {{/pattern}}
- @{{{name}}} = {{{name}}}
- end
-
- {{/hasValidation}}
- {{/isEnum}}
- {{/vars}}
- # Checks equality by comparing each attribute.
- # @param [Object] Object to be compared
- def ==(o)
- return true if self.equal?(o)
- self.class == o.class{{#vars}} &&
- {{name}} == o.{{name}}{{/vars}}
- end
-
- # @see the `==` method
- # @param [Object] Object to be compared
- def eql?(o)
- self == o
- end
-
- # Calculates hash code according to all attributes.
- # @return [Fixnum] Hash code
- def hash
- [{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash
- end
-
-{{> base_object}}
- end
-{{/model}}
-{{/models}}
+module {{moduleName}}
+{{#models}}{{#model}}{{#isEnum}}{{>partial_model_enum_class}}{{/isEnum}}{{^isEnum}}{{>partial_model_generic}}{{/isEnum}}{{/model}}{{/models}}
end
diff --git a/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache b/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache
new file mode 100644
index 00000000000..e0e1ca9403d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache
@@ -0,0 +1,4 @@
+ class {{classname}}
+ {{#allowableValues}}{{#enumVars}}
+ {{{name}}} = {{{value}}}.freeze{{/enumVars}}{{/allowableValues}}
+ end
diff --git a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache
new file mode 100644
index 00000000000..25a71610168
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache
@@ -0,0 +1,232 @@
+{{#description}} # {{{description}}}{{/description}}
+ class {{classname}}{{#vars}}{{#description}}
+ # {{{description}}}{{/description}}
+ attr_accessor :{{{name}}}
+ {{/vars}}
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ {{#vars}}
+ :'{{{name}}}' => :'{{{baseName}}}'{{#hasMore}},{{/hasMore}}
+ {{/vars}}
+ }
+ end
+
+ # Attribute type mapping.
+ def self.swagger_types
+ {
+ {{#vars}}
+ :'{{{name}}}' => :'{{{datatype}}}'{{#hasMore}},{{/hasMore}}
+ {{/vars}}
+ }
+ end
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ return unless attributes.is_a?(Hash)
+
+ # convert string to symbol for hash key
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
+
+ {{#vars}}
+ if attributes.has_key?(:'{{{baseName}}}')
+ {{#isContainer}}
+ if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
+ self.{{{name}}} = value
+ end
+ {{/isContainer}}
+ {{^isContainer}}
+ self.{{{name}}} = attributes[:'{{{baseName}}}']
+ {{/isContainer}}
+ {{#defaultValue}}
+ else
+ self.{{{name}}} = {{{defaultValue}}}
+ {{/defaultValue}}
+ end
+
+ {{/vars}}
+ end
+
+ # Show invalid properties with the reasons. Usually used together with valid?
+ # @return Array for valid properies with the reasons
+ def list_invalid_properties
+ invalid_properties = Array.new
+ {{#isEnum}}
+ allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
+ if @{{{name}}} && !allowed_values.include?({{{name}}})
+ invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.")
+ end
+
+ {{/isEnum}}
+ {{#hasValidation}}
+ if @{{{name}}}.nil?
+ fail ArgumentError, "{{{name}}} cannot be nil"
+ end
+
+ {{#minLength}}
+ if @{{{name}}}.to_s.length > {{{maxLength}}}
+ invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.")
+ end
+
+ {{/minLength}}
+ {{#maxLength}}
+ if @{{{name}}}.to_s.length < {{{minLength}}}
+ invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.")
+ end
+
+ {{/maxLength}}
+ {{#maximum}}
+ if @{{{name}}} > {{{maximum}}}
+ invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.")
+ end
+
+ {{/maximum}}
+ {{#minimum}}
+ if @{{{name}}} < {{{minimum}}}
+ invalid_properties.push("invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}.")
+ end
+
+ {{/minimum}}
+ {{#pattern}}
+ if @{{{name}}} !~ Regexp.new({{{pattern}}})
+ invalid_properties.push("invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}.")
+ end
+
+ {{/pattern}}
+ {{/hasValidation}}
+ return invalid_properties
+ end
+
+ # Check to see if the all the properties in the model are valid
+ # @return true if the model is valid
+ def valid?
+ {{#vars}}
+ {{#required}}
+ if @{{{name}}}.nil?
+ return false
+ end
+
+ {{/required}}
+ {{#isEnum}}
+ allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
+ if @{{{name}}} && !allowed_values.include?(@{{{name}}})
+ return false
+ end
+ {{/isEnum}}
+ {{#hasValidation}}
+ {{#minLength}}
+ if @{{{name}}}.to_s.length > {{{maxLength}}}
+ return false
+ end
+
+ {{/minLength}}
+ {{#maxLength}}
+ if @{{{name}}}.to_s.length < {{{minLength}}}
+ return false
+ end
+
+ {{/maxLength}}
+ {{#maximum}}
+ if @{{{name}}} > {{{maximum}}}
+ return false
+ end
+
+ {{/maximum}}
+ {{#minimum}}
+ if @{{{name}}} < {{{minimum}}}
+ return false
+ end
+
+ {{/minimum}}
+ {{#pattern}}
+ if @{{{name}}} !~ Regexp.new({{{pattern}}})
+ return false
+ end
+
+ {{/pattern}}
+ {{/hasValidation}}
+ {{/vars}}
+ end
+
+ {{#vars}}
+ {{#isEnum}}
+ # Custom attribute writer method checking allowed values (enum).
+ # @param [Object] {{{name}}} Object to be assigned
+ def {{{name}}}=({{{name}}})
+ allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
+ if {{{name}}} && !allowed_values.include?({{{name}}})
+ fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}."
+ end
+ @{{{name}}} = {{{name}}}
+ end
+
+ {{/isEnum}}
+ {{^isEnum}}
+ {{#hasValidation}}
+ # Custom attribute writer method with validation
+ # @param [Object] {{{name}}} Value to be assigned
+ def {{{name}}}=({{{name}}})
+ if {{{name}}}.nil?
+ fail ArgumentError, "{{{name}}} cannot be nil"
+ end
+
+ {{#minLength}}
+ if {{{name}}}.to_s.length > {{{maxLength}}}
+ fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}."
+ end
+
+ {{/minLength}}
+ {{#maxLength}}
+ if {{{name}}}.to_s.length < {{{minLength}}}
+ fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}."
+ end
+
+ {{/maxLength}}
+ {{#maximum}}
+ if {{{name}}} > {{{maximum}}}
+ fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}."
+ end
+
+ {{/maximum}}
+ {{#minimum}}
+ if {{{name}}} < {{{minimum}}}
+ fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}."
+ end
+
+ {{/minimum}}
+ {{#pattern}}
+ if @{{{name}}} !~ Regexp.new({{{pattern}}})
+ fail ArgumentError, "invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}."
+ end
+
+ {{/pattern}}
+ @{{{name}}} = {{{name}}}
+ end
+
+ {{/hasValidation}}
+ {{/isEnum}}
+ {{/vars}}
+ # Checks equality by comparing each attribute.
+ # @param [Object] Object to be compared
+ def ==(o)
+ return true if self.equal?(o)
+ self.class == o.class{{#vars}} &&
+ {{name}} == o.{{name}}{{/vars}}
+ end
+
+ # @see the `==` method
+ # @param [Object] Object to be compared
+ def eql?(o)
+ self == o
+ end
+
+ # Calculates hash code according to all attributes.
+ # @return [Fixnum] Hash code
+ def hash
+ [{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash
+ end
+
+{{> base_object}}
+ end
diff --git a/modules/swagger-codegen/src/main/resources/scala/api.mustache b/modules/swagger-codegen/src/main/resources/scala/api.mustache
index 6345cd876c8..2600e71cffd 100644
--- a/modules/swagger-codegen/src/main/resources/scala/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/scala/api.mustache
@@ -36,7 +36,7 @@ class {{classname}}(val defBasePath: String = "{{basePath}}",
{{/pathParams}}
- val contentTypes = List({{#consumes}}"{{mediaType}}", {{/consumes}}"application/json")
+ val contentTypes = List({{#consumes}}"{{{mediaType}}}", {{/consumes}}"application/json")
val contentType = contentTypes(0)
// query params
diff --git a/modules/swagger-codegen/src/main/resources/slim/index.mustache b/modules/swagger-codegen/src/main/resources/slim/index.mustache
index 4fdd77681c3..383094821dd 100644
--- a/modules/swagger-codegen/src/main/resources/slim/index.mustache
+++ b/modules/swagger-codegen/src/main/resources/slim/index.mustache
@@ -13,7 +13,7 @@ $app = new Slim\App();
* {{httpMethod}} {{nickname}}
* Summary: {{summary}}
* Notes: {{notes}}
-{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
+{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
*/
$app->{{httpMethod}}('{{path}}', function($request, $response, $args) {
{{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}}
diff --git a/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache b/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache
index 418f1c8512b..7041709f365 100644
--- a/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache
@@ -18,4 +18,22 @@ class APIHelper {
}
return destination
}
+
+ static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject] {
+ var destination = [String:AnyObject]()
+ let theTrue = NSNumber(bool: true)
+ let theFalse = NSNumber(bool: false)
+ if (source != nil) {
+ for (key, value) in source! {
+ switch value {
+ case let x where x === theTrue || x === theFalse:
+ destination[key] = "\(value as! Bool)"
+ default:
+ destination[key] = value
+ }
+ }
+ }
+ return destination
+ }
+
}
diff --git a/modules/swagger-codegen/src/main/resources/swift/Models.mustache b/modules/swagger-codegen/src/main/resources/swift/Models.mustache
index 378c83525f1..49798250e72 100644
--- a/modules/swagger-codegen/src/main/resources/swift/Models.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/Models.mustache
@@ -46,9 +46,9 @@ class Decoders {
}
static func decode(clazz clazz: [Key:T].Type, source: AnyObject) -> [Key:T] {
- let sourceDictinoary = source as! [Key: AnyObject]
+ let sourceDictionary = source as! [Key: AnyObject]
var dictionary = [Key:T]()
- for (key, value) in sourceDictinoary {
+ for (key, value) in sourceDictionary {
dictionary[key] = Decoders.decode(clazz: T.self, source: value)
}
return dictionary
diff --git a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache
index 85b227ece87..3af6910a094 100644
--- a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache
@@ -15,6 +15,6 @@ Pod::Spec.new do |s|
s.screenshots = {{& podScreenshots}}{{/podScreenshots}}{{#podDocumentationURL}}
s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}}
s.source_files = '{{projectName}}/Classes/Swaggers/**/*.swift'{{#usePromiseKit}}
- s.dependency 'PromiseKit', '~> 3.0.0'{{/usePromiseKit}}
- s.dependency 'Alamofire', '~> 3.1.4'
+ s.dependency 'PromiseKit', '~> 3.1.1'{{/usePromiseKit}}
+ s.dependency 'Alamofire', '~> 3.1.5'
end
diff --git a/modules/swagger-codegen/src/main/resources/swift/api.mustache b/modules/swagger-codegen/src/main/resources/swift/api.mustache
index 9801182e082..298aa69e45e 100644
--- a/modules/swagger-codegen/src/main/resources/swift/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/api.mustache
@@ -16,6 +16,18 @@ extension {{projectName}}API {
/** {{description}} */{{/description}}
public class {{classname}}: APIBase {
{{#operation}}
+ {{#allParams}}
+ {{#isEnum}}
+ /**
+
+ enum for parameter {{paramName}}
+ */
+ public enum {{{datatypeWithEnum}}}_{{operationId}}: String { {{#allowableValues}}{{#values}}
+ case {{enum}} = "{{raw}}"{{/values}}{{/allowableValues}}
+ }
+
+ {{/isEnum}}
+ {{/allParams}}
/**
{{#summary}}
{{{summary}}}
@@ -23,7 +35,7 @@ public class {{classname}}: APIBase {
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
- parameter completion: completion handler to receive the data and the error objects
*/
- public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: (({{#returnType}}data: {{{returnType}}}?, {{/returnType}}error: ErrorType?) -> Void)) {
+ public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{#isEnum}}{{{datatypeWithEnum}}}_{{operationId}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: (({{#returnType}}data: {{{returnType}}}?, {{/returnType}}error: ErrorType?) -> Void)) {
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).execute { (response, error) -> Void in
completion({{#returnType}}data: response?.body, {{/returnType}}error: error);
}
@@ -37,7 +49,7 @@ public class {{classname}}: APIBase {
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
- returns: Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
*/
- public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
+ public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{#isEnum}}{{{datatypeWithEnum}}}_{{operationId}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
let deferred = Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.pendingPromise()
{{operationId}}({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#returnType}}data, {{/returnType}}error in
if let error = error {
@@ -69,22 +81,25 @@ public class {{classname}}: APIBase {
- returns: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{description}}
*/
- public class func {{operationId}}WithRequestBuilder({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
+ public class func {{operationId}}WithRequestBuilder({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{#isEnum}}{{{datatypeWithEnum}}}_{{operationId}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
{{^pathParams}}let{{/pathParams}}{{#pathParams}}{{^secondaryParam}}var{{/secondaryParam}}{{/pathParams}} path = "{{path}}"{{#pathParams}}
- path = path.stringByReplacingOccurrencesOfString("{{=<% %>=}}{<%paramName%>}<%={{ }}=%>", withString: "\({{paramName}})", options: .LiteralSearch, range: nil){{/pathParams}}
+ path = path.stringByReplacingOccurrencesOfString("{{=<% %>=}}{<%paramName%>}<%={{ }}=%>", withString: "\({{paramName}}{{#isEnum}}.rawValue{{/isEnum}})", options: .LiteralSearch, range: nil){{/pathParams}}
let URLString = {{projectName}}API.basePath + path
{{#bodyParam}}
let parameters = {{paramName}}{{^required}}?{{/required}}.encodeToJSON() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}}
let nillableParameters: [String:AnyObject?] = {{^queryParams}}{{^formParams}}[:]{{/formParams}}{{#formParams}}{{^secondaryParam}}[{{/secondaryParam}}
"{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
]{{/hasMore}}{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}}
- "{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
+ "{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#isEnum}}{{^required}}?{{/required}}.rawValue{{/isEnum}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
]{{/hasMore}}{{/queryParams}}
+
let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}}
-
+
+ let convertedParameters = APIHelper.convertBoolToString(parameters)
+
let requestBuilder: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.getBuilder()
- return requestBuilder.init(method: "{{httpMethod}}", URLString: URLString, parameters: parameters, isBody: {{^queryParams}}{{^formParams}}true{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}}{{#formParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/formParams}})
+ return requestBuilder.init(method: "{{httpMethod}}", URLString: URLString, parameters: convertedParameters, isBody: {{^queryParams}}{{^formParams}}true{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}}{{#formParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/formParams}})
}
{{/operation}}
diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache
index 427479cf675..5a735cc58e1 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache
@@ -15,10 +15,10 @@ namespace {{package}} {
protected basePath = '{{basePath}}';
public defaultHeaders : any = {};
- static $inject: string[] = ['$http', '$httpParamSerializer'];
+ static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
- if (basePath) {
+ if (basePath !== undefined) {
this.basePath = basePath;
}
}
diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache
index fd37bdd1194..817afd33f34 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache
@@ -1,7 +1,8 @@
-import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
-import {Injectable} from 'angular2/core';
+import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
+import {Injectable, Optional} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import * as models from '../model/models';
+import 'rxjs/Rx';
/* tslint:disable:no-unused-variable member-ordering */
@@ -18,7 +19,7 @@ export class {{classname}} {
protected basePath = '{{basePath}}';
public defaultHeaders : Headers = new Headers();
- constructor(protected http: Http, basePath: string) {
+ constructor(protected http: Http, @Optional() basePath: string) {
if (basePath) {
this.basePath = basePath;
}
@@ -34,7 +35,7 @@ export class {{classname}} {
const path = this.basePath + '{{path}}'{{#pathParams}}
.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
- let queryParameters: any = ""; // This should probably be an object in the future
+ let queryParameters = new URLSearchParams();
let headerParams = this.defaultHeaders;
{{#hasFormParams}}
let formParams = new URLSearchParams();
@@ -50,7 +51,7 @@ export class {{classname}} {
{{/allParams}}
{{#queryParams}}
if ({{paramName}} !== undefined) {
- queryParameters['{{baseName}}'] = {{paramName}};
+ queryParameters.set('{{baseName}}', {{paramName}});
}
{{/queryParams}}
diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache
index 05b5c6ec2ea..9a39b864538 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache
@@ -1,9 +1,7 @@
{{#apiInfo}}
{{#apis}}
{{#operations}}
-export * from '../api/{{classname}}';
+export * from './{{ classname }}';
{{/operations}}
{{/apis}}
-{{/apiInfo}}
-
-
+{{/apiInfo}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache
index 4170b2d1594..e8ce6c3642b 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache
@@ -9,6 +9,7 @@ import * as models from './models';
*/
{{/description}}
export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{
+ {{#additionalPropertiesType}}[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};{{/additionalPropertiesType}}
{{#vars}}
{{#description}}
@@ -19,7 +20,6 @@ export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}
{{name}}?: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
{{/vars}}
}
-
{{#hasEnums}}
export namespace {{classname}} {
{{#vars}}
@@ -33,4 +33,4 @@ export namespace {{classname}} {
}
{{/hasEnums}}
{{/model}}
-{{/models}}
+{{/models}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/models.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/models.mustache
index 677b6b87328..ace053bd55b 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-angular2/models.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/models.mustache
@@ -3,6 +3,3 @@
export * from './{{{ classname }}}';
{{/model}}
{{/models}}
-
-
-
diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache
index 0b2e50acb44..28a18bfb91b 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache
@@ -16,17 +16,23 @@
"build": "typings install && tsc"
},
"peerDependencies": {
- "angular2": "^2.0.0-beta.15",
- "rxjs": "^5.0.0-beta.2"
+ "@angular/core": "^2.0.0-rc.1",
+ "@angular/http": "^2.0.0-rc.1"
},
"devDependencies": {
+ "@angular/common": "^2.0.0-rc.1",
+ "@angular/compiler": "^2.0.0-rc.1",
+ "@angular/core": "^2.0.0-rc.1",
+ "@angular/http": "^2.0.0-rc.1",
+ "@angular/platform-browser": "^2.0.0-rc.1",
+ "@angular/platform-browser-dynamic": "^2.0.0-rc.1",
+ "core-js": "^2.3.0",
+ "rxjs": "^5.0.0-beta.6",
+ "zone.js": "^0.6.12",
"typescript": "^1.8.10",
"typings": "^0.8.1",
- "angular2": "^2.0.0-beta.15",
"es6-shim": "^0.35.0",
- "es7-reflect-metadata": "^1.6.0",
- "rxjs": "5.0.0-beta.2",
- "zone.js": "^0.6.10"
+ "es7-reflect-metadata": "^1.6.0"
}{{#npmRepository}},
"publishConfig":{
"registry":"{{npmRepository}}"
diff --git a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache
index 81163d686aa..00644f77401 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache
@@ -1,7 +1,7 @@
import request = require('request');
import http = require('http');
{{^supportsES6}}
-import promise = require('bluebird');
+import Promise = require('bluebird');
{{/supportsES6}}
let defaultBasePath = '{{basePath}}';
@@ -220,9 +220,6 @@ export class {{classname}} {
{{/isFile}}
{{/formParams}}
- {{^supportsES6}}
- let localVarDeferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>();
- {{/supportsES6}}
let requestOptions: request.Options = {
method: '{{httpMethod}}',
qs: queryParameters,
@@ -247,22 +244,7 @@ export class {{classname}} {
requestOptions.form = formParams;
}
}
- {{^supportsES6}}
- request(requestOptions, (error, response, body) => {
- if (error) {
- localVarDeferred.reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- localVarDeferred.resolve({ response: response, body: body });
- } else {
- localVarDeferred.reject({ response: response, body: body });
- }
- }
- });
- return localVarDeferred.promise;
- {{/supportsES6}}
- {{#supportsES6}}
- return new Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => {
+ return new Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
@@ -275,7 +257,6 @@ export class {{classname}} {
}
});
});
- {{/supportsES6}}
}
{{/operation}}
}
diff --git a/modules/swagger-codegen/src/main/resources/typescript-node/package.mustache b/modules/swagger-codegen/src/main/resources/typescript-node/package.mustache
index 96714500208..0d419996ed6 100644
--- a/modules/swagger-codegen/src/main/resources/typescript-node/package.mustache
+++ b/modules/swagger-codegen/src/main/resources/typescript-node/package.mustache
@@ -2,12 +2,14 @@
"name": "{{npmName}}",
"version": "{{npmVersion}}",
"description": "NodeJS client for {{npmName}}",
+ "repository": "{{gitUserId}}/{{gitRepoId}}",
"main": "api.js",
"scripts": {
+ "clean": "rm -Rf node_modules/ typings/ *.js",
"build": "typings install && tsc"
},
"author": "Swagger Codegen Contributors",
- "license": "MIT",
+ "license": "Apache-2.0",
"dependencies": {
"bluebird": "^3.3.5",
"request": "^2.72.0"
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractIntegrationTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractIntegrationTest.java
new file mode 100644
index 00000000000..8aaa127c6d8
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractIntegrationTest.java
@@ -0,0 +1,46 @@
+package io.swagger.codegen;
+
+import org.testng.annotations.Test;
+import org.testng.reporters.Files;
+
+import java.io.IOException;
+import java.util.Map;
+
+import io.swagger.codegen.testutils.IntegrationTestPathsConfig;
+import io.swagger.models.Swagger;
+import io.swagger.parser.SwaggerParser;
+
+import static io.swagger.codegen.testutils.AssertFile.assertPathEqualsRecursively;
+
+public abstract class AbstractIntegrationTest {
+
+ protected abstract IntegrationTestPathsConfig getIntegrationTestPathsConfig();
+
+ protected abstract CodegenConfig getCodegenConfig();
+
+ protected abstract Map configProperties();
+
+ // @wing328: ignore for the time being until we fix the error with the integration test
+ @Test(enabled = false)
+ public void generatesCorrectDirectoryStructure() throws IOException {
+ DefaultGenerator codeGen = new DefaultGenerator();
+ IntegrationTestPathsConfig integrationTestPathsConfig = getIntegrationTestPathsConfig();
+
+ String specContent = Files.readFile(integrationTestPathsConfig.getSpecPath().toFile());
+ Swagger swagger = new SwaggerParser().parse(specContent);
+
+ CodegenConfig codegenConfig = getCodegenConfig();
+ codegenConfig.setOutputDir(integrationTestPathsConfig.getOutputPath().toString());
+
+ ClientOpts clientOpts = new ClientOpts();
+ clientOpts.setProperties(configProperties());
+ ClientOptInput opts = new ClientOptInput()
+ .config(codegenConfig)
+ .opts(clientOpts)
+ .swagger(swagger);
+
+ codeGen.opts(opts).generate();
+
+ assertPathEqualsRecursively(integrationTestPathsConfig.getExpectedPath(), integrationTestPathsConfig.getOutputPath());
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/CodegenIgnoreProcessorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/CodegenIgnoreProcessorTest.java
new file mode 100644
index 00000000000..a9fe89214d5
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/CodegenIgnoreProcessorTest.java
@@ -0,0 +1,21 @@
+package io.swagger.codegen.ignore;
+
+import org.testng.annotations.Test;
+
+public class CodegenIgnoreProcessorTest {
+ @Test
+ public void loadCodegenRules() throws Exception {
+
+ }
+
+ @Test
+ public void getInclusionRules() throws Exception {
+
+ }
+
+ @Test
+ public void getExclusionRules() throws Exception {
+
+ }
+
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/FileRuleTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/FileRuleTest.java
new file mode 100644
index 00000000000..f093507d84c
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/FileRuleTest.java
@@ -0,0 +1,70 @@
+package io.swagger.codegen.ignore.rules;
+
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.testng.Assert.*;
+
+public class FileRuleTest {
+ @Test
+ public void testMatchComplex() throws Exception {
+ // Arrange
+ final String definition = "path/to/**/complex/*.txt";
+ final String relativePath = "path/to/some/nested/complex/xyzzy.txt";
+
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "path"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.TEXT, "to"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.MATCH_ALL),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.TEXT, "complex"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".txt")
+ );
+
+ Rule rule = new FileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testNonMatchComplex() throws Exception {
+ // Arrange
+ final String definition = "path/to/**/complex/*.txt";
+ final String relativePath = "path/to/some/nested/invalid/xyzzy.txt";
+
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "path"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.TEXT, "to"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.MATCH_ALL),
+ new Part(IgnoreLineParser.Token.TEXT, "complex"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".txt")
+ );
+
+ Rule rule = new FileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/IgnoreLineParserTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/IgnoreLineParserTest.java
new file mode 100644
index 00000000000..17a96932d72
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/IgnoreLineParserTest.java
@@ -0,0 +1,158 @@
+package io.swagger.codegen.ignore.rules;
+
+import org.testng.annotations.Test;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+import static org.testng.Assert.*;
+
+public class IgnoreLineParserTest {
+ private IgnoreLineParser.Token verifyInputToSingleToken(final String input, IgnoreLineParser.Token token) throws ParserException {
+ // Act
+ List result = IgnoreLineParser.parse(input);
+
+ // Assert
+ assertNotNull(result);
+ assertEquals(result.size(), 1);
+ IgnoreLineParser.Token actual = result.get(0).getToken();
+ assertEquals(actual, token);
+
+ return actual;
+ }
+
+ @Test
+ public void parseMatchAll() throws Exception {
+ verifyInputToSingleToken("**", IgnoreLineParser.Token.MATCH_ALL);
+ }
+
+ @Test
+ public void parseMatchAny() throws Exception {
+ verifyInputToSingleToken("*", IgnoreLineParser.Token.MATCH_ANY);
+ }
+
+ @Test(expectedExceptions = ParserException.class,
+ expectedExceptionsMessageRegExp = "Negation with no negated pattern\\.")
+ public void parseNegate() throws Exception {
+ verifyInputToSingleToken("!", IgnoreLineParser.Token.NEGATE);
+
+ // Assert
+ fail("Expected simple pattern '!' to throw a ParserException.");
+ }
+
+ @Test
+ public void parseComment() throws Exception {
+ // Arrange
+ final String input = "# This is a comment";
+ Part actual = null;
+
+ // Act
+ List result = IgnoreLineParser.parse(input);
+
+ // Assert
+ assertEquals(result.size(), 1);
+ actual = result.get(0);
+ assertEquals(actual.getToken(), IgnoreLineParser.Token.COMMENT);
+ assertEquals(actual.getValue(), input);
+ }
+
+ @Test
+ public void parseEscapedExclamation() throws Exception {
+ final String input = "\\!";
+ verifyInputToSingleToken(input, IgnoreLineParser.Token.ESCAPED_EXCLAMATION);
+ }
+
+ @Test
+ public void parseEscapedSpace() throws Exception {
+ final String input = "\\ ";
+ verifyInputToSingleToken(input, IgnoreLineParser.Token.ESCAPED_SPACE);
+ }
+
+ @Test
+ public void parseDirectoryMarker() throws Exception {
+ // Arrange
+ final String input = "foo/";
+ Part actual = null;
+
+ // Act
+ List result = IgnoreLineParser.parse(input);
+
+ // Assert
+ assertEquals(result.size(), 2);
+ actual = result.get(0);
+ assertEquals(actual.getToken(), IgnoreLineParser.Token.TEXT);
+ assertEquals(actual.getValue(), "foo");
+ actual = result.get(1);
+ assertEquals(actual.getToken(), IgnoreLineParser.Token.DIRECTORY_MARKER);
+ }
+
+ @Test
+ public void parseRooted() throws Exception {
+ // Arrange
+ final String input = "/abcd";
+ Part actual = null;
+
+ // Act
+ List result = IgnoreLineParser.parse(input);
+
+ // Assert
+ assertEquals(result.size(), 2);
+ actual = result.get(0);
+ assertEquals(actual.getToken(), IgnoreLineParser.Token.ROOTED_MARKER);
+ actual = result.get(1);
+ assertEquals(actual.getToken(), IgnoreLineParser.Token.TEXT);
+ assertEquals(actual.getValue(), "abcd");
+ }
+
+ @Test
+ public void parseComplex() throws Exception {
+ // Arrange
+ final String input = "**/abcd/**/foo/bar/sample.txt";
+ Part current = null;
+
+ // Act
+ Queue result = new LinkedList<>(IgnoreLineParser.parse(input));
+
+ // Assert
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.MATCH_ALL);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.PATH_DELIM);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.TEXT);
+ assertEquals(current.getValue(), "abcd");
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.PATH_DELIM);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.MATCH_ALL);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.PATH_DELIM);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.TEXT);
+ assertEquals(current.getValue(), "foo");
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.PATH_DELIM);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.TEXT);
+ assertEquals(current.getValue(), "bar");
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.PATH_DELIM);
+ current = result.remove();
+ assertEquals(current.getToken(), IgnoreLineParser.Token.TEXT);
+ assertEquals(current.getValue(), "sample.txt");
+ }
+
+ @Test(expectedExceptions = ParserException.class,
+ expectedExceptionsMessageRegExp = "The pattern \\*\\*\\* is invalid\\.")
+ public void parseTripleStarPattern() throws Exception {
+ // Arrange
+ final String input = "should/throw/***/anywhere";
+
+ // Act
+ List result = IgnoreLineParser.parse(input);
+
+ // Assert
+ fail("Expected pattern containing '***' to throw a ParserException.");
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/RootedFileRuleTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/RootedFileRuleTest.java
new file mode 100644
index 00000000000..471422fcc03
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/rules/RootedFileRuleTest.java
@@ -0,0 +1,285 @@
+package io.swagger.codegen.ignore.rules;
+
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.testng.Assert.*;
+
+public class RootedFileRuleTest {
+ @Test
+ public void testMatchFilenameOnly() throws Exception {
+ // Arrange
+ final String definition = "/foo";
+ final String relativePath = "foo";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testNonMatchFilenameOnly() throws Exception {
+ // Arrange
+ final String definition = "/foo";
+ final String relativePath = "bar";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+
+ @Test
+ public void testMatchFilenameAndExtension() throws Exception {
+ // Arrange
+ final String definition = "/foo.txt";
+ final String relativePath = "foo.txt";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo.txt")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testNonMatchFilenameAndExtension() throws Exception {
+ // Arrange
+ final String definition = "/foo.txt";
+ final String relativePath = "bar.baz";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo.txt")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+
+ @Test
+ public void testMatchFilenameWithGlob() throws Exception {
+ // Arrange
+ final String definition = "/foo*";
+ final String relativePath = "foobarbaz";
+
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY)
+ );
+
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testNonMatchFilenameWithGlob() throws Exception {
+ // Arrange
+ final String definition = "/foo*";
+ final String relativePath = "boobarbaz";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY)
+ );
+
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+
+ @Test
+ public void testMatchFilenameAndExtensionWithFilenameGlob() throws Exception {
+ // Arrange
+ final String definition = "/foo*.txt";
+ final String relativePath = "foobarbaz.txt";
+
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".txt")
+ );
+
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testNonMatchFilenameAndExtensionWithFilenameGlob() throws Exception {
+ // Arrange
+ final String definition = "/foo*qux.txt";
+ final String relativePath = "foobarbaz.txt";
+
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, "qux.txt")
+ );
+
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+
+ @Test
+ public void testMatchFilenameAndExtensionWithExtensionGlob() throws Exception {
+ // Arrange
+ final String definition = "/foo.*";
+ final String relativePath = "foo.bak";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo."),
+ new Part(IgnoreLineParser.Token.MATCH_ANY)
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testMatchFilenameAndExtensionWithMultiplePeriods() throws Exception {
+ // Arrange
+ final String definition = "/foo*.xyzzy.txt";
+ final String relativePath = "foo.bar.baz.xyzzy.txt";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".xyzzy.txt")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testNonMatchFilenameAndExtensionWithMultiplePeriods() throws Exception {
+ // Arrange
+ final String definition = "/foo*.xyzzy.txt";
+ final String relativePath = "foo.bar.baz.qux.txt";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".xyzzy.txt")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+
+ @Test
+ public void testMatchWithoutLeadingForwardSlash() throws Exception {
+ // Arrange
+ final String definition = "foo*.xyzzy.txt";
+ final String relativePath = "foo.bar.baz.xyzzy.txt";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "foo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".xyzzy.txt")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertTrue(actual);
+ }
+
+ @Test
+ public void testMatchesOnlyRooted() throws Exception {
+ // Arrange
+ final String definition = "/path/to/some/foo*.xyzzy.txt";
+ final String relativePath = "foo.bar.baz.xyzzy.txt";
+ final List syntax = Arrays.asList(
+ new Part(IgnoreLineParser.Token.ROOTED_MARKER),
+ new Part(IgnoreLineParser.Token.TEXT, "path"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.TEXT, "to"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.TEXT, "some"),
+ new Part(IgnoreLineParser.Token.PATH_DELIM),
+ new Part(IgnoreLineParser.Token.TEXT, "oo"),
+ new Part(IgnoreLineParser.Token.MATCH_ANY),
+ new Part(IgnoreLineParser.Token.TEXT, ".xyzzy.txt")
+ );
+ Rule rule = new RootedFileRule(syntax, definition);
+ Boolean actual = null;
+
+ // Act
+ actual = rule.matches(relativePath);
+
+ // Assert
+ assertFalse(actual);
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java
index 82bb13029e5..82ffa437f2a 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AndroidClientOptionsProvider.java
@@ -18,7 +18,7 @@ public class AndroidClientOptionsProvider implements OptionsProvider {
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
public static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true";
- public static final String LIBRARY_VALUE = "volley";
+ public static final String LIBRARY_VALUE = "httpclient";
@Override
public String getLanguage() {
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PhpClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PhpClientOptionsProvider.java
index dcd7a06438f..8aa37f12fd0 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PhpClientOptionsProvider.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PhpClientOptionsProvider.java
@@ -18,6 +18,8 @@ public class PhpClientOptionsProvider implements OptionsProvider {
public static final String SRC_BASE_PATH_VALUE = "libPhp";
public static final String COMPOSER_VENDOR_NAME_VALUE = "swaggerPhp";
public static final String COMPOSER_PROJECT_NAME_VALUE = "swagger-client-php";
+ public static final String GIT_USER_ID_VALUE = "gitSwaggerPhp";
+ public static final String GIT_REPO_ID_VALUE = "git-swagger-client-php";
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
@Override
@@ -37,7 +39,9 @@ public class PhpClientOptionsProvider implements OptionsProvider {
.put(PhpClientCodegen.PACKAGE_PATH, PACKAGE_PATH_VALUE)
.put(PhpClientCodegen.SRC_BASE_PATH, SRC_BASE_PATH_VALUE)
.put(PhpClientCodegen.COMPOSER_VENDOR_NAME, COMPOSER_VENDOR_NAME_VALUE)
+ .put(CodegenConstants.GIT_USER_ID, GIT_USER_ID_VALUE)
.put(PhpClientCodegen.COMPOSER_PROJECT_NAME, COMPOSER_PROJECT_NAME_VALUE)
+ .put(CodegenConstants.GIT_REPO_ID, GIT_REPO_ID_VALUE)
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
.build();
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/Rails5ServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/Rails5ServerOptionsProvider.java
new file mode 100644
index 00000000000..c75053b84e2
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/Rails5ServerOptionsProvider.java
@@ -0,0 +1,23 @@
+package io.swagger.codegen.options;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+
+public class Rails5ServerOptionsProvider implements OptionsProvider {
+ @Override
+ public String getLanguage() {
+ return "Rails5";
+ }
+
+ @Override
+ public Map createOptions() {
+ //Rails5ServerCodegen doesn't have its own options and base options are cleared
+ return ImmutableMap.of();
+ }
+
+ @Override
+ public boolean isServer() {
+ return true;
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
index fb5e21d1cce..76f31deaacd 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
@@ -42,8 +42,12 @@ public class PhpClientOptionsTest extends AbstractOptionsTest {
times = 1;
clientCodegen.setComposerVendorName(PhpClientOptionsProvider.COMPOSER_VENDOR_NAME_VALUE);
times = 1;
+ clientCodegen.setGitUserId(PhpClientOptionsProvider.GIT_USER_ID_VALUE);
+ times = 1;
clientCodegen.setComposerProjectName(PhpClientOptionsProvider.COMPOSER_PROJECT_NAME_VALUE);
times = 1;
+ clientCodegen.setGitRepoId(PhpClientOptionsProvider.GIT_REPO_ID_VALUE);
+ times = 1;
clientCodegen.setArtifactVersion(PhpClientOptionsProvider.ARTIFACT_VERSION_VALUE);
times = 1;
}};
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/testutils/AssertFile.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/testutils/AssertFile.java
new file mode 100644
index 00000000000..f810e20eb0a
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/testutils/AssertFile.java
@@ -0,0 +1,132 @@
+package io.swagger.codegen.testutils;
+
+import org.testng.Assert;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.FileVisitResult;
+import java.nio.file.FileVisitor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.List;
+
+import difflib.Delta;
+import difflib.DiffUtils;
+import difflib.Patch;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+/**
+ * Assertion for recursively testing directories.
+ *
+ * @author andreas
+ */
+public class AssertFile {
+
+ private AssertFile() {
+ throw new RuntimeException("This class should not be instantiated");
+ }
+
+ /**
+ * Asserts that two directories are recursively equal. If they are not, an {@link AssertionError} is thrown with the
+ * given message.
+ * There will be a textual comparison of all files under expected with all files under actual. File attributes will
+ * not be considered.
+ * Missing or additional files are considered an error.
+ *
+ * @param expected Path expected directory
+ * @param actual Path actual directory
+ */
+ public static void assertPathEqualsRecursively(final Path expected, final Path actual) {
+ Assert.assertNotNull(expected);
+ Assert.assertNotNull(actual);
+ final Path absoluteExpected = expected.toAbsolutePath();
+ final Path absoluteActual = actual.toAbsolutePath();
+ try {
+ Files.walkFileTree(expected, new FileVisitor() {
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path expectedDir, BasicFileAttributes attrs) throws IOException {
+ Path relativeExpectedDir = absoluteExpected.relativize(expectedDir.toAbsolutePath());
+ Path actualDir = absoluteActual.resolve(relativeExpectedDir);
+
+ if (!Files.exists(actualDir)) {
+ fail(String.format("Directory '%s' is missing.", actualDir));
+ }
+
+ assertEquals(expectedDir.toFile().list(),
+ actualDir.toFile().list(),
+ String.format("Directory content of '%s' and '%s' differ.", expectedDir, actualDir));
+
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path expectedFile, BasicFileAttributes attrs) throws IOException {
+ Path relativeExpectedFile = absoluteExpected.relativize(expectedFile.toAbsolutePath());
+ Path actualFile = absoluteActual.resolve(relativeExpectedFile);
+
+ if (!Files.exists(actualFile)) {
+ fail(String.format("File '%s' is missing.", actualFile));
+ }
+
+ assertFilesAreEqual(expectedFile, actualFile);
+
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
+ fail(exc.getMessage());
+ return FileVisitResult.TERMINATE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+
+ });
+ } catch (IOException e) {
+ fail(e.getMessage(), e);
+ }
+ }
+
+
+ public static void assertFilesAreEqual(final Path expected, final Path actual) {
+
+ if(!Files.isRegularFile(expected)) {
+ fail("expected: '%s' is not a readable file");
+ }
+
+ if(!Files.isRegularFile(actual)) {
+ fail("actual: '%s' is not a readable file");
+ }
+
+ try {
+ List expectedLines = Files.readAllLines(expected, Charset.defaultCharset());
+ List actualLines = Files.readAllLines(actual, Charset.defaultCharset());
+ Patch diff = DiffUtils.diff(expectedLines, actualLines);
+ List deltas = diff.getDeltas();
+ if(!deltas.isEmpty()) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("files diff:\n");
+ stringBuilder.append("\tfile: '" + expected.toAbsolutePath().toString() + "' \n");
+ stringBuilder.append("\tfile: '" + actual.toAbsolutePath().toString() + "' \n");
+ stringBuilder.append("\tdiffs:\n");
+
+ for (Delta delta: deltas) {
+ stringBuilder.append(delta.toString() + "\n");
+ }
+
+ fail(stringBuilder.toString());
+ }
+
+ } catch (IOException e) {
+ fail(e.getMessage(), e);
+ }
+ }
+}
+
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/testutils/IntegrationTestPathsConfig.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/testutils/IntegrationTestPathsConfig.java
new file mode 100644
index 00000000000..4335c69dd2d
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/testutils/IntegrationTestPathsConfig.java
@@ -0,0 +1,33 @@
+package io.swagger.codegen.testutils;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class IntegrationTestPathsConfig {
+ private static final Path INTEGRATION_TEST_PATH = Paths.get("target/test-classes/integrationtests").toAbsolutePath();
+ private final Path outputPath;
+ private final Path specPath;
+ private final Path expectedPath;
+
+ public IntegrationTestPathsConfig(String location) {
+ this(location + "-spec.json", location + "-result", location + "-expected");
+ }
+
+ public IntegrationTestPathsConfig(String specLocation, String outputLocation, String expectedLocation) {
+ outputPath = INTEGRATION_TEST_PATH.resolve(outputLocation);
+ expectedPath = INTEGRATION_TEST_PATH.resolve(expectedLocation);
+ specPath = INTEGRATION_TEST_PATH.resolve(specLocation);
+ }
+
+ public Path getOutputPath() {
+ return outputPath;
+ }
+
+ public Path getSpecPath() {
+ return specPath;
+ }
+
+ public Path getExpectedPath() {
+ return expectedPath;
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptfetch/TypeScriptFetchClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
similarity index 96%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptfetch/TypeScriptFetchClientOptionsTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
index 09f16799ad9..c2744cc8258 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptfetch/TypeScriptFetchClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptfetch;
+package io.swagger.codegen.typescript.fetch;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptfetch/TypeScriptFetchModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/fetch/TypeScriptFetchModelTest.java
similarity index 96%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptfetch/TypeScriptFetchModelTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/fetch/TypeScriptFetchModelTest.java
index d2173fdb710..d1b0a4be233 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptfetch/TypeScriptFetchModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/fetch/TypeScriptFetchModelTest.java
@@ -1,6 +1,10 @@
-package io.swagger.codegen.typescriptfetch;
+package io.swagger.codegen.typescript.fetch;
import com.google.common.collect.Sets;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.DefaultCodegen;
@@ -8,9 +12,11 @@ import io.swagger.codegen.languages.TypeScriptFetchClientCodegen;
import io.swagger.models.ArrayModel;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
-import io.swagger.models.properties.*;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.DateTimeProperty;
+import io.swagger.models.properties.LongProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
@SuppressWarnings("static-method")
public class TypeScriptFetchModelTest {
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
similarity index 95%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
index 70cfb3d250d..2a68ab37110 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptangular;
+package io.swagger.codegen.typescript.typescriptangular;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular/TypeScriptAngularModelTest.java
similarity index 99%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular/TypeScriptAngularModelTest.java
index 26e8f841be9..75ab210966d 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular/TypeScriptAngularModelTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptangular;
+package io.swagger.codegen.typescript.typescriptangular;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java
similarity index 95%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java
index 74e575c4496..73ace65a207 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptangular2;
+package io.swagger.codegen.typescript.typescriptangular2;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ModelTest.java
similarity index 98%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ModelTest.java
index 3aa33df7da4..685495f03c2 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ModelTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptangular2;
+package io.swagger.codegen.typescript.typescriptangular2;
import com.google.common.collect.Sets;
@@ -178,6 +178,7 @@ public class TypeScriptAngular2ModelTest {
Assert.assertEquals(cm.description, "a map model");
Assert.assertEquals(cm.vars.size(), 0);
Assert.assertEquals(cm.imports.size(), 1);
+ Assert.assertEquals(cm.additionalPropertiesType, "models.Children");
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("models.Children")).size(), 1);
}
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypescriptAngular2AdditionalPropertiesIntegrationTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypescriptAngular2AdditionalPropertiesIntegrationTest.java
new file mode 100644
index 00000000000..8b23105f28c
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypescriptAngular2AdditionalPropertiesIntegrationTest.java
@@ -0,0 +1,32 @@
+package io.swagger.codegen.typescript.typescriptangular2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.swagger.codegen.AbstractIntegrationTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
+import io.swagger.codegen.testutils.IntegrationTestPathsConfig;
+
+public class TypescriptAngular2AdditionalPropertiesIntegrationTest extends AbstractIntegrationTest {
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return new TypeScriptAngular2ClientCodegen();
+ }
+
+ @Override
+ protected Map configProperties() {
+ Map propeties = new HashMap<>();
+ propeties.put("npmName", "additionalPropertiesTest");
+ propeties.put("npmVersion", "1.0.2");
+ propeties.put("snapshot", "false");
+
+ return propeties;
+ }
+
+ @Override
+ protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
+ return new IntegrationTestPathsConfig("typescript/additional-properties");
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypescriptAngular2ArrayAndObjectTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypescriptAngular2ArrayAndObjectTest.java
new file mode 100644
index 00000000000..b9a8868a6b8
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypescriptAngular2ArrayAndObjectTest.java
@@ -0,0 +1,32 @@
+package io.swagger.codegen.typescript.typescriptangular2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.swagger.codegen.AbstractIntegrationTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
+import io.swagger.codegen.testutils.IntegrationTestPathsConfig;
+
+public class TypescriptAngular2ArrayAndObjectTest extends AbstractIntegrationTest {
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return new TypeScriptAngular2ClientCodegen();
+ }
+
+ @Override
+ protected Map configProperties() {
+ Map propeties = new HashMap<>();
+ propeties.put("npmName", "arrayAndAnyTest");
+ propeties.put("npmVersion", "1.0.2");
+ propeties.put("snapshot", "false");
+
+ return propeties;
+ }
+
+ @Override
+ protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
+ return new IntegrationTestPathsConfig("typescript/array-and-object");
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
similarity index 95%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
index 72b55b0b39d..4872e1d419d 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptnode;
+package io.swagger.codegen.typescript.typescriptnode;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypeScriptNodeModelTest.java
similarity index 99%
rename from modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java
rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypeScriptNodeModelTest.java
index 81a67e87b87..37e4fb688e0 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypeScriptNodeModelTest.java
@@ -1,4 +1,4 @@
-package io.swagger.codegen.typescriptnode;
+package io.swagger.codegen.typescript.typescriptnode;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypescriptNodeES5IntegrationTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypescriptNodeES5IntegrationTest.java
new file mode 100644
index 00000000000..22bac4ea316
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptnode/TypescriptNodeES5IntegrationTest.java
@@ -0,0 +1,33 @@
+package io.swagger.codegen.typescript.typescriptnode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.swagger.codegen.AbstractIntegrationTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.languages.TypeScriptNodeClientCodegen;
+import io.swagger.codegen.testutils.IntegrationTestPathsConfig;
+
+public class TypescriptNodeES5IntegrationTest extends AbstractIntegrationTest {
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return new TypeScriptNodeClientCodegen();
+ }
+
+ @Override
+ protected Map configProperties() {
+ Map propeties = new HashMap<>();
+ propeties.put("npmName", "node-es6-test");
+ propeties.put("npmVersion", "1.0.3");
+ propeties.put("snapshot", "false");
+ propeties.put("supportsES6", "false");
+
+ return propeties;
+ }
+
+ @Override
+ protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
+ return new IntegrationTestPathsConfig("typescript/node-es5");
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
index b9fa750d38a..cb710b32566 100644
--- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -575,9 +575,12 @@ paths:
偽のエンドポイント
가짜 엔드 포인트
operationId: testEndpointParameters
+ consumes:
+ - application/xml; charset=utf-8
+ - application/json; charset=utf-8
produces:
- - application/xml
- - application/json
+ - application/xml; charset=utf-8
+ - application/json; charset=utf-8
parameters:
- name: integer
type: integer
@@ -944,6 +947,30 @@ definitions:
enum:
- 1.1
- -1.2
+ AdditionalPropertiesClass:
+ type: object
+ additionalProperties:
+ type: string
+ MixedPropertiesAndAdditionalPropertiesClass:
+ type: object
+ properties:
+ uuid:
+ type: string
+ format: uuid
+ dateTime:
+ type: string
+ format: date-time
+ additionalProperties:
+ type: string
+ $ref: '#/definitions/Animal'
+ ReadOnlyFirst:
+ type: object
+ properties:
+ bar:
+ type: string
+ readOnly: true
+ baz:
+ type: string
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/.swagger-codegen-ignore b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/.swagger-codegen-ignore
new file mode 100644
index 00000000000..19d3377182e
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/.swagger-codegen-ignore
@@ -0,0 +1,23 @@
+# Swagger Codegen Ignore
+# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/README.md b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/README.md
new file mode 100644
index 00000000000..b5338574869
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/README.md
@@ -0,0 +1,33 @@
+## additionalPropertiesTest@1.0.2
+
+### Building
+
+To build an compile the typescript sources to javascript use:
+```
+npm install
+npm run build
+```
+
+### publishing
+
+First build the package than run ```npm publish```
+
+### consuming
+
+navigate to the folder of your consuming project and run one of next commando's.
+
+_published:_
+
+```
+npm install additionalPropertiesTest@1.0.2 --save
+```
+
+_unPublished (not recommended):_
+
+```
+npm install PATH_TO_GENERATED_PACKAGE --save
+```
+
+In your angular2 project:
+
+TODO: paste example.
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/api/UserApi.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/api/UserApi.ts
new file mode 100644
index 00000000000..77b6c013a8b
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/api/UserApi.ts
@@ -0,0 +1,64 @@
+import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
+import {Injectable, Optional} from '@angular/core';
+import {Observable} from 'rxjs/Observable';
+import * as models from '../model/models';
+import 'rxjs/Rx';
+
+/* tslint:disable:no-unused-variable member-ordering */
+
+'use strict';
+
+@Injectable()
+export class UserApi {
+ protected basePath = 'http://additional-properties.swagger.io/v2';
+ public defaultHeaders : Headers = new Headers();
+
+ constructor(protected http: Http, @Optional() basePath: string) {
+ if (basePath) {
+ this.basePath = basePath;
+ }
+ }
+
+ /**
+ * Add a new User to the store
+ *
+ * @param body User object that needs to be added to the store
+ */
+ public addUser (body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> {
+ const path = this.basePath + '/user';
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ let requestOptions: RequestOptionsArgs = {
+ method: 'POST',
+ headers: headerParams,
+ search: queryParameters
+ };
+ requestOptions.body = JSON.stringify(body);
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+ /**
+ * Update an existing User
+ *
+ * @param body User object that needs to be added to the store
+ */
+ public updateUser (body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> {
+ const path = this.basePath + '/user';
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ let requestOptions: RequestOptionsArgs = {
+ method: 'PUT',
+ headers: headerParams,
+ search: queryParameters
+ };
+ requestOptions.body = JSON.stringify(body);
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/api/api.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/api/api.ts
new file mode 100644
index 00000000000..d3bd8432806
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/api/api.ts
@@ -0,0 +1 @@
+export * from './UserApi';
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/index.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/index.ts
new file mode 100644
index 00000000000..cdfea183ad3
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/index.ts
@@ -0,0 +1,2 @@
+export * from './api/api';
+export * from './model/models';
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/model/User.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/model/User.ts
new file mode 100644
index 00000000000..66f270cea01
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/model/User.ts
@@ -0,0 +1,13 @@
+'use strict';
+import * as models from './models';
+
+export interface User {
+ [key: string]: string | any;
+
+ id?: number;
+
+ /**
+ * User Status
+ */
+ userStatus?: number;
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/model/models.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/model/models.ts
new file mode 100644
index 00000000000..f6b9f36c6e1
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/model/models.ts
@@ -0,0 +1 @@
+export * from './User';
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/package.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/package.json
new file mode 100644
index 00000000000..36ec153321d
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "additionalPropertiesTest",
+ "version": "1.0.2",
+ "description": "swagger client for additionalPropertiesTest",
+ "author": "Swagger Codegen Contributors",
+ "keywords": [
+ "swagger-client"
+ ],
+ "license": "MIT",
+ "files": [
+ "lib"
+ ],
+ "main": "./lib/index.js",
+ "typings": "./lib/index.d.ts",
+ "scripts": {
+ "build": "typings install && tsc"
+ },
+ "peerDependencies": {
+ "@angular/core": "^2.0.0-rc.1",
+ "@angular/http": "^2.0.0-rc.1"
+ },
+ "devDependencies": {
+ "@angular/common": "^2.0.0-rc.1",
+ "@angular/compiler": "^2.0.0-rc.1",
+ "@angular/core": "^2.0.0-rc.1",
+ "@angular/http": "^2.0.0-rc.1",
+ "@angular/platform-browser": "^2.0.0-rc.1",
+ "@angular/platform-browser-dynamic": "^2.0.0-rc.1",
+ "core-js": "^2.3.0",
+ "rxjs": "^5.0.0-beta.6",
+ "zone.js": "^0.6.12",
+ "typescript": "^1.8.10",
+ "typings": "^0.8.1",
+ "es6-shim": "^0.35.0",
+ "es7-reflect-metadata": "^1.6.0"
+ }}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json
new file mode 100644
index 00000000000..07fbdf7e1b1
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json
@@ -0,0 +1,27 @@
+{
+ "compilerOptions": {
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "noImplicitAny": false,
+ "suppressImplicitAnyIndexErrors": true,
+ "target": "es5",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "removeComments": true,
+ "sourceMap": true,
+ "outDir": "./lib",
+ "noLib": false,
+ "declaration": true
+ },
+ "exclude": [
+ "node_modules",
+ "typings/main.d.ts",
+ "typings/main",
+ "lib"
+ ],
+ "filesGlob": [
+ "./model/*.ts",
+ "./api/*.ts",
+ "typings/browser.d.ts"
+ ]
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/typings.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/typings.json
new file mode 100644
index 00000000000..0848dcffe31
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-expected/typings.json
@@ -0,0 +1,5 @@
+{
+ "ambientDependencies": {
+ "core-js": "registry:dt/core-js#0.0.0+20160317120654"
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-spec.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-spec.json
new file mode 100644
index 00000000000..3a06b88986c
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/additional-properties-spec.json
@@ -0,0 +1,110 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "description": "This is a test spec",
+ "version": "1.0.0",
+ "title": "Swagger Additional Properties",
+ "termsOfService": "http://swagger.io/terms/",
+ "contact": {
+ "email": "apiteam@swagger.io"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "host": "additional-properties.swagger.io",
+ "basePath": "/v2",
+ "schemes": [
+ "http"
+ ],
+ "paths": {
+ "/user": {
+ "post": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Add a new User to the store",
+ "description": "",
+ "operationId": "addUser",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "User object that needs to be added to the store",
+ "required": false,
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ }
+ },
+ "put": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Update an existing User",
+ "description": "",
+ "operationId": "updateUser",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "User object that needs to be added to the store",
+ "required": false,
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Validation exception"
+ },
+ "404": {
+ "description": "User not found"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "User": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "userStatus": {
+ "type": "integer",
+ "format": "int32",
+ "description": "User Status"
+ }
+ },
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/.swagger-codegen-ignore b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/.swagger-codegen-ignore
new file mode 100644
index 00000000000..19d3377182e
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/.swagger-codegen-ignore
@@ -0,0 +1,23 @@
+# Swagger Codegen Ignore
+# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/README.md b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/README.md
new file mode 100644
index 00000000000..85e98e0f9d9
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/README.md
@@ -0,0 +1,33 @@
+## arrayAndAnyTest@1.0.2
+
+### Building
+
+To build an compile the typescript sources to javascript use:
+```
+npm install
+npm run build
+```
+
+### publishing
+
+First build the package than run ```npm publish```
+
+### consuming
+
+navigate to the folder of your consuming project and run one of next commando's.
+
+_published:_
+
+```
+npm install arrayAndAnyTest@1.0.2 --save
+```
+
+_unPublished (not recommended):_
+
+```
+npm install PATH_TO_GENERATED_PACKAGE --save
+```
+
+In your angular2 project:
+
+TODO: paste example.
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/api/ProjectApi.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/api/ProjectApi.ts
new file mode 100644
index 00000000000..dbcdbe5fb7a
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/api/ProjectApi.ts
@@ -0,0 +1,218 @@
+import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
+import {Injectable, Optional} from '@angular/core';
+import {Observable} from 'rxjs/Observable';
+import * as models from '../model/models';
+import 'rxjs/Rx';
+
+/* tslint:disable:no-unused-variable member-ordering */
+
+'use strict';
+
+@Injectable()
+export class ProjectApi {
+ protected basePath = 'https://localhost/v1';
+ public defaultHeaders : Headers = new Headers();
+
+ constructor(protected http: Http, @Optional() basePath: string) {
+ if (basePath) {
+ this.basePath = basePath;
+ }
+ }
+
+ /**
+ * Create a Project
+ * Creates an empty Project
+ * @param name
+ * @param address
+ * @param longitude
+ * @param latitude
+ * @param meta
+ */
+ public createProject (name?: string, address?: string, longitude?: number, latitude?: number, meta?: string, extraHttpRequestParams?: any ) : Observable {
+ const path = this.basePath + '/projects';
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ let formParams = new URLSearchParams();
+
+ headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
+
+ formParams['name'] = name;
+
+ formParams['address'] = address;
+
+ formParams['longitude'] = longitude;
+
+ formParams['latitude'] = latitude;
+
+ formParams['meta'] = meta;
+
+ let requestOptions: RequestOptionsArgs = {
+ method: 'POST',
+ headers: headerParams,
+ search: queryParameters
+ };
+ requestOptions.body = formParams.toString();
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+ /**
+ * Delete a Project
+ * Returns a Project JSON object
+ * @param id Project id
+ */
+ public deleteProjectById (id: number, extraHttpRequestParams?: any ) : Observable<{}> {
+ const path = this.basePath + '/projects/{id}'
+ .replace('{' + 'id' + '}', String(id));
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ // verify required parameter 'id' is set
+ if (!id) {
+ throw new Error('Missing required parameter id when calling deleteProjectById');
+ }
+ let requestOptions: RequestOptionsArgs = {
+ method: 'DELETE',
+ headers: headerParams,
+ search: queryParameters
+ };
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+ /**
+ * Get a Project
+ * Returns a Project JSON object
+ * @param id Project id
+ */
+ public getProjectById (id: number, extraHttpRequestParams?: any ) : Observable {
+ const path = this.basePath + '/projects/{id}'
+ .replace('{' + 'id' + '}', String(id));
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ // verify required parameter 'id' is set
+ if (!id) {
+ throw new Error('Missing required parameter id when calling getProjectById');
+ }
+ let requestOptions: RequestOptionsArgs = {
+ method: 'GET',
+ headers: headerParams,
+ search: queryParameters
+ };
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+ /**
+ * Get project list
+ * Returns a Project JSON object
+ * @param page
+ * @param perPage
+ * @param kind
+ * @param q
+ * @param filter
+ * @param latitude Valid with kind as location
+ * @param longitude Valid with kind as location
+ * @param scope Valid with kind as location, and between 1~9
+ */
+ public getProjectList (page?: number, perPage?: number, kind?: string, q?: string, filter?: string, latitude?: number, longitude?: number, scope?: number, extraHttpRequestParams?: any ) : Observable {
+ const path = this.basePath + '/projects';
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ if (page !== undefined) {
+ queryParameters['page'] = page;
+ }
+
+ if (perPage !== undefined) {
+ queryParameters['per_page'] = perPage;
+ }
+
+ if (kind !== undefined) {
+ queryParameters['kind'] = kind;
+ }
+
+ if (q !== undefined) {
+ queryParameters['q'] = q;
+ }
+
+ if (filter !== undefined) {
+ queryParameters['filter'] = filter;
+ }
+
+ if (latitude !== undefined) {
+ queryParameters['latitude'] = latitude;
+ }
+
+ if (longitude !== undefined) {
+ queryParameters['longitude'] = longitude;
+ }
+
+ if (scope !== undefined) {
+ queryParameters['scope'] = scope;
+ }
+
+ let requestOptions: RequestOptionsArgs = {
+ method: 'GET',
+ headers: headerParams,
+ search: queryParameters
+ };
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+ /**
+ * Update project
+ *
+ * @param id Project id
+ * @param name User ID
+ * @param address Address
+ * @param longitude
+ * @param latitude
+ * @param meta
+ * @param thumbnail Project thumbnail
+ */
+ public updateProject (id: number, name?: string, address?: string, longitude?: number, latitude?: number, meta?: string, thumbnail?: any, extraHttpRequestParams?: any ) : Observable {
+ const path = this.basePath + '/projects/{id}'
+ .replace('{' + 'id' + '}', String(id));
+
+ let queryParameters: any = ""; // This should probably be an object in the future
+ let headerParams = this.defaultHeaders;
+ let formParams = new URLSearchParams();
+
+ // verify required parameter 'id' is set
+ if (!id) {
+ throw new Error('Missing required parameter id when calling updateProject');
+ }
+ headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
+
+ formParams['name'] = name;
+
+ formParams['address'] = address;
+
+ formParams['longitude'] = longitude;
+
+ formParams['latitude'] = latitude;
+
+ formParams['meta'] = meta;
+
+ formParams['thumbnail'] = thumbnail;
+
+ let requestOptions: RequestOptionsArgs = {
+ method: 'PUT',
+ headers: headerParams,
+ search: queryParameters
+ };
+ requestOptions.body = formParams.toString();
+
+ return this.http.request(path, requestOptions)
+ .map((response: Response) => response.json());
+ }
+
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/api/api.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/api/api.ts
new file mode 100644
index 00000000000..d919ee6d629
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/api/api.ts
@@ -0,0 +1 @@
+export * from './ProjectApi';
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/index.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/index.ts
new file mode 100644
index 00000000000..557365516ad
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/index.ts
@@ -0,0 +1,2 @@
+export * from './api/api';
+export * from './model/models';
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectEntity.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectEntity.ts
new file mode 100644
index 00000000000..dc3bd6bdce9
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectEntity.ts
@@ -0,0 +1,32 @@
+'use strict';
+import * as models from './models';
+
+export interface ProjectEntity {
+
+
+ id?: number;
+
+ kind?: ProjectEntity.KindEnum;
+
+ thumbnailUrl?: string;
+
+ name?: string;
+
+ state?: string;
+
+ meta?: any;
+
+ location?: models.ProjectEntityLocation;
+
+ createdAt?: Date;
+
+ updatedAt?: Date;
+
+ publishedAt?: Date;
+}
+export namespace ProjectEntity {
+
+ export enum KindEnum {
+ project = 'project',
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectEntityLocation.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectEntityLocation.ts
new file mode 100644
index 00000000000..81fd66511a6
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectEntityLocation.ts
@@ -0,0 +1,10 @@
+'use strict';
+import * as models from './models';
+
+export interface ProjectEntityLocation {
+
+
+ lat?: number;
+
+ lon?: number;
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectList.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectList.ts
new file mode 100644
index 00000000000..a8a98e93a75
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/ProjectList.ts
@@ -0,0 +1,8 @@
+'use strict';
+import * as models from './models';
+
+export interface ProjectList {
+
+
+ contents?: Array;
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/models.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/models.ts
new file mode 100644
index 00000000000..b917c007157
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/model/models.ts
@@ -0,0 +1,3 @@
+export * from './ProjectEntity';
+export * from './ProjectEntityLocation';
+export * from './ProjectList';
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/package.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/package.json
new file mode 100644
index 00000000000..83a9a586ab9
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "arrayAndAnyTest",
+ "version": "1.0.2",
+ "description": "swagger client for arrayAndAnyTest",
+ "author": "Swagger Codegen Contributors",
+ "keywords": [
+ "swagger-client"
+ ],
+ "license": "MIT",
+ "files": [
+ "lib"
+ ],
+ "main": "./lib/index.js",
+ "typings": "./lib/index.d.ts",
+ "scripts": {
+ "build": "typings install && tsc"
+ },
+ "peerDependencies": {
+ "@angular/core": "^2.0.0-rc.1",
+ "@angular/http": "^2.0.0-rc.1"
+ },
+ "devDependencies": {
+ "@angular/common": "^2.0.0-rc.1",
+ "@angular/compiler": "^2.0.0-rc.1",
+ "@angular/core": "^2.0.0-rc.1",
+ "@angular/http": "^2.0.0-rc.1",
+ "@angular/platform-browser": "^2.0.0-rc.1",
+ "@angular/platform-browser-dynamic": "^2.0.0-rc.1",
+ "core-js": "^2.3.0",
+ "rxjs": "^5.0.0-beta.6",
+ "zone.js": "^0.6.12",
+ "typescript": "^1.8.10",
+ "typings": "^0.8.1",
+ "es6-shim": "^0.35.0",
+ "es7-reflect-metadata": "^1.6.0"
+ }}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json
new file mode 100644
index 00000000000..07fbdf7e1b1
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json
@@ -0,0 +1,27 @@
+{
+ "compilerOptions": {
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "noImplicitAny": false,
+ "suppressImplicitAnyIndexErrors": true,
+ "target": "es5",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "removeComments": true,
+ "sourceMap": true,
+ "outDir": "./lib",
+ "noLib": false,
+ "declaration": true
+ },
+ "exclude": [
+ "node_modules",
+ "typings/main.d.ts",
+ "typings/main",
+ "lib"
+ ],
+ "filesGlob": [
+ "./model/*.ts",
+ "./api/*.ts",
+ "typings/browser.d.ts"
+ ]
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/typings.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/typings.json
new file mode 100644
index 00000000000..0848dcffe31
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-expected/typings.json
@@ -0,0 +1,5 @@
+{
+ "ambientDependencies": {
+ "core-js": "registry:dt/core-js#0.0.0+20160317120654"
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-spec.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-spec.json
new file mode 100644
index 00000000000..366cbb9cb39
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/array-and-object-spec.json
@@ -0,0 +1,570 @@
+{
+ "swagger": "2.0",
+ "info":
+ {
+ "version": "1.7.0",
+ "title": "Cupix API",
+ "contact":
+ {
+ "name": "inska.lee@cupix.com"
+ }
+ },
+ "basePath": "/v1",
+ "consumes":
+ [
+ "application/json"
+ ],
+ "produces":
+ [
+ "application/json"
+ ],
+ "schemes":
+ [
+ "https"
+ ],
+ "paths":
+ {
+ "/projects":
+ {
+ "post":
+ {
+ "tags":
+ [
+ "Project"
+ ],
+ "summary": "Create a Project",
+ "operationId": "create_project",
+ "description": "Creates an empty Project",
+ "consumes":
+ [
+ "application/x-www-form-urlencoded"
+ ],
+ "produces":
+ [
+ "application/json"
+ ],
+ "parameters":
+ [
+
+ {
+ "name": "name",
+ "type": "string",
+ "in": "formData"
+ },
+
+ {
+ "name": "address",
+ "type": "string",
+ "in": "formData"
+ },
+
+ {
+ "name": "longitude",
+ "type": "number",
+ "format": "float",
+ "in": "formData"
+ },
+
+ {
+ "name": "latitude",
+ "type": "number",
+ "format": "float",
+ "in": "formData"
+ },
+
+ {
+ "name": "meta",
+ "type": "string",
+ "in": "formData"
+ }
+ ],
+ "responses":
+ {
+ "200":
+ {
+ "description": "Project information",
+ "schema":
+ {
+ "$ref": "#/definitions/ProjectEntity"
+ }
+ },
+ "400":
+ {
+ "description": "Bad Request",
+ "schema":
+ {
+ "$ref": "#/definitions/Error"
+ }
+ },
+ "401":
+ {
+ "description": "Unauthorized request"
+ },
+ "403":
+ {
+ "description": "Forbidden"
+ },
+ "404":
+ {
+ "description": "Project not found"
+ }
+ }
+ },
+ "get":
+ {
+ "tags":
+ [
+ "Project"
+ ],
+ "summary": "Get project list",
+ "operationId": "get_project_list",
+ "description": "Returns a Project JSON object",
+ "produces":
+ [
+ "application/json"
+ ],
+ "security":
+ [
+
+ {
+ "key":
+ [
+
+ ]
+ },
+
+ {
+ "token":
+ [
+
+ ]
+ }
+ ],
+ "parameters":
+ [
+
+ {
+ "name": "page",
+ "type": "integer",
+ "format": "int32",
+ "in": "query"
+ },
+
+ {
+ "name": "per_page",
+ "type": "integer",
+ "format": "int32",
+ "in": "query"
+ },
+
+ {
+ "name": "kind",
+ "type": "string",
+ "in": "query",
+ "enum":
+ [
+ "my_models",
+ "published",
+ "location"
+ ]
+ },
+
+ {
+ "name": "q",
+ "type": "string",
+ "in": "query"
+ },
+
+ {
+ "name": "filter",
+ "type": "string",
+ "in": "query"
+ },
+
+ {
+ "name": "latitude",
+ "in": "query",
+ "type": "number",
+ "format": "float",
+ "description": "Valid with kind as location"
+ },
+
+ {
+ "name": "longitude",
+ "in": "query",
+ "type": "number",
+ "format": "float",
+ "description": "Valid with kind as location"
+ },
+
+ {
+ "name": "scope",
+ "in": "query",
+ "type": "integer",
+ "description": "Valid with kind as location, and between 1~9"
+ }
+ ],
+ "responses":
+ {
+ "200":
+ {
+ "description": "Project list",
+ "schema":
+ {
+ "$ref": "#/definitions/ProjectList"
+ }
+ },
+ "400":
+ {
+ "description": "Bad Request",
+ "schema":
+ {
+ "$ref": "#/definitions/Error"
+ }
+ },
+ "401":
+ {
+ "description": "Unauthorized request"
+ },
+ "403":
+ {
+ "description": "Forbidden"
+ },
+ "404":
+ {
+ "description": "Project not found"
+ }
+ }
+ }
+ },
+ "/projects/{id}":
+ {
+ "get":
+ {
+ "tags":
+ [
+ "Project"
+ ],
+ "summary": "Get a Project",
+ "operationId": "get_project_by_id",
+ "description": "Returns a Project JSON object",
+ "produces":
+ [
+ "application/json"
+ ],
+ "parameters":
+ [
+
+ {
+ "name": "id",
+ "in": "path",
+ "description": "Project id",
+ "required": true,
+ "type": "integer",
+ "format": "int32"
+ }
+ ],
+ "responses":
+ {
+ "200":
+ {
+ "description": "Project information",
+ "schema":
+ {
+ "$ref": "#/definitions/ProjectEntity"
+ }
+ },
+ "400":
+ {
+ "description": "Bad Request",
+ "schema":
+ {
+ "$ref": "#/definitions/Error"
+ }
+ },
+ "401":
+ {
+ "description": "Unauthorized request"
+ },
+ "403":
+ {
+ "description": "Forbidden"
+ },
+ "404":
+ {
+ "description": "Project not found"
+ }
+ }
+ },
+ "put":
+ {
+ "tags":
+ [
+ "Project"
+ ],
+ "summary": "Update project",
+ "operationId": "update_project",
+ "consumes":
+ [
+ "multipart/form-data"
+ ],
+ "produces":
+ [
+ "application/json"
+ ],
+ "parameters":
+ [
+
+ {
+ "name": "id",
+ "in": "path",
+ "description": "Project id",
+ "required": true,
+ "type": "integer",
+ "format": "int32"
+ },
+
+ {
+ "name": "name",
+ "in": "formData",
+ "description": "User ID",
+ "type": "string"
+ },
+
+ {
+ "name": "address",
+ "in": "formData",
+ "description": "Address",
+ "type": "string"
+ },
+
+ {
+ "name": "longitude",
+ "type": "number",
+ "format": "float",
+ "in": "formData"
+ },
+
+ {
+ "name": "latitude",
+ "type": "number",
+ "format": "float",
+ "in": "formData"
+ },
+
+ {
+ "name": "meta",
+ "type": "string",
+ "in": "formData"
+ },
+
+ {
+ "name": "thumbnail",
+ "in": "formData",
+ "description": "Project thumbnail",
+ "type": "file"
+ }
+ ],
+ "responses":
+ {
+ "200":
+ {
+ "description": "Project information",
+ "schema":
+ {
+ "$ref": "#/definitions/ProjectEntity"
+ }
+ },
+ "400":
+ {
+ "description": "Bad Request",
+ "schema":
+ {
+ "$ref": "#/definitions/Error"
+ }
+ },
+ "401":
+ {
+ "description": "Unauthorized request"
+ },
+ "403":
+ {
+ "description": "Forbidden"
+ },
+ "404":
+ {
+ "description": "Project not found"
+ }
+ }
+ },
+ "delete":
+ {
+ "tags":
+ [
+ "Project"
+ ],
+ "summary": "Delete a Project",
+ "operationId": "delete_project_by_id",
+ "description": "Returns a Project JSON object",
+ "produces":
+ [
+ "application/json"
+ ],
+ "parameters":
+ [
+
+ {
+ "name": "id",
+ "in": "path",
+ "description": "Project id",
+ "required": true,
+ "type": "integer",
+ "format": "int32"
+ }
+ ],
+ "security":
+ [
+
+ {
+ "key":
+ [
+
+ ]
+ },
+
+ {
+ "token":
+ [
+
+ ]
+ }
+ ],
+ "responses":
+ {
+ "200":
+ {
+ "description": "Empty"
+ },
+ "204":
+ {
+ "description": "Deleted"
+ },
+ "400":
+ {
+ "description": "Bad Request",
+ "schema":
+ {
+ "$ref": "#/definitions/Error"
+ }
+ },
+ "401":
+ {
+ "description": "Unauthorized request"
+ },
+ "403":
+ {
+ "description": "Forbidden"
+ },
+ "404":
+ {
+ "description": "Project not found"
+ }
+ }
+ }
+ }
+ },
+ "definitions":
+ {
+ "ProjectList":
+ {
+ "type": "object",
+ "required":
+ [
+ "contents"
+ ],
+ "properties":
+ {
+ "contents":
+ {
+ "type": "array",
+ "items":
+ {
+ "$ref": "#/definitions/ProjectEntity"
+ }
+ }
+ }
+ },
+ "ProjectEntity":
+ {
+ "type": "object",
+ "required":
+ [
+ "id"
+ ],
+ "properties":
+ {
+ "id":
+ {
+ "type": "integer",
+ "format": "int32"
+ },
+ "kind":
+ {
+ "type": "string",
+ "enum":
+ [
+ "project"
+ ]
+ },
+ "thumbnail_url":
+ {
+ "type": "string"
+ },
+ "name":
+ {
+ "type": "string"
+ },
+ "state":
+ {
+ "type": "string"
+ },
+ "meta":
+ {
+ "type": "object"
+ },
+ "location":
+ {
+ "type": "object",
+ "properties":
+ {
+ "lat":
+ {
+ "type": "number",
+ "format": "float"
+ },
+ "lon":
+ {
+ "type": "number",
+ "format": "float"
+ }
+ }
+ },
+ "created_at":
+ {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updated_at":
+ {
+ "type": "string",
+ "format": "date-time"
+ },
+ "published_at":
+ {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/.swagger-codegen-ignore b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/.swagger-codegen-ignore
new file mode 100644
index 00000000000..19d3377182e
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/.swagger-codegen-ignore
@@ -0,0 +1,23 @@
+# Swagger Codegen Ignore
+# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/api.ts b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/api.ts
new file mode 100644
index 00000000000..6a1cfed4d79
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/api.ts
@@ -0,0 +1,594 @@
+import request = require('request');
+import http = require('http');
+import Promise = require('bluebird');
+
+let defaultBasePath = 'http://petstore.swagger.io/v1';
+
+// ===============================================
+// This file is autogenerated - Please do not edit
+// ===============================================
+
+/* tslint:disable:no-unused-variable */
+
+export class Category {
+ 'id': number;
+ 'name': string;
+}
+
+export class Pet {
+ 'id': number;
+ 'category': Category;
+ 'name': string;
+}
+
+
+export interface Authentication {
+ /**
+ * Apply authentication settings to header and query params.
+ */
+ applyToRequest(requestOptions: request.Options): void;
+}
+
+export class HttpBasicAuth implements Authentication {
+ public username: string;
+ public password: string;
+ applyToRequest(requestOptions: request.Options): void {
+ requestOptions.auth = {
+ username: this.username, password: this.password
+ }
+ }
+}
+
+export class ApiKeyAuth implements Authentication {
+ public apiKey: string;
+
+ constructor(private location: string, private paramName: string) {
+ }
+
+ applyToRequest(requestOptions: request.Options): void {
+ if (this.location == "query") {
+ (requestOptions.qs)[this.paramName] = this.apiKey;
+ } else if (this.location == "header") {
+ requestOptions.headers[this.paramName] = this.apiKey;
+ }
+ }
+}
+
+export class OAuth implements Authentication {
+ public accessToken: string;
+
+ applyToRequest(requestOptions: request.Options): void {
+ requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
+ }
+}
+
+export class VoidAuth implements Authentication {
+ public username: string;
+ public password: string;
+ applyToRequest(requestOptions: request.Options): void {
+ // Do nothing
+ }
+}
+
+export enum PetApiApiKeys {
+}
+
+export class PetApi {
+ protected basePath = defaultBasePath;
+ protected defaultHeaders : any = {};
+
+ protected authentications = {
+ 'default': new VoidAuth(),
+ }
+
+ constructor(basePath?: string);
+ constructor(basePathOrUsername: string, password?: string, basePath?: string) {
+ if (password) {
+ if (basePath) {
+ this.basePath = basePath;
+ }
+ } else {
+ if (basePathOrUsername) {
+ this.basePath = basePathOrUsername
+ }
+ }
+ }
+
+ public setApiKey(key: PetApiApiKeys, value: string) {
+ this.authentications[PetApiApiKeys[key]].apiKey = value;
+ }
+ private extendObj(objA: T1, objB: T2) {
+ for(let key in objB){
+ if(objB.hasOwnProperty(key)){
+ objA[key] = objB[key];
+ }
+ }
+ return objA;
+ }
+ /**
+ * Add a new pet to the store
+ *
+ * @param body Pet object that needs to be added to the store
+ */
+ public addPet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
+ const localVarPath = this.basePath + '/pet';
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'POST',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ body: body,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Deletes a pet
+ *
+ * @param petId Pet id to delete
+ * @param apiKey
+ */
+ public deletePet (petId: number, apiKey?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
+ const localVarPath = this.basePath + '/pet/{petId}'
+ .replace('{' + 'petId' + '}', String(petId));
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ // verify required parameter 'petId' is not null or undefined
+ if (petId === null || petId === undefined) {
+ throw new Error('Required parameter petId was null or undefined when calling deletePet.');
+ }
+
+ headerParams['api_key'] = apiKey;
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'DELETE',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Find pet by ID
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param petId ID of pet that needs to be fetched
+ */
+ public getPetById (petId: number) : Promise<{ response: http.ClientResponse; body: Pet; }> {
+ const localVarPath = this.basePath + '/pet/{petId}'
+ .replace('{' + 'petId' + '}', String(petId));
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ // verify required parameter 'petId' is not null or undefined
+ if (petId === null || petId === undefined) {
+ throw new Error('Required parameter petId was null or undefined when calling getPetById.');
+ }
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'GET',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body: Pet; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Update an existing pet
+ *
+ * @param body Pet object that needs to be added to the store
+ */
+ public updatePet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
+ const localVarPath = this.basePath + '/pet';
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'PUT',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ body: body,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Updates a pet in the store with form data
+ *
+ * @param petId ID of pet that needs to be updated
+ * @param name Updated name of the pet
+ * @param status Updated status of the pet
+ */
+ public updatePetWithForm (petId: string, name?: string, status?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
+ const localVarPath = this.basePath + '/pet/{petId}'
+ .replace('{' + 'petId' + '}', String(petId));
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ // verify required parameter 'petId' is not null or undefined
+ if (petId === null || petId === undefined) {
+ throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
+ }
+
+ let useFormData = false;
+
+ if (name !== undefined) {
+ formParams['name'] = name;
+ }
+
+ if (status !== undefined) {
+ formParams['status'] = status;
+ }
+
+ let requestOptions: request.Options = {
+ method: 'POST',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+}
+export enum StoreApiApiKeys {
+}
+
+export class StoreApi {
+ protected basePath = defaultBasePath;
+ protected defaultHeaders : any = {};
+
+ protected authentications = {
+ 'default': new VoidAuth(),
+ }
+
+ constructor(basePath?: string);
+ constructor(basePathOrUsername: string, password?: string, basePath?: string) {
+ if (password) {
+ if (basePath) {
+ this.basePath = basePath;
+ }
+ } else {
+ if (basePathOrUsername) {
+ this.basePath = basePathOrUsername
+ }
+ }
+ }
+
+ public setApiKey(key: StoreApiApiKeys, value: string) {
+ this.authentications[StoreApiApiKeys[key]].apiKey = value;
+ }
+ private extendObj(objA: T1, objB: T2) {
+ for(let key in objB){
+ if(objB.hasOwnProperty(key)){
+ objA[key] = objB[key];
+ }
+ }
+ return objA;
+ }
+ /**
+ * Delete purchase order by ID
+ * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ * @param orderId ID of the order that needs to be deleted
+ */
+ public deleteOrder (orderId: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
+ const localVarPath = this.basePath + '/store/order/{orderId}'
+ .replace('{' + 'orderId' + '}', String(orderId));
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ // verify required parameter 'orderId' is not null or undefined
+ if (orderId === null || orderId === undefined) {
+ throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
+ }
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'DELETE',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Returns pet inventories by status
+ * Returns a map of status codes to quantities
+ */
+ public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> {
+ const localVarPath = this.basePath + '/store/inventory';
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'GET',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Find purchase order by ID
+ * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ * @param orderId ID of pet that needs to be fetched
+ */
+ public getOrderById (orderId: string) : Promise<{ response: http.ClientResponse; body: Order; }> {
+ const localVarPath = this.basePath + '/store/order/{orderId}'
+ .replace('{' + 'orderId' + '}', String(orderId));
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ // verify required parameter 'orderId' is not null or undefined
+ if (orderId === null || orderId === undefined) {
+ throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
+ }
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'GET',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body: Order; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+ /**
+ * Place an order for a pet
+ *
+ * @param body order placed for purchasing the pet
+ */
+ public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> {
+ const localVarPath = this.basePath + '/store/order';
+ let queryParameters: any = {};
+ let headerParams: any = this.extendObj({}, this.defaultHeaders);
+ let formParams: any = {};
+
+
+ let useFormData = false;
+
+ let requestOptions: request.Options = {
+ method: 'POST',
+ qs: queryParameters,
+ headers: headerParams,
+ uri: localVarPath,
+ json: true,
+ body: body,
+ };
+
+ this.authentications.default.applyToRequest(requestOptions);
+
+ if (Object.keys(formParams).length) {
+ if (useFormData) {
+ (requestOptions).formData = formParams;
+ } else {
+ requestOptions.form = formParams;
+ }
+ }
+ return new Promise<{ response: http.ClientResponse; body: Order; }>((resolve, reject) => {
+ request(requestOptions, (error, response, body) => {
+ if (error) {
+ reject(error);
+ } else {
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
+ resolve({ response: response, body: body });
+ } else {
+ reject({ response: response, body: body });
+ }
+ }
+ });
+ });
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh
new file mode 100644
index 00000000000..6ca091b49d9
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
+#
+# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
+
+git_user_id=$1
+git_repo_id=$2
+release_note=$3
+
+if [ "$git_user_id" = "" ]; then
+ git_user_id=""
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
+fi
+
+if [ "$git_repo_id" = "" ]; then
+ git_repo_id=""
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
+fi
+
+if [ "$release_note" = "" ]; then
+ release_note=""
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
+fi
+
+# Initialize the local directory as a Git repository
+git init
+
+# Adds the files in the local repository and stages them for commit.
+git add .
+
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
+git commit -m "$release_note"
+
+# Sets the new remote
+git_remote=`git remote`
+if [ "$git_remote" = "" ]; then # git remote not defined
+
+ if [ "$GIT_TOKEN" = "" ]; then
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ else
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ fi
+
+fi
+
+git pull origin master
+
+# Pushes (Forces) the changes in the local repository up to the remote repository
+echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+git push origin master 2>&1 | grep -v 'To https'
+
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/package.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/package.json
new file mode 100644
index 00000000000..960338ff787
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "node-es6-test",
+ "version": "1.0.3",
+ "description": "NodeJS client for node-es6-test",
+ "main": "api.js",
+ "scripts": {
+ "build": "typings install && tsc"
+ },
+ "author": "Swagger Codegen Contributors",
+ "license": "MIT",
+ "dependencies": {
+ "bluebird": "^3.3.5",
+ "request": "^2.72.0"
+ },
+ "devDependencies": {
+ "typescript": "^1.8.10",
+ "typings": "^0.8.1"
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json
new file mode 100644
index 00000000000..2dd166566e9
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "noImplicitAny": false,
+ "suppressImplicitAnyIndexErrors": true,
+ "target": "ES5",
+ "moduleResolution": "node",
+ "removeComments": true,
+ "sourceMap": true,
+ "noLib": false,
+ "declaration": true
+ },
+ "files": [
+ "api.ts",
+ "typings/main.d.ts"
+ ]
+}
+
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/typings.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/typings.json
new file mode 100644
index 00000000000..76c4cc8e6af
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-expected/typings.json
@@ -0,0 +1,10 @@
+{
+ "ambientDependencies": {
+ "bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
+ "core-js": "registry:dt/core-js#0.0.0+20160317120654",
+ "node": "registry:dt/node#4.0.0+20160423143914"
+ },
+ "dependencies": {
+ "request": "registry:npm/request#2.69.0+20160304121250"
+ }
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-spec.json b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-spec.json
new file mode 100644
index 00000000000..2bf01d61584
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/integrationtests/typescript/node-es5-spec.json
@@ -0,0 +1,418 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "description": "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
+ "version": "1.0.0",
+ "title": "Swagger Petstore",
+ "termsOfService": "http://helloreverb.com/terms/",
+ "contact": {
+ "email": "apiteam@wordnik.com"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "host": "petstore.swagger.io",
+ "basePath": "/v1",
+ "schemes": [
+ "http"
+ ],
+ "paths": {
+ "/pet": {
+ "post": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Add a new pet to the store",
+ "description": "",
+ "operationId": "addPet",
+ "consumes": [
+ "application/json",
+ "application/xml"
+ ],
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Pet object that needs to be added to the store",
+ "required": false,
+ "schema": {
+ "$ref": "#/definitions/Pet"
+ }
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ },
+ "put": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Update an existing pet",
+ "description": "",
+ "operationId": "updatePet",
+ "consumes": [
+ "application/json",
+ "application/xml"
+ ],
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Pet object that needs to be added to the store",
+ "required": false,
+ "schema": {
+ "$ref": "#/definitions/Pet"
+ }
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Validation exception"
+ },
+ "404": {
+ "description": "Pet not found"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/pet/{petId}": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Find pet by ID",
+ "description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
+ "operationId": "getPetById",
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "ID of pet that needs to be fetched",
+ "required": true,
+ "type": "integer",
+ "format": "int64"
+ }
+ ],
+ "responses": {
+ "404": {
+ "description": "Pet not found"
+ },
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/Pet"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ },
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ },
+ "post": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Updates a pet in the store with form data",
+ "description": "",
+ "operationId": "updatePetWithForm",
+ "consumes": [
+ "application/x-www-form-urlencoded"
+ ],
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "ID of pet that needs to be updated",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "name": "name",
+ "in": "formData",
+ "description": "Updated name of the pet",
+ "required": false,
+ "type": "string"
+ },
+ {
+ "name": "status",
+ "in": "formData",
+ "description": "Updated status of the pet",
+ "required": false,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ },
+ "delete": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Deletes a pet",
+ "description": "",
+ "operationId": "deletePet",
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "name": "api_key",
+ "in": "header",
+ "description": "",
+ "required": false,
+ "type": "string"
+ },
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "Pet id to delete",
+ "required": true,
+ "type": "integer",
+ "format": "int64"
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid pet value"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/store/inventory": {
+ "get": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Returns pet inventories by status",
+ "description": "Returns a map of status codes to quantities",
+ "operationId": "getInventory",
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "integer",
+ "format": "int32"
+ }
+ }
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
+ "/store/order": {
+ "post": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Place an order for a pet",
+ "description": "",
+ "operationId": "placeOrder",
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "order placed for purchasing the pet",
+ "required": false,
+ "schema": {
+ "$ref": "#/definitions/Order"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/Order"
+ }
+ },
+ "400": {
+ "description": "Invalid Order"
+ }
+ }
+ }
+ },
+ "/store/order/{orderId}": {
+ "get": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Find purchase order by ID",
+ "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
+ "operationId": "getOrderById",
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "name": "orderId",
+ "in": "path",
+ "description": "ID of pet that needs to be fetched",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "404": {
+ "description": "Order not found"
+ },
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/Order"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Delete purchase order by ID",
+ "description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
+ "operationId": "deleteOrder",
+ "produces": [
+ "application/json",
+ "application/xml"
+ ],
+ "parameters": [
+ {
+ "name": "orderId",
+ "in": "path",
+ "description": "ID of the order that needs to be deleted",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "404": {
+ "description": "Order not found"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "Category": {
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "Pet": {
+ "required": [
+ "name",
+ "photoUrls"
+ ],
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "category": {
+ "$ref": "#/definitions/Category"
+ },
+ "name": {
+ "type": "string",
+ "example": "doggie"
+ }
+ }
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index 1b5c3d7580f..4dfd8c6fdcd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -267,7 +267,7 @@
- samples/client/petstore/android/default
+ samples/client/petstore/android/volley
@@ -438,6 +438,78 @@
samples/server/petstore/jaxrs
+
+ typescript-fetch-client-tests-default
+
+
+ env
+ java
+
+
+
+ samples/client/petstore/typescript-fetch/tests/default
+
+
+
+ typescript-fetch-client-builds-default
+
+
+ env
+ java
+
+
+
+ samples/client/petstore/typescript-fetch/builds/default
+
+
+
+ typescript-fetch-client-builds-es6-target
+
+
+ env
+ java
+
+
+
+ samples/client/petstore/typescript-fetch/builds/es6-target
+
+
+
+ typescript-fetch-client-builds-with-npm-version
+
+
+ env
+ java
+
+
+
+ samples/client/petstore/typescript-fetch/builds/with-npm-version
+
+
+
+ typescript-angular-client
+
+
+ env
+ java
+
+
+
+ samples/client/petstore/typescript-angular/npm
+
+
+
+ typescript-node-npm-client
+
+
+ env
+ java
+
+
+
+ samples/client/petstore/typescript-node/npm
+
+
ruby-client
@@ -471,7 +543,16 @@
- samples/client/petstore/android/default
+
+
+ samples/client/petstore/ruby
+ samples/client/petstore/typescript-angular
+ samples/client/petstore/typescript-node/npm
+ samples/client/petstore/android/volley
samples/client/petstore/clojure
samples/client/petstore/java/default
samples/client/petstore/java/feign
@@ -483,7 +564,6 @@
samples/client/petstore/javascript
samples/client/petstore/scala
samples/server/petstore/spring-mvc
- samples/client/petstore/ruby
samples/server/petstore/jaxrs
samples/server/petstore/jaxrs-resteasy
@@ -562,7 +642,7 @@
1.0.19
2.11.1
2.3.4
- 1.5.8
+ 1.5.9
2.4
1.2
4.8.1
diff --git a/samples/client/petstore/android/default/.gitignore b/samples/client/petstore/android/httpclient/.gitignore
similarity index 100%
rename from samples/client/petstore/android/default/.gitignore
rename to samples/client/petstore/android/httpclient/.gitignore
diff --git a/samples/client/petstore/android/default/README.md b/samples/client/petstore/android/httpclient/README.md
similarity index 100%
rename from samples/client/petstore/android/default/README.md
rename to samples/client/petstore/android/httpclient/README.md
index a1c37674b81..65931066a32 100644
--- a/samples/client/petstore/android/default/README.md
+++ b/samples/client/petstore/android/httpclient/README.md
@@ -116,6 +116,12 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
Authentication schemes defined for the API:
+### api_key
+
+- **Type**: API key
+- **API key parameter name**: api_key
+- **Location**: HTTP header
+
### petstore_auth
- **Type**: OAuth
@@ -125,12 +131,6 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account
- read:pets: read your pets
-### api_key
-
-- **Type**: API key
-- **API key parameter name**: api_key
-- **Location**: HTTP header
-
## Recommendation
diff --git a/samples/client/petstore/android/default/build.gradle b/samples/client/petstore/android/httpclient/build.gradle
similarity index 100%
rename from samples/client/petstore/android/default/build.gradle
rename to samples/client/petstore/android/httpclient/build.gradle
diff --git a/samples/client/petstore/android/default/docs/Category.md b/samples/client/petstore/android/httpclient/docs/Category.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/Category.md
rename to samples/client/petstore/android/httpclient/docs/Category.md
diff --git a/samples/client/petstore/android/default/docs/Order.md b/samples/client/petstore/android/httpclient/docs/Order.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/Order.md
rename to samples/client/petstore/android/httpclient/docs/Order.md
diff --git a/samples/client/petstore/android/default/docs/Pet.md b/samples/client/petstore/android/httpclient/docs/Pet.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/Pet.md
rename to samples/client/petstore/android/httpclient/docs/Pet.md
diff --git a/samples/client/petstore/android/default/docs/PetApi.md b/samples/client/petstore/android/httpclient/docs/PetApi.md
similarity index 99%
rename from samples/client/petstore/android/default/docs/PetApi.md
rename to samples/client/petstore/android/httpclient/docs/PetApi.md
index f8ba698c05a..f0f8ad40fbe 100644
--- a/samples/client/petstore/android/default/docs/PetApi.md
+++ b/samples/client/petstore/android/httpclient/docs/PetApi.md
@@ -222,7 +222,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers
diff --git a/samples/client/petstore/android/default/docs/StoreApi.md b/samples/client/petstore/android/httpclient/docs/StoreApi.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/StoreApi.md
rename to samples/client/petstore/android/httpclient/docs/StoreApi.md
diff --git a/samples/client/petstore/android/default/docs/Tag.md b/samples/client/petstore/android/httpclient/docs/Tag.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/Tag.md
rename to samples/client/petstore/android/httpclient/docs/Tag.md
diff --git a/samples/client/petstore/android/default/docs/User.md b/samples/client/petstore/android/httpclient/docs/User.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/User.md
rename to samples/client/petstore/android/httpclient/docs/User.md
diff --git a/samples/client/petstore/android/default/docs/UserApi.md b/samples/client/petstore/android/httpclient/docs/UserApi.md
similarity index 100%
rename from samples/client/petstore/android/default/docs/UserApi.md
rename to samples/client/petstore/android/httpclient/docs/UserApi.md
diff --git a/samples/client/petstore/android/default/git_push.sh b/samples/client/petstore/android/httpclient/git_push.sh
similarity index 100%
rename from samples/client/petstore/android/default/git_push.sh
rename to samples/client/petstore/android/httpclient/git_push.sh
diff --git a/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000000..2c6137b8789
Binary files /dev/null and b/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000000..fa452523ac0
--- /dev/null
+++ b/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon May 16 21:00:11 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
diff --git a/samples/client/petstore/android/httpclient/gradlew b/samples/client/petstore/android/httpclient/gradlew
new file mode 100755
index 00000000000..9d82f789151
--- /dev/null
+++ b/samples/client/petstore/android/httpclient/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/samples/client/petstore/android/httpclient/gradlew.bat b/samples/client/petstore/android/httpclient/gradlew.bat
new file mode 100644
index 00000000000..5f192121eb4
--- /dev/null
+++ b/samples/client/petstore/android/httpclient/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/samples/client/petstore/android/default/pom.xml b/samples/client/petstore/android/httpclient/pom.xml
similarity index 100%
rename from samples/client/petstore/android/default/pom.xml
rename to samples/client/petstore/android/httpclient/pom.xml
diff --git a/samples/client/petstore/android/default/settings.gradle b/samples/client/petstore/android/httpclient/settings.gradle
similarity index 100%
rename from samples/client/petstore/android/default/settings.gradle
rename to samples/client/petstore/android/httpclient/settings.gradle
diff --git a/samples/client/petstore/android/default/src/main/AndroidManifest.xml b/samples/client/petstore/android/httpclient/src/main/AndroidManifest.xml
similarity index 100%
rename from samples/client/petstore/android/default/src/main/AndroidManifest.xml
rename to samples/client/petstore/android/httpclient/src/main/AndroidManifest.xml
diff --git a/samples/client/petstore/android/httpclient/src/main/java/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/android/httpclient/src/main/java/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000000..008a64a2444
--- /dev/null
+++ b/samples/client/petstore/android/httpclient/src/main/java/gradle/wrapper/gradle-wrapper.jar
@@ -0,0 +1,53 @@
+" zip.vim version v27
+" Browsing zipfile /Users/huangzhenjun/Public/git/PartTime/swagger-codegen/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.jar
+" Select a file with cursor and press ENTER
+
+META-INF/
+META-INF/MANIFEST.MF
+org/
+org/gradle/
+org/gradle/wrapper/
+org/gradle/wrapper/Download$1.class
+org/gradle/wrapper/Download$SystemPropertiesProxyAuthenticator.class
+org/gradle/wrapper/IDownload.class
+org/gradle/wrapper/GradleUserHomeLookup.class
+org/gradle/wrapper/ExclusiveFileAccessManager.class
+org/gradle/wrapper/WrapperConfiguration.class
+org/gradle/wrapper/SystemPropertiesHandler.class
+org/gradle/wrapper/Logger.class
+org/gradle/wrapper/PathAssembler.class
+org/gradle/wrapper/Install.class
+org/gradle/wrapper/BootstrapMainStarter.class
+org/gradle/wrapper/WrapperExecutor.class
+org/gradle/wrapper/GradleWrapperMain.class
+org/gradle/wrapper/Install$1.class
+org/gradle/wrapper/PathAssembler$LocalDistribution.class
+org/gradle/wrapper/Download.class
+gradle-wrapper-classpath.properties
+build-receipt.properties
+org/gradle/cli/
+org/gradle/cli/AbstractCommandLineConverter.class
+org/gradle/cli/CommandLineParser$1.class
+org/gradle/cli/CommandLineParser$MissingOptionArgState.class
+org/gradle/cli/CommandLineParser$OptionStringComparator.class
+org/gradle/cli/CommandLineArgumentException.class
+org/gradle/cli/CommandLineParser$KnownOptionParserState.class
+org/gradle/cli/CommandLineParser$OptionComparator.class
+org/gradle/cli/CommandLineParser$UnknownOptionParserState.class
+org/gradle/cli/CommandLineOption.class
+org/gradle/cli/CommandLineParser$OptionParserState.class
+org/gradle/cli/ParsedCommandLine.class
+org/gradle/cli/ProjectPropertiesCommandLineConverter.class
+org/gradle/cli/CommandLineParser$CaseInsensitiveStringComparator.class
+org/gradle/cli/CommandLineParser.class
+org/gradle/cli/CommandLineParser$AfterOptions.class
+org/gradle/cli/CommandLineParser$OptionString.class
+org/gradle/cli/AbstractPropertiesCommandLineConverter.class
+org/gradle/cli/ParsedCommandLineOption.class
+org/gradle/cli/CommandLineParser$OptionAwareParserState.class
+org/gradle/cli/CommandLineConverter.class
+org/gradle/cli/CommandLineParser$BeforeFirstSubCommand.class
+org/gradle/cli/SystemPropertiesCommandLineConverter.class
+org/gradle/cli/CommandLineParser$ParserState.class
+org/gradle/cli/CommandLineParser$AfterFirstSubCommand.class
+gradle-cli-classpath.properties
diff --git a/samples/client/petstore/android/httpclient/src/main/java/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/httpclient/src/main/java/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000000..fa452523ac0
--- /dev/null
+++ b/samples/client/petstore/android/httpclient/src/main/java/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon May 16 21:00:11 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiException.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiException.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiException.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiInvoker.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/ApiInvoker.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiInvoker.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/HttpPatch.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/HttpPatch.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/HttpPatch.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/HttpPatch.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/JsonUtil.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/JsonUtil.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/Pair.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/Pair.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/Pair.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/api/PetApi.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/api/PetApi.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/api/StoreApi.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/api/StoreApi.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/api/UserApi.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/api/UserApi.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Category.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Category.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Category.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Order.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Order.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Order.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Pet.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Pet.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Pet.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Tag.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Tag.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/Tag.java
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/User.java
similarity index 100%
rename from samples/client/petstore/android/default/src/main/java/io/swagger/client/model/User.java
rename to samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/model/User.java
diff --git a/samples/client/petstore/android/volley/.gitignore b/samples/client/petstore/android/volley/.gitignore
new file mode 100644
index 00000000000..a7b72d554da
--- /dev/null
+++ b/samples/client/petstore/android/volley/.gitignore
@@ -0,0 +1,39 @@
+# Built application files
+*.apk
+*.ap_
+
+# Files for the Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+
+# Keystore files
+*.jks
\ No newline at end of file
diff --git a/samples/client/petstore/android/volley/README.md b/samples/client/petstore/android/volley/README.md
index 6f0a2c65f92..65931066a32 100644
--- a/samples/client/petstore/android/volley/README.md
+++ b/samples/client/petstore/android/volley/README.md
@@ -1,4 +1,4 @@
-# swagger-petstore-android-volley
+# swagger-android-client
## Requirements
@@ -27,7 +27,7 @@ Add this dependency to your project's POM:
```xml
io.swagger
- swagger-petstore-android-volley
+ swagger-android-client
1.0.0
compile
@@ -38,7 +38,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:
```groovy
-compile "io.swagger:swagger-petstore-android-volley:1.0.0"
+compile "io.swagger:swagger-android-client:1.0.0"
```
### Others
@@ -49,7 +49,7 @@ At first generate the JAR by executing:
Then manually install the following JARs:
-* target/swagger-petstore-android-volley-1.0.0.jar
+* target/swagger-android-client-1.0.0.jar
* target/lib/*.jar
## Getting Started
@@ -116,6 +116,12 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
Authentication schemes defined for the API:
+### api_key
+
+- **Type**: API key
+- **API key parameter name**: api_key
+- **Location**: HTTP header
+
### petstore_auth
- **Type**: OAuth
@@ -125,12 +131,6 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account
- read:pets: read your pets
-### api_key
-
-- **Type**: API key
-- **API key parameter name**: api_key
-- **Location**: HTTP header
-
## Recommendation
diff --git a/samples/client/petstore/android/volley/docs/PetApi.md b/samples/client/petstore/android/volley/docs/PetApi.md
index f8ba698c05a..f0f8ad40fbe 100644
--- a/samples/client/petstore/android/volley/docs/PetApi.md
+++ b/samples/client/petstore/android/volley/docs/PetApi.md
@@ -222,7 +222,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers
diff --git a/samples/client/petstore/android/volley/git_push.sh b/samples/client/petstore/android/volley/git_push.sh
new file mode 100644
index 00000000000..f711c4b3130
--- /dev/null
+++ b/samples/client/petstore/android/volley/git_push.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
+#
+# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
+
+git_user_id=$1
+git_repo_id=$2
+release_note=$3
+
+if [ "$git_user_id" = "" ]; then
+ git_user_id="GIT_USER_ID"
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
+fi
+
+if [ "$git_repo_id" = "" ]; then
+ git_repo_id="GIT_REPO_ID"
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
+fi
+
+if [ "$release_note" = "" ]; then
+ release_note="Minor update"
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
+fi
+
+# Initialize the local directory as a Git repository
+git init
+
+# Adds the files in the local repository and stages them for commit.
+git add .
+
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
+git commit -m "$release_note"
+
+# Sets the new remote
+git_remote=`git remote`
+if [ "$git_remote" = "" ]; then # git remote not defined
+
+ if [ "$GIT_TOKEN" = "" ]; then
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ else
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ fi
+
+fi
+
+git pull origin master
+
+# Pushes (Forces) the changes in the local repository up to the remote repository
+echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+git push origin master 2>&1 | grep -v 'To https'
\ No newline at end of file
diff --git a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000000..2c6137b8789
Binary files /dev/null and b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000000..1bbc424ca7e
--- /dev/null
+++ b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon May 16 21:00:31 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
diff --git a/samples/client/petstore/android/volley/gradlew b/samples/client/petstore/android/volley/gradlew
new file mode 100755
index 00000000000..9d82f789151
--- /dev/null
+++ b/samples/client/petstore/android/volley/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/samples/client/petstore/android/volley/gradlew.bat b/samples/client/petstore/android/volley/gradlew.bat
new file mode 100644
index 00000000000..5f192121eb4
--- /dev/null
+++ b/samples/client/petstore/android/volley/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/samples/client/petstore/android/volley/pom.xml b/samples/client/petstore/android/volley/pom.xml
index 98572662fb2..04369688c3b 100644
--- a/samples/client/petstore/android/volley/pom.xml
+++ b/samples/client/petstore/android/volley/pom.xml
@@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
io.swagger
- swagger-petstore-android-volley
+ swagger-android-client
1.0.0
@@ -37,11 +37,24 @@
${android-platform-version}
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.6
+ 1.6
+
+
+
+
- 1.5.0
+ 1.5.8
4.4.4
4.5.2
- 2.3.1
+ 2.6.2
1.0.19
4.1.1.4
diff --git a/samples/client/petstore/android/volley/src/main/java/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/android/volley/src/main/java/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000000..126985b8a44
--- /dev/null
+++ b/samples/client/petstore/android/volley/src/main/java/gradle/wrapper/gradle-wrapper.jar
@@ -0,0 +1,53 @@
+" zip.vim version v27
+" Browsing zipfile /Users/huangzhenjun/Public/git/PartTime/swagger-codegen/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar
+" Select a file with cursor and press ENTER
+
+META-INF/
+META-INF/MANIFEST.MF
+org/
+org/gradle/
+org/gradle/wrapper/
+org/gradle/wrapper/Download$1.class
+org/gradle/wrapper/Download$SystemPropertiesProxyAuthenticator.class
+org/gradle/wrapper/IDownload.class
+org/gradle/wrapper/GradleUserHomeLookup.class
+org/gradle/wrapper/ExclusiveFileAccessManager.class
+org/gradle/wrapper/WrapperConfiguration.class
+org/gradle/wrapper/SystemPropertiesHandler.class
+org/gradle/wrapper/Logger.class
+org/gradle/wrapper/PathAssembler.class
+org/gradle/wrapper/Install.class
+org/gradle/wrapper/BootstrapMainStarter.class
+org/gradle/wrapper/WrapperExecutor.class
+org/gradle/wrapper/GradleWrapperMain.class
+org/gradle/wrapper/Install$1.class
+org/gradle/wrapper/PathAssembler$LocalDistribution.class
+org/gradle/wrapper/Download.class
+gradle-wrapper-classpath.properties
+build-receipt.properties
+org/gradle/cli/
+org/gradle/cli/AbstractCommandLineConverter.class
+org/gradle/cli/CommandLineParser$1.class
+org/gradle/cli/CommandLineParser$MissingOptionArgState.class
+org/gradle/cli/CommandLineParser$OptionStringComparator.class
+org/gradle/cli/CommandLineArgumentException.class
+org/gradle/cli/CommandLineParser$KnownOptionParserState.class
+org/gradle/cli/CommandLineParser$OptionComparator.class
+org/gradle/cli/CommandLineParser$UnknownOptionParserState.class
+org/gradle/cli/CommandLineOption.class
+org/gradle/cli/CommandLineParser$OptionParserState.class
+org/gradle/cli/ParsedCommandLine.class
+org/gradle/cli/ProjectPropertiesCommandLineConverter.class
+org/gradle/cli/CommandLineParser$CaseInsensitiveStringComparator.class
+org/gradle/cli/CommandLineParser.class
+org/gradle/cli/CommandLineParser$AfterOptions.class
+org/gradle/cli/CommandLineParser$OptionString.class
+org/gradle/cli/AbstractPropertiesCommandLineConverter.class
+org/gradle/cli/ParsedCommandLineOption.class
+org/gradle/cli/CommandLineParser$OptionAwareParserState.class
+org/gradle/cli/CommandLineConverter.class
+org/gradle/cli/CommandLineParser$BeforeFirstSubCommand.class
+org/gradle/cli/SystemPropertiesCommandLineConverter.class
+org/gradle/cli/CommandLineParser$ParserState.class
+org/gradle/cli/CommandLineParser$AfterFirstSubCommand.class
+gradle-cli-classpath.properties
diff --git a/samples/client/petstore/android/volley/src/main/java/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/volley/src/main/java/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000000..1bbc424ca7e
--- /dev/null
+++ b/samples/client/petstore/android/volley/src/main/java/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon May 16 21:00:31 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
diff --git a/samples/client/petstore/csharp/SwaggerClient/.swagger-codegen-ignore b/samples/client/petstore/csharp/SwaggerClient/.swagger-codegen-ignore
new file mode 100644
index 00000000000..19d3377182e
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClient/.swagger-codegen-ignore
@@ -0,0 +1,23 @@
+# Swagger Codegen Ignore
+# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln b/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln
index 3c26ad6be49..d6a0243de57 100644
--- a/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln
+++ b/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln
@@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{098D14FD-4F35-417E-9B8E-67875ACD0AD3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
EndProject
@@ -12,10 +12,10 @@ Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
-{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Release|Any CPU.Build.0 = Release|Any CPU
+{098D14FD-4F35-417E-9B8E-67875ACD0AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+{098D14FD-4F35-417E-9B8E-67875ACD0AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+{098D14FD-4F35-417E-9B8E-67875ACD0AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+{098D14FD-4F35-417E-9B8E-67875ACD0AD3}.Release|Any CPU.Build.0 = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/samples/client/petstore/csharp/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClient/README.md
index c546b834c18..7cd00026612 100644
--- a/samples/client/petstore/csharp/SwaggerClient/README.md
+++ b/samples/client/petstore/csharp/SwaggerClient/README.md
@@ -1,12 +1,12 @@
# IO.Swagger - the C# library for the Swagger Petstore
-This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.
+This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0
- SDK version: 1.0.0
-- Build date: 2016-05-10T17:39:13.582+08:00
+- Build date: 2016-05-21T22:36:46.367+08:00
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
## Frameworks supported
@@ -112,6 +112,7 @@ Class | Method | HTTP request | Description
## Documentation for Models
+ - [Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [Model.Animal](docs/Animal.md)
- [Model.AnimalFarm](docs/AnimalFarm.md)
- [Model.ApiResponse](docs/ApiResponse.md)
@@ -121,11 +122,13 @@ Class | Method | HTTP request | Description
- [Model.EnumClass](docs/EnumClass.md)
- [Model.EnumTest](docs/EnumTest.md)
- [Model.FormatTest](docs/FormatTest.md)
+ - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model.Model200Response](docs/Model200Response.md)
- [Model.ModelReturn](docs/ModelReturn.md)
- [Model.Name](docs/Name.md)
- [Model.Order](docs/Order.md)
- [Model.Pet](docs/Pet.md)
+ - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [Model.SpecialModelName](docs/SpecialModelName.md)
- [Model.Tag](docs/Tag.md)
- [Model.User](docs/User.md)
diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/SwaggerClient/docs/AdditionalPropertiesClass.md
new file mode 100644
index 00000000000..e9922fe6e91
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClient/docs/AdditionalPropertiesClass.md
@@ -0,0 +1,8 @@
+# IO.Swagger.Model.AdditionalPropertiesClass
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md
index 65b04a12ccb..e4325274999 100644
--- a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md
+++ b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md
@@ -84,8 +84,8 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+ - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8
+ - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/csharp/SwaggerClient/docs/MixedPropertiesAndAdditionalPropertiesClass.md
new file mode 100644
index 00000000000..0db3f9ee52d
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClient/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -0,0 +1,10 @@
+# IO.Swagger.Model.MixedPropertiesAndAdditionalPropertiesClass
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**Uuid** | **Guid?** | | [optional]
+**DateTime** | **DateTime?** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/ReadOnlyFirst.md b/samples/client/petstore/csharp/SwaggerClient/docs/ReadOnlyFirst.md
new file mode 100644
index 00000000000..b5f8d484869
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClient/docs/ReadOnlyFirst.md
@@ -0,0 +1,10 @@
+# IO.Swagger.Model.ReadOnlyFirst
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**Bar** | **string** | | [optional]
+**Baz** | **string** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs
index 478311b649e..71a4063af4e 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs
@@ -58,20 +58,22 @@ namespace IO.Swagger.Test
[Test]
public void TestEndpointParametersTest()
{
+ /* comment out the following as the endpiont is fake
// TODO: add unit test for the method 'TestEndpointParameters'
- double? number = null; // TODO: replace null with proper value
- double? _double = null; // TODO: replace null with proper value
- string _string = null; // TODO: replace null with proper value
- byte[] _byte = null; // TODO: replace null with proper value
- int? integer = null; // TODO: replace null with proper value
- int? int32 = null; // TODO: replace null with proper value
- long? int64 = null; // TODO: replace null with proper value
- float? _float = null; // TODO: replace null with proper value
+ double? number = 12.3; // TODO: replace null with proper value
+ double? _double = 34.5; // TODO: replace null with proper value
+ string _string = "charp test"; // TODO: replace null with proper value
+ byte[] _byte = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };; // TODO: replace null with proper value
+ int? integer = 3; // TODO: replace null with proper value
+ int? int32 = 2; // TODO: replace null with proper value
+ long? int64 = 1; // TODO: replace null with proper value
+ float? _float = 7.8F; // TODO: replace null with proper value
byte[] binary = null; // TODO: replace null with proper value
- DateTime? date = null; // TODO: replace null with proper value
+ DateTime? date = null; // TODO: replace null with proper value
DateTime? dateTime = null; // TODO: replace null with proper value
string password = null; // TODO: replace null with proper value
instance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
+ */
}
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/PetApiTests.cs
index a24e297eea1..b9dae814b68 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/PetApiTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/PetApiTests.cs
@@ -25,13 +25,59 @@ namespace IO.Swagger.Test
{
private PetApi instance;
+ private long petId = 11088;
+
+ ///
+ /// Create a Pet object
+ ///
+ private Pet createPet()
+ {
+ // create pet
+ Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List { "http://petstore.com/csharp_test" });
+ p.Id = petId;
+ //p.Name = "Csharp test";
+ p.Status = Pet.StatusEnum.Available;
+ // create Category object
+ Category category = new Category();
+ category.Id = 56;
+ category.Name = "sample category name2";
+ List photoUrls = new List(new String[] {"sample photoUrls"});
+ // create Tag object
+ Tag tag = new Tag();
+ tag.Id = petId;
+ tag.Name = "csharp sample tag name1";
+ List tags = new List(new Tag[] {tag});
+ p.Tags = tags;
+ p.Category = category;
+ p.PhotoUrls = photoUrls;
+
+ return p;
+ }
+
+ ///
+ /// Convert string to byte array
+ ///
+ private byte[] GetBytes(string str)
+ {
+ byte[] bytes = new byte[str.Length * sizeof(char)];
+ System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
+ return bytes;
+ }
+
///
/// Setup before each unit test
///
[SetUp]
public void Init()
{
- instance = new PetApi();
+ instance = new PetApi();
+
+ // create pet
+ Pet p = createPet();
+
+ // add pet before testing
+ PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
+ petApi.AddPet (p);
}
///
@@ -40,7 +86,9 @@ namespace IO.Swagger.Test
[TearDown]
public void Cleanup()
{
-
+ // remove the pet after testing
+ PetApi petApi = new PetApi ();
+ petApi.DeletePet(petId, "test key");
}
///
@@ -59,10 +107,10 @@ namespace IO.Swagger.Test
[Test]
public void AddPetTest()
{
- // TODO: add unit test for the method 'AddPet'
- Pet body = null; // TODO: replace null with proper value
- instance.AddPet(body);
-
+ // create pet
+ Pet p = createPet();
+
+ instance.AddPet(p);
}
///
@@ -71,11 +119,7 @@ namespace IO.Swagger.Test
[Test]
public void DeletePetTest()
{
- // TODO: add unit test for the method 'DeletePet'
- long? petId = null; // TODO: replace null with proper value
- string apiKey = null; // TODO: replace null with proper value
- instance.DeletePet(petId, apiKey);
-
+ // no need to test as it'c covered by Cleanup() already
}
///
@@ -84,10 +128,15 @@ namespace IO.Swagger.Test
[Test]
public void FindPetsByStatusTest()
{
- // TODO: add unit test for the method 'FindPetsByStatus'
- List status = null; // TODO: replace null with proper value
- var response = instance.FindPetsByStatus(status);
- Assert.IsInstanceOf> (response, "response is List");
+ PetApi petApi = new PetApi ();
+ List tagsList = new List(new String[] {"available"});
+
+ List listPet = petApi.FindPetsByTags (tagsList);
+ foreach (Pet pet in listPet) // Loop through List with foreach.
+ {
+ Assert.IsInstanceOf (pet, "Response is a Pet");
+ Assert.AreEqual ("csharp sample tag name1", pet.Tags[0]);
+ }
}
///
@@ -96,8 +145,7 @@ namespace IO.Swagger.Test
[Test]
public void FindPetsByTagsTest()
{
- // TODO: add unit test for the method 'FindPetsByTags'
- List tags = null; // TODO: replace null with proper value
+ List tags = new List(new String[] {"pet"});
var response = instance.FindPetsByTags(tags);
Assert.IsInstanceOf> (response, "response is List");
}
@@ -108,22 +156,96 @@ namespace IO.Swagger.Test
[Test]
public void GetPetByIdTest()
{
- // TODO: add unit test for the method 'GetPetById'
- long? petId = null; // TODO: replace null with proper value
- var response = instance.GetPetById(petId);
- Assert.IsInstanceOf (response, "response is Pet");
+ // set timeout to 10 seconds
+ Configuration c1 = new Configuration (timeout: 10000, userAgent: "TEST_USER_AGENT");
+
+ PetApi petApi = new PetApi (c1);
+ Pet response = petApi.GetPetById (petId);
+ Assert.IsInstanceOf (response, "Response is a Pet");
+
+ Assert.AreEqual ("Csharp test", response.Name);
+ Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
+
+ Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
+ Assert.AreEqual (petId, response.Tags [0].Id);
+ Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
+
+ Assert.IsInstanceOf> (response.PhotoUrls, "Response.PhotoUrls is a Array");
+ Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
+
+ Assert.IsInstanceOf (response.Category, "Response.Category is a Category");
+ Assert.AreEqual (56, response.Category.Id);
+ Assert.AreEqual ("sample category name2", response.Category.Name);
}
+
+ ///
+ /// Test GetPetByIdAsync
+ ///
+ [Test ()]
+ public void TestGetPetByIdAsync ()
+ {
+ PetApi petApi = new PetApi ();
+ var task = petApi.GetPetByIdAsync (petId);
+ Pet response = task.Result;
+ Assert.IsInstanceOf (response, "Response is a Pet");
+
+ Assert.AreEqual ("Csharp test", response.Name);
+ Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
+
+ Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
+ Assert.AreEqual (petId, response.Tags [0].Id);
+ Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
+
+ Assert.IsInstanceOf> (response.PhotoUrls, "Response.PhotoUrls is a Array");
+ Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
+
+ Assert.IsInstanceOf (response.Category, "Response.Category is a Category");
+ Assert.AreEqual (56, response.Category.Id);
+ Assert.AreEqual ("sample category name2", response.Category.Name);
+
+ }
+ ///
+ /// Test GetPetByIdAsyncWithHttpInfo
+ ///
+ [Test ()]
+ public void TestGetPetByIdAsyncWithHttpInfo ()
+ {
+ PetApi petApi = new PetApi ();
+ var task = petApi.GetPetByIdAsyncWithHttpInfo (petId);
+
+ Assert.AreEqual (200, task.Result.StatusCode);
+ Assert.IsTrue (task.Result.Headers.ContainsKey("Content-Type"));
+ Assert.AreEqual (task.Result.Headers["Content-Type"], "application/json");
+
+ Pet response = task.Result.Data;
+ Assert.IsInstanceOf (response, "Response is a Pet");
+
+ Assert.AreEqual ("Csharp test", response.Name);
+ Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
+
+ Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
+ Assert.AreEqual (petId, response.Tags [0].Id);
+ Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
+
+ Assert.IsInstanceOf> (response.PhotoUrls, "Response.PhotoUrls is a Array");
+ Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
+
+ Assert.IsInstanceOf (response.Category, "Response.Category is a Category");
+ Assert.AreEqual (56, response.Category.Id);
+ Assert.AreEqual ("sample category name2", response.Category.Name);
+
+ }
+
///
/// Test UpdatePet
///
[Test]
public void UpdatePetTest()
{
- // TODO: add unit test for the method 'UpdatePet'
- Pet body = null; // TODO: replace null with proper value
- instance.UpdatePet(body);
-
+ // create pet
+ Pet p = createPet();
+ instance.UpdatePet(p);
}
///
@@ -132,12 +254,24 @@ namespace IO.Swagger.Test
[Test]
public void UpdatePetWithFormTest()
{
- // TODO: add unit test for the method 'UpdatePetWithForm'
- long? petId = null; // TODO: replace null with proper value
- string name = null; // TODO: replace null with proper value
- string status = null; // TODO: replace null with proper value
- instance.UpdatePetWithForm(petId, name, status);
-
+ PetApi petApi = new PetApi ();
+ petApi.UpdatePetWithForm (petId, "new form name", "pending");
+
+ Pet response = petApi.GetPetById (petId);
+ Assert.IsInstanceOf (response, "Response is a Pet");
+ Assert.IsInstanceOf (response.Category, "Response.Category is a Category");
+ Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
+
+ Assert.AreEqual ("new form name", response.Name);
+ Assert.AreEqual (Pet.StatusEnum.Pending, response.Status);
+
+ Assert.AreEqual (petId, response.Tags [0].Id);
+ Assert.AreEqual (56, response.Category.Id);
+
+ // test optional parameter
+ petApi.UpdatePetWithForm (petId, "new form name2");
+ Pet response2 = petApi.GetPetById (petId);
+ Assert.AreEqual ("new form name2", response2.Name);
}
///
@@ -146,13 +280,45 @@ namespace IO.Swagger.Test
[Test]
public void UploadFileTest()
{
- // TODO: add unit test for the method 'UploadFile'
- long? petId = null; // TODO: replace null with proper value
- string additionalMetadata = null; // TODO: replace null with proper value
- System.IO.Stream file = null; // TODO: replace null with proper value
- var response = instance.UploadFile(petId, additionalMetadata, file);
- Assert.IsInstanceOf (response, "response is ApiResponse");
+ Assembly _assembly = Assembly.GetExecutingAssembly();
+ Stream _imageStream = _assembly.GetManifestResourceStream("IO.Swagger.Test.swagger-logo.png");
+ PetApi petApi = new PetApi ();
+ // test file upload with form parameters
+ petApi.UploadFile(petId, "new form name", _imageStream);
+
+ // test file upload without any form parameters
+ // using optional parameter syntax introduced at .net 4.0
+ petApi.UploadFile(petId: petId, file: _imageStream);
+
}
+
+ ///
+ /// Test status code
+ ///
+ [Test ()]
+ public void TestStatusCodeAndHeader ()
+ {
+ PetApi petApi = new PetApi ();
+ var response = petApi.GetPetByIdWithHttpInfo (petId);
+ Assert.AreEqual (response.StatusCode, 200);
+ Assert.IsTrue (response.Headers.ContainsKey("Content-Type"));
+ Assert.AreEqual (response.Headers["Content-Type"], "application/json");
+ }
+
+ ///
+ /// Test default header (should be deprecated
+ ///
+ [Test ()]
+ public void TestDefaultHeader ()
+ {
+ PetApi petApi = new PetApi ();
+ // commented out the warning test below as it's confirmed the warning is working as expected
+ // there should be a warning for using AddDefaultHeader (deprecated) below
+ //petApi.AddDefaultHeader ("header_key", "header_value");
+ // the following should be used instead as suggested in the doc
+ petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");
+
+ }
}
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/StoreApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/StoreApiTests.cs
index 5ccac40bbfb..e1237b51c0b 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/StoreApiTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/StoreApiTests.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
+using Newtonsoft.Json;
using IO.Swagger.Client;
using IO.Swagger.Api;
@@ -60,8 +61,8 @@ namespace IO.Swagger.Test
public void DeleteOrderTest()
{
// TODO: add unit test for the method 'DeleteOrder'
- string orderId = null; // TODO: replace null with proper value
- instance.DeleteOrder(orderId);
+ //string orderId = null; // TODO: replace null with proper value
+ //instance.DeleteOrder(orderId);
}
@@ -72,8 +73,19 @@ namespace IO.Swagger.Test
public void GetInventoryTest()
{
// TODO: add unit test for the method 'GetInventory'
- var response = instance.GetInventory();
- Assert.IsInstanceOf> (response, "response is Dictionary");
+ //var response = instance.GetInventory();
+ //Assert.IsInstanceOf> (response, "response is Dictionary");
+
+ // set timeout to 10 seconds
+ Configuration c1 = new Configuration (timeout: 10000);
+
+ StoreApi storeApi = new StoreApi (c1);
+ Dictionary response = storeApi.GetInventory ();
+
+ foreach(KeyValuePair entry in response)
+ {
+ Assert.IsInstanceOf (typeof(int?), entry.Value);
+ }
}
///
@@ -83,9 +95,9 @@ namespace IO.Swagger.Test
public void GetOrderByIdTest()
{
// TODO: add unit test for the method 'GetOrderById'
- long? orderId = null; // TODO: replace null with proper value
- var response = instance.GetOrderById(orderId);
- Assert.IsInstanceOf (response, "response is Order");
+ //long? orderId = null; // TODO: replace null with proper value
+ //var response = instance.GetOrderById(orderId);
+ //Assert.IsInstanceOf (response, "response is Order");
}
///
@@ -95,11 +107,41 @@ namespace IO.Swagger.Test
public void PlaceOrderTest()
{
// TODO: add unit test for the method 'PlaceOrder'
- Order body = null; // TODO: replace null with proper value
- var response = instance.PlaceOrder(body);
- Assert.IsInstanceOf (response, "response is Order");
+ //Order body = null; // TODO: replace null with proper value
+ //var response = instance.PlaceOrder(body);
+ //Assert.IsInstanceOf (response, "response is Order");
}
+ ///
+ /// Test Enum
+ ///
+ [Test ()]
+ public void TestEnum ()
+ {
+ Assert.AreEqual (Order.StatusEnum.Approved.ToString(), "Approved");
+ }
+
+ ///
+ /// Test deserialization of JSON to Order and its readonly property
+ ///
+ [Test ()]
+ public void TesOrderDeserialization()
+ {
+ string json = @"{
+'id': 1982,
+'petId': 1020,
+'quantity': 1,
+'status': 'placed',
+'complete': true,
+}";
+ var o = JsonConvert.DeserializeObject(json);
+ Assert.AreEqual (1982, o.Id);
+ Assert.AreEqual (1020, o.PetId);
+ Assert.AreEqual (1, o.Quantity);
+ Assert.AreEqual (Order.StatusEnum.Placed, o.Status);
+ Assert.AreEqual (true, o.Complete);
+
+ }
}
}
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/UserApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/UserApiTests.cs
index ffb0593aa88..77f6bd5ec99 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/UserApiTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/UserApiTests.cs
@@ -60,8 +60,8 @@ namespace IO.Swagger.Test
public void CreateUserTest()
{
// TODO: add unit test for the method 'CreateUser'
- User body = null; // TODO: replace null with proper value
- instance.CreateUser(body);
+ //User body = null; // TODO: replace null with proper value
+ //instance.CreateUser(body);
}
@@ -72,8 +72,8 @@ namespace IO.Swagger.Test
public void CreateUsersWithArrayInputTest()
{
// TODO: add unit test for the method 'CreateUsersWithArrayInput'
- List body = null; // TODO: replace null with proper value
- instance.CreateUsersWithArrayInput(body);
+ //List body = null; // TODO: replace null with proper value
+ //instance.CreateUsersWithArrayInput(body);
}
@@ -84,8 +84,8 @@ namespace IO.Swagger.Test
public void CreateUsersWithListInputTest()
{
// TODO: add unit test for the method 'CreateUsersWithListInput'
- List body = null; // TODO: replace null with proper value
- instance.CreateUsersWithListInput(body);
+ //List body = null; // TODO: replace null with proper value
+ //instance.CreateUsersWithListInput(body);
}
@@ -96,8 +96,8 @@ namespace IO.Swagger.Test
public void DeleteUserTest()
{
// TODO: add unit test for the method 'DeleteUser'
- string username = null; // TODO: replace null with proper value
- instance.DeleteUser(username);
+ //string username = null; // TODO: replace null with proper value
+ //instance.DeleteUser(username);
}
@@ -108,9 +108,9 @@ namespace IO.Swagger.Test
public void GetUserByNameTest()
{
// TODO: add unit test for the method 'GetUserByName'
- string username = null; // TODO: replace null with proper value
- var response = instance.GetUserByName(username);
- Assert.IsInstanceOf (response, "response is User");
+ //string username = null; // TODO: replace null with proper value
+ //var response = instance.GetUserByName(username);
+ //Assert.IsInstanceOf (response, "response is User");
}
///
@@ -120,10 +120,10 @@ namespace IO.Swagger.Test
public void LoginUserTest()
{
// TODO: add unit test for the method 'LoginUser'
- string username = null; // TODO: replace null with proper value
- string password = null; // TODO: replace null with proper value
- var response = instance.LoginUser(username, password);
- Assert.IsInstanceOf (response, "response is string");
+ //string username = null; // TODO: replace null with proper value
+ //string password = null; // TODO: replace null with proper value
+ //var response = instance.LoginUser(username, password);
+ //Assert.IsInstanceOf (response, "response is string");
}
///
@@ -133,7 +133,7 @@ namespace IO.Swagger.Test
public void LogoutUserTest()
{
// TODO: add unit test for the method 'LogoutUser'
- instance.LogoutUser();
+ //instance.LogoutUser();
}
@@ -144,9 +144,9 @@ namespace IO.Swagger.Test
public void UpdateUserTest()
{
// TODO: add unit test for the method 'UpdateUser'
- string username = null; // TODO: replace null with proper value
- User body = null; // TODO: replace null with proper value
- instance.UpdateUser(username, body);
+ //string username = null; // TODO: replace null with proper value
+ //User body = null; // TODO: replace null with proper value
+ //instance.UpdateUser(username, body);
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Client/ApiClientTests.cs
similarity index 67%
rename from samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs
rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Client/ApiClientTests.cs
index 9d1921d8ea7..4f31bc0b302 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Client/ApiClientTests.cs
@@ -3,17 +3,22 @@ using System;
using System.Collections.Generic;
using IO.Swagger.Client;
using IO.Swagger.Api;
+using IO.Swagger.Model;
-namespace SwaggerClientTest.TestApiClient
+namespace IO.Swagger.Test
{
- public class TestApiClient
+ public class ApiClientTests
{
- [TearDown()]
- public void TearDown()
- {
- // Reset to default, just in case
- Configuration.Default.DateTimeFormat = "o";
- }
+ public ApiClientTests ()
+ {
+ }
+
+ [TearDown()]
+ public void TearDown()
+ {
+ // Reset to default, just in case
+ Configuration.Default.DateTimeFormat = "o";
+ }
///
/// Test SelectHeaderContentType
@@ -35,7 +40,7 @@ namespace SwaggerClientTest.TestApiClient
///
/// Test ParameterToString
///
- [Test ()]
+ [Test ()]
public void TestParameterToString ()
{
ApiClient api = new ApiClient ();
@@ -49,8 +54,8 @@ namespace SwaggerClientTest.TestApiClient
Assert.AreEqual("1,37", api.ParameterToString (numList));
}
- [Test ()]
- public void TestParameterToStringForDateTime ()
+ [Test ()]
+ public void TestParameterToStringForDateTime ()
{
ApiClient api = new ApiClient ();
@@ -68,34 +73,34 @@ namespace SwaggerClientTest.TestApiClient
public void TestParameterToStringWithTimeZoneForDateTime ()
{
ApiClient api = new ApiClient ();
- // test datetime with a time zone
- DateTimeOffset dateWithTz = DateTimeOffset.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind);
- Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz));
- }
+ // test datetime with a time zone
+ DateTimeOffset dateWithTz = DateTimeOffset.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind);
+ Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz));
+ }
- [Test ()]
- public void TestParameterToStringForDateTimeWithUFormat ()
- {
- // Setup the DateTimeFormat across all of the calls
- Configuration.Default.DateTimeFormat = "u";
- ApiClient api = new ApiClient();
-
- // test datetime
- DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
- Assert.AreEqual("2009-06-15 20:45:30Z", api.ParameterToString(dateUtc));
- }
+ [Test ()]
+ public void TestParameterToStringForDateTimeWithUFormat ()
+ {
+ // Setup the DateTimeFormat across all of the calls
+ Configuration.Default.DateTimeFormat = "u";
+ ApiClient api = new ApiClient();
- [Test ()]
- public void TestParameterToStringForDateTimeWithCustomFormat ()
- {
- // Setup the DateTimeFormat across all of the calls
- Configuration.Default.DateTimeFormat = "dd/MM/yy HH:mm:ss";
- ApiClient api = new ApiClient();
+ // test datetime
+ DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
+ Assert.AreEqual("2009-06-15 20:45:30Z", api.ParameterToString(dateUtc));
+ }
- // test datetime
- DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
- Assert.AreEqual("15/06/09 20:45:30", api.ParameterToString(dateUtc));
- }
+ [Test ()]
+ public void TestParameterToStringForDateTimeWithCustomFormat ()
+ {
+ // Setup the DateTimeFormat across all of the calls
+ Configuration.Default.DateTimeFormat = "dd/MM/yy HH:mm:ss";
+ ApiClient api = new ApiClient();
+
+ // test datetime
+ DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
+ Assert.AreEqual("15/06/09 20:45:30", api.ParameterToString(dateUtc));
+ }
[Test ()]
public void TestSanitizeFilename ()
@@ -104,7 +109,7 @@ namespace SwaggerClientTest.TestApiClient
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("../sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("/var/tmp/sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("./sun.gif"));
-
+
Assert.AreEqual("sun", ApiClient.SanitizeFilename("sun"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("..\\sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("\\var\\tmp\\sun.gif"));
@@ -140,6 +145,5 @@ namespace SwaggerClientTest.TestApiClient
Assert.AreNotSame(p4.Configuration.ApiClient, Configuration.Default.ApiClient);
}
- }
-}
-
+ }
+}
\ No newline at end of file
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Client/ConfigurationTests.cs
similarity index 71%
rename from samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs
rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Client/ConfigurationTests.cs
index 140fd269834..936751317ab 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Client/ConfigurationTests.cs
@@ -5,16 +5,20 @@ using IO.Swagger.Client;
using IO.Swagger.Api;
using IO.Swagger.Model;
-namespace SwaggerClientTest.TestConfiguration
+namespace IO.Swagger.Test
{
- public class TestConfiguration
+ public class ConfigurationTests
{
- [TearDown ()]
- public void TearDown ()
- {
- // Reset to default, just in case
- Configuration.Default.DateTimeFormat = "o";
- }
+ public ConfigurationTests ()
+ {
+ }
+
+ [TearDown ()]
+ public void TearDown ()
+ {
+ // Reset to default, just in case
+ Configuration.Default.DateTimeFormat = "o";
+ }
[Test ()]
public void TestAuthentication ()
@@ -39,21 +43,21 @@ namespace SwaggerClientTest.TestConfiguration
Assert.AreNotSame (p.Configuration, Configuration.Default);
}
- [Test ()]
- public void TestDateTimeFormat_Default ()
- {
- // Should default to the Round-trip Format Specifier - "o"
- // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
- Assert.AreEqual("o", Configuration.Default.DateTimeFormat);
- }
+ [Test ()]
+ public void TestDateTimeFormat_Default ()
+ {
+ // Should default to the Round-trip Format Specifier - "o"
+ // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
+ Assert.AreEqual("o", Configuration.Default.DateTimeFormat);
+ }
- [Test ()]
- public void TestDateTimeFormat_UType()
- {
- Configuration.Default.DateTimeFormat = "u";
+ [Test ()]
+ public void TestDateTimeFormat_UType()
+ {
+ Configuration.Default.DateTimeFormat = "u";
- Assert.AreEqual("u", Configuration.Default.DateTimeFormat);
- }
+ Assert.AreEqual("u", Configuration.Default.DateTimeFormat);
+ }
[Test ()]
public void TestConstructor()
@@ -64,7 +68,7 @@ namespace SwaggerClientTest.TestConfiguration
}
- [Test ()]
+ [Test ()]
public void TestDefautlConfiguration ()
{
PetApi p1 = new PetApi ();
@@ -110,14 +114,16 @@ namespace SwaggerClientTest.TestConfiguration
[Test ()]
public void TestTimeout ()
{
- Configuration c1 = new Configuration();
- Assert.AreEqual(100000, c1.Timeout); // default vaue
+ Configuration c1 = new Configuration ();
+ Assert.AreEqual (100000, c1.Timeout); // default vaue
c1.Timeout = 50000;
- Assert.AreEqual(50000, c1.Timeout);
+ Assert.AreEqual (50000, c1.Timeout);
- Configuration c2 = new Configuration(timeout: 20000);
- Assert.AreEqual(20000, c2.Timeout);
+ Configuration c2 = new Configuration (timeout: 20000);
+ Assert.AreEqual (20000, c2.Timeout);
}
+
}
-}
\ No newline at end of file
+}
+
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj
index 743b0b97853..a2f1f209fa3 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj
@@ -65,7 +65,7 @@
- {C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}
+ {098D14FD-4F35-417E-9B8E-67875ACD0AD3}
IO.Swagger
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AdditionalPropertiesClassTests.cs
new file mode 100644
index 00000000000..fca6d20d0dc
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AdditionalPropertiesClassTests.cs
@@ -0,0 +1,56 @@
+using NUnit.Framework;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using IO.Swagger.Api;
+using IO.Swagger.Model;
+using IO.Swagger.Client;
+using System.Reflection;
+
+namespace IO.Swagger.Test
+{
+ ///
+ /// Class for testing AdditionalPropertiesClass
+ ///
+ ///
+ /// This file is automatically generated by Swagger Codegen.
+ /// Please update the test case below to test the model.
+ ///
+ [TestFixture]
+ public class AdditionalPropertiesClassTests
+ {
+ private AdditionalPropertiesClass instance;
+
+ ///
+ /// Setup before each test
+ ///
+ [SetUp]
+ public void Init()
+ {
+ instance = new AdditionalPropertiesClass();
+ }
+
+ ///
+ /// Clean up after each test
+ ///
+ [TearDown]
+ public void Cleanup()
+ {
+
+ }
+
+ ///
+ /// Test an instance of AdditionalPropertiesClass
+ ///
+ [Test]
+ public void AdditionalPropertiesClassInstanceTest()
+ {
+ Assert.IsInstanceOf (instance, "instance is a AdditionalPropertiesClass");
+ }
+
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalTests.cs
index 861ca5fe026..e7356e3750d 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalTests.cs
@@ -29,7 +29,7 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
- instance = new Animal();
+ instance = new Animal(ClassName: "csharp test");
}
///
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CatTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CatTests.cs
index 15cc1ab22de..72e65f60bf0 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CatTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CatTests.cs
@@ -29,7 +29,7 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
- instance = new Cat();
+ instance = new Cat(ClassName: "csharp test");
}
///
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/DogTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/DogTests.cs
index 33aa6cb51af..624c16d479d 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/DogTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/DogTests.cs
@@ -29,7 +29,7 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
- instance = new Dog();
+ instance = new Dog(ClassName: "csharp test");
}
///
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs
index 8c81c81fbb1..d2a3fc86c78 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs
@@ -50,6 +50,22 @@ namespace IO.Swagger.Test
Assert.IsInstanceOf (instance, "instance is a EnumClass");
}
+ ///
+ /// Test EnumClass
+ ///
+ [Test]
+ public void EnumClassValueTest ()
+ {
+ // test serialization for string
+ Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumClass.Abc), "\"_abc\"");
+
+ // test serialization for number
+ Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumTest.EnumIntegerEnum.NUMBER_MINUS_1), "\"-1\"");
+
+ // test cast to int
+ Assert.AreEqual ((int)EnumTest.EnumIntegerEnum.NUMBER_MINUS_1, -1);
+
+ }
}
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/FormatTestTests.cs
index 7676fcae9b9..e1d59bcc174 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/FormatTestTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/FormatTestTests.cs
@@ -29,7 +29,7 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
- instance = new FormatTest();
+ instance = new FormatTest(Number: 123, _Byte: new byte[] { 0x20 }, Date: new DateTime(2015, 1, 18), Password: "xyz");
}
///
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs
new file mode 100644
index 00000000000..e21779241db
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs
@@ -0,0 +1,72 @@
+using NUnit.Framework;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using IO.Swagger.Api;
+using IO.Swagger.Model;
+using IO.Swagger.Client;
+using System.Reflection;
+
+namespace IO.Swagger.Test
+{
+ ///
+ /// Class for testing MixedPropertiesAndAdditionalPropertiesClass
+ ///
+ ///
+ /// This file is automatically generated by Swagger Codegen.
+ /// Please update the test case below to test the model.
+ ///
+ [TestFixture]
+ public class MixedPropertiesAndAdditionalPropertiesClassTests
+ {
+ private MixedPropertiesAndAdditionalPropertiesClass instance;
+
+ ///
+ /// Setup before each test
+ ///
+ [SetUp]
+ public void Init()
+ {
+ instance = new MixedPropertiesAndAdditionalPropertiesClass();
+ }
+
+ ///
+ /// Clean up after each test
+ ///
+ [TearDown]
+ public void Cleanup()
+ {
+
+ }
+
+ ///
+ /// Test an instance of MixedPropertiesAndAdditionalPropertiesClass
+ ///
+ [Test]
+ public void MixedPropertiesAndAdditionalPropertiesClassInstanceTest()
+ {
+ Assert.IsInstanceOf (instance, "instance is a MixedPropertiesAndAdditionalPropertiesClass");
+ }
+
+ ///
+ /// Test the property 'Uuid'
+ ///
+ [Test]
+ public void UuidTest()
+ {
+ // TODO: unit test for the property 'Uuid'
+ }
+ ///
+ /// Test the property 'DateTime'
+ ///
+ [Test]
+ public void DateTimeTest()
+ {
+ // TODO: unit test for the property 'DateTime'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/NameTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/NameTests.cs
index c6c68253ca0..d8fbafe238c 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/NameTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/NameTests.cs
@@ -29,7 +29,7 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
- instance = new Name();
+ instance = new Name(_Name: 1, Property: "csharp");
}
///
diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/OrderTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/OrderTests.cs
index 9363c7409e4..2d55d2300f9 100644
--- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/OrderTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/OrderTests.cs
@@ -41,6 +41,16 @@ namespace IO.Swagger.Test
}
+ ///