Skip to content

Commit a72be48

Browse files
committed
2 parents 733fd9d + b049a5d commit a72be48

564 files changed

Lines changed: 35043 additions & 3569 deletions

File tree

Some content is hidden

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
77
- [ ] If contributing template-only or documentation-only changes which will change sample output, [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) beforehand.
8-
- [ ] Run the shell script `./bin/generate-samples.sh`to update all Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/config/java*`.
9-
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.3.x`, `5.0.x`. Default: `master`.
8+
- [ ] Run the shell script `./bin/generate-samples.sh`to update all Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/config/java*`. For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
9+
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`
1010
- [ ] Copy the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
8585
To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen)
8686

8787
To test the templates, please perform the following:
88-
- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion)
88+
- Update the Petstore sample by running the shell scripts under `bin` folder. For example, run `./bin/generate-samples.sh ./bin/configs/python*` to update the Python PetStore samples under [`samples/`](https://github.com/openapitools/openapi-generator/tree/master/samples/). For Windows users, please install [Git BASH](https://gitforwindows.org/) in order to run the scripts.
8989
- Run the tests in the sample folder using maven `mvn integration-test -rf :<artifactId>`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests)
9090
- Finally, git commit the updated samples files: `git commit -a`
9191
(`git add -A` if added files with new test cases)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ To reinstall with the latest master, run `brew uninstall openapi-generator && br
257257

258258
To install OpenJDK (pre-requisites), please run
259259
```sh
260+
brew tap AdoptOpenJDK/openjdk
260261
brew cask install adoptopenjdk12
261262
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/
262263
```

bin/configs/java-retrofit2rx3.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
generatorName: java
2+
outputDir: samples/client/petstore/java/retrofit2rx3
3+
library: retrofit2
4+
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
useRxJava3: "true"
8+
artifactId: petstore-retrofit2-rx3
9+
hideGenerationTimestamp: "true"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: python-experimental
2+
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/extensions/x-auth-id-alias.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/python
5+
additionalProperties:
6+
packageName: x_auth_id_alias
File renamed without changes.

bin/configs/other/rust-reqwest-petstore-async.yaml renamed to bin/configs/rust-reqwest-petstore-async.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ library: reqwest
44
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
55
templateDir: modules/openapi-generator/src/main/resources/rust
66
additionalProperties:
7-
supportAsync: "true"
7+
supportAsync: true
88
packageName: petstore-reqwest-async
9+
useSingleRequestParameter: true
File renamed without changes.

bin/generate-samples.sh

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,61 @@ declare cwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
declare root="$(cd "$cwd" && cd ../ && pwd)"
77
declare executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"
88

9-
echo "# START SCRIPT: $0"
10-
echo "This script generates all configs under bin/configs by default."
11-
echo "You may generate a targeted script or set of scripts using glob patterns."
12-
echo "For example: $0 bin/configs/java-*"
13-
echo ""
14-
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
15-
16-
sleep 5
179
if [ ! -f "$executable" ]; then
1810
(cd "${root}" && mvn -B --no-snapshot-updates clean package -DskipTests=true -Dmaven.javadoc.skip=true -Djacoco.skip=true)
1911
fi
2012

21-
export JAVA_OPTS="${JAVA_OPTS} -server -Duser.timezone=UTC"
13+
export JAVA_OPTS="${JAVA_OPTS} -ea -server -Duser.timezone=UTC"
2214

23-
configs=${@:-"${root}"/bin/configs/*.yaml}
15+
files=()
16+
args=()
17+
end_option=false
18+
while [[ $# -gt 0 ]]; do
19+
key="$1"
20+
if [ "--" == "$key" ]; then
21+
end_option=true
22+
else
23+
if [[ "$end_option" = true ]]; then
24+
args+=("$1")
25+
else
26+
files+=("$1")
27+
fi
28+
fi
29+
shift
30+
done
31+
32+
header="# START SCRIPT: $0
33+
This script generates all configs under bin/configs by default.
34+
You may generate a targeted script or set of scripts using glob patterns.
35+
36+
For example:
37+
$0 bin/configs/java-*
38+
39+
You may generate a single config with additional options if you use -- to
40+
separate the single config file from the generator arguments.
41+
42+
For example:
43+
$0 bin/configs/java-vertx.yaml -- --global-property debugModels=true
44+
45+
"
46+
47+
echo "$header"
48+
49+
if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
50+
# shellcheck disable=SC2086
51+
# shellcheck disable=SC2068
52+
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
53+
else
54+
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
55+
56+
sleep 5
57+
58+
if [ ${#files[@]} -eq 0 ]; then
59+
files=("${root}"/bin/configs/*.yaml)
60+
fi
61+
62+
# shellcheck disable=SC2086
63+
# shellcheck disable=SC2068
64+
java ${JAVA_OPTS} -jar "$executable" batch --includes-base-dir "${root}" --fail-fast -- ${files[@]}
65+
fi
2466

25-
# shellcheck disable=SC2086
26-
java $JAVA_OPTS -jar "$executable" batch --includes-base-dir "${root}" --fail-fast -- $configs

bin/utils/ensure-up-to-date

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ declare root="$(cd "$cwd" && cd ../../ && pwd)"
88
declare executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"
99

1010
echo "# START SCRIPT: $0"
11-
1211
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) to ensure that the 'samples/' folder is up to date."
13-
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
14-
15-
sleep 5
12+
echo ""
1613

1714
"${root}/bin/generate-samples.sh"
1815

0 commit comments

Comments
 (0)