Merge branch '4.3.x' into 5.0.x

This commit is contained in:
William Cheng 2019-11-21 15:19:31 +08:00
commit facabd4472
1736 changed files with 27265 additions and 4446 deletions

View File

@ -6,5 +6,5 @@
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
- [ ] 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) before.
- [ ] Run the shell script(s) under `./bin/` (or Windows batch scripts under`.\bin\windows`) to update Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run `./bin/{LANG}-petstore.sh`, `./bin/openapi3/{LANG}-petstore.sh` if updating the code or mustache templates for a language (`{LANG}`) (e.g. php, ruby, python, etc).
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.1.x`, `5.0.x`. Default: `master`.
- [ ] 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`.
- [ ] 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.

View File

@ -138,6 +138,8 @@ script:
# test maven plugin
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml
# test gradle plugin
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk)
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)

View File

@ -2,6 +2,17 @@ kind: pipeline
name: default
steps:
# test ocaml petstore client
- name: ocaml-test
image: ocaml/opam2:4.07
commands:
- sudo apt-get -y install m4
- cd samples/client/petstore/ocaml
- opam install ppx_deriving_yojson cohttp ppx_deriving cohttp-lwt-unix
- opam pin add ocaml-migrate-parsetree 1.3.1
- eval $(opam env)
- sudo chmod -R 777 .
- dune build --build-dir=./_build
# test haskell client
- name: haskell-client-test
image: haskell:8.6.5
@ -28,13 +39,3 @@ steps:
- /bin/bash bin/run-all-petstore
# generate all petstore samples (openapi3)
- /bin/bash bin/openapi3/run-all-petstore
# test ocaml petstore client
- name: ocaml-test
image: ocaml/opam2:4.07
commands:
- sudo apt-get -y install m4
- cd samples/client/petstore/ocaml
- opam install ppx_deriving_yojson cohttp ppx_deriving cohttp-lwt-unix
- eval $(opam env)
- sudo chmod -R 777 .
- dune build --build-dir=./_build

View File

@ -1,55 +1,25 @@
sudo: required
language: objective-c
osx_image: xcode8.1
cache:
directories:
- $HOME/.m2
- $HOME/.ivy2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.stack
- $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor
- $HOME/samples/client/petstore/ruby/venodr/bundle
- $HOME/samples/client/petstore/python/.venv/
- $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
- $HOME/samples/client/petstore/typescript-fetch/tests/default/typings
- $HOME/samples/client/petstore/typescript-fetch/builds/default/node_modules
- $HOME/samples/client/petstore/typescript-fetch/builds/default/typings
- $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/node_modules
- $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/typings
- $HOME/samples/client/petstore/typescript-fetch/builds/with-npm-version/node_modules
- $HOME/samples/client/petstore/typescript-fetch/npm/with-npm-version/typings
- $HOME/samples/client/petstore/typescript-angularjs/node_modules
- $HOME/samples/client/petstore/typescript-angularjs/typings
- $HOME/.cocoapods/repos/master
timeout: 1000
# comment out the host table change to use the public petstore server
addons:
hosts:
- petstore.swagger.io
osx_image: xcode10.3
before_install:
- export SW=`pwd`
- rvm list
- rvm use 2.3.3
#- rvm use 2.3.3
- gem environment
- gem install bundler -N --no-ri --no-rdoc
- gem install cocoapods -v 1.2.1 -N --no-ri --no-rdoc
- gem install xcpretty -N --no-ri --no-rdoc
- gem install bundler -N
- gem install cocoapods -v 1.2.1 -N
- gem install xcpretty -N
- pod --version
# comment out below to avoid errors
#- pod repo update
- pod setup --silent > /dev/null
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
# start local petstore server
- git clone -b docker --single-branch https://github.com/wing328/swagger-samples
- cd swagger-samples/java/java-jersey-jaxrs
- sudo mvn jetty:run &
- cd $SW
#- pod setup --silent > /dev/null
#- mkdir -p ~/.local/bin
#- export PATH=$HOME/.local/bin:$PATH
## start local petstore server
#- git clone -b docker --single-branch https://github.com/wing328/swagger-samples
#- cd swagger-samples/java/java-jersey-jaxrs
#- sudo mvn jetty:run &
#- cd $SW
# show host table to confirm petstore.swagger.io is mapped to localhost
- cat /etc/hosts
@ -64,4 +34,4 @@ before_install:
script:
# run integration tests defined in maven pom.xml
- mvn -q --batch-mode verify -Psamples
- mvn -q --batch-mode verify -Psamples.ios -Dmaven.javadoc.skip=true

View File

@ -28,7 +28,7 @@ elif [ "$NODE_INDEX" = "2" ]; then
git checkout -- .
# look for outdated samples
./bin/utils/ensure-up-to-date
./bin/utils/ensure-up-to-date --batch
fi
#elif [ "$NODE_INDEX" = "3" ]; then
echo "Running node $NODE_INDEX to test haskell"

View File

@ -128,8 +128,6 @@ public class PetApiTest {
//empty
}
});
// the API call should be executed asynchronously, so result should be empty at the moment
assertTrue(result.isEmpty());
// wait for the asynchronous call to finish (at most 10 seconds)
final int maxTry = 10;

View File

@ -2,12 +2,18 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.2.1-SNAPSHOT`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.2.2-SNAPSHOT`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=master)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/master)](https://cloud.drone.io/OpenAPITools/openapi-generator)
[`4.3.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.3.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.3.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.3.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.3.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=4.3.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/4.3.x)](https://cloud.drone.io/OpenAPITools/openapi-generator)
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/5.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/5.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=5.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
@ -103,8 +109,8 @@ OpenAPI Generator Version | Release Date | Notes
---------------------------- | ------------ | -----
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
4.3.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.3.0-SNAPSHOT/)| 29.02.2020 | Minor release (breaking changes with fallbacks)
4.2.1 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.1-SNAPSHOT/)| 15.11.2019 | Patch release
[4.2.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.2.0) (latest stable release) | 31.10.2019 | Minor release (bug fixes, enhancements, breaking chanages with fallbacks)
4.2.2-SNAPSHOT (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.2-SNAPSHOT/)| 02.12.2019 | Patch release
[4.2.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.2.1) (latest stable release) | 15.11.2019 | Patch release
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@ -160,16 +166,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.0/openapi-generator-cli-4.2.0.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.1/openapi-generator-cli-4.2.1.jar`
For **Mac/Linux** users:
```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.0/openapi-generator-cli-4.2.0.jar -O openapi-generator-cli.jar
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.1/openapi-generator-cli-4.2.1.jar -O openapi-generator-cli.jar
```
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.0/openapi-generator-cli-4.2.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.1/openapi-generator-cli-4.2.1.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@ -384,10 +390,10 @@ openapi-generator version
```
<!-- RELEASE_VERSION -->
Or install a particular OpenAPI Generator version (e.g. v4.2.0):
Or install a particular OpenAPI Generator version (e.g. v4.1.2):
```sh
npm install @openapitools/openapi-generator-cli@cli-4.2.0 -g
npm install @openapitools/openapi-generator-cli@cli-4.1.2 -g
```
Or install it as dev-dependency:
@ -411,7 +417,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
<!-- RELEASE_VERSION -->
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.0/openapi-generator-cli-4.2.0.jar)
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.1/openapi-generator-cli-4.2.1.jar)
<!-- /RELEASE_VERSION -->
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
@ -516,7 +522,7 @@ Please refer to [customization.md](docs/customization.md) on how to customize th
### [3.2 - Workflow Integration (Maven, Gradle, Github, CI/CD)](#table-of-contents)
Please refer to [integration.md](docs/integration.md) on how to integrate OpenAPI generator with Maven, Gradle, Github and CI/CD.
Please refer to [integration.md](docs/integration.md) on how to integrate OpenAPI generator with Maven, Gradle, sbt, Bazel, Github and CI/CD.
### [3.3 - Online OpenAPI generator](#table-of-contents)
@ -578,15 +584,18 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [Element AI](https://www.elementai.com/)
- [Fenergo](https://www.fenergo.com/)
- [FormAPI](https://formapi.io/)
- [FreshCells](https://www.freshcells.de/)
- [Fuse](https://www.fuse.no/)
- [Gantner](https://www.gantner.com)
- [GenFlow](https://github.com/RepreZen/GenFlow)
- [GetYourGuide](https://www.getyourguide.com/)
- [GMO Pepabo](https://pepabo.com/en/)
- [GoDaddy](https://godaddy.com)
- [Here](https://developer.here.com/)
- [IBM](https://www.ibm.com/)
- [JustStar](https://www.juststarinfo.com)
- [Klarna](https://www.klarna.com/)
- [Kronsoft Development](https://www.kronsoft.ro/home/)
- [Médiavision](https://www.mediavision.fr/)
- [Metaswitch](https://www.metaswitch.com/)
- [Myworkout](https://myworkout.com)
@ -596,6 +605,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [Ponicode](https://ponicode.dev/)
- [Pricefx](https://www.pricefx.com/)
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
- [QEDIT](https://qed-it.com)
- [Qulix Systems](https://www.qulix.com)
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
- [RedHat](https://www.redhat.com)
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
@ -678,6 +689,12 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-10-16 - [How to ship APIs faster?](https://medium.com/@accounts_76224/how-to-ship-apis-faster-cabef2f819e4) by [Simon Guilliams @ PoniCode](https://ponicode.dev)
- 2019-10-22 - [OpenAPI + Spring Boot(Kotlin)でファイルダウンロードAPIを作成する](https://qiita.com/boronngo/items/4b78b92526209daeaee9) by [Yuki Furukawa](https://twitter.com/yuki_furukawa5)
- 2019-10-24 - [Microprofile OpenAPI - Code First or Design First?](https://github.com/pe-st/apidocs/blob/master/MicroProfile-OpenAPI-all-slides.pdf) by [Peter [pɛʃə] Steiner](https://twitter.com/pesche) at [eclipsecon Europe 2019](https://www.eclipsecon.org/europe2019/sessions/microprofile-openapi-code-first-or-design-first)
- 2019-11-06 - [Generating API clients based on OpenAPI v3 specifications](https://98elements.com/blog/generating-api-clients-based-on-openapi-v3-specifications) by [Dominik Jastrzębski @ 98elements](https://98elements.com)
- 2019-11-06 - [OpenAPIを利用して自前のAPIサーバー(Sinatra)を移植した時のメモ](https://qiita.com/YasuhiroABE/items/c73920eab2d9d6e97fd9) by [Yasuhiro ABE](https://twitter.com/YasuhiroABE)
- 2019-11-07 - [API First development with OpenAPI - You should you practise it !?](https://www.youtube.com/watch?v=F9iF3a1Z8Y8) by [Nick Van Hoof](https://www.nickvanhoof.com/) at [Devoxx Belgium 2019](https://devoxx.be/)
- 2019-11-08 - [JHipster beyond CRUD - API-First for Enterprises by Enrico Costanzi](https://www.youtube.com/watch?v=m28JFovKQ20) by [Enrico Costanzi](https://twitter.com/enricocostanzi) at [JHipster Conf 2019 in Paris](https://jhipster-conf.github.io/)
- 2019-11-11 - [TypeScript REST APIクライアント](https://qiita.com/unhurried/items/7b74f7d3c43545dadd2b) by [@unhurried](https://qiita.com/unhurried)
- 2019-11-11 - [One Spec to Rule them all - OpenAPI in Action](https://www.youtube.com/watch?v=MMay_nht8ec) by [Andreas Litt](https://github.com/littldr) at [code.talks 2019](https://www.codetalks.com/)
## [6 - About Us](#table-of-contents)
@ -871,7 +888,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Groovy | |
| Haskell | |
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) |
| Lua | @daurnimator (2017/08) |
| Nim | |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
@ -880,7 +897,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) |
| PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ackintosh (2017/09) [:heart:](https://www.patreon.com/ackintosh/overview), @ybelenko (2018/07), @renepardon (2018/12) |
| PowerShell | |
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @slash-arun (2019/11) |
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @slash-arun (2019/11) @spacether (2019/11)|
| R | @Ramanth (2019/07) @saigiridhar21 (2019/07) |
| Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) |
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) @richardwhiuk (2019/07) |

View File

@ -1,6 +1,6 @@
{
"generatorName": "php-symfony",
"inputSpec": "/Users/jim/projects/openapi-generator/bin/../modules/openapi-generator/src/test/resources/2_0/petstore.yaml",
"outputDir": "/Users/jim/projects/openapi-generator/bin/../samples/server/petstore/php-symfony/SymfonyBundle-php",
"templateDir": "/Users/jim/projects/openapi-generator/bin/../modules/openapi-generator/src/main/resources/php-symfony"
"inputSpec": "modules/openapi-generator/src/test/resources/2_0/petstore.yaml",
"outputDir": "samples/server/petstore/php-symfony/SymfonyBundle-php",
"templateDir": "modules/openapi-generator/src/main/resources/php-symfony"
}

View File

@ -0,0 +1,9 @@
{
"generatorName": "python-experimental",
"inputSpec": "modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml",
"outputDir": "samples/client/petstore/python-experimental",
"templateDir": "modules/openapi-generator/src/main/resources/python",
"additionalProperties": {
"packageName": "petstore_api"
}
}

View File

@ -5,6 +5,7 @@
"outputDir": "samples/server/petstore/springboot",
"templateDir": "modules/openapi-generator/src/main/resources/JavaSpring",
"additionalProperties": {
"hideGenerationTimestamp": true
"hideGenerationTimestamp": true,
"snapshotVersion": true
}
}

View File

@ -0,0 +1,8 @@
{
"inputSpec": "modules/openapi-generator/src/test/resources/2_0/petstore.yaml",
"outputDir": "samples/client/petstore/cpp-qt5",
"additionalProperties": {
"cppNamespace": "test_namespace",
"modelNamePrefix": "PFX"
}
}

View File

@ -27,6 +27,10 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
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 $@"
args="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 \
-c cpp-qt5-petstore.json \
$@"
java $JAVA_OPTS -jar $executable $ags
java $JAVA_OPTS -jar $executable $args

View File

@ -1,8 +1,10 @@
#!/bin/sh
./bin/kotlin-client-gson.sh
./bin/kotlin-client-nonpublic.sh
./bin/kotlin-client-okhttp3.sh
./bin/kotlin-client-petstore-multiplatform.sh
./bin/kotlin-client-petstore.sh
./bin/kotlin-client-string.sh
./bin/kotlin-client-threetenbp.sh
./bin/kotlin-client-nullable.sh

32
bin/kotlin-client-gson.sh Executable file
View File

@ -0,0 +1,32 @@
#!/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"
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} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-gson --additional-properties serializationLibrary=gson -o samples/client/petstore/kotlin-gson $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -30,5 +30,3 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-nonpublic --additional-properties nonPublicApi=true -o samples/client/petstore/kotlin-nonpublic $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}
cp CI/samples.ci/client/petstore/kotlin-string/pom.xml samples/client/petstore/kotlin-string/pom.xml

32
bin/kotlin-client-nullable.sh Executable file
View File

@ -0,0 +1,32 @@
#!/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"
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} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-nullable --additional-properties nullableReturnType=true,serializableModel=true -o samples/client/petstore/kotlin-nullable $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -30,5 +30,3 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-okhttp3 --library jvm-okhttp3 -o samples/client/petstore/kotlin-okhttp3 $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}
#cp CI/samples.ci/client/petstore/kotlin-okhttp3/pom.xml samples/client/petstore/kotlin-okhttp3/pom.xml

40
bin/meta-codegen-kotlin.sh Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
declare cwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare root="$(cd "$cwd" && cd ../ && pwd)"
if ! command -v gradle > /dev/null; then
echo "[WARN] This script requires a system gradle to be installed. Not treating this as an error."
exit 0
fi
executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
(cd "$root" && ./mvnw -B clean package)
fi
\rm -rf "${root}/samples/meta-codegen-kotlin/lib"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="meta -n myClientCodegen -t DOCUMENTATION -p com.my.company.codegen -o samples/meta-codegen-kotlin/lib -l kotlin $@"
java $JAVA_OPTS -jar $executable $ags
if [ ! -f "${root}"samples/meta-codegen-kotlin/gradle/wrapper/gradle-wrapper.jar ]; then
(cd "${root}"/samples/meta-codegen-kotlin/ && gradle wrapper --gradle-version 5.6.2 --distribution-type bin)
fi
(cp "${root}"/samples/meta-codegen-kotlin/gradlew "${root}"/samples/meta-codegen-kotlin/lib/ && \
cp -R "${root}"/samples/meta-codegen-kotlin/gradle "${root}"/samples/meta-codegen-kotlin/lib/ && \
cd "${root}"/samples/meta-codegen-kotlin/lib && \
./gradlew shadowJar)
ags2="generate -g myClientCodegen -i modules/openapi-generator/src/test/resources/2_0/petstore.json -o samples/meta-codegen-kotlin/usage $@"
java $JAVA_OPTS -cp ${root}/samples/meta-codegen-kotlin/lib/build/libs/my-client-codegen-openapi-generator-1.0-SNAPSHOT-all.jar:$executable org.openapitools.codegen.OpenAPIGenerator $ags2

View File

@ -1,28 +1,15 @@
#!/bin/sh
#!/usr/bin/env bash
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
declare cwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare root="$(cd "$cwd" && cd ../ && pwd)"
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
./mvnw -B clean package
if [ ! -f "$executable" ]; then
(cd "$root" && ./mvnw -B clean package)
fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
@ -30,8 +17,8 @@ ags="meta -n myClientCodegen -t DOCUMENTATION -p com.my.company.codegen -o sampl
java $JAVA_OPTS -jar $executable $ags
./mvnw clean package -f samples/meta-codegen/pom.xml
(cd "$root" && ./mvnw clean package -f samples/meta-codegen/pom.xml)
ags2="generate -g myClientCodegen -i modules/openapi-generator/src/test/resources/2_0/petstore.json -o samples/meta-codegen/usage $@"
java $JAVA_OPTS -cp samples/meta-codegen/lib/target/myClientCodegen-openapi-generator-1.0.0.jar:$executable org.openapitools.codegen.OpenAPIGenerator $ags2
java $JAVA_OPTS -cp ${root}/samples/meta-codegen/lib/target/myClientCodegen-openapi-generator-1.0.0.jar:$executable org.openapitools.codegen.OpenAPIGenerator $ags2

5
bin/openapi3/elm-all.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
./bin/openapi3/elm-petstore.sh
./bin/openapi3/elm-composition.sh

35
bin/openapi3/elm-composition.sh Executable file
View File

@ -0,0 +1,35 @@
#!/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"
if [ ! -f "$executable" ]
then
mvn -B clean package
fi
# auto format elm code using elm-format
export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.19 --yes"
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/3_0/composition.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/openapi3/client/composition/elm --enable-post-process-file $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -3,4 +3,5 @@
./bin/python-asyncio-petstore.sh
./bin/python-petstore.sh
./bin/python-experimental-petstore.sh
./bin/python-tornado-petstore.sh

View File

@ -27,7 +27,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate --artifact-id springboot -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g spring -o samples/server/petstore/springboot --additional-properties hideGenerationTimestamp=true $@"
ags="generate --artifact-id springboot -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g spring -o samples/server/petstore/springboot --additional-properties hideGenerationTimestamp=true,snapshotVersion=true $@"
echo "Removing files and folders under samples/server/petstore/springboot/src/main"
rm -rf samples/server/petstore/springboot/src/main

View File

@ -15,3 +15,4 @@
./bin/typescript-angular-v7-petstore-provided-in-root-with-npm.sh
./bin/typescript-angular-v8-petstore-provided-in-root-with-npm.sh
./bin/typescript-angular-v8-petstore-provided-in-root-with-prefixed-module-name.sh
./bin/typescript-angular-v8-petstore-single-request-parameter.sh

View File

@ -0,0 +1,32 @@
#!/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"
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} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter --additional-properties ngVersion=8.0.0,useSingleRequestParameter=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -0,0 +1,20 @@
## What is the purpose?
Running `./save_dart_keywords.sh` from this directory will generate `dart-keywords.txt` which contains the current Dart keywords and is used by the dart generator as a set of reserved words.
## When should the keywords be generated?
`save_dart_keywords.sh` should be run when a new version of Dart is release to update the keywords file.
The last Dart version that was used to generate the keywords can be found in `dart-version.txt`.
## What does the shellscript do?
1. compile a dart app
- `dart2native save-dart-keywords.dart`
1. run the dart app
- `./save-dart-keywords.exe`
1. the ouput is `dart-keywords.txt` and `dart-version.txt`

View File

@ -0,0 +1 @@
Dart VM version: 2.7.0-dev.0.0 (Tue Nov 5 12:57:33 2019 +0100) on "macos_x64"

View File

@ -0,0 +1,194 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
analyzer:
dependency: "direct main"
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.1"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
front_end:
dependency: transitive
description:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.29"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.29"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
node_interop:
dependency: transitive
description:
name: node_interop
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
node_io:
dependency: transitive
description:
name: node_io
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1+2"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.2"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+12"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
sdks:
dart: ">=2.6.0 <3.0.0"

View File

@ -0,0 +1,10 @@
name: dart_keywords
description: Use the Dart SDK to generate Dart keywords.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
dependencies:
analyzer:

View File

@ -0,0 +1,16 @@
import 'dart:io';
import 'package:analyzer/dart/ast/token.dart';
main() {
// save keywords to a text file
final txtFile = File(
'../../../modules/openapi-generator/src/main/resources/dart/dart-keywords.txt');
String txtString = '';
for (String keyword in Keyword.keywords.keys.toList()) {
txtString += keyword + '\n';
}
txtString =
txtString.substring(0, txtString.length - 1); // remove last newline
txtFile.writeAsStringSync(txtString);
}

View File

@ -0,0 +1,3 @@
dart2native save-dart-keywords.dart
./save-dart-keywords.exe
dart --version &> dart-version.txt

View File

@ -1,93 +1,122 @@
#!/bin/bash
# this bash script run the scripts for the 'mature' generators
#!/usr/bin/env bash
# this bash script runs the scripts for the 'mature' generators by default.
# Supports --batch option which will compile all generators defined under bin/ci/*.json
# it ensures that all changes are committed into the 'samples/' folder
# shellcheck disable=SC2155
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"
declare batch_mode="false"
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."
if [ "--batch" = "$1" ]; then
batch_mode="true"
echo "Running in 'batch mode' (single JVM, mutliple threads)."
else
echo "When running locally execute with argument --batch."
fi
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
sleep 5
# LIST OF SCRIPTS:
declare -a scripts=(
# SAMPLES
"./bin/ruby-client-petstore.sh"
"./bin/ruby-client-petstore-faraday.sh"
"./bin/openapi3/ruby-client-petstore.sh"
"./bin/openapi3/ruby-client-faraday-petstore.sh"
declare -a samples=(
"${root}/bin/ruby-client-petstore.sh"
"${root}/bin/ruby-client-petstore-faraday.sh"
"${root}/bin/openapi3/ruby-client-petstore.sh"
"${root}/bin/openapi3/ruby-client-faraday-petstore.sh"
"${root}/bin/java-petstore-all.sh"
"${root}/bin/java-jaxrs-petstore-server-all.sh"
"${root}/bin/java-msf4j-petstore-server.sh"
"${root}/bin/openapi3/jaxrs-jersey-petstore.sh"
"${root}/bin/spring-all-petstore.sh"
"${root}/bin/javascript-petstore-all.sh"
"${root}/bin/kotlin-client-all.sh"
"${root}/bin/kotlin-server-petstore.sh"
"${root}/bin/kotlin-springboot-petstore-server.sh"
"${root}/bin/kotlin-springboot-petstore-server-reactive.sh"
"${root}/bin/mysql-schema-petstore.sh"
"${root}/bin/nim-client-petstore.sh"
"${root}/bin/python-petstore-all.sh"
"${root}/bin/openapi3/python-petstore.sh"
"${root}/bin/php-petstore.sh"
"${root}/bin/php-silex-petstore-server.sh"
"${root}/bin/php-symfony-petstore.sh"
"${root}/bin/php-lumen-petstore-server.sh"
"${root}/bin/php-slim-server-petstore.sh"
"${root}/bin/php-slim4-server-petstore.sh"
"${root}/bin/php-ze-ph-petstore-server.sh"
"${root}/bin/openapi3/php-petstore.sh"
"${root}/bin/typescript-angularjs-petstore.sh"
"${root}/bin/typescript-angular-petstore-all.sh"
"${root}/bin/typescript-aurelia-petstore.sh"
"${root}/bin/typescript-axios-petstore-all.sh"
"${root}/bin/typescript-fetch-petstore-all.sh"
"${root}/bin/typescript-inversify-petstore.sh"
"${root}/bin/typescript-jquery-petstore-all.sh"
"${root}/bin/typescript-node-petstore-all.sh"
"${root}/bin/typescript-rxjs-petstore-all.sh"
"${root}/bin/rust-server-petstore.sh"
"${root}/bin/r-petstore.sh"
"${root}/bin/haskell-http-client-petstore.sh"
"${root}/bin/csharp-petstore.sh"
"${root}/bin/csharp-netcore-petstore-all.sh"
"${root}/bin/elixir-petstore.sh"
"${root}/bin/openapi3/go-petstore.sh"
"${root}/bin/go-experimental-petstore.sh"
"${root}/bin/go-petstore.sh"
"${root}/bin/go-petstore-withxml.sh"
"${root}/bin/go-petstore-server.sh"
"${root}/bin/go-gin-petstore-server.sh"
"${root}/bin/groovy-petstore.sh"
"${root}/bin/apex-petstore.sh"
"${root}/bin/perl-petstore-all.sh"
"${root}/bin/dart-jaguar-petstore.sh"
#"${root}/bin/dart-dio-petstore.sh"
"${root}/bin/dart-petstore.sh"
"${root}/bin/dart2-petstore.sh"
"${root}/bin/java-play-framework-petstore-server-all.sh"
#"${root}/bin/elm-petstore-all.sh"
)
"./bin/java-petstore-all.sh"
"./bin/java-jaxrs-petstore-server-all.sh"
"./bin/java-msf4j-petstore-server.sh"
"./bin/openapi3/jaxrs-jersey-petstore.sh"
"./bin/spring-all-petstore.sh"
"./bin/javascript-petstore-all.sh"
"./bin/kotlin-client-petstore-multiplatform.sh"
"./bin/kotlin-client-petstore.sh"
"./bin/kotlin-client-string.sh"
"./bin/kotlin-client-threetenbp.sh"
"./bin/kotlin-server-petstore.sh"
"./bin/kotlin-springboot-petstore-server.sh"
"./bin/kotlin-springboot-petstore-server-reactive.sh"
"./bin/mysql-schema-petstore.sh"
"./bin/nim-client-petstore.sh"
"./bin/python-petstore-all.sh"
"./bin/openapi3/python-petstore.sh"
"./bin/php-petstore.sh"
"./bin/php-silex-petstore-server.sh"
"./bin/php-symfony-petstore.sh"
"./bin/php-lumen-petstore-server.sh"
"./bin/php-slim-server-petstore.sh"
"./bin/php-slim4-server-petstore.sh"
"./bin/php-ze-ph-petstore-server.sh"
"./bin/openapi3/php-petstore.sh"
"./bin/typescript-angularjs-petstore.sh"
"./bin/typescript-angular-petstore-all.sh"
"./bin/typescript-aurelia-petstore.sh"
"./bin/typescript-axios-petstore-all.sh"
"./bin/typescript-fetch-petstore-all.sh"
"./bin/typescript-inversify-petstore.sh"
"./bin/typescript-jquery-petstore-all.sh"
"./bin/typescript-node-petstore-all.sh"
"./bin/typescript-rxjs-petstore-all.sh"
"./bin/rust-server-petstore.sh"
"./bin/r-petstore.sh"
"./bin/haskell-http-client-petstore.sh"
"./bin/csharp-petstore.sh"
"./bin/csharp-netcore-petstore-all.sh"
"./bin/elixir-petstore.sh"
"./bin/openapi3/go-petstore.sh"
"./bin/go-experimental-petstore.sh"
"./bin/go-petstore.sh"
"./bin/go-petstore-withxml.sh"
"./bin/go-petstore-server.sh"
"./bin/go-gin-petstore-server.sh"
"./bin/groovy-petstore.sh"
"./bin/apex-petstore.sh"
"./bin/perl-petstore-all.sh"
"./bin/dart-jaguar-petstore.sh"
#"./bin/dart-dio-petstore.sh"
"./bin/dart-petstore.sh"
"./bin/dart2-petstore.sh"
"./bin/java-play-framework-petstore-server-all.sh"
"./bin/elm-petstore-all.sh"
"./bin/meta-codegen.sh"
# OTHERS
"./bin/utils/export_docs_generators.sh"
"./bin/utils/copy-to-website.sh"
"./bin/utils/export_generators_readme.sh")
# Some special case generators may expect to be run as a stanalone process (e.g. modifying classpath)
# Docs should always be run, regardless of batch or operation.
declare -a always_iterate=(
"${root}/bin/meta-codegen.sh"
"${root}/bin/utils/export_docs_generators.sh"
"${root}/bin/utils/copy-to-website.sh"
"${root}/bin/utils/export_generators_readme.sh"
)
export JAVA_OPTS="-Djava.awt.headless=true"
export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"
for script in "${scripts[@]}"; do
if eval $script > /dev/null 2>&1; then
if [ "true" = "$batch_mode" ]; then
if [ ! -f "$executable" ]; then
(cd "${root}" && mvn -B clean package -DskipTests=true -Dmaven.javadoc.skip=true)
fi
# shellcheck disable=SC2086
java $JAVA_OPTS -jar "$executable" batch --includes-base-dir "${root}" --fail-fast -- "${root}"/bin/ci/*
else
for script in "${samples[@]}"; do
if eval "$script" > /dev/null 2>&1; then
echo "Executed $script successfully!"
else
echo "ERROR: Failed to run $script"
exit 1
fi
done
fi
for i in "${always_iterate[@]}"; do
if eval "$i" > /dev/null 2>&1; then
echo "Executed $i successfully!"
else
echo "ERROR: Failed to run $i"
exit 1
fi
done
# Check:
if [ -n "$(git status --porcelain)" ]; then
@ -102,3 +131,4 @@ if [ -n "$(git status --porcelain)" ]; then
else
echo "Git working tree is clean"
fi

View File

@ -0,0 +1,8 @@
call powershell -command "& '%~dp0\kotlin-client-gson.bat'"
call powershell -command "& '%~dp0\kotlin-client-nonpublic.bat'"
call powershell -command "& '%~dp0\kotlin-client-okhttp3.bat'"
call powershell -command "& '%~dp0\kotlin-client-petstore-multiplatform.bat'"
call powershell -command "& '%~dp0\kotlin-client-petstore.bat'"
call powershell -command "& '%~dp0\kotlin-client-string.bat'"
call powershell -command "& '%~dp0\kotlin-client-threetenbp.bat'"
call powershell -command "& '%~dp0\kotlin-client-nullable.bat'"

View File

@ -0,0 +1,10 @@
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 -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "kotlin-petstore-gson" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --additional-properties serializationLibrary=gson -o samples\client\petstore\kotlin-gson
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -0,0 +1,10 @@
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 -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "kotlin-petstore-nonpublic" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --additional-properties nonPublicApi=true -o samples\client\petstore\kotlin-nonpublic
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -0,0 +1,10 @@
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 -DloggerPath=conf/log4j.properties
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --artifact-id "kotlin-petstore-nullable" --additional-properties nullableReturnType=true,serializableModel=true -o samples\client\petstore\kotlin-nullable
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -0,0 +1,10 @@
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 -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "kotlin-petstore-okhttp3" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --library jvm-okhttp3 -o samples\client\petstore\kotlin-okhttp3
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "kotlin-petstore-client" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin -o samples\client\petstore\kotlin
set ags=generate --artifact-id "kotlin-petstore-client" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin -o samples\client\petstore\kotlin --additional-properties dateLibrary=java8,serializableModel=true
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -0,0 +1,10 @@
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 -DloggerPath=conf/log4j.properties
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --artifact-id "kotlin-petstore-string" --additional-properties dateLibrary=string,serializableModel=true -o samples\client\petstore\kotlin-string
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -0,0 +1,10 @@
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 -DloggerPath=conf/log4j.properties
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --artifact-id "kotlin-petstore-threetenbp" --additional-properties dateLibrary=threetenbp -o samples\client\petstore\kotlin-threetenbp
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -13,3 +13,4 @@ call .\bin\windows\typescript-angular-v7-not-provided-in-root.bat
call .\bin\windows\typescript-angular-v7-not-provided-in-root-with-npm.bat
call .\bin\windows\typescript-angular-v8-provided-in-root-with-npm.bat
call .\bin\windows\typescript-angular-v8-petstore-provided-in-root-with-prefixed-module-name.bat
call .\bin\windows\typescript-angular-v8-single-request-parameter.bat

View File

@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v8-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v8-provided-in-root\builds\single-request-parameter --additional-properties ngVersion=8.0.0,useSingleRequestParameter=true
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -18,6 +18,9 @@ sidebar_label: csharp-netcore
|useCollection|Deserialize array types to Collection&lt;T&gt; instead of List&lt;T&gt;.| |false|
|returnICollection|Return ICollection&lt;T&gt; instead of the concrete type.| |false|
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|

View File

@ -10,3 +10,4 @@ sidebar_label: go-server
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|sourceFolder|source folder for generated code| |go|
|serverPort|The network port the generated server binds to| |8080|
|featureCORS|Enable Cross-Origin Resource Sharing middleware| |false|

View File

@ -28,4 +28,5 @@ sidebar_label: kotlin-spring
|useBeanValidation|Use BeanValidation API annotations to validate data types| |true|
|reactive|use coroutines for reactive behavior| |false|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dl>|spring-boot|

View File

@ -16,6 +16,7 @@ sidebar_label: typescript-angular
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|
|providedInRoot|Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).| |false|
|ngVersion|The version of Angular.| |8.0.0|

View File

@ -19,6 +19,14 @@ Supported tasks include:
See the [openapi-generator-maven-plugin README](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md) for details related to configuring and using the Maven Plugin.
### sbt Integration
Please refer to https://github.com/upstart-commerce/sbt-openapi-generator
### Bazel Integration
Please refer to https://github.com/OpenAPITools/openapi-generator-bazel
### GitHub Integration
To push the auto-generated SDK to GitHub, we provide `git_push.sh` to streamline the process. For example:

View File

@ -72,15 +72,34 @@ public class Meta implements Runnable {
allowedValues = {"CLIENT", "SERVER", "DOCUMENTATION", "CONFIG", "OTHER"})
private String type = "OTHER";
@Option(name = {"-l", "--language"}, title = "language",
description = "the implementation language for the generator class",
allowedValues = {"java", "kotlin"}
)
private String language = "java";
@Override
public void run() {
final File targetDir = new File(outputFolder);
LOGGER.info("writing to folder [{}]", targetDir.getAbsolutePath());
String mainClass = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name) + "Generator";
String kebabName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name);
List<SupportingFile> supportingFiles =
List<SupportingFile> supportingFiles = "kotlin".equals(language) ?
ImmutableList.of(
new SupportingFile("kotlin/build_gradle.mustache", "", "build.gradle.kts"),
new SupportingFile("kotlin/gradle.properties", "", "gradle.properties"),
new SupportingFile("kotlin/settings.mustache", "", "settings.gradle"),
new SupportingFile("kotlin/generatorClass.mustache", on(File.separator).join("src/main/kotlin", asPath(targetPackage)), mainClass.concat(".kt")),
new SupportingFile("kotlin/generatorClassTest.mustache", on(File.separator).join("src/test/kotlin", asPath(targetPackage)), mainClass.concat("Test.kt")),
new SupportingFile("kotlin/README.mustache", "", "README.md"),
new SupportingFile("api.template", "src/main/resources" + File.separator + name,"api.mustache"),
new SupportingFile("model.template", "src/main/resources" + File.separator + name,"model.mustache"),
new SupportingFile("myFile.template", String.join(File.separator, "src", "main", "resources", name), "myFile.mustache"),
new SupportingFile("services.mustache", "src/main/resources/META-INF/services", CodegenConfig.class.getCanonicalName()))
: ImmutableList.of(
new SupportingFile("pom.mustache", "", "pom.xml"),
new SupportingFile("generatorClass.mustache", on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")),
new SupportingFile("generatorClassTest.mustache", on(File.separator).join("src/test/java", asPath(targetPackage)), mainClass.concat("Test.java")),
@ -97,6 +116,7 @@ public class Meta implements Runnable {
.put("generatorPackage", targetPackage)
.put("generatorClass", mainClass)
.put("name", name)
.put("kebabName", kebabName)
.put("generatorType", type)
.put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass)
.put("openapiGeneratorVersion", currentVersion).build();

View File

@ -103,7 +103,9 @@ public class WorkflowSettings {
builder.strictSpecBehavior = copy.isStrictSpecBehavior();
builder.templatingEngineName = copy.getTemplatingEngineName();
builder.ignoreFileOverride = copy.getIgnoreFileOverride();
builder.systemProperties = ImmutableMap.copyOf(copy.getSystemProperties());
// this, and any other collections, must be mutable in the builder.
builder.systemProperties = new HashMap<>(copy.getSystemProperties());
// force builder "with" methods to invoke side effects
builder.withTemplateDir(copy.getTemplateDir());
@ -272,6 +274,8 @@ public class WorkflowSettings {
private String templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String ignoreFileOverride;
// NOTE: All collections must be mutable in the builder, and copied to a new immutable collection in .build()
private Map<String, String> systemProperties = new HashMap<>();;
private Builder() {

View File

@ -19,6 +19,7 @@ package org.openapitools.codegen.config;
import org.testng.annotations.Test;
import java.nio.file.Paths;
import java.util.Map;
import static org.testng.Assert.*;
@ -48,6 +49,25 @@ public class WorkflowSettingsTest {
assertTrue(settings.isStrictSpecBehavior());
}
@Test
public void newBuilderFromCopyShouldMutateSystemProperties(){
WorkflowSettings original = WorkflowSettings.newBuilder()
.withOutputDir("output")
.withVerbose(true)
.withSkipOverwrite(false)
.withSystemProperty("first", "1st")
.build();
WorkflowSettings modified = WorkflowSettings.newBuilder(original)
.withSystemProperty("second", "2nd")
.build();
Map<String, String> properties = modified.getSystemProperties();
assertEquals(properties.size(), 2, "System Properties map should allow mutation when invoked via copy constructor");
assertEquals(properties.getOrDefault("first", ""), "1st");
assertEquals(properties.getOrDefault("second", ""), "2nd");
}
private void assertOnChangesToDefaults(WorkflowSettings defaults) {
WorkflowSettings settings = WorkflowSettings.newBuilder()
.withOutputDir("output")

View File

@ -45,7 +45,7 @@ compileJava.dependsOn tasks.openApiGenerate
[source,group]
----
plugins {
id "org.openapi.generator" version "4.2.0"
id "org.openapi.generator" version "4.2.2-SNAPSHOT"
}
----

View File

@ -11,11 +11,12 @@ gradle openApiGenerate
gradle openApiMeta
gradle openApiValidate
gradle buildGoSdk
gradle buildDotnetSdk
gradle generateGoWithInvalidSpec
```
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
```bash
gradle -PopenApiGeneratorVersion=4.2.0 openApiValidate
gradle -PopenApiGeneratorVersion=4.2.2-SNAPSHOT openApiValidate
```

View File

@ -65,6 +65,20 @@ task buildGoSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTas
]
}
task buildDotnetSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
generatorName = "csharp-netcore"
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
additionalProperties = [
packageGuid: "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}",
useCompareNetObjects: "true"
]
outputDir = "$buildDir/csharp-netcore".toString()
systemProperties = [
models: "",
apis : "",
]
}
task generateGoWithInvalidSpec(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
validateSpec = true
generatorName = "go"

View File

@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=4.1.1
openApiGeneratorVersion=4.2.0
# /RELEASE_VERSION

View File

@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.2.0</version>
<version>4.2.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.3-SNAPSHOT</version>
<version>4.2.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -0,0 +1,237 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>sample-project</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sample-project</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<!-- activate the plugin -->
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<id>default</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- specify the swagger yaml -->
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
<!-- target to generate java client code -->
<generatorName>kotlin</generatorName>
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
you can use the following target: <generatorName>spring</generatorName> -->
<!-- pass any necessary config options -->
<configOptions>
<serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
<execution>
<id>kotlin</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- specify the swagger yaml -->
<inputSpec>https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml
</inputSpec>
<!-- target to generate java client code -->
<generatorName>kotlin</generatorName>
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
you can use the following target: <generatorName>spring</generatorName> -->
<!-- pass any necessary config options -->
<configOptions>
<serializableModel>true</serializableModel>
</configOptions>
<output>${project.build.directory}/generated-sources/kotlin</output>
<apiPackage>kotlintest.org.openapitools.client.api</apiPackage>
<modelPackage>kotlintest.org.openapitools.client.model</modelPackage>
<invokerPackage>kotlintest.org.openapitools.client</invokerPackage>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<proc>none</proc>
</configuration>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<configuration>
<jvmTarget>${kotlinJvmTarget}</jvmTarget>
<javacOptions/>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.build.directory}/generated-sources/kotlin/src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- dependencies are needed for the client being generated -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<!-- You can find the dependencies for the library configuation you chose by looking in JavaClientCodegen.
Then find the corresponding dependency on Maven Central, and set the versions in the property section below -->
<!-- HTTP client: jersey-client -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable-version}</version>
</dependency>
<!-- Joda time: if you use it -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>${migbase64.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.moshi</groupId>
<artifactId>moshi-kotlin</artifactId>
<version>${moshi-kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.moshi</groupId>
<artifactId>moshi-adapters</artifactId>
<version>${moshi-kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.2.2</version>
</dependency>
</dependencies>
<properties>
<swagger-annotations-version>1.5.8</swagger-annotations-version>
<jersey-version>2.27</jersey-version>
<jackson-version>2.8.9</jackson-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
<jodatime-version>2.7</jodatime-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
<kotlin.version>1.3.50</kotlin.version>
<kotlinJvmTarget>1.8</kotlinJvmTarget>
<moshi-kotlin.version>1.8.0</moshi-kotlin.version>
<migbase64.version>2.2</migbase64.version>
</properties>
</project>

View File

@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.1</version>
<version>4.2.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.1</version>
<version>4.2.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -0,0 +1,126 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>sample-project</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sample-project</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
</parent>
<build>
<plugins>
<!-- activate the plugin -->
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.2.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<id>spring-server</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- specify the swagger yaml -->
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
<!-- target to generate java client code -->
<generatorName>spring</generatorName>
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
you can use the following target: <generatorName>spring</generatorName> -->
<!-- pass any necessary config options -->
<configOptions>
<serializableModel>true</serializableModel>
<snapshotVersion>true</snapshotVersion>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<proc>none</proc>
</configuration>
</plugin>
</plugins>
<pluginManagement>
</pluginManagement>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- dependencies are needed for the client being generated -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<!-- You can find the dependencies for the library configuation you chose by looking in JavaClientCodegen.
Then find the corresponding dependency on Maven Central, and set the versions in the property section below -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--SpringFox dependencies -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.1.0</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
</dependencies>
<properties>
<swagger-annotations-version>1.5.8</swagger-annotations-version>
<spring-boot-starter-web.version>2.2.1.RELEASE</spring-boot-starter-web.version>
<springfox-version>2.8.0</springfox-version>
</properties>
</project>

View File

@ -17,6 +17,7 @@
package org.openapitools.codegen;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@ -38,7 +39,7 @@ public class CodegenSecurity {
// Oauth specific
public String flow, authorizationUrl, tokenUrl;
public List<Map<String, Object>> scopes;
public Boolean isCode, isPassword, isApplication, isImplicit, hasScopes;
public Boolean isCode, isPassword, isApplication, isImplicit;
@Override
public String toString() {
@ -100,4 +101,47 @@ public class CodegenSecurity {
isImplicit,
scopes);
}
// Return a copy of the security object, filtering out any scopes from the passed-in list.
public CodegenSecurity filterByScopeNames(List<String> filterScopes) {
CodegenSecurity filteredSecurity = new CodegenSecurity();
// Copy all fields except the scopes.
filteredSecurity.name = name;
filteredSecurity.type = type;
filteredSecurity.hasMore = false;
filteredSecurity.isBasic = isBasic;
filteredSecurity.isBasicBasic = isBasicBasic;
filteredSecurity.isBasicBearer = isBasicBearer;
filteredSecurity.isApiKey = isApiKey;
filteredSecurity.isOAuth = isOAuth;
filteredSecurity.keyParamName = keyParamName;
filteredSecurity.isCode = isCode;
filteredSecurity.isImplicit = isImplicit;
filteredSecurity.isApplication = isApplication;
filteredSecurity.isPassword = isPassword;
filteredSecurity.isKeyInCookie = isKeyInCookie;
filteredSecurity.isKeyInHeader = isKeyInHeader;
filteredSecurity.isKeyInQuery = isKeyInQuery;
filteredSecurity.flow = flow;
filteredSecurity.tokenUrl = tokenUrl;
filteredSecurity.authorizationUrl = authorizationUrl;
// It is not possible to deep copy the extensions, as we have no idea what types they are.
// So the filtered method *will* refer to the original extensions, if any.
filteredSecurity.vendorExtensions = new HashMap<String, Object>(vendorExtensions);
List<Map<String, Object>> returnedScopes = new ArrayList<Map<String, Object>>();
Map<String, Object> lastScope = null;
for (String filterScopeName : filterScopes) {
for (Map<String, Object> scope : scopes) {
String name = (String) scope.get("scope");
if (filterScopeName.equals(name)) {
returnedScopes.add(scope);
lastScope = scope;
break;
}
}
}
filteredSecurity.scopes = returnedScopes;
return filteredSecurity;
}
}

View File

@ -1086,6 +1086,7 @@ public class DefaultCodegen implements CodegenConfig {
reservedWords = new HashSet<String>();
// TODO: Move Java specific import mappings out of DefaultCodegen.
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
@ -1895,6 +1896,7 @@ public class DefaultCodegen implements CodegenConfig {
if (composed.getRequired() != null) {
required.addAll(composed.getRequired());
allRequired.addAll(composed.getRequired());
}
addVars(m, unaliasPropertySchema(properties), required, unaliasPropertySchema(allProperties), allRequired);
@ -4401,14 +4403,9 @@ public class DefaultCodegen implements CodegenConfig {
* @return property value as boolean
*/
public boolean convertPropertyToBooleanAndWriteBack(String propertyKey) {
boolean booleanValue = false;
if (additionalProperties.containsKey(propertyKey)) {
booleanValue = convertPropertyToBoolean(propertyKey);
// write back as boolean
writePropertyBack(propertyKey, booleanValue);
}
return booleanValue;
boolean result = convertPropertyToBoolean(propertyKey);
writePropertyBack(propertyKey, result);
return result;
}
/**
@ -4432,12 +4429,16 @@ public class DefaultCodegen implements CodegenConfig {
}
public boolean convertPropertyToBoolean(String propertyKey) {
boolean booleanValue = false;
if (additionalProperties.containsKey(propertyKey)) {
booleanValue = Boolean.valueOf(additionalProperties.get(propertyKey).toString());
final Object booleanValue = additionalProperties.get(propertyKey);
Boolean result = Boolean.FALSE;
if (booleanValue instanceof Boolean) {
result = (Boolean) booleanValue;
} else if (booleanValue instanceof String) {
result = Boolean.parseBoolean((String) booleanValue);
} else {
LOGGER.warn("The value (generator's option) must be either boolean or string. Default to `false`.");
}
return booleanValue;
return result;
}
public void writePropertyBack(String propertyKey, boolean value) {

View File

@ -1057,55 +1057,21 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
}
Map<String, SecurityScheme> authMethods = getAuthMethods(securities, securitySchemes);
if (authMethods == null || authMethods.isEmpty()) {
authMethods = getAuthMethods(globalSecurities, securitySchemes);
}
if (authMethods != null && !authMethods.isEmpty()) {
codegenOperation.authMethods = config.fromSecurity(authMethods);
List<Map<String, Object>> scopes = new ArrayList<Map<String, Object>>();
if (codegenOperation.authMethods != null) {
for (CodegenSecurity security : codegenOperation.authMethods) {
if (security != null && security.isBasicBearer != null && security.isBasicBearer &&
securities != null) {
for (SecurityRequirement req : securities) {
if (req == null) continue;
for (String key : req.keySet()) {
if (security.name != null && key.equals(security.name)) {
int count = 0;
for (String sc : req.get(key)) {
Map<String, Object> scope = new HashMap<String, Object>();
scope.put("scope", sc);
scope.put("description", "");
count++;
if (req.get(key) != null && count < req.get(key).size()) {
scope.put("hasMore", "true");
List<CodegenSecurity> fullAuthMethods = config.fromSecurity(authMethods);
codegenOperation.authMethods = filterAuthMethods(fullAuthMethods, securities);
codegenOperation.hasAuthMethods = true;
} else {
scope.put("hasMore", null);
}
scopes.add(scope);
}
//end this inner for
break;
authMethods = getAuthMethods(globalSecurities, securitySchemes);
if (authMethods != null && !authMethods.isEmpty()) {
List<CodegenSecurity> fullAuthMethods = config.fromSecurity(authMethods);
codegenOperation.authMethods = filterAuthMethods(fullAuthMethods, globalSecurities);
codegenOperation.hasAuthMethods = true;
}
}
}
security.hasScopes = scopes.size() > 0;
security.scopes = scopes;
}
}
}
codegenOperation.hasAuthMethods = true;
}
/* TODO need to revise the logic below
Map<String, SecurityScheme> securitySchemeMap = openAPI.getComponents().getSecuritySchemes();
if (securitySchemeMap != null && !securitySchemeMap.isEmpty()) {
codegenOperation.authMethods = config.fromSecurity(securitySchemeMap);
codegenOperation.hasAuthMethods = true;
}
*/
} catch (Exception ex) {
String msg = "Could not process operation:\n" //
+ " Tag: " + tag + "\n"//
@ -1311,6 +1277,40 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
.scopes(newScopes);
}
private List<CodegenSecurity> filterAuthMethods(List<CodegenSecurity> authMethods, List<SecurityRequirement> securities) {
if (securities == null || securities.isEmpty() || authMethods == null) {
return authMethods;
}
List<CodegenSecurity> result = new ArrayList<CodegenSecurity>();
for (CodegenSecurity security : authMethods) {
boolean filtered = false;
if (security != null && security.scopes != null) {
for (SecurityRequirement requirement : securities) {
List<String> opScopes = requirement.get(security.name);
if (opScopes != null) {
// We have operation-level scopes for this method, so filter the auth method to
// describe the operation auth method with only the scopes that it requires.
// We have to create a new auth method instance because the original object must
// not be modified.
CodegenSecurity opSecurity = security.filterByScopeNames(opScopes);
result.add(opSecurity);
filtered = true;
break;
}
}
}
// If we didn't get a filtered version, then we can keep the original auth method.
if (!filtered) {
result.add(security);
}
}
return result;
}
private boolean hasOAuthMethods(List<CodegenSecurity> authMethods) {
for (CodegenSecurity cs : authMethods) {
if (Boolean.TRUE.equals(cs.isOAuth)) {

View File

@ -300,12 +300,17 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
String port = URLPathUtils.getPort(url, "");
String host = url.getHost();
String scheme = url.getProtocol();
if(!port.isEmpty()) {
this.additionalProperties.put("serverPort", port);
}
if(!host.isEmpty()) {
this.additionalProperties.put("serverHost", host);
}
if(!scheme.isEmpty()) {
this.additionalProperties.put("scheme", scheme);
}
}
@Override

View File

@ -1040,23 +1040,22 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
}
// TODO: Setting additionalProperties is not the responsibility of this method. These side-effects should be moved elsewhere to prevent unexpected behaviors.
if(artifactVersion == null) {
// If no artifactVersion is provided in additional properties, version from API specification is used.
// If none of them is provided then fallbacks to default version
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION) && additionalProperties.get(CodegenConstants.ARTIFACT_VERSION) != null) {
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
} else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) {
this.setArtifactVersion(openAPI.getInfo().getVersion());
} else {
this.setArtifactVersion(ARTIFACT_VERSION_DEFAULT_VALUE);
}
} else {
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
}
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
if (additionalProperties.containsKey(CodegenConstants.SNAPSHOT_VERSION)) {
Boolean useSnapshotVersion = Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SNAPSHOT_VERSION));
if (useSnapshotVersion) {
if (convertPropertyToBooleanAndWriteBack(CodegenConstants.SNAPSHOT_VERSION)) {
this.setArtifactVersion(this.buildSnapshotVersion(this.getArtifactVersion()));
}
}

View File

@ -434,19 +434,19 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) {
this.setSerializableModel(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL)));
this.setSerializableModel(convertPropertyToBooleanAndWriteBack(CodegenConstants.SERIALIZABLE_MODEL));
} else {
additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
}
if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) {
this.setParcelizeModels(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
this.setParcelizeModels(convertPropertyToBooleanAndWriteBack(CodegenConstants.PARCELIZE_MODELS));
} else {
additionalProperties.put(CodegenConstants.PARCELIZE_MODELS, parcelizeModels);
}
if (additionalProperties.containsKey(CodegenConstants.NON_PUBLIC_API)) {
this.setNonPublicApi(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.NON_PUBLIC_API)));
this.setNonPublicApi(convertPropertyToBooleanAndWriteBack(CodegenConstants.NON_PUBLIC_API));
} else {
additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi);
}

View File

@ -81,10 +81,10 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
if (Files.isRegularFile(filePathToInclude)) {
LOGGER.debug(
"including " + ++includeCount + ". file into markup from: " + filePathToInclude.toString());
out.write("\ninclude::" + relativeFileName + "[]\n");
out.write("\ninclude::" + relativeFileName + "[opts=optional]\n");
} else {
LOGGER.debug(++notFoundCount + ". file not found, skip include for: " + filePathToInclude.toString());
out.write("\n// markup not found, no include ::" + relativeFileName + "[]\n");
out.write("\n// markup not found, no include ::" + relativeFileName + "[opts=optional]\n");
}
}
}
@ -158,6 +158,8 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
*/
static String sanitize(final String name) {
String sanitized = name == null ? "" : name.trim();
sanitized = sanitized.replace("//", "/"); // rest paths may or may not end with slashes, leading to redundant
// path separators.
return sanitized.startsWith(File.separator) || sanitized.startsWith("/") ? sanitized.substring(1) : sanitized;
}

View File

@ -181,6 +181,18 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
"C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).",
this.optionalMethodArgumentFlag);
addSwitch(CodegenConstants.OPTIONAL_ASSEMBLY_INFO,
CodegenConstants.OPTIONAL_ASSEMBLY_INFO_DESC,
this.optionalAssemblyInfoFlag);
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
this.optionalEmitDefaultValuesFlag);
addSwitch(CodegenConstants.OPTIONAL_PROJECT_FILE,
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
this.optionalProjectFileFlag);
// NOTE: This will reduce visibility of all public members in templates. Users can use InternalsVisibleTo
// https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx
// to expose to shared code if the generated code is not embedded into another project. Otherwise, users of codegen
@ -362,6 +374,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
postProcessPattern(property.pattern, property.vendorExtensions);
postProcessEmitDefaultValue(property.vendorExtensions);
super.postProcessModelProperty(model, property);
}
@ -395,6 +409,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
@Override
public void postProcessParameter(CodegenParameter parameter) {
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
postProcessEmitDefaultValue(parameter.vendorExtensions);
super.postProcessParameter(parameter);
if (!parameter.required && nullableType.contains(parameter.dataType)) { //optional
@ -438,6 +453,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
}
}
public void postProcessEmitDefaultValue(Map<String, Object> vendorExtensions) {
vendorExtensions.put("x-emit-default-value", optionalEmitDefaultValuesFlag);
}
@Override
public Mustache.Compiler processCompiler(Mustache.Compiler compiler) {
// To avoid unexpected behaviors when options are passed programmatically such as { "supportsAsync": "" }
@ -457,6 +476,13 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
* if (additionalProperties.containsKey(prop)) convertPropertyToBooleanAndWriteBack(prop);
*/
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)) {
setOptionalEmitDefaultValuesFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES));
} else {
additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValuesFlag);
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
}
@ -572,6 +598,18 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
this.netStandard = netStandard;
}
public void setOptionalAssemblyInfoFlag(boolean flag) {
this.optionalAssemblyInfoFlag = flag;
}
public void setOptionalEmitDefaultValuesFlag(boolean flag){
this.optionalEmitDefaultValuesFlag = flag;
}
public void setOptionalProjectFileFlag(boolean flag) {
this.optionalProjectFileFlag = flag;
}
public void setPackageGuid(String packageGuid) {
this.packageGuid = packageGuid;
}

View File

@ -26,12 +26,47 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
// import static org.openapitools.codegen.utils.StringUtils.camelize;
// import static org.openapitools.codegen.utils.StringUtils.underscore;
// import java.io.BufferedReader;
// import java.io.File;
// import java.io.FileInputStream;
// import java.io.InputStreamReader;
// import java.nio.charset.Charset;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.HashMap;
// import java.util.HashSet;
// import java.util.List;
// import java.util.Map;
// import java.util.Set;
// import javax.xml.validation.Schema;
// import org.apache.commons.io.FilenameUtils;
// import org.openapitools.codegen.CodegenConfig;
// import org.openapitools.codegen.CodegenConstants;
// import org.openapitools.codegen.CodegenModel;
// import org.openapitools.codegen.CodegenProperty;
// import org.openapitools.codegen.CodegenType;
// import org.openapitools.codegen.DefaultCodegen;
// import org.openapitools.codegen.utils.ModelUtils;
// import org.openapitools.codegen.utils.StringUtils;
// import org.slf4j.LoggerFactory;
// import io.swagger.v3.oas.models.media.ArraySchema;
public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);
@ -55,8 +90,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
public DartClientCodegen() {
super();
// clear import mapping (from default generator) as dart does not use it
// at the moment
// clear import mapping (from default generator) as dart does not use it at the moment
importMapping.clear();
outputFolder = "generated-code/dart";
@ -71,19 +105,15 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
modelTestTemplateFiles.put("model_test.mustache", ".dart");
apiTestTemplateFiles.put("api_test.mustache", ".dart");
setReservedWordsLowerCase(
Arrays.asList(
"abstract", "as", "assert", "async", "async*", "await",
"break", "case", "catch", "class", "const", "continue",
"default", "deferred", "do", "dynamic", "else", "enum",
"export", "external", "extends", "factory", "false", "final",
"finally", "for", "get", "if", "implements", "import", "in",
"is", "library", "new", "null", "operator", "part", "rethrow",
"return", "set", "static", "super", "switch", "sync*", "this",
"throw", "true", "try", "typedef", "var", "void", "while",
"with", "yield", "yield*", "hide", "interface", "mixin", "on",
"show", "async")
);
List<String> reservedWordsList = new ArrayList<String>();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"), Charset.forName("UTF-8")));
while(reader.ready()) { reservedWordsList.add(reader.readLine()); }
reader.close();
} catch (Exception e) {
LOGGER.error("Error reading dart keywords. Exception: {}", e.getMessage());
}
setReservedWordsLowerCase(reservedWordsList);
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(

View File

@ -80,6 +80,7 @@ public class DartDioClientCodegen extends DartClientCodegen {
importMapping.put("BuiltList", "package:built_collection/built_collection.dart");
importMapping.put("BuiltMap", "package:built_collection/built_collection.dart");
importMapping.put("JsonObject", "package:built_value/json_object.dart");
importMapping.put("Uint8List", "dart:typed_data");
}
@ -129,6 +130,13 @@ public class DartDioClientCodegen extends DartClientCodegen {
return name;
}
@Override
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
//super.addAdditionPropertiesToCodeGenModel(codegenModel, schema);
codegenModel.additionalPropertiesType = getSchemaType(ModelUtils.getAdditionalProperties(schema));
addImport(codegenModel, codegenModel.additionalPropertiesType);
}
@Override
public void processOpts() {
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
@ -230,9 +238,16 @@ public class DartDioClientCodegen extends DartClientCodegen {
//Updates any List properties on a model to a BuiltList. This happens in post processing rather
//than type mapping as we only want this to apply to models, not every other class.
if ("List".equals(property.baseType)) {
property.setDatatype(property.dataType.replaceAll(property.baseType, "BuiltList"));
property.setDatatype(
property.dataType.replaceAll(property.baseType, "BuiltList"));
property.setBaseType("BuiltList");
model.imports.add("BuiltList");
if ("Object".equals(property.items.baseType)) {
property.setDatatype(
property.dataType.replaceAll("Object", "JsonObject"));
property.items.setDatatype("JsonObject");
model.imports.add("JsonObject");
}
}
}
if (property.isMapContainer) {
@ -242,6 +257,11 @@ public class DartDioClientCodegen extends DartClientCodegen {
property.setDatatype(property.dataType.replaceAll(property.baseType, "BuiltMap"));
property.setBaseType("BuiltMap");
model.imports.add("BuiltMap");
if ("Object".equals(property.items.baseType)) {
property.setDatatype(property.dataType.replaceAll("Object", "JsonObject"));
property.items.setDatatype("JsonObject");
model.imports.add("JsonObject");
}
}
}

View File

@ -373,7 +373,13 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImports.add(elmImport);
}
}
if (cm.discriminator != null) {
if (cm.oneOf != null) {
for (String variant : cm.oneOf) {
final ElmImport elmImport = createImport(variant);
elmImports.add(elmImport);
}
}
if (cm.discriminator != null && cm.children != null) {
for (CodegenModel child : cm.children) {
// add child imports
final ElmImport elmImport = createImport(child.classname);

View File

@ -39,6 +39,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
protected int serverPort = 8080;
protected String projectName = "openapi-server";
protected String sourceFolder = "go";
protected Boolean corsFeatureEnabled = false;
public GoServerCodegen() {
@ -55,6 +56,11 @@ public class GoServerCodegen extends AbstractGoCodegen {
optServerPort.defaultValue(Integer.toString(serverPort));
cliOptions.add(optServerPort);
CliOption optFeatureCORS = new CliOption("featureCORS", "Enable Cross-Origin Resource Sharing middleware");
optFeatureCORS.setType("bool");
optFeatureCORS.defaultValue(corsFeatureEnabled.toString());
cliOptions.add(optFeatureCORS);
/*
* Models. You can write model files using the modelTemplateFiles map.
* if you want to create one template for file, you can do so here.
@ -142,6 +148,12 @@ public class GoServerCodegen extends AbstractGoCodegen {
additionalProperties.put("serverPort", serverPort);
}
if (additionalProperties.containsKey("featureCORS")) {
this.setFeatureCORS(convertPropertyToBooleanAndWriteBack("featureCORS"));
} else {
additionalProperties.put("featureCORS", corsFeatureEnabled);
}
modelPackage = packageName;
apiPackage = packageName;
@ -263,4 +275,8 @@ public class GoServerCodegen extends AbstractGoCodegen {
public void setServerPort(int serverPort) {
this.serverPort = serverPort;
}
public void setFeatureCORS(Boolean featureCORS) {
this.corsFeatureEnabled = featureCORS;
}
}

View File

@ -30,6 +30,8 @@ import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class KotlinClientCodegen extends AbstractKotlinCodegen {
@ -186,6 +188,10 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.gson) {
supportingFiles.add(new SupportingFile("infrastructure/DateAdapter.kt.mustache", infrastructureFolder,
"DateAdapter.kt"));
}
} else if (MULTIPLATFORM.equals(getLibrary())) {
additionalProperties.put(MULTIPLATFORM, true);
@ -287,17 +293,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
CodegenModel cm = (CodegenModel) mo.get("model");
// escape the variable base name for use as a string literal
if (cm.requiredVars != null) {
for (CodegenProperty var : cm.requiredVars) {
List<CodegenProperty> vars = Stream.of(
cm.vars,
cm.allVars,
cm.optionalVars,
cm.requiredVars,
cm.readOnlyVars,
cm.readWriteVars,
cm.parentVars
)
.flatMap(List::stream)
.collect(Collectors.toList());
for (CodegenProperty var : vars) {
var.vendorExtensions.put(VENDOR_EXTENSION_BASE_NAME_LITERAL, var.baseName.replace("$", "\\$"));
}
}
if (cm.optionalVars != null) {
for (CodegenProperty var : cm.optionalVars) {
var.vendorExtensions.put(VENDOR_EXTENSION_BASE_NAME_LITERAL, var.baseName.replace("$", "\\$"));
}
}
}
return objects;
}

View File

@ -22,6 +22,7 @@ import com.samskivert.mustache.Template;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
@ -63,6 +64,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String SERVICE_IMPLEMENTATION = "serviceImplementation";
public static final String REACTIVE = "reactive";
public static final String INTERFACE_ONLY = "interfaceOnly";
public static final String DELEGATE_PATTERN = "delegatePattern";
private String basePackage;
private String invokerPackage;
@ -77,6 +79,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
private boolean serviceImplementation = false;
private boolean reactive = false;
private boolean interfaceOnly = false;
private boolean delegatePattern = false;
public KotlinSpringServerCodegen() {
super();
@ -125,6 +128,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
addSwitch(USE_BEANVALIDATION, "Use BeanValidation API annotations to validate data types", useBeanValidation);
addSwitch(REACTIVE, "use coroutines for reactive behavior", reactive);
addSwitch(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.", interfaceOnly);
addSwitch(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern", delegatePattern);
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
setLibrary(SPRING_BOOT);
@ -214,6 +218,10 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
this.interfaceOnly = interfaceOnly;
}
public void setDelegatePattern(boolean delegatePattern) {
this.delegatePattern = delegatePattern;
}
@Override
public void setUseBeanValidation(boolean useBeanValidation) {
this.useBeanValidation = useBeanValidation;
@ -331,15 +339,30 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
this.setInterfaceOnly(Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString()));
}
if (additionalProperties.containsKey(DELEGATE_PATTERN)) {
this.setDelegatePattern(Boolean.valueOf(additionalProperties.get(DELEGATE_PATTERN).toString()));
if (!this.interfaceOnly) {
this.setSwaggerAnnotations(true);
}
}
modelTemplateFiles.put("model.mustache", ".kt");
if (interfaceOnly) {
if (!this.interfaceOnly && this.delegatePattern) {
apiTemplateFiles.put("apiInterface.mustache", ".kt");
apiTemplateFiles.put("apiController.mustache", "Controller.kt");
} else if (interfaceOnly) {
apiTemplateFiles.put("apiInterface.mustache", ".kt");
} else {
apiTemplateFiles.put("api.mustache", ".kt");
apiTestTemplateFiles.put("api_test.mustache", ".kt");
}
if (SPRING_BOOT.equals(library)) {
supportingFiles.add(new SupportingFile("apiUtil.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtil.kt"));
}
if (this.serviceInterface) {
apiTemplateFiles.put("service.mustache", "Service.kt");
} else if (this.serviceImplementation) {
@ -349,6 +372,11 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
apiTemplateFiles.put("serviceImpl.mustache", "ServiceImpl.kt");
}
if (this.delegatePattern) {
additionalProperties.put("isDelegate", "true");
apiTemplateFiles.put("apiDelegate.mustache", "Delegate.kt");
}
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
@ -373,6 +401,12 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
// spring uses the jackson lib, and we disallow configuration.
additionalProperties.put("jackson", "true");
// add lambda for mustache templates
additionalProperties.put("lambdaEscapeDoubleQuote",
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))));
additionalProperties.put("lambdaRemoveLineBreak",
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\\r|\\n", "")));
}
@Override
@ -381,6 +415,31 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
.put("escapeDoubleQuote", new EscapeLambda("\"", "\\\""));
}
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
if (library.equals(SPRING_BOOT) && this.delegatePattern) {
String basePath = resourcePath;
if (basePath.startsWith("/")) {
basePath = basePath.substring(1);
}
int pos = basePath.indexOf("/");
if (pos > 0) {
basePath = basePath.substring(0, pos);
}
if (basePath.equals("")) {
basePath = "default";
} else {
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.computeIfAbsent(basePath, k -> new ArrayList<>());
opList.add(co);
co.baseName = basePath;
} else {
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
}
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
super.preprocessOpenAPI(openAPI);

View File

@ -19,8 +19,11 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -63,6 +66,8 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
additionalProperties.put("apiPackage", apiPackage);
// Explicitly defining bulid.properties helps guarantee our sample remains compilable against the embedded target 2.11 scala
supportingFiles.add(new SupportingFile("build.properties.mustache", "", "project/build.properties"));
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
supportingFiles.add(new SupportingFile("dateTimeCodecs.mustache", (sourceFolder + File.separator + apiPackage).replace(".", File.separator), "DateTimeCodecs.scala"));
supportingFiles.add(new SupportingFile("HelperCodecs.mustache", (sourceFolder + File.separator + apiPackage).replace(".", File.separator), "HelperCodecs.scala"));
@ -72,9 +77,15 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
importMapping.remove("Set");
importMapping.remove("Map");
importMapping.put("Date", "java.util.Date");
importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer");
// Overrides defaults applied in DefaultCodegen which don't apply cleanly to Scala.
importMapping.put("Date", "java.util.Date");
importMapping.put("DateTime", "org.joda.time.DateTime");
importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime");
importMapping.put("LocalDate", "org.joda.time.LocalDate");
importMapping.put("LocalTime", "org.joda.time.LocalTime");
typeMapping = new HashMap<String, String>();
typeMapping.put("enum", "NSString");
typeMapping.put("array", "List");
@ -179,6 +190,42 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
}
@Override
public String toDefaultValue(Schema p) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
// comment out the following as the default value is no handled differently
if (ModelUtils.isBooleanSchema(p)) {
return null;
} else if (ModelUtils.isDateSchema(p)) {
return null;
} else if (ModelUtils.isDateTimeSchema(p)) {
return null;
} else if (ModelUtils.isNumberSchema(p)) {
return null;
} else if (ModelUtils.isIntegerSchema(p)) {
return null;
} else if (ModelUtils.isMapSchema(p)) {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "Map.empty[String, " + inner + "] ";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String collectionType = typeMapping.get("array");
// We assume that users would map these collections to a monoid with an identity function
// There's no reason to assume mutable structure here (which may make consumption more difficult)
return collectionType + ".empty[" + inner + "] ";
} else if (ModelUtils.isStringSchema(p)) {
return null;
} else {
return null;
}
}
@Override
public CodegenType getTag() {
return CodegenType.CLIENT;

View File

@ -26,6 +26,8 @@ import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.OptionalFeatures;
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
import org.openapitools.codegen.templating.mustache.SplitStringLambda;
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -303,9 +305,8 @@ public class SpringCodegen extends AbstractJavaCodegen
if (additionalProperties.containsKey(UNHANDLED_EXCEPTION_HANDLING)) {
this.setUnhandledException(Boolean.valueOf(additionalProperties.get(UNHANDLED_EXCEPTION_HANDLING).toString()));
} else {
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
}
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
typeMapping.put("file", "Resource");
importMapping.put("Resource", "org.springframework.core.io.Resource");
@ -463,6 +464,10 @@ public class SpringCodegen extends AbstractJavaCodegen
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))));
additionalProperties.put("lambdaRemoveLineBreak",
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\\r|\\n", "")));
additionalProperties.put("lambdaTrimWhitespace", new TrimWhitespaceLambda());
additionalProperties.put("lambdaSplitString", new SplitStringLambda());
}
@Override

View File

@ -44,6 +44,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String NPM_REPOSITORY = "npmRepository";
public static final String WITH_INTERFACES = "withInterfaces";
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
public static final String TAGGED_UNIONS = "taggedUnions";
public static final String NG_VERSION = "ngVersion";
public static final String PROVIDED_IN_ROOT = "providedInRoot";
@ -58,6 +59,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
protected String ngVersion = "8.0.0";
protected String npmRepository = null;
private boolean useSingleRequestParameter = false;
protected String serviceSuffix = "Service";
protected String serviceFileSuffix = ".service";
protected String modelSuffix = "";
@ -86,6 +88,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
this.cliOptions.add(CliOption.newBoolean(WITH_INTERFACES,
"Setting this property to true will generate interfaces next to the default class implementations.",
false));
this.cliOptions.add(CliOption.newBoolean(USE_SINGLE_REQUEST_PARAMETER,
"Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.",
false));
this.cliOptions.add(CliOption.newBoolean(TAGGED_UNIONS,
"Use discriminators to create tagged unions instead of extending interfaces.",
this.taggedUnions));
@ -164,6 +169,11 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
}
if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) {
this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER));
}
writePropertyBack(USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter());
if (additionalProperties.containsKey(TAGGED_UNIONS)) {
taggedUnions = Boolean.parseBoolean(additionalProperties.get(TAGGED_UNIONS).toString());
}
@ -576,6 +586,14 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
this.npmRepository = npmRepository;
}
private boolean getUseSingleRequestParameter() {
return useSingleRequestParameter;
}
private void setUseSingleRequestParameter(boolean useSingleRequestParameter) {
this.useSingleRequestParameter = useSingleRequestParameter;
}
private String getApiFilenameFromClassname(String classname) {
String name = classname.substring(0, classname.length() - serviceSuffix.length());
return toApiFilename(name);

View File

@ -54,8 +54,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
outputFolder = "generated-code/typescript-fetch";
embeddedTemplateDir = templateDir = "typescript-fetch";
this.apiPackage = "src" + File.separator +"apis";
this.modelPackage = "src" + File.separator + "models";
this.apiTemplateFiles.put("apis.mustache", ".ts");
this.modelTemplateFiles.put("models.mustache", ".ts");
this.addExtraReservedWords();
@ -98,10 +96,17 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
super.processOpts();
additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original"));
additionalProperties.put("modelPropertyNaming", getModelPropertyNaming());
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.ts"));
supportingFiles.add(new SupportingFile("runtime.mustache", "src", "runtime.ts"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
String sourceDir = "";
if (additionalProperties.containsKey(NPM_NAME)) {
sourceDir = "src" + File.separator;
}
this.apiPackage = sourceDir + "apis";
this.modelPackage = sourceDir + "models";
supportingFiles.add(new SupportingFile("index.mustache", sourceDir, "index.ts"));
supportingFiles.add(new SupportingFile("runtime.mustache", sourceDir, "runtime.ts"));
if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) {
this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER));
@ -211,7 +216,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
//Files for building our lib
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("npmignore.mustache", "", ".npmignore"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
}
@Override

View File

@ -0,0 +1,104 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.templating.mustache;
import java.io.IOException;
import java.io.Writer;
import java.util.Locale;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template.Fragment;
/**
* Splits long fragments into smaller strings and uses a StringBuilder to merge
* them back.
*
* Register:
*
* <pre>
* additionalProperties.put("lambdaSplitString", new SplitStringLambda());
* </pre>
*
* Use:
*
* <pre>
* {{#lambdaSplitString}}{{summary}}{{/lambdaSplitString}}
* </pre>
*/
public class SplitStringLambda implements Mustache.Lambda {
private static final int DEFAULT_MAX_LENGTH = 65535;
private static final String SPLIT_INIT = "new StringBuilder(%d)";
private static final String SPLIT_PART = ".append(\"%s\")";
private static final String SPLIT_SUFFIX = ".toString()";
private final int maxLength;
public SplitStringLambda() {
this(DEFAULT_MAX_LENGTH);
}
public SplitStringLambda(int maxLength) {
this.maxLength = maxLength;
}
@Override
public void execute(Fragment fragment, Writer writer) throws IOException {
String input = fragment.execute();
int inputLength = input.length();
StringBuilder builder = new StringBuilder();
if (inputLength > maxLength) {
// Initialize a StringBuilder
builder.append(String.format(Locale.ROOT, SPLIT_INIT, inputLength));
int currentPosition = 0;
int currentStringLength = 0;
char currentLastChar = '\\';
// Split input into parts of at most maxLength and not ending with an escape character
// Append each part to the StringBuilder
while (currentPosition + maxLength < input.length()) {
currentStringLength = maxLength;
currentLastChar = input.charAt(currentPosition + currentStringLength - 1);
if (currentLastChar == '\\') {
--currentStringLength;
}
builder.append(String.format(Locale.ROOT, SPLIT_PART, input.substring(currentPosition, currentPosition + currentStringLength)));
currentPosition += currentStringLength;
}
// Append last part if necessary
if (currentPosition < input.length()) {
builder.append(String.format(Locale.ROOT, SPLIT_PART, input.substring(currentPosition)));
}
// Close the builder and merge everything back to a string
builder.append(SPLIT_SUFFIX);
} else {
builder.append(String.format(Locale.ROOT, "\"%s\"", input));
}
writer.write(builder.toString());
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.templating.mustache;
import java.io.IOException;
import java.io.Writer;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template.Fragment;
/**
* Replaces duplicate whitespace characters in a fragment with single space.
*
* Register:
* <pre>
* additionalProperties.put("lambdaTrimWhitespace", new TrimWhitespaceLambda());
* </pre>
*
* Use:
* <pre>
* {{#lambdaTrimWhitespace}}{{name}}{{/lambdaTrimWhitespace}}
* </pre>
*/
public class TrimWhitespaceLambda implements Mustache.Lambda {
private static final String SINGLE_SPACE = " ";
private static final String WHITESPACE_REGEX = "\\s+";
@Override
public void execute(Fragment fragment, Writer writer) throws IOException {
writer.write(fragment.execute().replaceAll(WHITESPACE_REGEX, SINGLE_SPACE));
}
}

View File

@ -73,11 +73,14 @@ set(HDRS "")
## This section shows how to use the above compiled libary to compile the source files
## set source files
#set(SRCS
# unit-tests/manual-PetAPI.c
# unit-tests/manual-StoreAPI.c
# unit-tests/manual-UserAPI.c
# unit-tests/manual-order.c
# unit-tests/manual-user.c)
{{#apiInfo}}
{{#apis}}
{{#operations}}
# unit-tests/manual-{{classname}}.c
{{/operations}}
{{/apis}}
{{/apiInfo}}
#)
##set header files
#set(HDRS

View File

@ -14,7 +14,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}
## Installation
You'll need the `curl 7.58.0` package in order to build the API. To have code formatted nicely you also need to have uncrustify version 0.67.
You'll need the `curl 7.58.0` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.
# Prerequisites
@ -40,11 +40,11 @@ sudo make install
```
## Compile the sample:
This will compile the generated code and create a library in build folder which has to be linked to the codes where API will be used.
This will compile the generated code and create a library in the build folder which has to be linked to the codes where API will be used.
```bash
mkdir build
cd build
// To install library to specific location use following command
// To install library to specific location, use following commands
cmake -DCMAKE_INSTALL_PREFIX=/pathtolocaiton ..
// for normal install use following command
cmake ..
@ -58,11 +58,11 @@ To compile main.c(considering the file is present in build folder) use following
-L - locaiton of the library(not required if cmake with normal installation is performed)
-l library name
```bash
gcc main.c -L. -lpetstore -o main
gcc main.c -L. -l{{projectName}} -o main
```
once compile, you can run it with ``` ./main ```
Once compiled, you can run it with ``` ./main ```
Note: You dont need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
Note: You don't need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
## Author

View File

@ -28,6 +28,7 @@ repositories {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
}
dependencies {
@ -35,7 +36,7 @@ dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
compile 'io.github.http-builder-ng:http-builder-ng-core:1.0.3'

View File

@ -137,7 +137,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
jackson_databind_nullable_version = "0.2.0"
jersey_version = "1.19.4"
jodatime_version = "2.9.9"

View File

@ -121,7 +121,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
jackson_databind_nullable_version = "0.2.0"
google_api_client_version = "1.23.0"
jersey_common_version = "2.25.1"

View File

@ -14,7 +14,7 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.core" % "jersey-common" % "2.25.1",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile",
{{#withXml}}
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.9.10" % "compile",
{{/withXml}}

View File

@ -307,7 +307,7 @@
<google-api-client-version>1.30.2</google-api-client-version>
<jersey-common-version>2.25.1</jersey-common-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-version>2.9.10.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
{{#joda}}
<jodatime-version>2.9.9</jodatime-version>

View File

@ -120,7 +120,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
jackson_databind_nullable_version = "0.2.0"
{{#supportJava6}}
jersey_version = "2.6"

View File

@ -15,7 +15,7 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile",
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.10" % "compile",
{{/joda}}

View File

@ -361,7 +361,7 @@
<commons_lang3_version>3.6</commons_lang3_version>
{{/supportJava6}}
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-version>2.9.10.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
{{#threetenbp}}
<threetenbp-version>2.9.10</threetenbp-version>

View File

@ -148,7 +148,10 @@ public class {{classname}} {
{{#returnType}}
return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {});
{{/returnType}}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}

View File

@ -120,7 +120,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
jackson_databind_nullable_version = "0.2.0"
threetenbp_version = "2.9.10"
resteasy_version = "3.1.3.Final"

View File

@ -15,7 +15,7 @@ lazy val root = (project in file(".")).
"org.jboss.resteasy" % "resteasy-jackson2-provider" % "3.1.3.Final" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile",
{{#java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile",

View File

@ -295,7 +295,7 @@
<swagger-annotations-version>1.5.22</swagger-annotations-version>
<resteasy-version>3.1.3.Final</resteasy-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-version>2.9.10.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
<threetenbp-version>2.9.10</threetenbp-version>
{{^java8}}

View File

@ -84,7 +84,7 @@ public class ApiClient {
this.separator = separator;
}
private String collectionToString(Collection<? extends CharSequence> collection) {
private String collectionToString(Collection<?> collection) {
return StringUtils.collectionToDelimitedString(collection, separator);
}
}
@ -407,7 +407,7 @@ public class ApiClient {
* @param values The values of the parameter.
* @return String representation of the parameter
*/
public String collectionPathParameterToString(CollectionFormat collectionFormat, Collection<? extends CharSequence> values) {
public String collectionPathParameterToString(CollectionFormat collectionFormat, Collection<?> values) {
// create the value based on the collection format
if (CollectionFormat.MULTI.equals(collectionFormat)) {
// not valid for path params

View File

@ -116,7 +116,7 @@ public class {{classname}} {
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();{{#hasQueryParams}}
final MultiValueMap formParams = new LinkedMultiValueMap();{{#hasQueryParams}}
{{#queryParams}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}}
{{/hasMore}}{{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}}
@ -130,7 +130,7 @@ public class {{classname}} {
{{/hasMore}}{{/cookieParams}}{{/hasCookieParams}}{{#hasFormParams}}
{{#formParams}}if ({{paramName}} != null)
formParams.add("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
formParams.{{^collectionFormat}}add{{/collectionFormat}}{{#collectionFormat}}put{{/collectionFormat}}("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
{{/hasMore}}{{/formParams}}{{/hasFormParams}}
final String[] accepts = { {{#hasProduces}}

View File

@ -121,7 +121,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
jackson_databind_nullable_version = "0.2.0"
spring_web_version = "4.3.9.RELEASE"
jodatime_version = "2.9.9"

View File

@ -310,7 +310,7 @@
<swagger-annotations-version>1.5.22</swagger-annotations-version>
<spring-web-version>4.3.9.RELEASE</spring-web-version>
<jackson-version>2.9.10</jackson-version>
<jackson-databind-version>2.9.10</jackson-databind-version>
<jackson-databind-version>2.9.10.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.0</jackson-databind-nullable-version>
{{#joda}}
<jodatime-version>2.9.9</jodatime-version>

View File

@ -132,7 +132,7 @@ ext {
{{/play25}}
{{#play26}}
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
jackson_databind_nullable_version = "0.2.0"
play_version = "2.6.7"
{{/play26}}

View File

@ -25,7 +25,7 @@ lazy val root = (project in file(".")).
"com.typesafe.play" % "play-java-ws_2.11" % "2.5.15" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile",
{{/play25}}
{{#play26}}
"com.typesafe.play" % "play-ahc-ws_2.12" % "2.6.7" % "compile",

Some files were not shown because too many files have changed in this diff Show More