Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Jun 15, 2017
2 parents 29a0159 + 85850b2 commit fee5415
Show file tree
Hide file tree
Showing 282 changed files with 5,770 additions and 721 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ samples/client/petstore/java/hello.txt
samples/client/petstore/java/okhttp-gson/hello.txt
samples/client/petstore/java/jersey1/hello.txt
samples/client/petstore/java/jersey2-java8/hello.txt
samples/client/petstore/java/jersey2/hello.txt
samples/client/petstore/android/default/hello.txt
samples/client/petstore/android/volley/.gradle/
samples/client/petstore/android/volley/build/
Expand Down Expand Up @@ -159,4 +160,3 @@ samples/client/petstore/typescript-node/npm/npm-debug.log

# aspnetcore
samples/server/petstore/aspnetcore/.vs/

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:

- **API clients**: **ActionScript**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign), **Kotlin**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Restbed), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
- **API documentation generators**: **HTML**, **Confluence Wiki**
- **Others**: **JMeter**

Expand Down Expand Up @@ -932,6 +932,7 @@ Here is a list of template creators:
* Server Stubs
* C# ASP.NET5: @jimschubert
* C# NancyFX: @mstefaniuk
* C++ Pistache: @sebymiano
* C++ Restbed: @stkrwork
* Erlang Server: @galaxie
* Go Server: @guohuang
Expand Down
31 changes: 31 additions & 0 deletions bin/pistache-server-petstore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -l pistache-server -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/pistache-server"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class CodegenConstants {
public static final String ENSURE_UNIQUE_PARAMS = "ensureUniqueParams";
public static final String ENSURE_UNIQUE_PARAMS_DESC = "Whether to ensure parameter names are unique in an operation (rename parameters that are not).";

public static final String PROJECT_NAME = "projectName";
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_VERSION = "packageVersion";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public boolean isRestfulIndex() {
* @return true if act as Restful show method, false otherwise
*/
public boolean isRestfulShow() {
return "GET".equals(httpMethod) && isMemberPath();
return "GET".equalsIgnoreCase(httpMethod) && isMemberPath();
}

/**
Expand All @@ -127,7 +127,7 @@ public boolean isRestfulShow() {
* @return true if act as Restful create method, false otherwise
*/
public boolean isRestfulCreate() {
return "POST".equals(httpMethod) && "".equals(pathWithoutBaseName());
return "POST".equalsIgnoreCase(httpMethod) && "".equals(pathWithoutBaseName());
}

/**
Expand All @@ -136,7 +136,7 @@ public boolean isRestfulCreate() {
* @return true if act as Restful update method, false otherwise
*/
public boolean isRestfulUpdate() {
return Arrays.asList("PUT", "PATCH").contains(httpMethod) && isMemberPath();
return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isMemberPath();
}

/**
Expand All @@ -145,7 +145,7 @@ public boolean isRestfulUpdate() {
* @return true if act as Restful destroy method, false otherwise
*/
public boolean isRestfulDestroy() {
return "DELETE".equals(httpMethod) && isMemberPath();
return "DELETE".equalsIgnoreCase(httpMethod) && isMemberPath();
}

/**
Expand Down Expand Up @@ -173,7 +173,6 @@ private String pathWithoutBaseName() {
*/
private boolean isMemberPath() {
if (pathParams.size() != 1) return false;

String id = pathParams.get(0).baseName;
return ("/{" + id + "}").equals(pathWithoutBaseName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public FlaskConnexionCodegen() {
defaultValue("default_controller"));
cliOptions.add(new CliOption(SUPPORT_PYTHON2, "support python2").
defaultValue("false"));
cliOptions.add(new CliOption("serverPort", "TCP port to listen to in app.run").
defaultValue("8080"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.*;
import io.swagger.models.properties.*;
import io.swagger.models.Swagger;

import java.util.TreeSet;
import java.util.*;
Expand All @@ -11,8 +12,14 @@
import org.apache.commons.lang3.StringUtils;

public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig {

public static final String USE_ES6 = "useEs6";

protected boolean useEs6;

public JavascriptClosureAngularClientCodegen() {
super();
outputFolder = "generated-code/javascript-closure-angular";

supportsInheritance = false;
setReservedWordsLowerCase(Arrays.asList("abstract",
Expand Down Expand Up @@ -64,15 +71,11 @@ public JavascriptClosureAngularClientCodegen() {

typeMapping.put("binary", "string");

outputFolder = "generated-code/javascript-closure-angular";
modelTemplateFiles.put("model.mustache", ".js");
apiTemplateFiles.put("api.mustache", ".js");
embeddedTemplateDir = templateDir = "Javascript-Closure-Angular";
apiPackage = "API.Client";
modelPackage = "API.Client";

cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(USE_ES6,
"use ES6 templates")
.defaultValue(Boolean.FALSE.toString()));
}

@Override
Expand All @@ -83,6 +86,28 @@ public void processOpts() {
if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
}

if (additionalProperties.containsKey(USE_ES6)) {
setUseEs6(convertPropertyToBooleanAndWriteBack(USE_ES6));
}
}

@Override
public void preprocessSwagger(Swagger swagger) {
super.preprocessSwagger(swagger);

if (useEs6) {
embeddedTemplateDir = templateDir = "Javascript-Closure-Angular/es6";
apiPackage = "resources";
apiTemplateFiles.put("api.mustache", ".js");
supportingFiles.add(new SupportingFile("module.mustache", "", "module.js"));
} else {
modelTemplateFiles.put("model.mustache", ".js");
apiTemplateFiles.put("api.mustache", ".js");
embeddedTemplateDir = templateDir = "Javascript-Closure-Angular";
apiPackage = "API.Client";
modelPackage = "API.Client";
}
}

@Override
Expand All @@ -102,7 +127,7 @@ public CodegenType getTag() {
}

@Override
public String escapeReservedWord(String name) {
public String escapeReservedWord(String name) {
if(this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
Expand All @@ -121,7 +146,7 @@ public String modelFileFolder() {
@Override
public String toVarName(String name) {
// sanitize name
name = sanitizeName(name);
name = sanitizeName(name);

// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
Expand Down Expand Up @@ -273,4 +298,7 @@ public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}

public void setUseEs6(boolean useEs6) {
this.useEs6 = useEs6;
}
}
Loading

0 comments on commit fee5415

Please sign in to comment.