Skip to content

Commit fc38d22

Browse files
committed
Merge branch 'master' into release-versioning-helper
* master: [Java][okhttp-gson] Update dependencies (OpenAPITools#3103) Link query parameter to model object (OpenAPITools#2710) scala-play-server: fix enum names for reserved words (OpenAPITools#3080) Add @Sunn to openapi generator core team (OpenAPITools#3105) fix NPE in go generator (OpenAPITools#3104) scala-play-server: fix API doc url (OpenAPITools#3096) [maven-plugin] fix strictSpec parameter without alias (OpenAPITools#3095) Ruby: Avoid double escaping path items (OpenAPITools#3093) [Golang][client] Allow generating go client code as a submodule. (OpenAPITools#3012) [CI] Test maven plugin in Travis, move jobs from Shippable to Circle CI (OpenAPITools#3087) general support to add scopes for bearer auth too (OpenAPITools#1984) feat(java-jersey2): Making response headers case-insensitive (OpenAPITools#3072) [KOTLIN Spring] fix generation with modelNamePrefix/Suffix (OpenAPITools#3038) Mark nodejs-server as deprecated (OpenAPITools#3083) Use 4.0.2-SNAPSHOT version in gradle samples (OpenAPITools#3085)
2 parents 7f0813c + 19f47d0 commit fc38d22

File tree

116 files changed

+1147
-748
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1147
-748
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ script:
131131
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
132132
- mvn --quiet --batch-mode --show-version clean install
133133
- mvn --quiet --batch-mode --show-version verify -Psamples
134+
# test maven plugin
135+
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml
136+
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
134137
after_success:
135138
# push to maven repo
136139
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then

CI/circle_parallel.sh

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ if [ "$NODE_INDEX" = "1" ]; then
1212
#cp CI/pom.xml.circleci pom.xml
1313
java -version
1414
mvn --quiet verify -Psamples.circleci
15+
16+
# generate all petstore samples (client, servers, doc)
17+
./bin/run-all-petstore
18+
# generate all petstore samples (openapi3)
19+
./bin/openapi3/run-all-petstore
20+
# generate test scripts
21+
./bin/tests/run-all-test
22+
# test all generators with fake petstore spec (2.0, 3.0)
23+
./bin/utils/test-fake-petstore-for-all.sh
1524
elif [ "$NODE_INDEX" = "2" ]; then
1625
# run ensure-up-to-date sample script on SNAPSHOT version only
1726
project_version=`mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout`

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ OpenAPI Generator core team members are contributors who have been making signif
604604
* [@cbornet](https://github.com/cbornet) (2016/05)
605605
* [@ackintosh](https://github.com/ackintosh) (2018/02) [:heart:](https://www.patreon.com/ackintosh/overview)
606606
* [@jmini](https://github.com/jmini) (2018/04)
607+
* [@sunn](https://github.com/sunn) (2019/06)
607608

608609
:heart: = Link to support the contributor directly
609610

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ build_script:
5050
# install openapi-generator locally
5151
- mvn clean install --quiet
5252
# run the locally installed openapi-generator-gradle-plugin
53-
- gradle -PopenApiGeneratorVersion=4.0.2-SNAPSHOT -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
53+
- gradle -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
5454
test_script:
5555
# restore test-related files
5656
- copy /b/v/y CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj

bin/nodejs-petstore-google-cloud-functions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
30+
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/nodejs-petstore-server.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server -o samples/server/petstore/nodejs -Dservice $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/nodejs-petstore-google-cloud-functions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
30+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/nodejs-petstore-server.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server -o samples/server/petstore/nodejs -Dservice $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/utils/ensure-up-to-date

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ declare -a scripts=(
5151
"./bin/csharp-netcore-petstore-all.sh"
5252
"./bin/elixir-petstore.sh"
5353
"./bin/go-petstore.sh"
54+
"./bin/go-petstore-withxml.sh"
5455
"./bin/go-gin-petstore-server.sh"
5556
"./bin/groovy-petstore.sh"
5657
"./bin/apex-petstore.sh"

docs/generators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The following generators are available:
9191
- [jaxrs-spec](generators/jaxrs-spec.md)
9292
- [kotlin-server](generators/kotlin-server.md)
9393
- [kotlin-spring](generators/kotlin-spring.md)
94-
- [nodejs-server](generators/nodejs-server.md)
94+
- [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated)
9595
- [php-laravel](generators/php-laravel.md)
9696
- [php-lumen](generators/php-lumen.md)
9797
- [php-silex](generators/php-silex.md)

docs/generators/go.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sidebar_label: go
1010
|packageName|Go package name (convention: lowercase).| |openapi|
1111
|packageVersion|Go package version.| |1.0.0|
1212
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
13+
|isGoSubmodule|whether the generated Go module is a submodule| |false|
1314
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
1415
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
1516
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|

docs/generators/java.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ sidebar_label: java
5454
|useRuntimeException|Use RuntimeException instead of Exception| |false|
5555
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
5656
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
57-
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive in okhttp-gson library| |false|
57+
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
5858
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
---
3+
id: generator-opts-server-nodejs-server-deprecated
4+
title: Config Options for nodejs-server-deprecated
5+
sidebar_label: nodejs-server-deprecated
6+
---
7+
8+
| Option | Description | Values | Default |
9+
| ------ | ----------- | ------ | ------- |
10+
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
11+
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
12+
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
13+
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
14+
|googleCloudFunctions|When specified, it will generate the code which runs within Google Cloud Functions instead of standalone Node.JS server. See https://cloud.google.com/functions/docs/quickstart for the details of how to deploy the generated code.| |false|
15+
|exportedName|When the generated code will be deployed to Google Cloud Functions, this option can be used to update the name of the exported function. By default, it refers to the basePath. This does not affect normal standalone nodejs server code.| |null|
16+
|serverPort|TCP port to listen on.| |null|

modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ public class CodeGenMojo extends AbstractMojo {
244244
/**
245245
* To treat a document strictly against the spec.
246246
*/
247-
@Parameter(name = "strictSpecBehavior", alias = "strictSpec", property = "openapi.generator.maven.plugin.strictSpec", required = false)
248-
private Boolean strictSpecBehavior;
247+
@Parameter(name = "strictSpec", property = "openapi.generator.maven.plugin.strictSpec", required = false)
248+
private Boolean strictSpec;
249249

250250
/**
251251
* To generate alias (array, map) as model
@@ -471,8 +471,8 @@ public void execute() throws MojoExecutionException {
471471
configurator.setValidateSpec(!skipValidateSpec);
472472
}
473473

474-
if (strictSpecBehavior != null) {
475-
configurator.setStrictSpecBehavior(strictSpecBehavior);
474+
if (strictSpec != null) {
475+
configurator.setStrictSpecBehavior(strictSpec);
476476
}
477477

478478
if (logToStderr != null) {

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public class CodegenConstants {
6969
public static final String WITH_GO_CODEGEN_COMMENT = "withGoCodegenComment";
7070
public static final String WITH_GO_CODEGEN_COMMENT_DESC = "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs";
7171

72+
public static final String IS_GO_SUBMODULE = "isGoSubmodule";
73+
public static final String IS_GO_SUBMODULE_DESC = "whether the generated Go module is a submodule";
74+
7275
public static final String GROUP_ID = "groupId";
7376
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
7477

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CodegenSecurity {
3838
// Oauth specific
3939
public String flow, authorizationUrl, tokenUrl;
4040
public List<Map<String, Object>> scopes;
41-
public Boolean isCode, isPassword, isApplication, isImplicit;
41+
public Boolean isCode, isPassword, isApplication, isImplicit, hasScopes;
4242

4343
@Override
4444
public String toString() {

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

+8
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
22102210
// property.baseType = getSimpleRef(p.get$ref());
22112211
//}
22122212
// --END of revision
2213+
property.isModel = ModelUtils.isModel(p);
22132214
setNonArrayMapProperty(property, type);
22142215
}
22152216

@@ -3035,6 +3036,9 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
30353036
} else {
30363037
codegenParameter.dataType = codegenProperty.dataType;
30373038
}
3039+
if (ModelUtils.isObjectSchema(parameterSchema)) {
3040+
codegenProperty.complexType = codegenParameter.dataType;
3041+
}
30383042
codegenParameter.dataFormat = codegenProperty.dataFormat;
30393043
codegenParameter.required = codegenProperty.required;
30403044

@@ -3221,6 +3225,10 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
32213225
* @return data type
32223226
*/
32233227
protected String getParameterDataType(Parameter parameter, Schema schema) {
3228+
if (parameter.get$ref() != null) {
3229+
String refName = ModelUtils.getSimpleRef(parameter.get$ref());
3230+
return toModelName(refName);
3231+
}
32243232
return null;
32253233
}
32263234

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java

+34
Original file line numberDiff line numberDiff line change
@@ -1051,13 +1051,47 @@ private void processOperation(String resourcePath, String httpMethod, Operation
10511051
if (securities != null && securities.isEmpty()) {
10521052
continue;
10531053
}
1054+
10541055
Map<String, SecurityScheme> authMethods = getAuthMethods(securities, securitySchemes);
10551056
if (authMethods == null || authMethods.isEmpty()) {
10561057
authMethods = getAuthMethods(globalSecurities, securitySchemes);
10571058
}
10581059

10591060
if (authMethods != null && !authMethods.isEmpty()) {
10601061
codegenOperation.authMethods = config.fromSecurity(authMethods);
1062+
List<Map<String, Object>> scopes = new ArrayList<Map<String, Object>>();
1063+
if (codegenOperation.authMethods != null){
1064+
for (CodegenSecurity security : codegenOperation.authMethods){
1065+
if (security != null && security.isBasicBearer != null && security.isBasicBearer &&
1066+
securities != null){
1067+
for (SecurityRequirement req : securities){
1068+
if (req == null) continue;
1069+
for (String key : req.keySet()){
1070+
if (security.name != null && key.equals(security.name)){
1071+
int count = 0;
1072+
for (String sc : req.get(key)){
1073+
Map<String, Object> scope = new HashMap<String, Object>();
1074+
scope.put("scope", sc);
1075+
scope.put("description", "");
1076+
count++;
1077+
if (req.get(key) != null && count < req.get(key).size()){
1078+
scope.put("hasMore", "true");
1079+
} else {
1080+
scope.put("hasMore", null);
1081+
}
1082+
scopes.add(scope);
1083+
}
1084+
//end this inner for
1085+
break;
1086+
}
1087+
}
1088+
1089+
}
1090+
security.hasScopes = scopes.size() > 0;
1091+
security.scopes = scopes;
1092+
}
1093+
}
1094+
}
10611095
codegenOperation.hasAuthMethods = true;
10621096
}
10631097

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java

+13
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
3333
protected String packageVersion = "1.0.0";
3434
protected String apiDocPath = "docs/";
3535
protected String modelDocPath = "docs/";
36+
protected boolean isGoSubmodule = false;
3637
public static final String WITH_GO_CODEGEN_COMMENT = "withGoCodegenComment";
3738
public static final String WITH_XML = "withXml";
3839

@@ -51,6 +52,7 @@ public GoClientCodegen() {
5152
// default HIDE_GENERATION_TIMESTAMP to true
5253
hideGenerationTimestamp = Boolean.TRUE;
5354

55+
cliOptions.add(CliOption.newBoolean(CodegenConstants.IS_GO_SUBMODULE, CodegenConstants.IS_GO_SUBMODULE_DESC));
5456
cliOptions.add(CliOption.newBoolean(WITH_GO_CODEGEN_COMMENT, "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs"));
5557
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
5658

@@ -111,6 +113,13 @@ public void processOpts() {
111113
additionalProperties.put(WITH_XML, "true");
112114
}
113115
}
116+
117+
if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) {
118+
setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString()));
119+
if (isGoSubmodule) {
120+
additionalProperties.put(CodegenConstants.IS_GO_SUBMODULE, "true");
121+
}
122+
}
114123
}
115124

116125
/**
@@ -184,4 +193,8 @@ public void setPackageVersion(String packageVersion) {
184193
this.packageVersion = packageVersion;
185194
}
186195

196+
public void setIsGoSubmodule(boolean isGoSubmodule) {
197+
this.isGoSubmodule = isGoSubmodule;
198+
}
199+
187200
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public JavaClientCodegen() {
124124
cliOptions.add(CliOption.newBoolean(USE_RUNTIME_EXCEPTION, "Use RuntimeException instead of Exception"));
125125
cliOptions.add(CliOption.newBoolean(FEIGN_VERSION, "Version of OpenFeign: '10.x', '9.x' (default)"));
126126
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
127-
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive in " + OKHTTP_GSON + " library"));
127+
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
128128

129129

130130
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");

0 commit comments

Comments
 (0)