forked from loafle/openapi-generator-original
update petstore samples
This commit is contained in:
commit
257a97b6cd
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
- [ ] 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\`.
|
||||
- [ ] 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.
|
||||
|
||||
### Description of the PR
|
||||
|
@ -1,24 +1,27 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# A bash script to run CircleCI node/test in parallel
|
||||
#
|
||||
|
||||
NODE_INDEX=${CIRCLE_NODE_INDEX:-0}
|
||||
|
||||
|
||||
if [ "$NODE_INDEX" = "1" ]; then
|
||||
echo "Running node $NODE_INDEX to test CI/pom.xml.circleci ..."
|
||||
cp CI/pom.xml.circleci pom.xml
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..."
|
||||
#cp CI/pom.xml.circleci pom.xml
|
||||
java -version
|
||||
mvn --quiet verify -Psamples
|
||||
mvn --quiet verify -Psamples.circleci
|
||||
elif [ "$NODE_INDEX" = "2" ]; then
|
||||
echo "Running node $NODE_INDEX to test ensure-up-to-date"
|
||||
java -version
|
||||
#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
|
||||
./bin/utils/ensure-up-to-date
|
||||
#./bin/utils/ensure-up-to-date
|
||||
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
|
||||
java -version
|
||||
cp CI/pom.xml.circleci.java7 pom.xml
|
||||
mvn --quiet verify -Psamples
|
||||
#cp CI/pom.xml.circleci.java7 pom.xml
|
||||
mvn --quiet verify -Psamples.circleci.jdk7
|
||||
fi
|
||||
|
||||
|
||||
|
19
README.md
19
README.md
@ -2,11 +2,16 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.3.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.3.1`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`3.4.x`](https://github.com/OpenAPITools/openapi-generator/tree/3.4.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`4.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](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:
|
||||
|
||||
: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:
|
||||
|
||||
@ -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)
|
||||
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.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.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.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
|
||||
|
||||
@ -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):
|
||||
|
||||
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:
|
||||
```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.
|
||||
```
|
||||
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.
|
||||
|
14
Vagrantfile
vendored
14
Vagrantfile
vendored
@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
config.vm.box = "ubuntu/bionic64"
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.name = "openapi-generator"
|
||||
@ -23,13 +23,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
#Provision
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
sudo touch /var/lib/cloud/instance/locale-check.skip
|
||||
sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
||||
sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list'
|
||||
sudo apt-cache policy docker-engine
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
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 upgrade -y
|
||||
sudo apt-get install -y docker-engine
|
||||
sudo apt-get install -y docker-ce
|
||||
sudo usermod -aG docker vagrant
|
||||
SHELL
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
echo "# START SCRIPT: ${SCRIPT}"
|
||||
|
||||
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
|
||||
./bin/utils/export_generator.sh $GENERATOR
|
||||
done
|
||||
./bin/utils/export_generator.sh ${GENERATOR}
|
||||
done
|
||||
|
@ -1,17 +1,19 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
if [[ "$1" != "" ]]; then
|
||||
NAME="$1"
|
||||
echo "# START SCRIPT: ${SCRIPT} ${NAME}"
|
||||
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;
|
||||
fi
|
||||
|
||||
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
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for groovy
|
||||
booleanGetterPrefix
|
||||
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
|
||||
configuration package for generated code
|
||||
|
||||
|
@ -104,4 +104,13 @@ CONFIG OPTIONS for java-inflector
|
||||
booleanGetterPrefix
|
||||
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)
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for java-msf4j
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for java-pkmst
|
||||
booleanGetterPrefix
|
||||
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 in generated pom.xml
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for java-play-framework
|
||||
booleanGetterPrefix
|
||||
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
|
||||
server title name or client service name
|
||||
|
||||
|
@ -104,4 +104,13 @@ CONFIG OPTIONS for java-undertow-server
|
||||
booleanGetterPrefix
|
||||
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)
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for java-vertx
|
||||
booleanGetterPrefix
|
||||
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
|
||||
When specified, API interfaces are generated with RX and methods return Single<> and Comparable. (Default: false)
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for java
|
||||
booleanGetterPrefix
|
||||
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
|
||||
Whether to use the RxJava adapter with the retrofit2 library. (Default: false)
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-cxf-cdi
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-cxf-client
|
||||
booleanGetterPrefix
|
||||
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
|
||||
Use BeanValidation API annotations (Default: false)
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-cxf
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-jersey
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-resteasy-eap
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-resteasy
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for jaxrs-spec
|
||||
booleanGetterPrefix
|
||||
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
|
||||
folder for generated implementation code
|
||||
|
||||
|
@ -104,6 +104,15 @@ CONFIG OPTIONS for spring
|
||||
booleanGetterPrefix
|
||||
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
|
||||
server title name or client service name
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process-resources</id>
|
||||
|
@ -26,6 +26,9 @@ import org.openapitools.codegen.GeneratorNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
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.isNotEmpty;
|
||||
|
||||
@ -42,6 +45,16 @@ public class ConfigHelp implements Runnable {
|
||||
description = "generator to get config help for")
|
||||
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
|
||||
public void run() {
|
||||
|
||||
@ -57,19 +70,47 @@ public class ConfigHelp implements Runnable {
|
||||
}
|
||||
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
|
||||
System.out.println();
|
||||
System.out.println("CONFIG OPTIONS");
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
System.out.println("\t" + langCliOption.getOpt());
|
||||
System.out.println("\t "
|
||||
+ langCliOption.getOptionHelp().replaceAll("\n", System.lineSeparator() + "\t "));
|
||||
System.out.println();
|
||||
|
||||
generatePlainTextHelp(sb, config);
|
||||
|
||||
if (!isEmpty(outputFile)) {
|
||||
File out = new File(outputFile);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
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) {
|
||||
System.err.println(e.getMessage());
|
||||
System.err.println("[error] Check the spelling of the generator's name and try again.");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.")
|
||||
private Boolean logToStderr;
|
||||
|
||||
@Option(name = {"--enable-post-process-file"}, title = "enable post-process file", description = CodegenConstants.ENABLE_POST_PROCESS_FILE)
|
||||
private Boolean enablePostProcessFile;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (logToStderr != null) {
|
||||
@ -329,6 +332,10 @@ public class Generate implements Runnable {
|
||||
configurator.setRemoveOperationIdPrefix(removeOperationIdPrefix);
|
||||
}
|
||||
|
||||
if (enablePostProcessFile != null) {
|
||||
configurator.setEnablePostProcessFile(enablePostProcessFile);
|
||||
}
|
||||
|
||||
applySystemPropertiesKvpList(systemProperties, configurator);
|
||||
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
||||
applyImportMappingsKvpList(importMappings, configurator);
|
||||
|
@ -48,7 +48,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.0"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
<properties>
|
||||
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
|
||||
<gradleVersion>4.10.2</gradleVersion>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -54,7 +55,7 @@
|
||||
<artifactId>gradle-maven-plugin</artifactId>
|
||||
<version>1.0.8</version>
|
||||
<configuration>
|
||||
<gradleVersion>4.10-rc-1</gradleVersion>
|
||||
<gradleVersion>${gradleVersion}</gradleVersion>
|
||||
<args>
|
||||
<arg>-P openApiGeneratorVersion=${project.version}</arg>
|
||||
</args>
|
||||
@ -76,6 +77,13 @@
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gradle</groupId>
|
||||
<artifactId>gradle-tooling-api</artifactId>
|
||||
<version>${gradleVersion}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=3.3.0 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=3.3.1 openApiValidate
|
||||
```
|
||||
|
@ -1 +1 @@
|
||||
openApiGeneratorVersion=3.3.0
|
||||
openApiGeneratorVersion=3.3.1
|
||||
|
@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -11,9 +11,6 @@
|
||||
<name>openapi-generator (maven-plugin)</name>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<description>maven plugin to build modules from OpenAPI Generator</description>
|
||||
<prerequisites>
|
||||
<maven>3.2.5</maven>
|
||||
</prerequisites>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
@ -62,7 +59,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>3.5.2</version>
|
||||
<configuration>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
|
@ -44,7 +44,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -81,7 +81,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
@ -103,7 +103,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>3.7.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -174,7 +174,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
@ -182,7 +182,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<version>3.0.0</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
@ -195,7 +195,7 @@
|
||||
</reporting>
|
||||
<properties>
|
||||
<diffutils-version>1.3.0</diffutils-version>
|
||||
<guava-version>20.0</guava-version>
|
||||
<guava-version>26.0-jre</guava-version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -270,12 +270,12 @@
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark</artifactId>
|
||||
<version>0.9.0</version>
|
||||
<version>0.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.8.47</version>
|
||||
<version>2.23.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -257,4 +257,8 @@ public interface CodegenConfig {
|
||||
|
||||
void postProcessFile(File file, String fileType);
|
||||
|
||||
boolean isEnablePostProcessFile();
|
||||
|
||||
public void setEnablePostProcessFile(boolean isEnablePostProcessFile);
|
||||
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ public class CodegenConstants {
|
||||
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 ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original, UPPERCASE}
|
||||
|
||||
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_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.";
|
||||
|
||||
}
|
@ -133,8 +133,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Boolean prependFormOrBodyParameters = false;
|
||||
// The extension of the generated documentation files (defaults to markdown .md)
|
||||
protected String docExtension;
|
||||
|
||||
protected String ignoreFilePathOverride;
|
||||
// flag to indicate whether to use environment variable to post process file
|
||||
protected boolean enablePostProcessFile = false;
|
||||
|
||||
|
||||
public List<CliOption> cliOptions() {
|
||||
return cliOptions;
|
||||
@ -196,6 +198,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.setDocExtension(String.valueOf(additionalProperties
|
||||
.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
|
||||
@ -239,6 +246,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
parent.setChildren(new ArrayList<CodegenModel>());
|
||||
}
|
||||
parent.getChildren().add(cm);
|
||||
parent.hasChildren = true;
|
||||
if (parent.getDiscriminator() == null) {
|
||||
parent = allModels.get(parent.getParent());
|
||||
} else {
|
||||
@ -1771,10 +1779,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.title = p.getTitle();
|
||||
property.getter = toGetter(name);
|
||||
property.setter = toSetter(name);
|
||||
String example = toExampleValue(p);
|
||||
if (!"null".equals(example)) {
|
||||
property.example = example;
|
||||
}
|
||||
property.example = toExampleValue(p);
|
||||
property.defaultValue = toDefaultValue(p);
|
||||
property.defaultValueWithParam = toDefaultValueWithParam(name, p);
|
||||
property.jsonSchema = Json.pretty(p);
|
||||
@ -2743,9 +2748,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// set default value
|
||||
if (parameterSchema.getDefault() != null) {
|
||||
codegenParameter.defaultValue = toDefaultValue(parameterSchema);
|
||||
}
|
||||
codegenParameter.defaultValue = toDefaultValue(parameterSchema);
|
||||
|
||||
// TDOO revise collectionFormat
|
||||
String collectionFormat = null;
|
||||
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
||||
@ -4215,12 +4219,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
protected String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||
if (composedSchema.getAllOf() != null && !composedSchema.getAllOf().isEmpty()) {
|
||||
Schema schema = composedSchema.getAllOf().get(0);
|
||||
String ref = schema.get$ref();
|
||||
if (StringUtils.isBlank(ref)) {
|
||||
return null;
|
||||
for (Schema schema : composedSchema.getAllOf()) {
|
||||
String ref = schema.get$ref();
|
||||
if (!StringUtils.isBlank(ref)) {
|
||||
return ModelUtils.getSimpleRef(ref);
|
||||
}
|
||||
}
|
||||
return ModelUtils.getSimpleRef(ref);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -4703,4 +4707,23 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public void postProcessFile(File file, String 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -273,7 +273,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
File written = processTemplateToFile(models, templateName, filename);
|
||||
if (written != null) {
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "model-test");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "model-test");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +292,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
File written = processTemplateToFile(models, templateName, filename);
|
||||
if (written != null) {
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "model-doc");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "model-doc");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,7 +310,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
File written = processTemplateToFile(models, templateName, filename);
|
||||
if (written != null) {
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "model");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "model");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -552,7 +558,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
File written = processTemplateToFile(operation, templateName, filename);
|
||||
if (written != null) {
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "api");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "api");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,7 +577,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
File written = processTemplateToFile(operation, templateName, filename);
|
||||
if (written != null) {
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "api-test");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "api-test");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,7 +597,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
File written = processTemplateToFile(operation, templateName, filename);
|
||||
if (written != null) {
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "api-doc");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "api-doc");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -660,7 +672,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
writeToFile(outputFilename, tmpl.execute(bundle));
|
||||
File written = new File(outputFilename);
|
||||
files.add(written);
|
||||
config.postProcessFile(written, "supporting-mustache");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(written, "supporting-mustache");
|
||||
}
|
||||
} else {
|
||||
InputStream in = null;
|
||||
|
||||
@ -674,7 +688,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
File outputFile = writeInputStreamToFile(outputFilename, in, templateFile);
|
||||
files.add(outputFile);
|
||||
config.postProcessFile(outputFile, "supporting-common");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(outputFile, "supporting-common");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("Skipped generation of " + outputFilename + " due to rule in .openapi-generator-ignore");
|
||||
@ -698,7 +714,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
throw new RuntimeException("Could not generate supporting file '" + openapiGeneratorIgnore + "'", e);
|
||||
}
|
||||
files.add(ignoreFile);
|
||||
config.postProcessFile(ignoreFile, "openapi-generator-ignore");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(ignoreFile, "openapi-generator-ignore");
|
||||
}
|
||||
}
|
||||
|
||||
if (generateMetadata) {
|
||||
@ -707,7 +725,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
try {
|
||||
writeToFile(versionMetadata, ImplementationVersion.read());
|
||||
files.add(versionMetadataFile);
|
||||
config.postProcessFile(ignoreFile, "openapi-generator-version");
|
||||
if (config.isEnablePostProcessFile()) {
|
||||
config.postProcessFile(ignoreFile, "openapi-generator-version");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not generate supporting file '" + versionMetadata + "'", e);
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ public class CodegenConfigurator implements Serializable {
|
||||
private boolean skipOverwrite;
|
||||
private boolean removeOperationIdPrefix;
|
||||
private boolean validateSpec;
|
||||
private boolean enablePostProcessFile;
|
||||
private String templateDir;
|
||||
private String auth;
|
||||
private String apiPackage;
|
||||
@ -210,6 +211,15 @@ public class CodegenConfigurator implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getEnablePostProcessFile() {
|
||||
return enablePostProcessFile;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setEnablePostProcessFile(boolean enablePostProcessFile) {
|
||||
this.enablePostProcessFile = enablePostProcessFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getModelNameSuffix() {
|
||||
return modelNameSuffix;
|
||||
}
|
||||
@ -503,6 +513,7 @@ public class CodegenConfigurator implements Serializable {
|
||||
config.setSkipOverwrite(skipOverwrite);
|
||||
config.setIgnoreFilePathOverride(ignoreFileOverride);
|
||||
config.setRemoveOperationIdPrefix(removeOperationIdPrefix);
|
||||
config.setEnablePostProcessFile(enablePostProcessFile);
|
||||
|
||||
config.instantiationTypes().putAll(instantiationTypes);
|
||||
config.typeMapping().putAll(typeMappings);
|
||||
|
@ -20,6 +20,7 @@ package org.openapitools.codegen.languages;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.*;
|
||||
@ -213,6 +214,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
public void 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}}
|
||||
if (additionalProperties.containsKey(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.isEnum = true;
|
||||
|
||||
updateCodegenPropertyEnum(var);
|
||||
|
||||
// We do these after updateCodegenPropertyEnum to avoid generalities that don't mesh with C#.
|
||||
var.isPrimitiveType = true;
|
||||
}
|
||||
@ -1015,6 +1018,33 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isString)) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected boolean disableHtmlEscaping = false;
|
||||
protected String booleanGetterPrefix = BOOLEAN_GETTER_PREFIX_DEFAULT;
|
||||
protected boolean useNullForUnknownEnumValue = false;
|
||||
protected String parentGroupId = "";
|
||||
protected String parentArtifactId = "";
|
||||
protected String parentVersion = "";
|
||||
protected boolean parentOverridden = false;
|
||||
|
||||
public AbstractJavaCodegen() {
|
||||
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.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
|
||||
@ -375,6 +383,22 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.setWithXml(Boolean.valueOf(additionalProperties.get(WITH_XML).toString()));
|
||||
}
|
||||
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
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
@ -754,7 +778,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
}
|
||||
return "null";
|
||||
return null;
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
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 "null";
|
||||
return null;
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
return "null";
|
||||
return null;
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
String _default = (String) p.getDefault();
|
||||
@ -779,7 +803,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
return "null";
|
||||
return null;
|
||||
}
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
@ -840,7 +864,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (example == null) {
|
||||
example = "null";
|
||||
} 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)) {
|
||||
example = "new HashMap()";
|
||||
}
|
||||
@ -853,7 +888,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (p.getExample() != null) {
|
||||
return escapeText(p.getExample().toString());
|
||||
} else {
|
||||
return super.toExampleValue(p);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1347,4 +1382,19 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
super.processOpts();
|
||||
|
||||
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)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,15 +25,19 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
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 DEFAULT_INCLUDE = "defaultInclude";
|
||||
|
||||
@ -287,25 +291,63 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isStringSchema(p)) {
|
||||
return "\"\"";
|
||||
if (p.getDefault() != null) {
|
||||
return "\"" + p.getDefault().toString() + "\"";
|
||||
} else {
|
||||
return "\"\"";
|
||||
}
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
return "false";
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
return "\"\"";
|
||||
if (p.getDefault() != null) {
|
||||
return "\"" + p.getDefault().toString() + "\"";
|
||||
} else {
|
||||
return "\"\"";
|
||||
}
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
return "\"\"";
|
||||
if (p.getDefault() != null) {
|
||||
return "\"" + p.getDefault().toString() + "\"";
|
||||
} else {
|
||||
return "\"\"";
|
||||
}
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
if (ModelUtils.isFloatSchema(p)) {
|
||||
return "0.0f";
|
||||
if (ModelUtils.isFloatSchema(p)) { // float
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "f";
|
||||
} else {
|
||||
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)) {
|
||||
if (ModelUtils.isLongSchema(p)) {
|
||||
return "0L";
|
||||
if (ModelUtils.isLongSchema(p)) { // long
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "L";
|
||||
} else {
|
||||
return "0L";
|
||||
}
|
||||
} else { // integer
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
return "0";
|
||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||
return "\"\"";
|
||||
if (p.getDefault() != null) {
|
||||
return "\"" + p.getDefault().toString() + "\"";
|
||||
} else {
|
||||
return "\"\"";
|
||||
}
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||
return "std::map<std::string, " + inner + ">()";
|
||||
@ -319,6 +361,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
} else if (!StringUtils.isEmpty(p.get$ref())) {
|
||||
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||
}
|
||||
|
||||
return "nullptr";
|
||||
}
|
||||
|
||||
|
@ -232,8 +232,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("JS_BEAUTIFY_PATH"))) {
|
||||
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)");
|
||||
if (StringUtils.isEmpty(System.getenv("JS_POST_PROCESS_FILE"))) {
|
||||
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)) {
|
||||
@ -1167,19 +1167,20 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return;
|
||||
}
|
||||
|
||||
String jsBeautifyPath = System.getenv("JS_BEAUTIFY_PATH");
|
||||
if (StringUtils.isEmpty(jsBeautifyPath)) {
|
||||
return; // skip if JS_BEAUTIFY_PATH env variable is not defined
|
||||
String jsPostProcessFile = System.getenv("JS_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(jsPostProcessFile)) {
|
||||
return; // skip if JS_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
|
||||
// only process files with js extension
|
||||
if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = jsBeautifyPath + " -r -f " + file.toString();
|
||||
String command = jsPostProcessFile + " " + file.toString();
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
if (p.exitValue() != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, p.exitValue());
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
}
|
||||
LOGGER.info("Successfully executed: " + command);
|
||||
} catch (Exception e) {
|
||||
@ -1187,5 +1188,4 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("PERLTIDY_PATH"))) {
|
||||
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)");
|
||||
if (StringUtils.isEmpty(System.getenv("PERL_POST_PROCESS_FILE"))) {
|
||||
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)) {
|
||||
@ -571,9 +571,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return;
|
||||
}
|
||||
|
||||
String perlTidyPath = System.getenv("PERLTIDY_PATH");
|
||||
String perlTidyPath = System.getenv("PERL_POST_PROCESS_FILE");
|
||||
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
|
||||
@ -583,11 +583,12 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
String command = perlTidyPath + " -b -bext='/' " + file.toString();
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
if (p.exitValue() != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, p.exitValue());
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: " + command);
|
||||
}
|
||||
LOGGER.info("Successfully executed: " + command);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
}
|
||||
|
@ -318,8 +318,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
// need vendor extensions for x-swagger-router-controller
|
||||
// can be changed to x-openapi-router-controller when https://github.com/zalando/connexion/issues/683 is done
|
||||
// need vendor extensions for x-openapi-router-controller
|
||||
Map<String, PathItem> paths = openAPI.getPaths();
|
||||
if (paths != null) {
|
||||
for (String pathname : paths.keySet()) {
|
||||
@ -337,9 +336,9 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
operationId = getOrGenerateOperationId(operation, pathname, method.toString());
|
||||
}
|
||||
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(
|
||||
"x-swagger-router-controller",
|
||||
"x-openapi-router-controller",
|
||||
controllerPackage + "." + toApiFilename(tag)
|
||||
);
|
||||
}
|
||||
|
@ -221,6 +221,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
|
||||
if (additionalProperties.containsKey(ASYNC)) {
|
||||
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
||||
//fix for issue/1164
|
||||
convertPropertyToBooleanAndWriteBack(ASYNC);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(REACTIVE)) {
|
||||
|
@ -472,7 +472,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return this.convertUsingFileNamingConvention(name) + modelFileSuffix;
|
||||
return this.sanitizeName(this.convertUsingFileNamingConvention(name) + modelFileSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,7 +46,7 @@ public class {{classname}} {
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#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}}
|
||||
{{#returnType}}
|
||||
* @return {{returnType}}
|
||||
|
@ -62,7 +62,7 @@ try {
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-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}}
|
||||
|
||||
### Return type
|
||||
|
@ -25,7 +25,7 @@ public interface {{classname}} extends ApiClient.Api {
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#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}}
|
||||
{{#returnType}}
|
||||
* @return {{returnType}}
|
||||
@ -55,14 +55,14 @@ public interface {{classname}} extends ApiClient.Api {
|
||||
* building up this map in a fluent style.
|
||||
{{#allParams}}
|
||||
{{^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}}
|
||||
{{/allParams}}
|
||||
* @param queryParams Map of query parameters as name-value pairs
|
||||
* <p>The following elements may be specified in the query map:</p>
|
||||
* <ul>
|
||||
{{#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}}
|
||||
* </ul>
|
||||
{{#returnType}}
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -54,6 +54,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth;
|
||||
import {{invokerPackage}}.auth.ApiKeyAuth;
|
||||
import {{invokerPackage}}.auth.OAuth;
|
||||
import {{invokerPackage}}.auth.RetryingOAuth;
|
||||
import {{invokerPackage}}.auth.OAuthFlow;
|
||||
|
||||
public class ApiClient {
|
||||
|
||||
@ -102,7 +103,7 @@ public class ApiClient {
|
||||
) {
|
||||
init();
|
||||
|
||||
RetryingOAuth retryingOAuth = new RetryingOAuth("{{tokenUrl}}", clientId, GrantType.valueOf("{{flow}}"), clientSecret, parameters);
|
||||
RetryingOAuth retryingOAuth = new RetryingOAuth("{{tokenUrl}}", clientId, OAuthFlow.{{flow}}, clientSecret, parameters);
|
||||
authentications.put(
|
||||
"{{name}}",
|
||||
retryingOAuth
|
||||
|
@ -65,7 +65,7 @@ public class {{classname}} {
|
||||
{{#operation}}
|
||||
/**
|
||||
* 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 progressRequestListener Progress request listener
|
||||
* @return Call to execute
|
||||
@ -188,7 +188,7 @@ public class {{classname}} {
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{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}}
|
||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||
{{#isDeprecated}}
|
||||
@ -210,7 +210,7 @@ public class {{classname}} {
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{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<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||
{{#isDeprecated}}
|
||||
@ -233,7 +233,7 @@ public class {{classname}} {
|
||||
/**
|
||||
* {{summary}} (asynchronously)
|
||||
* {{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
|
||||
* @return The request call
|
||||
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||
|
@ -35,15 +35,14 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
public RetryingOAuth(
|
||||
String tokenUrl,
|
||||
String clientId,
|
||||
GrantType grantType,
|
||||
OAuthFlow flow,
|
||||
String clientSecret,
|
||||
Map<String, String> parameters
|
||||
) {
|
||||
this(OAuthClientRequest.tokenLocation(tokenUrl)
|
||||
.setClientId(clientId)
|
||||
.setGrantType(grantType)
|
||||
.setClientSecret(clientSecret));
|
||||
|
||||
setFlow(flow);
|
||||
if (parameters != null) {
|
||||
for (String paramName : parameters.keySet()) {
|
||||
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
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
return retryingIntercept(chain, true);
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -11,6 +11,13 @@
|
||||
<developerConnection>scm:git:git@github.com:openapitools/openapi-generator.git</developerConnection>
|
||||
<url>https://openapi-generator.tech</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -62,7 +62,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -13,6 +13,13 @@
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -22,7 +22,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -15,7 +15,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
|
@ -40,7 +40,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
|
@ -25,7 +25,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -12,7 +12,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
|
||||
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
|
||||
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
|
||||
|
||||
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
|
||||
|
||||
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
|
||||
private {{#useBeanValidation}}@Valid{{/useBeanValidation}} {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||
private {{#useBeanValidation}}@Valid{{/useBeanValidation}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -16,8 +16,10 @@ public class ApiUtil {
|
||||
{{^reactive}}
|
||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||
try {
|
||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
||||
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
res.addHeader("Content-Type", contentType);
|
||||
res.getWriter().print(example);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -13,11 +13,20 @@
|
||||
<springfox-version>2.8.0</springfox-version>
|
||||
{{/useSpringfox}}
|
||||
</properties>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
{{^parentOverridden}}
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>{{#java8}}2.0.1.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
{{^interfaceOnly}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package {{package}};
|
||||
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import {{configPackage}}.ClientConfiguration;
|
||||
|
||||
{{=<% %>=}}
|
||||
|
@ -11,11 +11,20 @@
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<swagger-core-version>1.5.18</swagger-core-version>
|
||||
</properties>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
{{^parentOverridden}}
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.4.RELEASE</version>
|
||||
<version>2.0.5.RELEASE</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
</build>
|
||||
@ -25,7 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||
<version>Dalston.SR1</version>
|
||||
<version>Finchley.SR1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@ -40,56 +49,38 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-feign</artifactId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security.oauth</groupId>
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
<artifactId>spring-cloud-starter-oauth2</artifactId>
|
||||
</dependency>
|
||||
{{#withXml}}
|
||||
|
||||
<!-- XML processing: Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
{{/withXml}}
|
||||
{{#java8}}
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
{{#joda}}
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-joda</artifactId>
|
||||
</dependency>
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.joschi.jackson</groupId>
|
||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||
<version>2.6.4</version>
|
||||
</dependency>
|
||||
{{/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>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -5,6 +5,13 @@
|
||||
<packaging>jar</packaging>
|
||||
<name>{{artifactId}}</name>
|
||||
<version>{{artifactVersion}}</version>
|
||||
{{#parentOverridden}}
|
||||
<parent>
|
||||
<groupId>{{{parentGroupId}}}</groupId>
|
||||
<artifactId>{{{parentArtifactId}}}</artifactId>
|
||||
<version>{{{parentVersion}}}</version>
|
||||
</parent>
|
||||
{{/parentOverridden}}
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
|
@ -31,7 +31,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -25,7 +25,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -75,7 +75,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the path params
|
||||
{{#pathParams}}
|
||||
{{#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}}
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
@ -84,7 +84,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the query params
|
||||
{{#queryParams}}
|
||||
{{#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}}
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
@ -93,7 +93,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the headers
|
||||
{{#headerParams}}
|
||||
{{#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}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
@ -140,7 +140,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the path params
|
||||
{{#pathParams}}
|
||||
{{#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}}
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
@ -149,16 +149,16 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the query params
|
||||
{{#queryParams}}
|
||||
{{#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}}
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
|
||||
|
||||
{{#hasHeaderParams}}
|
||||
// Getting the headers
|
||||
{{#headerParams}}
|
||||
{{#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}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
|
@ -217,7 +217,7 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
|
||||
{{/generatePropertyChanged}}
|
||||
{{#validatable}}
|
||||
{{#discriminator}}
|
||||
{{#hasChildren}}
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
@ -235,8 +235,8 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
/// <returns>Validation Result</returns>
|
||||
protected IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> BaseValidate(ValidationContext validationContext)
|
||||
{
|
||||
{{/discriminator}}
|
||||
{{^discriminator}}
|
||||
{{/hasChildren}}
|
||||
{{^hasChildren}}
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
@ -244,11 +244,11 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
{{/discriminator}}
|
||||
{{/hasChildren}}
|
||||
{{#parent}}
|
||||
{{^isArrayModel}}
|
||||
{{^isMapModel}}
|
||||
foreach(var x in BaseValidate(validationContext)) yield return x;
|
||||
foreach(var x in base.BaseValidate(validationContext)) yield return x;
|
||||
{{/isMapModel}}
|
||||
{{/isArrayModel}}
|
||||
{{/parent}}
|
||||
|
@ -12,7 +12,7 @@ class {{classname}} {
|
||||
{{#description}}
|
||||
/// {{description}}
|
||||
{{/description}}
|
||||
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
|
||||
static const {{classname}} {{{name}}}} = const {{classname}}._internal({{{value}}});
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
@ -29,7 +29,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
|
||||
switch (data) {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
case {{value}}: return {{classname}}.{{name}};
|
||||
case {{{value}}}: return {{classname}}.{{{name}}}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default: throw('Unknown enum value to decode: $data');
|
||||
|
@ -10,7 +10,7 @@ class {{classname}} {
|
||||
{{#description}}
|
||||
/// {{description}}
|
||||
{{/description}}
|
||||
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
|
||||
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
|
||||
switch (data) {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
case {{value}}: return {{classname}}.{{name}};
|
||||
case {{{value}}}: return {{classname}}.{{{name}}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default: throw('Unknown enum value to decode: $data');
|
||||
|
@ -10,7 +10,7 @@ class {{classname}} {
|
||||
{{#description}}
|
||||
/// {{description}}
|
||||
{{/description}}
|
||||
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
|
||||
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
|
||||
switch (data) {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
case {{value}}: return {{classname}}.{{name}};
|
||||
case {{{value}}}: return {{classname}}.{{{name}}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default: throw('Unknown enum value to decode: $data');
|
||||
|
@ -1,6 +1,5 @@
|
||||
# Install flask-connexion from git branch dev-2.0. Change when connexion 2.0 is released
|
||||
git+https://github.com/zalando/connexion.git@35e4e678ef69e703eaf84a48126049808c73b17c#egg=connexion
|
||||
swagger-ui-bundle
|
||||
connexion == 2.0.0rc3
|
||||
swagger-ui-bundle == 0.0.2
|
||||
python_dateutil == 2.6.0
|
||||
{{#supportPython2}}
|
||||
typing == 3.5.2.2
|
||||
|
@ -19,6 +19,6 @@ const (
|
||||
type {{classname}} struct {
|
||||
{{#vars}}{{#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}}
|
||||
}{{/isEnum}}{{/model}}{{/models}}
|
||||
|
@ -19,6 +19,6 @@ const (
|
||||
type {{classname}} struct {
|
||||
{{#vars}}{{#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}}
|
||||
}{{/isEnum}}{{/model}}{{/models}}
|
||||
|
@ -50,14 +50,14 @@ type {{{nickname}}}Opts struct {
|
||||
{{^required}}
|
||||
{{#isPrimitiveType}}
|
||||
{{^isBinary}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
|
||||
{{/isBinary}}
|
||||
{{#isBinary}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.Interface
|
||||
{{vendorExtensions.x-exportParamName}} optional.Interface
|
||||
{{/isBinary}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.Interface
|
||||
{{vendorExtensions.x-exportParamName}} optional.Interface
|
||||
{{/isPrimitiveType}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
@ -66,13 +66,13 @@ type {{{nickname}}}Opts struct {
|
||||
{{/hasOptionalParams}}
|
||||
func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
|
||||
localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
{{#returnType}}
|
||||
localVarReturnValue {{{returnType}}}
|
||||
localVarReturnValue {{{returnType}}}
|
||||
{{/returnType}}
|
||||
)
|
||||
|
||||
@ -275,7 +275,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
||||
{{#returnType}}
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// 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 {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
|
||||
}
|
||||
@ -284,20 +284,20 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
||||
{{/returnType}}
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
{{#responses}}
|
||||
{{#dataType}}
|
||||
if localVarHttpResponse.StatusCode == {{{code}}} {
|
||||
var v {{{dataType}}}
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
|
||||
}
|
||||
{{/dataType}}
|
||||
{{/responses}}
|
||||
@ -307,4 +307,4 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil
|
||||
}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
||||
|
@ -188,7 +188,7 @@ func (c *APIClient) prepareRequest(
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
|
||||
}
|
||||
@ -227,6 +227,16 @@ func (c *APIClient) prepareRequest(
|
||||
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
|
||||
url, err := url.Parse(path)
|
||||
if err != nil {
|
||||
@ -469,4 +479,4 @@ func (e GenericOpenAPIError) Body() []byte {
|
||||
// Model returns the unpacked model of the error
|
||||
func (e GenericOpenAPIError) Model() interface{} {
|
||||
return e.model
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ type {{classname}} struct {
|
||||
{{#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}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
|
@ -32,7 +32,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
|
||||
{{/vars}}
|
||||
|
@ -39,28 +39,26 @@ class RESTClientObject(object):
|
||||
def __init__(self, configuration, pools_size=4, maxsize=4):
|
||||
# maxsize is number of requests to host that are allowed in parallel
|
||||
|
||||
if configuration.verify_ssl:
|
||||
|
||||
# ca_certs
|
||||
if configuration.ssl_ca_cert:
|
||||
ca_certs = configuration.ssl_ca_cert
|
||||
else:
|
||||
# if not set certificate file, use Mozilla's root certificates.
|
||||
ca_certs = certifi.where()
|
||||
|
||||
ssl_context = ssl.create_default_context(cafile=ca_certs)
|
||||
|
||||
if configuration.cert_file:
|
||||
ssl_context.load_cert_chain(
|
||||
configuration.cert_file, keyfile=configuration.key_file
|
||||
)
|
||||
# ca_certs
|
||||
if configuration.ssl_ca_cert:
|
||||
ca_certs = configuration.ssl_ca_cert
|
||||
else:
|
||||
ssl_context = None
|
||||
# if not set certificate file, use Mozilla's root certificates.
|
||||
ca_certs = certifi.where()
|
||||
|
||||
ssl_context = ssl.create_default_context(cafile=ca_certs)
|
||||
if configuration.cert_file:
|
||||
ssl_context.load_cert_chain(
|
||||
configuration.cert_file, keyfile=configuration.key_file
|
||||
)
|
||||
|
||||
if not configuration.verify_ssl:
|
||||
ssl_context.check_hostname = False
|
||||
ssl_context.verify_mode = ssl.CERT_NONE
|
||||
|
||||
connector = aiohttp.TCPConnector(
|
||||
limit=maxsize,
|
||||
ssl_context=ssl_context,
|
||||
verify_ssl=configuration.verify_ssl
|
||||
ssl_context=ssl_context
|
||||
)
|
||||
|
||||
# https pool manager
|
||||
|
@ -36,7 +36,7 @@ object {{classname}} {
|
||||
{{/operation}}
|
||||
|
||||
{{#unknownStatusCodes}}
|
||||
ApiInvoker.addCustomStatusCode({{value}}, isSuccess = false)
|
||||
ApiInvoker.addCustomStatusCode({{{value}}}, isSuccess = false)
|
||||
{{/unknownStatusCodes}}
|
||||
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ export interface {{classname}}Interface {
|
||||
* @throws {RequiredError}
|
||||
* @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}}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@
|
||||
"rewire": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^2.4.2"
|
||||
"typescript": "^2.4.2",
|
||||
"@types/node": "8.10.34"
|
||||
}{{#npmRepository}},
|
||||
"publishConfig": {
|
||||
"registry": "{{npmRepository}}"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user