Skip to content

Commit

Permalink
Merge pull request #1 from OpenAPITools/master
Browse files Browse the repository at this point in the history
Update my fork
  • Loading branch information
tgerth authored Jun 17, 2020
2 parents 9fdcbec + b729e1d commit c46b027
Show file tree
Hide file tree
Showing 5,288 changed files with 83,742 additions and 72,869 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ cache:
- $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor
- $HOME/samples/client/petstore/ruby/vendor/bundle
- $HOME/samples/client/petstore/python/.venv/
- $HOME/samples/openapi3/client/petstore/typescript/tests/default/node_modules
- $HOME/samples/openapi3/client/petstore/typescript/tests/jquery/node_modules
- $HOME/samples/openapi3/client/petstore/typescript/tests/object_params/node_modules
- $HOME/samples/openapi3/client/petstore/typescript/tests/inversify/node_modules
- $HOME/samples/client/petstore/typescript-node/npm/node_modules
- $HOME/samples/client/petstore/typescript-node/npm/typings/
- $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules
Expand Down Expand Up @@ -85,7 +89,7 @@ before_install:
#- sudo apt-get update
#- sudo apt-get install dart
# switch to php7
- phpenv global 7.1
- phpenv global 7.3
- php -v
# install perl module
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
Expand Down
20 changes: 5 additions & 15 deletions CI/bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ workflows:
- brew-install@0.10.2:
inputs:
- packages: maven
- script@1.1.5:
- script@1.1.6:
title: Install Cocoapods
inputs:
- content: |
#!/usr/bin/env bash
sudo gem install cocoapods
- script@1.1.5:
- script@1.1.6:
inputs:
- content: |
#!/usr/bin/env bash
Expand All @@ -30,16 +30,16 @@ workflows:
mvn --no-snapshot-updates package -Dorg.slf4j.simpleLogger.defaultLogLevel=error
title: Build openapi-generator
- script@1.1.5:
- script@1.1.6:
title: Update Swift samples
inputs:
- content: |
#!/usr/bin/env bash
set -e
sh bin/generate-samples.sh bin/configs/swift5-*.yaml
- script@1.1.5:
bin/generate-samples.sh ./bin/configs/other/swift5-*
- script@1.1.6:
title: Run Swift5 tests
inputs:
- content: |
Expand All @@ -48,14 +48,4 @@ workflows:
set -e
./samples/client/test/swift5/swift5_test_all.sh
# comment out the following as it's causing timeout
# - script@1.1.5:
# title: Run all bin scripts
# inputs:
# - content: |-
# #!/usr/bin/env bash
#
# set -e
#
# ./bin/run-all-petstore
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
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)

To test the templates, please perform the following:
- 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.
- 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)
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`.
- 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)
- Finally, git commit the updated samples files: `git commit -a`
(`git add -A` if added files with new test cases)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[![LightBow](https://openapi-generator.tech/img/companies/lightbow.png)](https://www.lightbow.net/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/docspring.png" width="128" height="128">](https://docspring.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/datadog.png" width="128" height="128">](https://datadoghq.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/thales.jpg" width="128" height="128">](https://cpl.thalesgroup.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)

#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS and Checkly for sponsoring the API monitoring

Expand Down Expand Up @@ -257,6 +258,7 @@ To reinstall with the latest master, run `brew uninstall openapi-generator && br

To install OpenJDK (pre-requisites), please run
```sh
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk12
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/
```
Expand Down
2 changes: 1 addition & 1 deletion bin/configs/java-jersey2-8.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generatorName: java
outputDir: samples/openapi3/client/petstore/java/jersey2-java8
library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
additionalProperties:
artifactId: petstore-openapi3-jersey2-java8
hideGenerationTimestamp: true
Expand Down
12 changes: 0 additions & 12 deletions bin/configs/java-retrofit2-play24.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions bin/configs/java-retrofit2-play25.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions bin/configs/java-retrofit2rx.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions bin/configs/java-retrofit2rx3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
generatorName: java
outputDir: samples/client/petstore/java/retrofit2rx3
library: retrofit2
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
useRxJava3: "true"
artifactId: petstore-retrofit2-rx3
hideGenerationTimestamp: "true"
File renamed without changes.
6 changes: 6 additions & 0 deletions bin/configs/python-experimental-extensions-x-auth-alias.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
generatorName: python-experimental
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/
inputSpec: modules/openapi-generator/src/test/resources/3_0/extensions/x-auth-id-alias.yaml
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
packageName: x_auth_id_alias
64 changes: 52 additions & 12 deletions bin/generate-samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,61 @@ declare cwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare root="$(cd "$cwd" && cd ../ && pwd)"
declare executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"

echo "# START SCRIPT: $0"
echo "This script generates all configs under bin/configs by default."
echo "You may generate a targeted script or set of scripts using glob patterns."
echo "For example: $0 bin/configs/java-*"
echo ""
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."

sleep 5
if [ ! -f "$executable" ]; then
(cd "${root}" && mvn -B --no-snapshot-updates clean package -DskipTests=true -Dmaven.javadoc.skip=true -Djacoco.skip=true)
fi

export JAVA_OPTS="${JAVA_OPTS} -server -Duser.timezone=UTC"
export JAVA_OPTS="${JAVA_OPTS} -ea -server -Duser.timezone=UTC"

configs=${@:-"${root}"/bin/configs/*.yaml}
files=()
args=()
end_option=false
while [[ $# -gt 0 ]]; do
key="$1"
if [ "--" == "$key" ]; then
end_option=true
else
if [[ "$end_option" = true ]]; then
args+=("$1")
else
files+=("$1")
fi
fi
shift
done

header="# START SCRIPT: $0
This script generates all configs under bin/configs by default.
You may generate a targeted script or set of scripts using glob patterns.
For example:
$0 bin/configs/java-*
You may generate a single config with additional options if you use -- to
separate the single config file from the generator arguments.
For example:
$0 bin/configs/java-vertx.yaml -- --global-property debugModels=true
"

echo "$header"

if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
# shellcheck disable=SC2086
# shellcheck disable=SC2068
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
else
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."

sleep 5

if [ ${#files[@]} -eq 0 ]; then
files=("${root}"/bin/configs/*.yaml)
fi

# shellcheck disable=SC2086
# shellcheck disable=SC2068
java ${JAVA_OPTS} -jar "$executable" batch --includes-base-dir "${root}" --fail-fast -- ${files[@]}
fi

# shellcheck disable=SC2086
java $JAVA_OPTS -jar "$executable" batch --includes-base-dir "${root}" --fail-fast -- $configs
47 changes: 47 additions & 0 deletions bin/typescript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"

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/openapi-generator-cli/target/openapi-generator-cli.jar"
common_args="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript"
samples="samples/openapi3/client/petstore/typescript/builds"

if [ ! -f "$executable" ]
then
mvn -B 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"

printf "\033[32m## Creating default (fetch) client!\033[0m\n"
args="-o $samples/default --additional-properties=platform=node,npmName=ts-petstore-client $@"
java $JAVA_OPTS -jar $executable $common_args $args

printf "\033[32m## Creating jquery client!\033[0m\n"
args="-o $samples/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@"
java $JAVA_OPTS -jar $executable $common_args $args

printf "\033[32m## Creating fetch object client!\033[0m\n"
args="-o $samples/object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters=true $@"
java $JAVA_OPTS -jar $executable $common_args $args

printf "\033[32m## Creating fetch client with InversifyJS support!\033[0m\n"
args="-o $samples/inversify --additional-properties=platform=node,npmName=ts-petstore-client,useInversify=true $@"
java $JAVA_OPTS -jar $executable $common_args $args
5 changes: 1 addition & 4 deletions bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ declare root="$(cd "$cwd" && cd ../../ && pwd)"
declare executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"

echo "# START SCRIPT: $0"

echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) to ensure that the 'samples/' folder is up to date."
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."

sleep 5
echo ""

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

Expand Down
19 changes: 19 additions & 0 deletions bin/windows/typescript.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M

set args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\default --additional-properties=platform=node,npmName=ts-petstore-client
java %JAVA_OPTS% -jar %executable% %args%

args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\jquery --additional-properties=framework=jquery,npmName=ts-petstore-client
java %JAVA_OPTS% -jar %executable% %args%

set args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters
java %JAVA_OPTS% -jar %executable% %args%

set args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\inversify --additional-properties=platform=node,npmName=ts-petstore-client,useInversify
java %JAVA_OPTS% -jar %executable% %args%
2 changes: 1 addition & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Once built, `run-in-docker.sh` will act as an executable for openapi-generator-c
```bash
./run-in-docker.sh help # Executes 'help' command for openapi-generator-cli
./run-in-docker.sh list # Executes 'list' command for openapi-generator-cli
./run-in-docker.sh /gen/bin/generate-samples.sh /gen/bin/configs/go-petstore.yaml/ # Builds the Go client
./run-in-docker.sh /gen/bin/generate-samples.sh /gen/bin/configs/go-petstore.yaml # Builds the Go client
./run-in-docker.sh generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
-g go -o /gen/out/go-petstore -DpackageName=petstore # generates go client, outputs locally to ./out/go-petstore
```
Expand Down
3 changes: 2 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
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)

To test the templates, please perform the following:
- 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.
- 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)
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`.
- 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)
- Finally, git commit the updated samples files: `git commit -a`
(`git add -A` if added files with new test cases)
Expand Down
1 change: 1 addition & 0 deletions docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The following generators are available:
* [scalaz](generators/scalaz.md)
* [swift4-deprecated (deprecated)](generators/swift4-deprecated.md)
* [swift5 (beta)](generators/swift5.md)
* [typescript (experimental)](generators/typescript.md)
* [typescript-angular](generators/typescript-angular.md)
* [typescript-angularjs](generators/typescript-angularjs.md)
* [typescript-aurelia](generators/typescript-aurelia.md)
Expand Down
Loading

0 comments on commit c46b027

Please sign in to comment.