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/AbstractCSharpCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java
index 128686b615b1..386e37e3f0df 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java
@@ -77,6 +77,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
"string",
"bool?",
"double?",
+ "decimal?",
"int?",
"long?",
"float?",
@@ -112,7 +113,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("float", "float?");
typeMapping.put("long", "long?");
typeMapping.put("double", "double?");
- typeMapping.put("number", "double?");
+ typeMapping.put("number", "decimal?");
typeMapping.put("datetime", "DateTime?");
typeMapping.put("date", "DateTime?");
typeMapping.put("file", "System.IO.Stream");
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 99fab6e5444a..fbb2831ab8b5 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
@@ -8,10 +8,12 @@ import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.*;
-public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
-{
+public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen {
/**
* Name of the sub-directory in "src/main/resource" where to find the
* Mustache template for the JAX-RS Codegen.
@@ -19,10 +21,13 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS";
protected String implFolder = "src/main/java";
protected String title = "Swagger Server";
+ static Logger LOGGER = LoggerFactory.getLogger(AbstractJavaJAXRSServerCodegen.class);
public AbstractJavaJAXRSServerCodegen()
{
super();
+ dateLibrary = "legacy";
+ apiTestTemplateFiles.clear(); // TODO: add test template
}
@Override
@@ -198,4 +203,5 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
public boolean shouldOverwrite(String filename) {
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
}
+
}
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 9e30ae657c82..cc41f3ea297a 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 58b59f713646..d11cc6ce0a35 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/";
@@ -418,6 +419,15 @@ 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() {
@@ -456,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 d9f9ff3a4776..4265f67709cd 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";
@@ -228,17 +233,29 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
clientPackageDir, "ApiException.cs"));
supportingFiles.add(new SupportingFile("ApiResponse.mustache",
clientPackageDir, "ApiResponse.cs"));
+ supportingFiles.add(new SupportingFile("ExceptionFactory.mustache",
+ clientPackageDir, "ExceptionFactory.cs"));
supportingFiles.add(new SupportingFile("compile.mustache", "", "build.bat"));
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "build.sh"));
+ // shell script to run the nunit test
+ supportingFiles.add(new SupportingFile("mono_nunit_test.mustache", "", "mono_nunit_test.sh"));
// 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"));
+ // .travis.yml for travis-ci.org CI
+ supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
+
+ 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"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
+ // apache v2 license
+ // UPDATE (20160612) no longer needed as the Apache v2 LICENSE is added globally
+ //supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
if (optionalAssemblyInfoFlag) {
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs"));
@@ -247,11 +264,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/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java
new file mode 100644
index 000000000000..f8299fc60cd8
--- /dev/null
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java
@@ -0,0 +1,380 @@
+package io.swagger.codegen.languages;
+
+import io.swagger.codegen.*;
+import io.swagger.codegen.examples.ExampleGenerator;
+import io.swagger.models.Model;
+import io.swagger.models.Operation;
+import io.swagger.models.Response;
+import io.swagger.models.Swagger;
+import io.swagger.models.properties.*;
+
+import java.util.*;
+import java.io.File;
+
+public class CppRestClientCodegen extends DefaultCodegen implements CodegenConfig {
+
+ public static final String DECLSPEC = "declspec";
+ public static final String DEFAULT_INCLUDE = "defaultInclude";
+
+ protected String packageVersion = "1.0.0";
+ protected String declspec = "";
+ protected String defaultInclude = "";
+
+ /**
+ * Configures the type of generator.
+ *
+ * @return the CodegenType for this generator
+ * @see io.swagger.codegen.CodegenType
+ */
+ public CodegenType getTag() {
+ return CodegenType.CLIENT;
+ }
+
+ /**
+ * Configures a friendly name for the generator. This will be used by the
+ * generator to select the library with the -l flag.
+ *
+ * @return the friendly name for the generator
+ */
+ public String getName() {
+ return "cpprest";
+ }
+
+ /**
+ * Returns human-friendly help for the generator. Provide the consumer with
+ * help tips, parameters here
+ *
+ * @return A string value for the help message
+ */
+ public String getHelp() {
+ return "Generates a C++ API client with C++ REST SDK (https://github.com/Microsoft/cpprestsdk).";
+ }
+
+ public CppRestClientCodegen() {
+ super();
+
+ apiPackage = "io.swagger.client.api";
+ modelPackage = "io.swagger.client.model";
+
+ modelTemplateFiles.put("model-header.mustache", ".h");
+ modelTemplateFiles.put("model-source.mustache", ".cpp");
+
+ apiTemplateFiles.put("api-header.mustache", ".h");
+ apiTemplateFiles.put("api-source.mustache", ".cpp");
+
+ templateDir = "cpprest";
+
+ cliOptions.clear();
+
+ // CLI options
+ addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).",
+ this.modelPackage);
+ addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).",
+ this.apiPackage);
+ addOption(CodegenConstants.PACKAGE_VERSION, "C++ package version.", this.packageVersion);
+ addOption(DECLSPEC, "C++ preprocessor to place before the class name for handling dllexport/dllimport.",
+ this.declspec);
+ addOption(DEFAULT_INCLUDE,
+ "The default include statement that should be placed in all headers for including things like the declspec (convention: #include \"Commons.h\" ",
+ this.defaultInclude);
+
+ reservedWords = new HashSet();
+
+ supportingFiles.add(new SupportingFile("modelbase-header.mustache", "", "ModelBase.h"));
+ supportingFiles.add(new SupportingFile("modelbase-source.mustache", "", "ModelBase.cpp"));
+ supportingFiles.add(new SupportingFile("apiclient-header.mustache", "", "ApiClient.h"));
+ supportingFiles.add(new SupportingFile("apiclient-source.mustache", "", "ApiClient.cpp"));
+ supportingFiles.add(new SupportingFile("apiconfiguration-header.mustache", "", "ApiConfiguration.h"));
+ supportingFiles.add(new SupportingFile("apiconfiguration-source.mustache", "", "ApiConfiguration.cpp"));
+ supportingFiles.add(new SupportingFile("apiexception-header.mustache", "", "ApiException.h"));
+ supportingFiles.add(new SupportingFile("apiexception-source.mustache", "", "ApiException.cpp"));
+ supportingFiles.add(new SupportingFile("ihttpbody-header.mustache", "", "IHttpBody.h"));
+ supportingFiles.add(new SupportingFile("jsonbody-header.mustache", "", "JsonBody.h"));
+ supportingFiles.add(new SupportingFile("jsonbody-source.mustache", "", "JsonBody.cpp"));
+ supportingFiles.add(new SupportingFile("httpcontent-header.mustache", "", "HttpContent.h"));
+ supportingFiles.add(new SupportingFile("httpcontent-source.mustache", "", "HttpContent.cpp"));
+ supportingFiles.add(new SupportingFile("multipart-header.mustache", "", "MultipartFormData.h"));
+ supportingFiles.add(new SupportingFile("multipart-source.mustache", "", "MultipartFormData.cpp"));
+ supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
+ supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
+
+ languageSpecificPrimitives = new HashSet(
+ Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
+
+ typeMapping = new HashMap();
+ typeMapping.put("date", "utility::datetime");
+ typeMapping.put("DateTime", "utility::datetime");
+ typeMapping.put("string", "utility::string_t");
+ typeMapping.put("integer", "int32_t");
+ typeMapping.put("long", "int64_t");
+ typeMapping.put("boolean", "bool");
+ typeMapping.put("array", "std::vector");
+ typeMapping.put("map", "std::map");
+ typeMapping.put("file", "HttpContent");
+ typeMapping.put("object", "Object");
+ typeMapping.put("binary", "std::string");
+
+ super.importMapping = new HashMap();
+ importMapping.put("std::vector", "#include ");
+ importMapping.put("std::map", "#include