update petstore samples

This commit is contained in:
William Cheng 2018-10-16 13:19:40 +08:00
commit 257a97b6cd
1655 changed files with 15531 additions and 7314 deletions

View File

@ -2,7 +2,7 @@
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md). - [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
- [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\bin\windows\`. - [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\bin\windows\`.
- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (3.3.x), `4.0.x`. Default: `master`. - [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `3.4.x`, `4.0.x`. Default: `master`.
- [ ] Copied 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. - [ ] Copied 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.
### Description of the PR ### Description of the PR

View File

@ -1,24 +1,27 @@
#!/bin/bash #!/bin/bash
#
# A bash script to run CircleCI node/test in parallel
#
NODE_INDEX=${CIRCLE_NODE_INDEX:-0} NODE_INDEX=${CIRCLE_NODE_INDEX:-0}
if [ "$NODE_INDEX" = "1" ]; then if [ "$NODE_INDEX" = "1" ]; then
echo "Running node $NODE_INDEX to test CI/pom.xml.circleci ..." echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..."
cp CI/pom.xml.circleci pom.xml #cp CI/pom.xml.circleci pom.xml
java -version java -version
mvn --quiet verify -Psamples mvn --quiet verify -Psamples.circleci
elif [ "$NODE_INDEX" = "2" ]; then elif [ "$NODE_INDEX" = "2" ]; then
echo "Running node $NODE_INDEX to test ensure-up-to-date" echo "Running node $NODE_INDEX to test ensure-up-to-date"
java -version
#export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" #export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"
# not formatting the code as different go versions may format the code a bit different # not formatting the code as different go versions may format the code a bit different
./bin/utils/ensure-up-to-date #./bin/utils/ensure-up-to-date
else else
echo "Running node $NODE_INDEX to test CI/pom.xml.circleci.java7 ..." echo "Running node $NODE_INDEX to test 'samples.circleci.jdk7' defined in pom.xml ..."
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
java -version java -version
cp CI/pom.xml.circleci.java7 pom.xml #cp CI/pom.xml.circleci.java7 pom.xml
mvn --quiet verify -Psamples mvn --quiet verify -Psamples.circleci.jdk7
fi fi

View File

@ -2,11 +2,16 @@
<div align="center"> <div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.3.0`): [![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) (`3.3.1`): [![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) [![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) [![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) [![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)
[`3.4.x`](https://github.com/OpenAPITools/openapi-generator/tree/3.4.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/3.4.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/3.4.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=3.4.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=3.4.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[`4.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) [`4.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) [![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator) [![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
@ -31,7 +36,7 @@
:notebook_with_decorative_cover: The eBook [A Beginner's Guide to Code Generation for REST APIs](https://gumroad.com/l/swagger_codegen_beginner) is a good starting point for beginners :notebook_with_decorative_cover: :notebook_with_decorative_cover: The eBook [A Beginner's Guide to Code Generation for REST APIs](https://gumroad.com/l/swagger_codegen_beginner) is a good starting point for beginners :notebook_with_decorative_cover:
:warning: If the OpenAPI spec is obtained from an untrusted source, please make sure you've reviewed the spec before using OpenAPI Generator to generate the API client, server stub or documentation as [code injection](https://en.wikipedia.org/wiki/Code_injection) may occur :warning: :warning: If the OpenAPI spec, templates or any input (e.g. options, envirionment variables) is obtained from an untrusted source or environment, please make sure you've reviewed these inputs before using OpenAPI Generator to generate the API client, server stub or documentation to avoid potential security issues (e.g. [code injection](https://en.wikipedia.org/wiki/Code_injection)) :warning:
:bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of OpenAPI Generator) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) :bangbang: :bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of OpenAPI Generator) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) :bangbang:
@ -84,8 +89,8 @@ OpenAPI Generator Version | Release Date | Notes
---------------------------- | ------------ | ----- ---------------------------- | ------------ | -----
4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | Major release with breaking changes (no fallback) 4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | Major release with breaking changes (no fallback)
3.4.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.4.0-SNAPSHOT/)| 01.11.2018 | Minor release (breaking changes with fallbacks) 3.4.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.4.0-SNAPSHOT/)| 01.11.2018 | Minor release (breaking changes with fallbacks)
3.3.1 (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.3.1-SNAPSHOT/) | 15.10.2018 | Bugfix release 3.3.2 (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.3.2-SNAPSHOT/) | 29.10.2018 | Bugfix release
[3.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.3.0) (latest stable release) | 01.10.2018 | Minor release (breaking changes with fallbacks) [3.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.3.1) (latest stable release) | 15.10.2018 | Bugfix release
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0 OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@ -141,16 +146,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum): 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/3.3.0/openapi-generator-cli-3.3.0.jar` JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.1/openapi-generator-cli-3.3.1.jar`
For **Mac/Linux** users: For **Mac/Linux** users:
```sh ```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.0/openapi-generator-cli-3.3.0.jar -O openapi-generator-cli.jar wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.1/openapi-generator-cli-3.3.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. 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/3.3.0/openapi-generator-cli-3.3.0.jar Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.1/openapi-generator-cli-3.3.1.jar
``` ```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage. After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.

14
Vagrantfile vendored
View File

@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64" config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |v| config.vm.provider "virtualbox" do |v|
v.name = "openapi-generator" v.name = "openapi-generator"
@ -23,13 +23,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#Provision #Provision
config.vm.provision "shell", inline: <<-SHELL config.vm.provision "shell", inline: <<-SHELL
sudo touch /var/lib/cloud/instance/locale-check.skip sudo apt-get update
sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list' curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-cache policy docker-engine sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable"
sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-cosmic main" > /etc/apt/sources.list.d/docker.list'
sudo apt-get update sudo apt-get update
sudo apt-get upgrade -y sudo apt-get upgrade -y
sudo apt-get install -y docker-engine sudo apt-get install -y docker-ce
sudo usermod -aG docker vagrant sudo usermod -aG docker vagrant
SHELL SHELL

View File

@ -1,11 +1,11 @@
#!/bin/sh #!/bin/bash
SCRIPT="$0" SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT" echo "# START SCRIPT: ${SCRIPT}"
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
for GENERATOR in $(java -jar $executable list --short | sed -e 's/,/\'$'\n''/g') for GENERATOR in $(java -jar ${executable} list --short | sed -e 's/,/\'$'\n''/g')
do do
./bin/utils/export_generator.sh $GENERATOR ./bin/utils/export_generator.sh ${GENERATOR}
done done

View File

@ -1,17 +1,19 @@
#!/bin/sh #!/bin/bash
SCRIPT="$0" SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
if [[ "$1" != "" ]]; then if [[ "$1" != "" ]]; then
NAME="$1" NAME="$1"
echo "# START SCRIPT: ${SCRIPT} ${NAME}"
else else
echo "Missing argument. Usage e.g.: ./bin/utils/export-generator.sh jaxrs-jersey" echo "Missing argument to ${SCRIPT}."
echo " Usage: ${SCRIPT} generator-name"
echo " Example: ${SCRIPT} groovy"
exit 1; exit 1;
fi fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
java -jar $executable config-help -g $NAME | sed -e 's/CONFIG OPTIONS/CONFIG OPTIONS for \'$NAME'\'$'\n''/g' > docs/generators/$NAME.md java -jar ${executable} config-help -g ${NAME} --named-header -o docs/generators/${NAME}.md
echo "Back to the [generators list](README.md)" >> docs/generators/$NAME.md echo "Back to the [generators list](README.md)" >> docs/generators/${NAME}.md

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for groovy
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
configPackage configPackage
configuration package for generated code configuration package for generated code

View File

@ -104,4 +104,13 @@ CONFIG OPTIONS for java-inflector
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
Back to the [generators list](README.md) Back to the [generators list](README.md)

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for java-msf4j
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for java-pkmst
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
groupId groupId
groupId in generated pom.xml groupId in generated pom.xml

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for java-play-framework
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
title title
server title name or client service name server title name or client service name

View File

@ -104,4 +104,13 @@ CONFIG OPTIONS for java-undertow-server
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
Back to the [generators list](README.md) Back to the [generators list](README.md)

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for java-vertx
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
rxInterface rxInterface
When specified, API interfaces are generated with RX and methods return Single<> and Comparable. (Default: false) When specified, API interfaces are generated with RX and methods return Single<> and Comparable. (Default: false)

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for java
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
useRxJava useRxJava
Whether to use the RxJava adapter with the retrofit2 library. (Default: false) Whether to use the RxJava adapter with the retrofit2 library. (Default: false)

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-cxf-cdi
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-cxf-client
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
useBeanValidation useBeanValidation
Use BeanValidation API annotations (Default: false) Use BeanValidation API annotations (Default: false)

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-cxf
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-jersey
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-resteasy-eap
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-resteasy
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-spec
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
implFolder implFolder
folder for generated implementation code folder for generated implementation code

View File

@ -104,6 +104,15 @@ CONFIG OPTIONS for spring
booleanGetterPrefix booleanGetterPrefix
Set booleanGetterPrefix (default value 'get') Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
title title
server title name or client service name server title name or client service name

View File

@ -38,7 +38,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.3</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>process-resources</id> <id>process-resources</id>

View File

@ -26,6 +26,9 @@ import org.openapitools.codegen.GeneratorNotFoundException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.apache.commons.lang3.StringUtils.isNotEmpty; import static org.apache.commons.lang3.StringUtils.isNotEmpty;
@ -42,6 +45,16 @@ public class ConfigHelp implements Runnable {
description = "generator to get config help for") description = "generator to get config help for")
private String generatorName; private String generatorName;
@Option(name = {"--named-header"}, title = "named header",
description = "Header includes the generator name, for clarity in output")
private Boolean namedHeader;
@Option(name = {"-o", "--output"}, title = "output location",
description = "Optionally write help to this location, otherwise default is standard output")
private String outputFile;
private String newline = System.lineSeparator();
@Override @Override
public void run() { public void run() {
@ -57,19 +70,47 @@ public class ConfigHelp implements Runnable {
} }
try { try {
StringBuilder sb = new StringBuilder();
CodegenConfig config = CodegenConfigLoader.forName(generatorName); CodegenConfig config = CodegenConfigLoader.forName(generatorName);
System.out.println();
System.out.println("CONFIG OPTIONS"); generatePlainTextHelp(sb, config);
for (CliOption langCliOption : config.cliOptions()) {
System.out.println("\t" + langCliOption.getOpt()); if (!isEmpty(outputFile)) {
System.out.println("\t " File out = new File(outputFile);
+ langCliOption.getOptionHelp().replaceAll("\n", System.lineSeparator() + "\t ")); //noinspection ResultOfMethodCallIgnored
System.out.println(); out.mkdirs();
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out), StandardCharsets.UTF_8));
writer.write(sb.toString());
writer.close();
} else {
System.out.print(sb.toString());
} }
} catch (GeneratorNotFoundException e) { } catch (GeneratorNotFoundException e) {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
System.err.println("[error] Check the spelling of the generator's name and try again."); System.err.println("[error] Check the spelling of the generator's name and try again.");
System.exit(1); System.exit(1);
} catch (IOException e) {
e.printStackTrace();
}
}
private void generatePlainTextHelp(StringBuilder sb, CodegenConfig config) {
sb.append(newline);
sb.append("CONFIG OPTIONS");
if (Boolean.TRUE.equals(namedHeader)) {
sb.append(" for ").append(generatorName).append(newline);
}
sb.append(newline);
for (CliOption langCliOption : config.cliOptions()) {
sb.append("\t").append(langCliOption.getOpt());
sb.append(newline);
sb.append("\t ").append(langCliOption.getOptionHelp().replaceAll("\n", System.lineSeparator() + "\t "));
sb.append(newline);
sb.append(newline);
} }
} }
} }

View File

@ -208,6 +208,9 @@ public class Generate implements Runnable {
+ " Useful for piping the JSON output of debug options (e.g. `-DdebugOperations`) to an external parser directly while testing a generator.") + " Useful for piping the JSON output of debug options (e.g. `-DdebugOperations`) to an external parser directly while testing a generator.")
private Boolean logToStderr; private Boolean logToStderr;
@Option(name = {"--enable-post-process-file"}, title = "enable post-process file", description = CodegenConstants.ENABLE_POST_PROCESS_FILE)
private Boolean enablePostProcessFile;
@Override @Override
public void run() { public void run() {
if (logToStderr != null) { if (logToStderr != null) {
@ -329,6 +332,10 @@ public class Generate implements Runnable {
configurator.setRemoveOperationIdPrefix(removeOperationIdPrefix); configurator.setRemoveOperationIdPrefix(removeOperationIdPrefix);
} }
if (enablePostProcessFile != null) {
configurator.setEnablePostProcessFile(enablePostProcessFile);
}
applySystemPropertiesKvpList(systemProperties, configurator); applySystemPropertiesKvpList(systemProperties, configurator);
applyInstantiationTypesKvpList(instantiationTypes, configurator); applyInstantiationTypesKvpList(instantiationTypes, configurator);
applyImportMappingsKvpList(importMappings, configurator); applyImportMappingsKvpList(importMappings, configurator);

View File

@ -48,7 +48,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.0" classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.1"
} }
} }

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-rc-1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -15,6 +15,7 @@
<properties> <properties>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo> <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
<gradleVersion>4.10.2</gradleVersion>
</properties> </properties>
<dependencies> <dependencies>
@ -54,7 +55,7 @@
<artifactId>gradle-maven-plugin</artifactId> <artifactId>gradle-maven-plugin</artifactId>
<version>1.0.8</version> <version>1.0.8</version>
<configuration> <configuration>
<gradleVersion>4.10-rc-1</gradleVersion> <gradleVersion>${gradleVersion}</gradleVersion>
<args> <args>
<arg>-P openApiGeneratorVersion=${project.version}</arg> <arg>-P openApiGeneratorVersion=${project.version}</arg>
</args> </args>
@ -76,6 +77,13 @@
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
<dependencies>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>${gradleVersion}</version>
</dependency>
</dependencies>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example: The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
```bash ```bash
gradle -PopenApiGeneratorVersion=3.3.0 openApiValidate gradle -PopenApiGeneratorVersion=3.3.1 openApiValidate
``` ```

View File

@ -1 +1 @@
openApiGeneratorVersion=3.3.0 openApiGeneratorVersion=3.3.1

View File

@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin> <plugin>
<groupId>org.openapitools</groupId> <groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId> <artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.0</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -12,7 +12,7 @@
<plugin> <plugin>
<groupId>org.openapitools</groupId> <groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId> <artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.0</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -12,7 +12,7 @@
<plugin> <plugin>
<groupId>org.openapitools</groupId> <groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId> <artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.0</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -12,7 +12,7 @@
<plugin> <plugin>
<groupId>org.openapitools</groupId> <groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId> <artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.0</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -11,9 +11,6 @@
<name>openapi-generator (maven-plugin)</name> <name>openapi-generator (maven-plugin)</name>
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
<description>maven plugin to build modules from OpenAPI Generator</description> <description>maven plugin to build modules from OpenAPI Generator</description>
<prerequisites>
<maven>3.2.5</maven>
</prerequisites>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -62,7 +59,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId> <artifactId>maven-plugin-plugin</artifactId>
<version>3.5.1</version> <version>3.5.2</version>
<configuration> <configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration> </configuration>

View File

@ -44,7 +44,7 @@
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version> <version>1.6.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@ -81,7 +81,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version> <version>3.1.0</version>
<configuration> <configuration>
<archive> <archive>
<manifestEntries> <manifestEntries>
@ -103,7 +103,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<version>3.5.1</version> <version>3.7.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -174,7 +174,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId> <artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version> <version>3.0.0</version>
<configuration> <configuration>
<aggregate>true</aggregate> <aggregate>true</aggregate>
</configuration> </configuration>
@ -182,7 +182,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version> <version>3.0.0</version>
<reportSets> <reportSets>
<reportSet> <reportSet>
<reports> <reports>
@ -195,7 +195,7 @@
</reporting> </reporting>
<properties> <properties>
<diffutils-version>1.3.0</diffutils-version> <diffutils-version>1.3.0</diffutils-version>
<guava-version>20.0</guava-version> <guava-version>26.0-jre</guava-version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -270,12 +270,12 @@
<dependency> <dependency>
<groupId>com.atlassian.commonmark</groupId> <groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId> <artifactId>commonmark</artifactId>
<version>0.9.0</version> <version>0.11.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>2.8.47</version> <version>2.23.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -257,4 +257,8 @@ public interface CodegenConfig {
void postProcessFile(File file, String fileType); void postProcessFile(File file, String fileType);
boolean isEnablePostProcessFile();
public void setEnablePostProcessFile(boolean isEnablePostProcessFile);
} }

View File

@ -182,6 +182,7 @@ public class CodegenConstants {
public static final String DOTNET_FRAMEWORK_DESC = "The target .NET framework version."; public static final String DOTNET_FRAMEWORK_DESC = "The target .NET framework version.";
public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original} public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original, UPPERCASE} public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original, UPPERCASE}
public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming"; public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming";
@ -265,4 +266,16 @@ public class CodegenConstants {
public static final String DATABASE_ADAPTER = "databaseAdapter"; public static final String DATABASE_ADAPTER = "databaseAdapter";
public static final String DATABASE_ADAPTER_DESC = "The adapter for database (e.g. mysql, sqlite). Default: sqlite"; public static final String DATABASE_ADAPTER_DESC = "The adapter for database (e.g. mysql, sqlite). Default: sqlite";
public static final String PARENT_GROUP_ID = "parentGroupId";
public static final String PARENT_GROUP_ID_DESC = "parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect";
public static final String PARENT_ARTIFACT_ID = "parentArtifactId";
public static final String PARENT_ARTIFACT_ID_DESC = "parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect";
public static final String PARENT_VERSION = "parentVersion";
public static final String PARENT_VERSION_DESC = "parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect";
public static final String ENABLE_POST_PROCESS_FILE = "enablePostProcessFile";
public static final String ENABLE_POST_PROCESS_FILE_DESC = "Enable post-processing file using environment variables.";
} }

View File

@ -133,8 +133,10 @@ public class DefaultCodegen implements CodegenConfig {
protected Boolean prependFormOrBodyParameters = false; protected Boolean prependFormOrBodyParameters = false;
// The extension of the generated documentation files (defaults to markdown .md) // The extension of the generated documentation files (defaults to markdown .md)
protected String docExtension; protected String docExtension;
protected String ignoreFilePathOverride; protected String ignoreFilePathOverride;
// flag to indicate whether to use environment variable to post process file
protected boolean enablePostProcessFile = false;
public List<CliOption> cliOptions() { public List<CliOption> cliOptions() {
return cliOptions; return cliOptions;
@ -196,6 +198,11 @@ public class DefaultCodegen implements CodegenConfig {
this.setDocExtension(String.valueOf(additionalProperties this.setDocExtension(String.valueOf(additionalProperties
.get(CodegenConstants.DOCEXTENSION).toString())); .get(CodegenConstants.DOCEXTENSION).toString()));
} }
if (additionalProperties.containsKey(CodegenConstants.ENABLE_POST_PROCESS_FILE)) {
this.setEnablePostProcessFile(Boolean.valueOf(additionalProperties
.get(CodegenConstants.ENABLE_POST_PROCESS_FILE).toString()));
}
} }
// override with any special post-processing for all models // override with any special post-processing for all models
@ -239,6 +246,7 @@ public class DefaultCodegen implements CodegenConfig {
parent.setChildren(new ArrayList<CodegenModel>()); parent.setChildren(new ArrayList<CodegenModel>());
} }
parent.getChildren().add(cm); parent.getChildren().add(cm);
parent.hasChildren = true;
if (parent.getDiscriminator() == null) { if (parent.getDiscriminator() == null) {
parent = allModels.get(parent.getParent()); parent = allModels.get(parent.getParent());
} else { } else {
@ -1771,10 +1779,7 @@ public class DefaultCodegen implements CodegenConfig {
property.title = p.getTitle(); property.title = p.getTitle();
property.getter = toGetter(name); property.getter = toGetter(name);
property.setter = toSetter(name); property.setter = toSetter(name);
String example = toExampleValue(p); property.example = toExampleValue(p);
if (!"null".equals(example)) {
property.example = example;
}
property.defaultValue = toDefaultValue(p); property.defaultValue = toDefaultValue(p);
property.defaultValueWithParam = toDefaultValueWithParam(name, p); property.defaultValueWithParam = toDefaultValueWithParam(name, p);
property.jsonSchema = Json.pretty(p); property.jsonSchema = Json.pretty(p);
@ -2743,9 +2748,8 @@ public class DefaultCodegen implements CodegenConfig {
} }
// set default value // set default value
if (parameterSchema.getDefault() != null) {
codegenParameter.defaultValue = toDefaultValue(parameterSchema); codegenParameter.defaultValue = toDefaultValue(parameterSchema);
}
// TDOO revise collectionFormat // TDOO revise collectionFormat
String collectionFormat = null; String collectionFormat = null;
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
@ -4215,13 +4219,13 @@ public class DefaultCodegen implements CodegenConfig {
protected String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) { protected String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
if (composedSchema.getAllOf() != null && !composedSchema.getAllOf().isEmpty()) { if (composedSchema.getAllOf() != null && !composedSchema.getAllOf().isEmpty()) {
Schema schema = composedSchema.getAllOf().get(0); for (Schema schema : composedSchema.getAllOf()) {
String ref = schema.get$ref(); String ref = schema.get$ref();
if (StringUtils.isBlank(ref)) { if (!StringUtils.isBlank(ref)) {
return null;
}
return ModelUtils.getSimpleRef(ref); return ModelUtils.getSimpleRef(ref);
} }
}
}
return null; return null;
} }
@ -4703,4 +4707,23 @@ public class DefaultCodegen implements CodegenConfig {
public void postProcessFile(File file, String fileType) { public void postProcessFile(File file, String fileType) {
LOGGER.debug("Post processing file {} ({})", file, fileType); LOGGER.debug("Post processing file {} ({})", file, fileType);
} }
/**
* Boolean value indicating the state of the option for post-processing file using envirionment variables.
*
* @return true if the option is enabled
*/
public boolean isEnablePostProcessFile() {
return enablePostProcessFile;
}
/**
* Set the boolean value indicating the state of the option for post-processing file using envirionment variables.
*
* @param enablePostProcessFile true to enable post-processing file
*/
public void setEnablePostProcessFile(boolean enablePostProcessFile) {
this.enablePostProcessFile = enablePostProcessFile;
}
} }

View File

@ -273,10 +273,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
File written = processTemplateToFile(models, templateName, filename); File written = processTemplateToFile(models, templateName, filename);
if (written != null) { if (written != null) {
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "model-test"); config.postProcessFile(written, "model-test");
} }
} }
} }
}
private void generateModelDocumentation(List<File> files, Map<String, Object> models, String modelName) throws IOException { private void generateModelDocumentation(List<File> files, Map<String, Object> models, String modelName) throws IOException {
for (String templateName : config.modelDocTemplateFiles().keySet()) { for (String templateName : config.modelDocTemplateFiles().keySet()) {
@ -290,10 +292,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
File written = processTemplateToFile(models, templateName, filename); File written = processTemplateToFile(models, templateName, filename);
if (written != null) { if (written != null) {
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "model-doc"); config.postProcessFile(written, "model-doc");
} }
} }
} }
}
private void generateModel(List<File> files, Map<String, Object> models, String modelName) throws IOException { private void generateModel(List<File> files, Map<String, Object> models, String modelName) throws IOException {
for (String templateName : config.modelTemplateFiles().keySet()) { for (String templateName : config.modelTemplateFiles().keySet()) {
@ -306,10 +310,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
File written = processTemplateToFile(models, templateName, filename); File written = processTemplateToFile(models, templateName, filename);
if (written != null) { if (written != null) {
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "model"); config.postProcessFile(written, "model");
} }
} }
} }
}
private void generateModels(List<File> files, List<Object> allModels, List<String> unusedModels) { private void generateModels(List<File> files, List<Object> allModels, List<String> unusedModels) {
if (!generateModels) { if (!generateModels) {
@ -552,9 +558,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
File written = processTemplateToFile(operation, templateName, filename); File written = processTemplateToFile(operation, templateName, filename);
if (written != null) { if (written != null) {
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "api"); config.postProcessFile(written, "api");
} }
} }
}
if (generateApiTests) { if (generateApiTests) {
// to generate api test files // to generate api test files
@ -569,10 +577,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
File written = processTemplateToFile(operation, templateName, filename); File written = processTemplateToFile(operation, templateName, filename);
if (written != null) { if (written != null) {
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "api-test"); config.postProcessFile(written, "api-test");
} }
} }
} }
}
if (generateApiDocumentation) { if (generateApiDocumentation) {
@ -587,10 +597,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
File written = processTemplateToFile(operation, templateName, filename); File written = processTemplateToFile(operation, templateName, filename);
if (written != null) { if (written != null) {
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "api-doc"); config.postProcessFile(written, "api-doc");
} }
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Could not generate api file for '" + tag + "'", e); throw new RuntimeException("Could not generate api file for '" + tag + "'", e);
@ -660,7 +672,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
writeToFile(outputFilename, tmpl.execute(bundle)); writeToFile(outputFilename, tmpl.execute(bundle));
File written = new File(outputFilename); File written = new File(outputFilename);
files.add(written); files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "supporting-mustache"); config.postProcessFile(written, "supporting-mustache");
}
} else { } else {
InputStream in = null; InputStream in = null;
@ -674,8 +688,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
} }
File outputFile = writeInputStreamToFile(outputFilename, in, templateFile); File outputFile = writeInputStreamToFile(outputFilename, in, templateFile);
files.add(outputFile); files.add(outputFile);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(outputFile, "supporting-common"); config.postProcessFile(outputFile, "supporting-common");
} }
}
} else { } else {
LOGGER.info("Skipped generation of " + outputFilename + " due to rule in .openapi-generator-ignore"); LOGGER.info("Skipped generation of " + outputFilename + " due to rule in .openapi-generator-ignore");
} }
@ -698,8 +714,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
throw new RuntimeException("Could not generate supporting file '" + openapiGeneratorIgnore + "'", e); throw new RuntimeException("Could not generate supporting file '" + openapiGeneratorIgnore + "'", e);
} }
files.add(ignoreFile); files.add(ignoreFile);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(ignoreFile, "openapi-generator-ignore"); config.postProcessFile(ignoreFile, "openapi-generator-ignore");
} }
}
if (generateMetadata) { if (generateMetadata) {
final String versionMetadata = config.outputFolder() + File.separator + ".openapi-generator" + File.separator + "VERSION"; final String versionMetadata = config.outputFolder() + File.separator + ".openapi-generator" + File.separator + "VERSION";
@ -707,7 +725,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
try { try {
writeToFile(versionMetadata, ImplementationVersion.read()); writeToFile(versionMetadata, ImplementationVersion.read());
files.add(versionMetadataFile); files.add(versionMetadataFile);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(ignoreFile, "openapi-generator-version"); config.postProcessFile(ignoreFile, "openapi-generator-version");
}
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Could not generate supporting file '" + versionMetadata + "'", e); throw new RuntimeException("Could not generate supporting file '" + versionMetadata + "'", e);
} }

View File

@ -96,6 +96,7 @@ public class CodegenConfigurator implements Serializable {
private boolean skipOverwrite; private boolean skipOverwrite;
private boolean removeOperationIdPrefix; private boolean removeOperationIdPrefix;
private boolean validateSpec; private boolean validateSpec;
private boolean enablePostProcessFile;
private String templateDir; private String templateDir;
private String auth; private String auth;
private String apiPackage; private String apiPackage;
@ -210,6 +211,15 @@ public class CodegenConfigurator implements Serializable {
return this; return this;
} }
public boolean getEnablePostProcessFile() {
return enablePostProcessFile;
}
public CodegenConfigurator setEnablePostProcessFile(boolean enablePostProcessFile) {
this.enablePostProcessFile = enablePostProcessFile;
return this;
}
public String getModelNameSuffix() { public String getModelNameSuffix() {
return modelNameSuffix; return modelNameSuffix;
} }
@ -503,6 +513,7 @@ public class CodegenConfigurator implements Serializable {
config.setSkipOverwrite(skipOverwrite); config.setSkipOverwrite(skipOverwrite);
config.setIgnoreFilePathOverride(ignoreFileOverride); config.setIgnoreFilePathOverride(ignoreFileOverride);
config.setRemoveOperationIdPrefix(removeOperationIdPrefix); config.setRemoveOperationIdPrefix(removeOperationIdPrefix);
config.setEnablePostProcessFile(enablePostProcessFile);
config.instantiationTypes().putAll(instantiationTypes); config.instantiationTypes().putAll(instantiationTypes);
config.typeMapping().putAll(typeMappings); config.typeMapping().putAll(typeMappings);

View File

@ -20,6 +20,7 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.*; import org.openapitools.codegen.utils.*;
@ -213,6 +214,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
if (StringUtils.isEmpty(System.getenv("CSHARP_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable CSHARP_POST_PROCESS_FILE not defined so the C# code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export CSHARP_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg");
}
// {{packageVersion}} // {{packageVersion}}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) { if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION)); setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
@ -422,8 +427,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
var.allowableValues = refModel.allowableValues; var.allowableValues = refModel.allowableValues;
var.isEnum = true; var.isEnum = true;
updateCodegenPropertyEnum(var);
// We do these after updateCodegenPropertyEnum to avoid generalities that don't mesh with C#. // We do these after updateCodegenPropertyEnum to avoid generalities that don't mesh with C#.
var.isPrimitiveType = true; var.isPrimitiveType = true;
} }
@ -1015,6 +1018,33 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
} else if (Boolean.TRUE.equals(codegenParameter.isString)) { } else if (Boolean.TRUE.equals(codegenParameter.isString)) {
codegenParameter.example = codegenParameter.paramName + "_example"; codegenParameter.example = codegenParameter.paramName + "_example";
} }
}
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String csharpPostProcessFile = System.getenv("CSHARP_POST_PROCESS_FILE");
if (StringUtils.isEmpty(csharpPostProcessFile)) {
return; // skip if CSHARP_POST_PROCESS_FILE env variable is not defined
}
// only process files with .cs extension
if ("cs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = csharpPostProcessFile + " " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
}
}
} }
} }

View File

@ -105,6 +105,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected boolean disableHtmlEscaping = false; protected boolean disableHtmlEscaping = false;
protected String booleanGetterPrefix = BOOLEAN_GETTER_PREFIX_DEFAULT; protected String booleanGetterPrefix = BOOLEAN_GETTER_PREFIX_DEFAULT;
protected boolean useNullForUnknownEnumValue = false; protected boolean useNullForUnknownEnumValue = false;
protected String parentGroupId = "";
protected String parentArtifactId = "";
protected String parentVersion = "";
protected boolean parentOverridden = false;
public AbstractJavaCodegen() { public AbstractJavaCodegen() {
super(); super();
@ -198,6 +202,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
cliOptions.add(CliOption.newBoolean(DISABLE_HTML_ESCAPING, "Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)")); cliOptions.add(CliOption.newBoolean(DISABLE_HTML_ESCAPING, "Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)"));
cliOptions.add(CliOption.newString(BOOLEAN_GETTER_PREFIX, "Set booleanGetterPrefix (default value '" + BOOLEAN_GETTER_PREFIX_DEFAULT + "')")); cliOptions.add(CliOption.newString(BOOLEAN_GETTER_PREFIX, "Set booleanGetterPrefix (default value '" + BOOLEAN_GETTER_PREFIX_DEFAULT + "')"));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_ARTIFACT_ID, CodegenConstants.PARENT_ARTIFACT_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_VERSION, CodegenConstants.PARENT_VERSION_DESC));
} }
@Override @Override
@ -376,6 +384,22 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} }
additionalProperties.put(WITH_XML, withXml); additionalProperties.put(WITH_XML, withXml);
if (additionalProperties.containsKey(CodegenConstants.PARENT_GROUP_ID)) {
this.setParentGroupId((String) additionalProperties.get(CodegenConstants.PARENT_GROUP_ID));
}
if (additionalProperties.containsKey(CodegenConstants.PARENT_ARTIFACT_ID)) {
this.setParentArtifactId((String) additionalProperties.get(CodegenConstants.PARENT_ARTIFACT_ID));
}
if (additionalProperties.containsKey(CodegenConstants.PARENT_VERSION)) {
this.setParentVersion((String) additionalProperties.get(CodegenConstants.PARENT_VERSION));
}
if (!StringUtils.isEmpty(parentGroupId) && !StringUtils.isEmpty(parentArtifactId) && !StringUtils.isEmpty(parentVersion)) {
additionalProperties.put("parentOverridden", true);
}
// make api and model doc path available in mustache template // make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath); additionalProperties.put("modelDocPath", modelDocPath);
@ -754,7 +778,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return p.getDefault().toString(); return p.getDefault().toString();
} }
} }
return "null"; return null;
} else if (ModelUtils.isNumberSchema(p)) { } else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) { if (p.getDefault() != null) {
if (SchemaTypeUtil.FLOAT_FORMAT.equals(p.getFormat())) { if (SchemaTypeUtil.FLOAT_FORMAT.equals(p.getFormat())) {
@ -763,12 +787,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return p.getDefault().toString() + "d"; return p.getDefault().toString() + "d";
} }
} }
return "null"; return null;
} else if (ModelUtils.isBooleanSchema(p)) { } else if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) { if (p.getDefault() != null) {
return p.getDefault().toString(); return p.getDefault().toString();
} }
return "null"; return null;
} else if (ModelUtils.isStringSchema(p)) { } else if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) { if (p.getDefault() != null) {
String _default = (String) p.getDefault(); String _default = (String) p.getDefault();
@ -779,7 +803,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return _default; return _default;
} }
} }
return "null"; return null;
} }
return super.toDefaultValue(p); return super.toDefaultValue(p);
} }
@ -840,7 +864,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (example == null) { if (example == null) {
example = "null"; example = "null";
} else if (Boolean.TRUE.equals(p.isListContainer)) { } else if (Boolean.TRUE.equals(p.isListContainer)) {
example = "Arrays.asList(" + example + ")";
if (p.items.defaultValue != null) {
String innerExample;
if ("String".equals(p.items.dataType)) {
innerExample = "\"" + p.items.defaultValue + "\"";
} else {
innerExample = p.items.defaultValue;
}
example = "Arrays.asList(" + innerExample + ")";
} else {
example = "Arrays.asList()";
}
} else if (Boolean.TRUE.equals(p.isMapContainer)) { } else if (Boolean.TRUE.equals(p.isMapContainer)) {
example = "new HashMap()"; example = "new HashMap()";
} }
@ -853,7 +888,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (p.getExample() != null) { if (p.getExample() != null) {
return escapeText(p.getExample().toString()); return escapeText(p.getExample().toString());
} else { } else {
return super.toExampleValue(p); return null;
} }
} }
@ -1347,4 +1382,19 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return tag; return tag;
} }
public void setParentGroupId(final String parentGroupId) {
this.parentGroupId = parentGroupId;
}
public void setParentArtifactId(final String parentArtifactId) {
this.parentArtifactId = parentArtifactId;
}
public void setParentVersion(final String parentVersion) {
this.parentVersion = parentVersion;
}
public void setParentOverridden(final boolean parentOverridden) {
this.parentOverridden = parentOverridden;
}
} }

View File

@ -85,7 +85,7 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
super.processOpts(); super.processOpts();
if (StringUtils.isEmpty(System.getenv("RUBY_POST_PROCESS_FILE"))) { if (StringUtils.isEmpty(System.getenv("RUBY_POST_PROCESS_FILE"))) {
LOGGER.info("Hint: Environment variable 'RUBY_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export RUBY_POST_PROCESS_FILE=/usr/local/bin/rubocop -a' (Linux/Mac)"); LOGGER.info("Hint: Environment variable 'RUBY_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export RUBY_POST_PROCESS_FILE=\"/usr/local/bin/rubocop -a\"' (Linux/Mac)");
} }
} }

View File

@ -25,15 +25,19 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.LoggerFactory;
import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.media.*;
public class CppRestbedServerCodegen extends AbstractCppCodegen { public class CppRestbedServerCodegen extends AbstractCppCodegen {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
public static final String DECLSPEC = "declspec"; public static final String DECLSPEC = "declspec";
public static final String DEFAULT_INCLUDE = "defaultInclude"; public static final String DEFAULT_INCLUDE = "defaultInclude";
@ -287,25 +291,63 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
@Override @Override
public String toDefaultValue(Schema p) { public String toDefaultValue(Schema p) {
if (ModelUtils.isStringSchema(p)) { if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
return "\"" + p.getDefault().toString() + "\"";
} else {
return "\"\""; return "\"\"";
}
} else if (ModelUtils.isBooleanSchema(p)) { } else if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
} else {
return "false"; return "false";
}
} else if (ModelUtils.isDateSchema(p)) { } else if (ModelUtils.isDateSchema(p)) {
if (p.getDefault() != null) {
return "\"" + p.getDefault().toString() + "\"";
} else {
return "\"\""; return "\"\"";
}
} else if (ModelUtils.isDateTimeSchema(p)) { } else if (ModelUtils.isDateTimeSchema(p)) {
if (p.getDefault() != null) {
return "\"" + p.getDefault().toString() + "\"";
} else {
return "\"\""; return "\"\"";
}
} else if (ModelUtils.isNumberSchema(p)) { } else if (ModelUtils.isNumberSchema(p)) {
if (ModelUtils.isFloatSchema(p)) { if (ModelUtils.isFloatSchema(p)) { // float
if (p.getDefault() != null) {
return p.getDefault().toString() + "f";
} else {
return "0.0f"; return "0.0f";
} }
} else { // double
if (p.getDefault() != null) {
return p.getDefault().toString();
} else {
return "0.0"; return "0.0";
}
}
} else if (ModelUtils.isIntegerSchema(p)) { } else if (ModelUtils.isIntegerSchema(p)) {
if (ModelUtils.isLongSchema(p)) { if (ModelUtils.isLongSchema(p)) { // long
if (p.getDefault() != null) {
return p.getDefault().toString() + "L";
} else {
return "0L"; return "0L";
} }
} else { // integer
if (p.getDefault() != null) {
return p.getDefault().toString();
} else {
return "0"; return "0";
}
}
} else if (ModelUtils.isByteArraySchema(p)) { } else if (ModelUtils.isByteArraySchema(p)) {
if (p.getDefault() != null) {
return "\"" + p.getDefault().toString() + "\"";
} else {
return "\"\""; return "\"\"";
}
} else if (ModelUtils.isMapSchema(p)) { } else if (ModelUtils.isMapSchema(p)) {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p)); String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "std::map<std::string, " + inner + ">()"; return "std::map<std::string, " + inner + ">()";
@ -319,6 +361,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
} else if (!StringUtils.isEmpty(p.get$ref())) { } else if (!StringUtils.isEmpty(p.get$ref())) {
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()"; return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
} }
return "nullptr"; return "nullptr";
} }

View File

@ -232,8 +232,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
} }
super.processOpts(); super.processOpts();
if (StringUtils.isEmpty(System.getenv("JS_BEAUTIFY_PATH"))) { if (StringUtils.isEmpty(System.getenv("JS_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable JS_BEAUTIFY_PATH not defined so the JS code may not be properly formatted. To define it, try 'export JS_BEAUTIFY_PATH=/usr/local/bin/js-beautify' (Linux/Mac)"); LOGGER.info("Environment variable JS_POST_PROCESS_FILE not defined so the JS code may not be properly formatted. To define it, try 'export JS_POST_PROCESS_FILE=\"/usr/local/bin/js-beautify -r -f\"' (Linux/Mac)");
} }
if (additionalProperties.containsKey(PROJECT_NAME)) { if (additionalProperties.containsKey(PROJECT_NAME)) {
@ -1167,19 +1167,20 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return; return;
} }
String jsBeautifyPath = System.getenv("JS_BEAUTIFY_PATH"); String jsPostProcessFile = System.getenv("JS_POST_PROCESS_FILE");
if (StringUtils.isEmpty(jsBeautifyPath)) { if (StringUtils.isEmpty(jsPostProcessFile)) {
return; // skip if JS_BEAUTIFY_PATH env variable is not defined return; // skip if JS_POST_PROCESS_FILE env variable is not defined
} }
// only process files with js extension // only process files with js extension
if ("js".equals(FilenameUtils.getExtension(file.toString()))) { if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
String command = jsBeautifyPath + " -r -f " + file.toString(); String command = jsPostProcessFile + " " + file.toString();
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();
if (p.exitValue() != 0) { int exitValue = p.exitValue();
LOGGER.error("Error running the command ({}). Exit code: {}", command, p.exitValue()); if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} }
LOGGER.info("Successfully executed: " + command); LOGGER.info("Successfully executed: " + command);
} catch (Exception e) { } catch (Exception e) {
@ -1187,5 +1188,4 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
} }
} }
} }
} }

View File

@ -133,8 +133,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
if (StringUtils.isEmpty(System.getenv("PERLTIDY_PATH"))) { if (StringUtils.isEmpty(System.getenv("PERL_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable PERLTIDY_PATH not defined so the Perl code may not be properly formatted. To define it, try 'export PERLTIDY_PATH=/usr/local/bin/perltidy' (Linux/Mac)"); LOGGER.info("Environment variable PERL_POST_PROCESS_FILE not defined so the Perl code may not be properly formatted. To define it, try 'export PERL_POST_PROCESS_FILE=/usr/local/bin/perltidy -b -bext=\"/\"' (Linux/Mac)");
} }
if (additionalProperties.containsKey(MODULE_VERSION)) { if (additionalProperties.containsKey(MODULE_VERSION)) {
@ -571,9 +571,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
return; return;
} }
String perlTidyPath = System.getenv("PERLTIDY_PATH"); String perlTidyPath = System.getenv("PERL_POST_PROCESS_FILE");
if (StringUtils.isEmpty(perlTidyPath)) { if (StringUtils.isEmpty(perlTidyPath)) {
return; // skip if PERLTIDY_PATH env variable is not defined return; // skip if PERL_POST_PROCESS_FILE env variable is not defined
} }
// only process files with .t, .pm extension // only process files with .t, .pm extension
@ -583,11 +583,12 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
String command = perlTidyPath + " -b -bext='/' " + file.toString(); String command = perlTidyPath + " -b -bext='/' " + file.toString();
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); int exitValue = p.waitFor();
if (p.exitValue() != 0) { if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, p.exitValue()); LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} } else {
LOGGER.info("Successfully executed: " + command); LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
} }

View File

@ -318,8 +318,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
@Override @Override
public void preprocessOpenAPI(OpenAPI openAPI) { public void preprocessOpenAPI(OpenAPI openAPI) {
// need vendor extensions for x-swagger-router-controller // need vendor extensions for x-openapi-router-controller
// can be changed to x-openapi-router-controller when https://github.com/zalando/connexion/issues/683 is done
Map<String, PathItem> paths = openAPI.getPaths(); Map<String, PathItem> paths = openAPI.getPaths();
if (paths != null) { if (paths != null) {
for (String pathname : paths.keySet()) { for (String pathname : paths.keySet()) {
@ -337,9 +336,9 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
operationId = getOrGenerateOperationId(operation, pathname, method.toString()); operationId = getOrGenerateOperationId(operation, pathname, method.toString());
} }
operation.setOperationId(toOperationId(operationId)); operation.setOperationId(toOperationId(operationId));
if (operation.getExtensions() == null || operation.getExtensions().get("x-swagger-router-controller") == null) { if (operation.getExtensions() == null || operation.getExtensions().get("x-openapi-router-controller") == null) {
operation.addExtension( operation.addExtension(
"x-swagger-router-controller", "x-openapi-router-controller",
controllerPackage + "." + toApiFilename(tag) controllerPackage + "." + toApiFilename(tag)
); );
} }

View File

@ -221,6 +221,8 @@ public class SpringCodegen extends AbstractJavaCodegen
if (additionalProperties.containsKey(ASYNC)) { if (additionalProperties.containsKey(ASYNC)) {
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString())); this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
//fix for issue/1164
convertPropertyToBooleanAndWriteBack(ASYNC);
} }
if (additionalProperties.containsKey(REACTIVE)) { if (additionalProperties.containsKey(REACTIVE)) {

View File

@ -472,7 +472,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
@Override @Override
public String toModelFilename(String name) { public String toModelFilename(String name) {
return this.convertUsingFileNamingConvention(name) + modelFileSuffix; return this.sanitizeName(this.convertUsingFileNamingConvention(name) + modelFileSuffix);
} }
@Override @Override

View File

@ -46,7 +46,7 @@ public class {{classname}} {
* {{summary}} * {{summary}}
* {{notes}} * {{notes}}
{{#allParams}} {{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
{{/allParams}} {{/allParams}}
{{#returnType}} {{#returnType}}
* @return {{returnType}} * @return {{returnType}}

View File

@ -62,7 +62,7 @@ try {
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} {{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{^isContainer}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{/isContainer}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}}
{{/allParams}} {{/allParams}}
### Return type ### Return type

View File

@ -25,7 +25,7 @@ public interface {{classname}} extends ApiClient.Api {
* {{summary}} * {{summary}}
* {{notes}} * {{notes}}
{{#allParams}} {{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
{{/allParams}} {{/allParams}}
{{#returnType}} {{#returnType}}
* @return {{returnType}} * @return {{returnType}}
@ -55,14 +55,14 @@ public interface {{classname}} extends ApiClient.Api {
* building up this map in a fluent style. * building up this map in a fluent style.
{{#allParams}} {{#allParams}}
{{^isQueryParam}} {{^isQueryParam}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
{{/isQueryParam}} {{/isQueryParam}}
{{/allParams}} {{/allParams}}
* @param queryParams Map of query parameters as name-value pairs * @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p> * <p>The following elements may be specified in the query map:</p>
* <ul> * <ul>
{{#queryParams}} {{#queryParams}}
* <li>{{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</li> * <li>{{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}</li>
{{/queryParams}} {{/queryParams}}
* </ul> * </ul>
{{#returnType}} {{#returnType}}

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -54,6 +54,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth;
import {{invokerPackage}}.auth.ApiKeyAuth; import {{invokerPackage}}.auth.ApiKeyAuth;
import {{invokerPackage}}.auth.OAuth; import {{invokerPackage}}.auth.OAuth;
import {{invokerPackage}}.auth.RetryingOAuth; import {{invokerPackage}}.auth.RetryingOAuth;
import {{invokerPackage}}.auth.OAuthFlow;
public class ApiClient { public class ApiClient {
@ -102,7 +103,7 @@ public class ApiClient {
) { ) {
init(); init();
RetryingOAuth retryingOAuth = new RetryingOAuth("{{tokenUrl}}", clientId, GrantType.valueOf("{{flow}}"), clientSecret, parameters); RetryingOAuth retryingOAuth = new RetryingOAuth("{{tokenUrl}}", clientId, OAuthFlow.{{flow}}, clientSecret, parameters);
authentications.put( authentications.put(
"{{name}}", "{{name}}",
retryingOAuth retryingOAuth

View File

@ -65,7 +65,7 @@ public class {{classname}} {
{{#operation}} {{#operation}}
/** /**
* Build call for {{operationId}}{{#allParams}} * Build call for {{operationId}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{/allParams}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param progressListener Progress listener * @param progressListener Progress listener
* @param progressRequestListener Progress request listener * @param progressRequestListener Progress request listener
* @return Call to execute * @return Call to execute
@ -188,7 +188,7 @@ public class {{classname}} {
/** /**
* {{summary}} * {{summary}}
* {{notes}}{{#allParams}} * {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
* @return {{returnType}}{{/returnType}} * @return {{returnType}}{{/returnType}}
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
{{#isDeprecated}} {{#isDeprecated}}
@ -210,7 +210,7 @@ public class {{classname}} {
/** /**
* {{summary}} * {{summary}}
* {{notes}}{{#allParams}} * {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{/allParams}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @return ApiResponse&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}&gt; * @return ApiResponse&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
{{#isDeprecated}} {{#isDeprecated}}
@ -233,7 +233,7 @@ public class {{classname}} {
/** /**
* {{summary}} (asynchronously) * {{summary}} (asynchronously)
* {{notes}}{{#allParams}} * {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{/allParams}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object * @throws ApiException If fail to process the API call, e.g. serializing the request body object

View File

@ -35,15 +35,14 @@ public class RetryingOAuth extends OAuth implements Interceptor {
public RetryingOAuth( public RetryingOAuth(
String tokenUrl, String tokenUrl,
String clientId, String clientId,
GrantType grantType, OAuthFlow flow,
String clientSecret, String clientSecret,
Map<String, String> parameters Map<String, String> parameters
) { ) {
this(OAuthClientRequest.tokenLocation(tokenUrl) this(OAuthClientRequest.tokenLocation(tokenUrl)
.setClientId(clientId) .setClientId(clientId)
.setGrantType(grantType)
.setClientSecret(clientSecret)); .setClientSecret(clientSecret));
setFlow(flow);
if (parameters != null) { if (parameters != null) {
for (String paramName : parameters.keySet()) { for (String paramName : parameters.keySet()) {
tokenRequestBuilder.setParameter(paramName, parameters.get(paramName)); tokenRequestBuilder.setParameter(paramName, parameters.get(paramName));
@ -51,6 +50,25 @@ public class RetryingOAuth extends OAuth implements Interceptor {
} }
} }
public void setFlow(OAuthFlow flow) {
switch(flow) {
case accessCode:
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
break;
case implicit:
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
break;
case password:
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
break;
case application:
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
break;
default:
break;
}
}
@Override @Override
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
return retryingIntercept(chain, true); return retryingIntercept(chain, true);

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -11,6 +11,13 @@
<developerConnection>scm:git:git@github.com:openapitools/openapi-generator.git</developerConnection> <developerConnection>scm:git:git@github.com:openapitools/openapi-generator.git</developerConnection>
<url>https://openapi-generator.tech</url> <url>https://openapi-generator.tech</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<build> <build>
<plugins> <plugins>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -62,7 +62,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection> <developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url> <url>{{scmUrl}}</url>
</scm> </scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses> <licenses>
<license> <license>

View File

@ -22,7 +22,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -15,7 +15,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}{{/vars}} {{/isContainer}}{{/vars}}
{{#vars}} {{#vars}}

View File

@ -40,7 +40,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}
{{#vars}} {{#vars}}

View File

@ -25,7 +25,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -12,7 +12,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}} {{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};{{/vars}}
{{#vars}} {{#vars}}
/** /**

View File

@ -11,7 +11,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}} {{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}} {{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};{{/vars}}
{{#vars}} {{#vars}}
/** /**

View File

@ -17,7 +17,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}} {{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}} {{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
private {{#useBeanValidation}}@Valid{{/useBeanValidation}} {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} private {{#useBeanValidation}}@Valid{{/useBeanValidation}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/vars}}
{{#vars}} {{#vars}}
/** /**

View File

@ -29,7 +29,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -16,8 +16,10 @@ public class ApiUtil {
{{^reactive}} {{^reactive}}
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
try { try {
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); res.setCharacterEncoding("UTF-8");
res.addHeader("Content-Type", contentType);
res.getWriter().print(example);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -13,11 +13,20 @@
<springfox-version>2.8.0</springfox-version> <springfox-version>2.8.0</springfox-version>
{{/useSpringfox}} {{/useSpringfox}}
</properties> </properties>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
{{^parentOverridden}}
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>{{#java8}}2.0.1.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}}</version> <version>{{#java8}}2.0.1.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}}</version>
</parent> </parent>
{{/parentOverridden}}
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
{{^interfaceOnly}} {{^interfaceOnly}}

View File

@ -1,6 +1,6 @@
package {{package}}; package {{package}};
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import {{configPackage}}.ClientConfiguration; import {{configPackage}}.ClientConfiguration;
{{=<% %>=}} {{=<% %>=}}

View File

@ -11,11 +11,20 @@
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.5.18</swagger-core-version> <swagger-core-version>1.5.18</swagger-core-version>
</properties> </properties>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
{{^parentOverridden}}
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version> <version>2.0.5.RELEASE</version>
</parent> </parent>
{{/parentOverridden}}
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
</build> </build>
@ -25,7 +34,7 @@
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId> <artifactId>spring-cloud-starter-parent</artifactId>
<version>Dalston.SR1</version> <version>Finchley.SR1</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -40,56 +49,38 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-security</artifactId> <artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency> </dependency>
{{#withXml}} {{#withXml}}
<!-- XML processing: Jackson --> <!-- XML processing: Jackson -->
<dependency> <dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId> <groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId> <artifactId>jackson-dataformat-xml</artifactId>
</dependency> </dependency>
{{/withXml}} {{/withXml}}
{{#java8}} {{#java8}}
<dependency> <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId> <artifactId>jackson-datatype-jsr310</artifactId>
</dependency> </dependency>
{{/java8}} {{/java8}}
{{#joda}} {{#joda}}
<dependency> <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId> <artifactId>jackson-datatype-joda</artifactId>
</dependency> </dependency>
{{/joda}} {{/joda}}
{{#threetenbp}} {{#threetenbp}}
<dependency> <dependency>
<groupId>com.github.joschi.jackson</groupId> <groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId> <artifactId>jackson-datatype-threetenbp</artifactId>
<version>2.6.4</version> <version>2.6.4</version>
</dependency> </dependency>
{{/threetenbp}} {{/threetenbp}}
{{#useBeanValidation}}
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
{{/useBeanValidation}}
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@ -5,6 +5,13 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<name>{{artifactId}}</name> <name>{{artifactId}}</name>
<version>{{artifactVersion}}</version> <version>{{artifactVersion}}</version>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
<plugins> <plugins>

View File

@ -31,7 +31,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -25,7 +25,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -75,7 +75,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
// Getting the path params // Getting the path params
{{#pathParams}} {{#pathParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
const {{{dataType}}} {{{paramName}}} = request->get_path_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}}); const {{{dataType}}} {{{paramName}}} = request->get_path_parameter("{{paramName}}", {{{defaultValue}}});
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/pathParams}} {{/pathParams}}
{{/hasPathParams}} {{/hasPathParams}}
@ -84,7 +84,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
// Getting the query params // Getting the query params
{{#queryParams}} {{#queryParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
const {{{dataType}}} {{{paramName}}} = request->get_query_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}}); const {{{dataType}}} {{{paramName}}} = request->get_query_parameter("{{paramName}}", {{{defaultValue}}});
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/queryParams}} {{/queryParams}}
{{/hasQueryParams}} {{/hasQueryParams}}
@ -93,7 +93,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
// Getting the headers // Getting the headers
{{#headerParams}} {{#headerParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}}); const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{{defaultValue}}});
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/headerParams}} {{/headerParams}}
{{/hasHeaderParams}} {{/hasHeaderParams}}
@ -140,7 +140,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
// Getting the path params // Getting the path params
{{#pathParams}} {{#pathParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
const {{dataType}} {{paramName}} = request->get_path_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}}); const {{{dataType}}} {{{paramName}}} = request->get_path_parameter("{{paramName}}", {{{defaultValue}}});
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/pathParams}} {{/pathParams}}
{{/hasPathParams}} {{/hasPathParams}}
@ -149,7 +149,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
// Getting the query params // Getting the query params
{{#queryParams}} {{#queryParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
const {{dataType}} {{paramName}} = request->get_query_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}}); const {{{dataType}}} {{{paramName}}} = request->get_query_parameter("{{paramName}}", {{{defaultValue}}});
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/queryParams}} {{/queryParams}}
{{/hasQueryParams}} {{/hasQueryParams}}
@ -158,7 +158,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
// Getting the headers // Getting the headers
{{#headerParams}} {{#headerParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
const {{dataType}} {{paramName}} = request->get_header("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}}); const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{{defaultValue}}});
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/headerParams}} {{/headerParams}}
{{/hasHeaderParams}} {{/hasHeaderParams}}

View File

@ -217,7 +217,7 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
{{/generatePropertyChanged}} {{/generatePropertyChanged}}
{{#validatable}} {{#validatable}}
{{#discriminator}} {{#hasChildren}}
/// <summary> /// <summary>
/// To validate all properties of the instance /// To validate all properties of the instance
/// </summary> /// </summary>
@ -235,8 +235,8 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
/// <returns>Validation Result</returns> /// <returns>Validation Result</returns>
protected IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> BaseValidate(ValidationContext validationContext) protected IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> BaseValidate(ValidationContext validationContext)
{ {
{{/discriminator}} {{/hasChildren}}
{{^discriminator}} {{^hasChildren}}
/// <summary> /// <summary>
/// To validate all properties of the instance /// To validate all properties of the instance
/// </summary> /// </summary>
@ -244,11 +244,11 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
/// <returns>Validation Result</returns> /// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{ {
{{/discriminator}} {{/hasChildren}}
{{#parent}} {{#parent}}
{{^isArrayModel}} {{^isArrayModel}}
{{^isMapModel}} {{^isMapModel}}
foreach(var x in BaseValidate(validationContext)) yield return x; foreach(var x in base.BaseValidate(validationContext)) yield return x;
{{/isMapModel}} {{/isMapModel}}
{{/isArrayModel}} {{/isArrayModel}}
{{/parent}} {{/parent}}

View File

@ -12,7 +12,7 @@ class {{classname}} {
{{#description}} {{#description}}
/// {{description}} /// {{description}}
{{/description}} {{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}}); static const {{classname}} {{{name}}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
@ -29,7 +29,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) { switch (data) {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
case {{value}}: return {{classname}}.{{name}}; case {{{value}}}: return {{classname}}.{{{name}}}};
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
default: throw('Unknown enum value to decode: $data'); default: throw('Unknown enum value to decode: $data');

View File

@ -10,7 +10,7 @@ class {{classname}} {
{{#description}} {{#description}}
/// {{description}} /// {{description}}
{{/description}} {{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}}); static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) { switch (data) {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
case {{value}}: return {{classname}}.{{name}}; case {{{value}}}: return {{classname}}.{{{name}}};
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
default: throw('Unknown enum value to decode: $data'); default: throw('Unknown enum value to decode: $data');

View File

@ -10,7 +10,7 @@ class {{classname}} {
{{#description}} {{#description}}
/// {{description}} /// {{description}}
{{/description}} {{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}}); static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) { switch (data) {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
case {{value}}: return {{classname}}.{{name}}; case {{{value}}}: return {{classname}}.{{{name}}};
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
default: throw('Unknown enum value to decode: $data'); default: throw('Unknown enum value to decode: $data');

View File

@ -1,6 +1,5 @@
# Install flask-connexion from git branch dev-2.0. Change when connexion 2.0 is released connexion == 2.0.0rc3
git+https://github.com/zalando/connexion.git@35e4e678ef69e703eaf84a48126049808c73b17c#egg=connexion swagger-ui-bundle == 0.0.2
swagger-ui-bundle
python_dateutil == 2.6.0 python_dateutil == 2.6.0
{{#supportPython2}} {{#supportPython2}}
typing == 3.5.2.2 typing == 3.5.2.2

View File

@ -19,6 +19,6 @@ const (
type {{classname}} struct { type {{classname}} struct {
{{#vars}}{{#description}} {{#vars}}{{#description}}
// {{{description}}}{{/description}} // {{{description}}}{{/description}}
{{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"` {{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
{{/vars}} {{/vars}}
}{{/isEnum}}{{/model}}{{/models}} }{{/isEnum}}{{/model}}{{/models}}

View File

@ -19,6 +19,6 @@ const (
type {{classname}} struct { type {{classname}} struct {
{{#vars}}{{#description}} {{#vars}}{{#description}}
// {{{description}}}{{/description}} // {{{description}}}{{/description}}
{{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"` {{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
{{/vars}} {{/vars}}
}{{/isEnum}}{{/model}}{{/models}} }{{/isEnum}}{{/model}}{{/models}}

View File

@ -275,7 +275,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{#returnType}} {{#returnType}}
if localVarHttpResponse.StatusCode < 300 { if localVarHttpResponse.StatusCode < 300 {
// If we succeed, return the data, otherwise pass on to decode error. // If we succeed, return the data, otherwise pass on to decode error.
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err == nil { if err == nil {
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
} }
@ -291,7 +291,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{#dataType}} {{#dataType}}
if localVarHttpResponse.StatusCode == {{{code}}} { if localVarHttpResponse.StatusCode == {{{code}}} {
var v {{{dataType}}} var v {{{dataType}}}
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil { if err != nil {
newErr.error = err.Error() newErr.error = err.Error()
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr

View File

@ -188,7 +188,7 @@ func (c *APIClient) prepareRequest(
} }
// add form parameters and file if available. // add form parameters and file if available.
if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") {
if body != nil { if body != nil {
return nil, errors.New("Cannot specify postBody and multipart form at the same time.") return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
} }
@ -227,6 +227,16 @@ func (c *APIClient) prepareRequest(
w.Close() w.Close()
} }
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
if body != nil {
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
}
body = &bytes.Buffer{}
body.WriteString(formParams.Encode())
// Set Content-Length
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
}
// Setup path and query parameters // Setup path and query parameters
url, err := url.Parse(path) url, err := url.Parse(path)
if err != nil { if err != nil {

View File

@ -35,7 +35,7 @@ type {{classname}} struct {
{{#description}} {{#description}}
// {{{description}}} // {{{description}}}
{{/description}} {{/description}}
{{name}} {{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}` {{name}} {{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
{{/vars}} {{/vars}}
} }
{{/isEnum}} {{/isEnum}}

View File

@ -32,7 +32,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}

View File

@ -39,8 +39,6 @@ class RESTClientObject(object):
def __init__(self, configuration, pools_size=4, maxsize=4): def __init__(self, configuration, pools_size=4, maxsize=4):
# maxsize is number of requests to host that are allowed in parallel # maxsize is number of requests to host that are allowed in parallel
if configuration.verify_ssl:
# ca_certs # ca_certs
if configuration.ssl_ca_cert: if configuration.ssl_ca_cert:
ca_certs = configuration.ssl_ca_cert ca_certs = configuration.ssl_ca_cert
@ -49,18 +47,18 @@ class RESTClientObject(object):
ca_certs = certifi.where() ca_certs = certifi.where()
ssl_context = ssl.create_default_context(cafile=ca_certs) ssl_context = ssl.create_default_context(cafile=ca_certs)
if configuration.cert_file: if configuration.cert_file:
ssl_context.load_cert_chain( ssl_context.load_cert_chain(
configuration.cert_file, keyfile=configuration.key_file configuration.cert_file, keyfile=configuration.key_file
) )
else:
ssl_context = None if not configuration.verify_ssl:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
connector = aiohttp.TCPConnector( connector = aiohttp.TCPConnector(
limit=maxsize, limit=maxsize,
ssl_context=ssl_context, ssl_context=ssl_context
verify_ssl=configuration.verify_ssl
) )
# https pool manager # https pool manager

View File

@ -36,7 +36,7 @@ object {{classname}} {
{{/operation}} {{/operation}}
{{#unknownStatusCodes}} {{#unknownStatusCodes}}
ApiInvoker.addCustomStatusCode({{value}}, isSuccess = false) ApiInvoker.addCustomStatusCode({{{value}}}, isSuccess = false)
{{/unknownStatusCodes}} {{/unknownStatusCodes}}
} }

View File

@ -313,7 +313,7 @@ export interface {{classname}}Interface {
* @throws {RequiredError} * @throws {RequiredError}
* @memberof {{classname}}Interface * @memberof {{classname}}Interface
*/ */
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>; {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>;
{{/operation}} {{/operation}}
} }

View File

@ -20,7 +20,8 @@
"rewire": "^3.0.2" "rewire": "^3.0.2"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^2.4.2" "typescript": "^2.4.2",
"@types/node": "8.10.34"
}{{#npmRepository}}, }{{#npmRepository}},
"publishConfig": { "publishConfig": {
"registry": "{{npmRepository}}" "registry": "{{npmRepository}}"

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