Skip to content

Commit deebee4

Browse files
committed
Merge remote-tracking branch 'origin/master' into nodejs-express-server
2 parents cf98d8f + 2c4fdd0 commit deebee4

File tree

1,093 files changed

+24210
-10408
lines changed

Some content is hidden

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

1,093 files changed

+24210
-10408
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>TypeScriptAngularBuildPestoreClientTests</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>TS Fetch Multiple Parameters Petstore Client</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
</plugins>
25+
</build>
26+
</project>

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ openapi-generator-cli version # is always 3.0.2, unless any of the above overrid
217217

218218
To build from source, you need the following installed and available in your `$PATH:`
219219

220-
* [Java 8](http://java.oracle.com)
220+
* [Java 8](https://www.oracle.com/technetwork/java/index.html)
221221

222-
* [Apache Maven 3.3.4 or greater](http://maven.apache.org/)
222+
* [Apache Maven 3.3.4 or greater](https://maven.apache.org/)
223223

224224
After cloning the project, you can build it from source with this command:
225225
```sh
@@ -342,7 +342,7 @@ Right now: no solution for this one :|
342342
#### Run Docker in Vagrant
343343
Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
344344
```sh
345-
git clone http://github.com/openapitools/openapi-generator.git
345+
git clone https://github.com/openapitools/openapi-generator.git
346346
cd openapi-generator
347347
vagrant up
348348
vagrant ssh
@@ -500,8 +500,8 @@ Please refer to [integration.md](docs/integration.md) on how to integrate OpenAP
500500

501501
Here are the public online services:
502502

503-
- latest stable version: http://api.openapi-generator.tech
504-
- latest master: http://api-latest-master.openapi-generator.tech (updated with latest master every hour)
503+
- latest stable version: https://api.openapi-generator.tech
504+
- latest master: https://api-latest-master.openapi-generator.tech (updated with latest master every hour)
505505

506506
The server is sponsored by [Linode](https://www.linode.com/) [![Linode Logo](https://www.linode.com/media/images/logos/standard/light/linode-logo_standard_light_small.png)](https://www.linode.com/)
507507

@@ -597,6 +597,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
597597
- 2019-07-04 - [REST API のためのコード生成入門 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh), [和田拓朗](https://github.com/taxpon)
598598
- 2019-07-08 - [OpenAPI Generator にコントリビュートしたら社名が載った話。(CAM) - CAM TECH BLOG](https://tech.cam-inc.co.jp/entry/2019/07/08/140000) by [CAM, Inc.](https://www.cam-inc.co.jp/)
599599
- 2019-07-14 - [OpenAPI GeneratorでPythonのクライアントライブラリを作成した](https://qiita.com/yuji38kwmt/items/dfb929316a1335a161c0) by [yuji38kwmt](https://qiita.com/yuji38kwmt)
600+
- 2019-07-19 - [Developer Experience (DX) for Open-Source Projects: How to Engage Developers and Build a Growing Developer Community](https://speakerdeck.com/wing328/developer-experience-dx-for-open-source-projects-english-japanese) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh) at [Open Source Summit Japan 2019](https://events.linuxfoundation.org/events/open-source-summit-japan-2019/)
600601

601602
## [6 - About Us](#table-of-contents)
602603

@@ -774,7 +775,7 @@ If you want to join the committee, please kindly apply by sending an email to te
774775
| Elm | @eriktim (2018/09) |
775776
| Erlang | @tsloughter (2017/11) @jfacorro (2018/10) @robertoaloi (2018/10) |
776777
| F# | @nmfisher (2019/05) |
777-
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09 |
778+
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09) |
778779
| GraphQL | @renepardon (2018/12) |
779780
| Groovy | |
780781
| Haskell | |
@@ -862,7 +863,7 @@ Copyright 2018 SmartBear Software
862863

863864
Licensed under the Apache License, Version 2.0 (the "License");
864865
you may not use this file except in compliance with the License.
865-
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
866+
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
866867

867868
Unless required by applicable law or agreed to in writing, software
868869
distributed under the License is distributed on an "AS IS" BASIS,

bin/cpp-qt5-petstore.sh

Lines changed: 1 addition & 1 deletion
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/cpp-qt5-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-qt5-client -o samples/client/petstore/cpp-qt5 $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-qt5-client -o samples/client/petstore/cpp-qt5 $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/go-experimental-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ rm -rf $STUB_DIR
3434

3535
# if you've executed sbt assembly previously it will use that instead.
3636
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
37-
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
37+
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR --additional-properties packageName=petstore $@"
3838

3939
java $JAVA_OPTS -jar $executable $ags

bin/swift4-petstore-objcCompatible.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-objcCompatible.json -o samples/client/petstore/swift4/objcCompatible $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
34+
if type "xcodegen" > /dev/null 2>&1; then
35+
cd samples/client/petstore/swift4/objcCompatible
36+
xcodegen generate
37+
fi
38+
39+
if type "swiftlint" > /dev/null 2>&1; then
40+
cd samples/client/petstore/swift4/objcCompatible
41+
swiftlint autocorrect
42+
fi

bin/swift4-petstore-promisekit.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-promisekit.json -o samples/client/petstore/swift4/promisekit --generate-alias-as-model $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
34+
if type "xcodegen" > /dev/null 2>&1; then
35+
cd samples/client/petstore/swift4/promisekit
36+
xcodegen generate
37+
fi
38+
39+
if type "swiftlint" > /dev/null 2>&1; then
40+
cd samples/client/petstore/swift4/promisekit
41+
swiftlint autocorrect
42+
fi

bin/swift4-petstore-rxswift.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-rxswift.json -o samples/client/petstore/swift4/rxswift --generate-alias-as-model $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
34+
if type "xcodegen" > /dev/null 2>&1; then
35+
cd samples/client/petstore/swift4/rxswift
36+
xcodegen generate
37+
fi
38+
39+
if type "swiftlint" > /dev/null 2>&1; then
40+
cd samples/client/petstore/swift4/rxswift
41+
swiftlint autocorrect
42+
fi

bin/swift4-petstore-unwrapRequired.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-unwrapRequired.json -o samples/client/petstore/swift4/unwrapRequired --generate-alias-as-model $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
34+
if type "xcodegen" > /dev/null 2>&1; then
35+
cd samples/client/petstore/swift4/unwrapRequired
36+
xcodegen generate
37+
fi
38+
39+
if type "swiftlint" > /dev/null 2>&1; then
40+
cd samples/client/petstore/swift4/unwrapRequired
41+
swiftlint autocorrect
42+
fi

bin/swift4-petstore.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore.json -o samples/client/petstore/swift4/default --generate-alias-as-model $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
34+
if type "xcodegen" > /dev/null 2>&1; then
35+
cd samples/client/petstore/swift4/default
36+
xcodegen generate
37+
fi
38+
39+
if type "swiftlint" > /dev/null 2>&1; then
40+
cd samples/client/petstore/swift4/default
41+
swiftlint autocorrect
42+
fi

bin/swift4-test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift4Test.json -g swift4 -c ./bin/swift4-test.json -o samples/client/test/swift4/default $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
34+
if type "xcodegen" > /dev/null 2>&1; then
35+
cd samples/client/test/swift4/default
36+
xcodegen generate
37+
fi
38+
39+
if type "swiftlint" > /dev/null 2>&1; then
40+
cd samples/client/test/swift4/default
41+
swiftlint autocorrect
42+
fi

bin/typescript-fetch-petstore-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
./bin/typescript-fetch-petstore-with-npm-version.sh
55
./bin/typescript-fetch-petstore-interfaces.sh
66
./bin/typescript-fetch-petstore.sh
7+
./bin/typescript-fetch-petstore-multiple-parameters.sh
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"snapshot" : false,
3+
"useSingleRequestParameter": false
4+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
echo "# START SCRIPT: $SCRIPT"
5+
6+
while [ -h "$SCRIPT" ] ; do
7+
ls=`ls -ld "$SCRIPT"`
8+
link=`expr "$ls" : '.*-> \(.*\)$'`
9+
if expr "$link" : '/.*' > /dev/null; then
10+
SCRIPT="$link"
11+
else
12+
SCRIPT=`dirname "$SCRIPT"`/"$link"
13+
fi
14+
done
15+
16+
if [ ! -d "${APP_DIR}" ]; then
17+
APP_DIR=`dirname "$SCRIPT"`/..
18+
APP_DIR=`cd "${APP_DIR}"; pwd`
19+
fi
20+
21+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
22+
23+
if [ ! -f "$executable" ]
24+
then
25+
mvn -B clean package
26+
fi
27+
28+
# if you've executed sbt assembly previously it will use that instead.
29+
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 typescript-fetch -c bin/typescript-fetch-petstore-multiple-parameters.json -o samples/client/petstore/typescript-fetch/builds/multiple-parameters $@"
31+
32+
java $JAVA_OPTS -jar $executable $ags
33+
cp CI/samples.ci/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml samples/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml
34+
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml

bin/windows/typescript-fetch-petstore-all.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ call bin\windows\typescript-fetch-petstore.bat
44
call bin\windows\typescript-fetch-petstore-target-es6.bat
55
call bin\windows\typescript-fetch-petstore-with-npm-version.bat
66
call bin\windows\typescript-fetch-petstore-interfaces.bat
7+
call bin\windows\typescript-fetch-petstore-multiple-parameters.bat
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@ECHO OFF
2+
3+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
4+
5+
If Not Exist %executable% (
6+
mvn clean package
7+
)
8+
9+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
10+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-fetch -c bin\typescript-fetch-petstore-multiple-parameters.json -o samples\client\petstore\typescript-fetch\builds\multiple-parameters
11+
12+
java %JAVA_OPTS% -jar %executable% %ags%

docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [[ -f "${codegen}" && -n "$(java ${JAVA_OPTS} -jar "${codegen}" completion |
1919
command=$1
2020
shift
2121
exec java ${JAVA_OPTS} -jar "${codegen}" "${command}" "$@"
22-
elif [[ -n "$(echo commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
22+
elif [[ -n "$(echo $commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
2323
# If CLI jar does not exist, and $1 is a known CLI command, build the CLI jar and run that command.
2424
if [[ ! -f "${codegen}" ]]; then
2525
(cd "${GEN_DIR}" && exec mvn -am -pl "modules/openapi-generator-cli" -Duser.home=$(dirname $MAVEN_CONFIG) package)

docs/debugging.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,26 @@ The steps are shown here for a specific version of the generator, but apply the
6262
Listening for transport dt_socket at address: 5005
6363
```
6464
* Set breakpoints in code, and then attach your remote debugger from your IDE (see above). The generator will automatically unblock once the remote debugger is attached. You can now step through the code.
65+
66+
## Logs
67+
68+
You can try to enable debugging log with `-Dlog.level=debug` option to the `JAVA_OPTS` environment variable to see more information:
69+
70+
```bash
71+
export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug"
72+
```
73+
74+
Set the option then DEBUG logs are printed out:
75+
76+
```bash
77+
openapi-generator generate -g go ...
78+
79+
...
80+
...
81+
[main] DEBUG o.o.codegen.DefaultCodegen - debugging fromProperty for files : class Schema {
82+
type: null
83+
format: null
84+
$ref: #/components/schemas/File
85+
...
86+
...
87+
```

docs/generators/typescript-fetch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ sidebar_label: typescript-fetch
1818
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1919
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
2020
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
21+
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|

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

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
import com.fasterxml.jackson.core.JsonProcessingException;
2121
import com.google.common.base.CaseFormat;
22+
import com.google.common.collect.ImmutableMap;
23+
import com.samskivert.mustache.Mustache;
2224
import com.samskivert.mustache.Mustache.Compiler;
25+
import com.samskivert.mustache.Mustache.Lambda;
26+
2327
import io.swagger.v3.core.util.Json;
2428
import io.swagger.v3.oas.models.OpenAPI;
2529
import io.swagger.v3.oas.models.Operation;
@@ -48,6 +52,11 @@
4852
import org.openapitools.codegen.meta.Stability;
4953
import org.openapitools.codegen.serializer.SerializerUtils;
5054
import org.openapitools.codegen.templating.MustacheEngineAdapter;
55+
import org.openapitools.codegen.templating.mustache.CamelCaseLambda;
56+
import org.openapitools.codegen.templating.mustache.IndentedLambda;
57+
import org.openapitools.codegen.templating.mustache.LowercaseLambda;
58+
import org.openapitools.codegen.templating.mustache.TitlecaseLambda;
59+
import org.openapitools.codegen.templating.mustache.UppercaseLambda;
5160
import org.openapitools.codegen.utils.ModelUtils;
5261
import org.slf4j.Logger;
5362
import org.slf4j.LoggerFactory;
@@ -199,6 +208,47 @@ public void processOpts() {
199208
}
200209
}
201210

211+
/***
212+
* Preset map builder with commonly used Mustache lambdas.
213+
*
214+
* To extend the map, override addMustacheLambdas(), call parent method
215+
* first and then add additional lambdas to the returned builder.
216+
*
217+
* If common lambdas are not desired, override addMustacheLambdas() method
218+
* and return empty builder.
219+
*
220+
* @return preinitialized map builder with common lambdas
221+
*/
222+
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
223+
224+
return new ImmutableMap.Builder<String, Mustache.Lambda>()
225+
.put("lowercase", new LowercaseLambda().generator(this))
226+
.put("uppercase", new UppercaseLambda())
227+
.put("titlecase", new TitlecaseLambda())
228+
.put("camelcase", new CamelCaseLambda().generator(this))
229+
.put("indented", new IndentedLambda())
230+
.put("indented_8", new IndentedLambda(8, " "))
231+
.put("indented_12", new IndentedLambda(12, " "))
232+
.put("indented_16", new IndentedLambda(16, " "));
233+
}
234+
235+
private void registerMustacheLambdas() {
236+
ImmutableMap<String, Lambda> lambdas = addMustacheLambdas().build();
237+
238+
if (lambdas.size() == 0) {
239+
return;
240+
}
241+
242+
if (additionalProperties.containsKey("lambda")) {
243+
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
244+
"You'll likely need to use a custom template, " +
245+
"see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
246+
additionalProperties.put("_lambda", lambdas);
247+
} else {
248+
additionalProperties.put("lambda", lambdas);
249+
}
250+
}
251+
202252
// override with any special post-processing for all models
203253
@SuppressWarnings({"static-method", "unchecked"})
204254
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
@@ -1060,6 +1110,9 @@ public DefaultCodegen() {
10601110

10611111
// initialize special character mapping
10621112
initalizeSpecialCharacterMapping();
1113+
1114+
// Register common Mustache lambdas.
1115+
registerMustacheLambdas();
10631116
}
10641117

10651118
/**
@@ -1523,7 +1576,7 @@ private String getPrimitiveType(Schema schema) {
15231576
// If the format matches a typeMapping (supplied with the --typeMappings flag)
15241577
// then treat the format as a primitive type.
15251578
// This allows the typeMapping flag to add a new custom type which can then
1526-
// be used in the format field.
1579+
// be used in the format field.
15271580
return schema.getFormat();
15281581
}
15291582
return "string";

0 commit comments

Comments
 (0)