forked from loafle/openapi-generator-original
Compare commits
10 Commits
v3.1.1
...
travis_tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2177039d7c | ||
|
|
8544382d53 | ||
|
|
151017b672 | ||
|
|
6095a0676c | ||
|
|
d3153a8eae | ||
|
|
f2f10b429e | ||
|
|
f7d31a3eab | ||
|
|
72f6bda2f7 | ||
|
|
3e99d2df73 | ||
|
|
44caf2e7cf |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -83,9 +83,6 @@ samples/client/petstore/scala/build/
|
|||||||
samples/client/petstore/java/resttemplate/hello.txt
|
samples/client/petstore/java/resttemplate/hello.txt
|
||||||
samples/client/petstore/java/retrofit2/hello.txt
|
samples/client/petstore/java/retrofit2/hello.txt
|
||||||
samples/client/petstore/java/feign/hello.txt
|
samples/client/petstore/java/feign/hello.txt
|
||||||
samples/client/petstore/java/jersey2-java6/project/
|
|
||||||
samples/client/petstore/java/jersey2-java8/project/
|
|
||||||
samples/client/petstore/java/jersey2/project/
|
|
||||||
|
|
||||||
#PHP
|
#PHP
|
||||||
samples/client/petstore/php/OpenAPIToolsClient-php/composer.lock
|
samples/client/petstore/php/OpenAPIToolsClient-php/composer.lock
|
||||||
@@ -161,9 +158,6 @@ samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt
|
|||||||
samples/client/petstore/python/.coverage
|
samples/client/petstore/python/.coverage
|
||||||
samples/client/petstore/python/.projectile
|
samples/client/petstore/python/.projectile
|
||||||
samples/client/petstore/python/.venv/
|
samples/client/petstore/python/.venv/
|
||||||
samples/client/petstore/python-asyncio/.venv/
|
|
||||||
samples/client/petstore/python-asyncio/.pytest_cache/
|
|
||||||
samples/client/petstore/python-tornado/.venv/
|
|
||||||
|
|
||||||
# ts
|
# ts
|
||||||
samples/client/petstore/typescript-node/npm/node_modules
|
samples/client/petstore/typescript-node/npm/node_modules
|
||||||
|
|||||||
73
.travis.yml
73
.travis.yml
@@ -41,29 +41,13 @@ addons:
|
|||||||
- petstore.swagger.io
|
- petstore.swagger.io
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
# install haskell
|
|
||||||
- curl -sSL https://get.haskellstack.org/ | sh
|
|
||||||
- stack upgrade
|
|
||||||
- stack --version
|
|
||||||
# install rust
|
|
||||||
- curl https://sh.rustup.rs -sSf | sh -s -- -y -v
|
|
||||||
# required when sudo: required for the Ruby petstore tests
|
|
||||||
- gem install bundler
|
|
||||||
- npm install -g typescript
|
|
||||||
- npm install -g npm
|
|
||||||
- npm install -g elm
|
|
||||||
- npm config set registry http://registry.npmjs.org/
|
|
||||||
# set python 3.6.3 as default
|
|
||||||
- source ~/virtualenv/python3.6/bin/activate
|
|
||||||
# to run petstore server locally via docker
|
# to run petstore server locally via docker
|
||||||
- docker pull swaggerapi/petstore
|
- docker pull swaggerapi/petstore
|
||||||
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||||
- docker ps -a
|
- docker ps -a
|
||||||
# Add bats test framework and cURL for Bash script integration tests
|
# Add bats test framework and cURL for Bash script integration tests
|
||||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
|
||||||
- sudo apt-get update -qq
|
|
||||||
- sudo apt-get install -qq bats
|
|
||||||
- sudo apt-get install -qq curl
|
|
||||||
# install perl module
|
# install perl module
|
||||||
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
||||||
#- cpanm Test::Exception Test::More Log::Any LWP::UserAgent JSON URI:Query Module::Runtime DateTime Module::Find Moose::Role
|
#- cpanm Test::Exception Test::More Log::Any LWP::UserAgent JSON URI:Query Module::Runtime DateTime Module::Find Moose::Role
|
||||||
@@ -93,41 +77,38 @@ install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
# fail fast
|
# fail fast
|
||||||
- set -e
|
- set -ev
|
||||||
# fail if templates/generators contain carriage return '\r'
|
# fail if templates/generators contain carriage return '\r'
|
||||||
- /bin/bash ./bin/utils/detect_carriage_return.sh
|
- /bin/bash ./bin/utils/detect_carriage_return.sh
|
||||||
# fail if generators contain merge conflicts
|
# fail if generators contain merge conflicts
|
||||||
- /bin/bash ./bin/utils/detect_merge_conflict.sh
|
- /bin/bash ./bin/utils/detect_merge_conflict.sh
|
||||||
# fail if generators contain tab '\t'
|
# fail if generators contain tab '\t'
|
||||||
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
|
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
|
||||||
# run integration tests defined in maven pom.xml
|
- mvn verify
|
||||||
- mvn --quiet clean install
|
|
||||||
- mvn --quiet verify -Psamples
|
|
||||||
after_success:
|
after_success:
|
||||||
# push to maven repo
|
## docker build and push images to DockerHub (openapi-generator-online, openapi-generator-cli)
|
||||||
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
- set -ev
|
||||||
if [ "$TRAVIS_BRANCH" = "master" ]; then
|
- read -r MVN_VERSION_FOR_DOCKER_TAG < target/ci/version-for-docker-tag.txt
|
||||||
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml;
|
- echo "Tag for Docker derived from maven version -> $MVN_VERSION_FOR_DOCKER_TAG"; sleep 5;
|
||||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
- if [ $DOCKER_HUB_USERNAME ]; then
|
||||||
pushd .;
|
echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin;
|
||||||
cd modules/openapi-generator-gradle-plugin;
|
if [ ! -z "$TRAVIS_TAG" ]; then
|
||||||
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online;
|
||||||
echo "Finished ./gradlew uploadArchives";
|
docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli;
|
||||||
popd;
|
elif [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||||
elif ([ "$TRAVIS_BRANCH" == "3.1.x" ] || [ "$TRAVIS_BRANCH" == "4.0.x" ]) ; then
|
docker build -t $DOCKER_GENERATOR_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online;
|
||||||
mvn clean deploy --settings CI/settings.xml;
|
docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli;
|
||||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
else
|
||||||
pushd .;
|
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online;
|
||||||
cd modules/openapi-generator-gradle-plugin;
|
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli;
|
||||||
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
fi;
|
||||||
echo "Finished ./gradlew uploadArchives";
|
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && ([ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "3.1.x" ] || [ "$TRAVIS_BRANCH" == "4.0.x" ]); then
|
||||||
popd;
|
docker push $DOCKER_GENERATOR_IMAGE_NAME;
|
||||||
fi;
|
echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME";
|
||||||
|
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME;
|
||||||
|
echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
|
||||||
|
fi;
|
||||||
fi;
|
fi;
|
||||||
## docker: build and push openapi-generator-online to DockerHub
|
sleep 5;
|
||||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME"; fi; fi
|
|
||||||
## docker: build cli image and push to Docker Hub
|
|
||||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
|
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
dist: trusty
|
|
||||||
sudo: required
|
|
||||||
language: java
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- openjdk-6-jdk
|
|
||||||
jdk: openjdk6
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.m2
|
|
||||||
- $HOME/.ivy2
|
|
||||||
- $HOME/.gradle/caches/
|
|
||||||
- $HOME/.gradle/wrapper/
|
|
||||||
|
|
||||||
install:
|
|
||||||
- jdk_switcher use openjdk6
|
|
||||||
- java -version
|
|
||||||
- curl -s "https://get.sdkman.io" | bash
|
|
||||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
|
||||||
- sdk version
|
|
||||||
- sdk install gradle 2.9
|
|
||||||
- sdk list gradle
|
|
||||||
- sdk version
|
|
||||||
- gradle --version
|
|
||||||
|
|
||||||
script:
|
|
||||||
- cd samples/client/petstore/java/jersey2-java6 && gradle test
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>openapi-generator-project</name>
|
<name>openapi-generator-project</name>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<url>https://github.com/openapi-tools/openapi-generator</url>
|
<url>https://github.com/openapi-tools/openapi-generator</url>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
|
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>openapi-generator-project</name>
|
<name>openapi-generator-project</name>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<url>https://github.com/openapitools/openapi-generator</url>
|
<url>https://github.com/openapitools/openapi-generator</url>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>openapi-generator-project</name>
|
<name>openapi-generator-project</name>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<url>https://github.com/openapitools/openapi-generator</url>
|
<url>https://github.com/openapitools/openapi-generator</url>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>openapi-generator-project</name>
|
<name>openapi-generator-project</name>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<url>https://github.com/openapitools/openapi-generator</url>
|
<url>https://github.com/openapitools/openapi-generator</url>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||||
|
|||||||
1
CI/resources/version-for-docker-tag.txt
Normal file
1
CI/resources/version-for-docker-tag.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
apply plugin: 'idea'
|
|
||||||
apply plugin: 'eclipse'
|
|
||||||
|
|
||||||
group = 'org.openapitools'
|
|
||||||
version = '1.0.0'
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
jcenter {
|
|
||||||
url "http://jcenter.bintray.com/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:2.3.+'
|
|
||||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
jcenter {
|
|
||||||
url "http://jcenter.bintray.com/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(hasProperty('target') && target == 'android') {
|
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
|
||||||
apply plugin: 'com.github.dcendents.android-maven'
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 25
|
|
||||||
buildToolsVersion '25.0.2'
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 14
|
|
||||||
targetSdkVersion 25
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename the aar correctly
|
|
||||||
libraryVariants.all { variant ->
|
|
||||||
variant.outputs.each { output ->
|
|
||||||
def outputFile = output.outputFile
|
|
||||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
|
||||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
|
||||||
output.outputFile = new File(outputFile.parent, fileName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
provided 'javax.annotation:jsr250-api:1.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
android.libraryVariants.all { variant ->
|
|
||||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
|
||||||
task.description = "Create jar artifact for ${variant.name}"
|
|
||||||
task.dependsOn variant.javaCompile
|
|
||||||
task.from variant.javaCompile.destinationDir
|
|
||||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
|
||||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
|
||||||
artifacts.add('archives', task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
|
||||||
from android.sourceSets.main.java.srcDirs
|
|
||||||
classifier = 'sources'
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives sourcesJar
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
|
||||||
apply plugin: 'maven'
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
|
|
||||||
install {
|
|
||||||
repositories.mavenInstaller {
|
|
||||||
pom.artifactId = 'petstore-jersey2-java6'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task execute(type:JavaExec) {
|
|
||||||
main = System.getProperty('mainClass')
|
|
||||||
classpath = sourceSets.main.runtimeClasspath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
|
||||||
swagger_annotations_version = "1.5.20"
|
|
||||||
jackson_version = "2.9.6"
|
|
||||||
jersey_version = "2.6"
|
|
||||||
commons_io_version=2.5
|
|
||||||
commons_lang3_version=3.6
|
|
||||||
junit_version = "4.12"
|
|
||||||
threetenbp_version = "2.6.4"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
|
||||||
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
|
|
||||||
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
|
|
||||||
compile "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
|
|
||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
|
||||||
compile "commons-io:commons-io:$commons_io_version"
|
|
||||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
|
||||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
|
||||||
testCompile "junit:junit:$junit_version"
|
|
||||||
}
|
|
||||||
41
README.md
41
README.md
@@ -2,16 +2,11 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.1.1`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.1.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||||
|
|
||||||
[`3.2.x`](https://github.com/OpenAPITools/openapi-generator/tree/3.2.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)
|
[`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://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||||
@@ -86,10 +81,7 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
|||||||
OpenAPI Generator Version | Release Date | OpenAPI Spec compatibility | Notes
|
OpenAPI Generator Version | Release Date | OpenAPI Spec compatibility | 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 | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes (no fallback)
|
4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes (no fallback)
|
||||||
3.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.2.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
|
3.1.0 (current master, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.1.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
|
||||||
3.1.2-SNAPSHOT (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.1.2-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
|
||||||
[3.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.1) | 18.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
|
||||||
[3.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.0) | 06.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
|
|
||||||
[3.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.3) | 27.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
[3.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.3) | 27.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||||
[3.0.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.2) | 18.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
[3.0.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.2) | 18.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||||
[3.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.1) | 11.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
[3.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.1) | 11.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||||
@@ -128,7 +120,7 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
|||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* See the different versions of the [openapi-generator-maven-plugin](https://mvnrepository.com/artifact/org.openapitools/openapi-generator-maven-plugin) artifact available on maven central.
|
* See the different versions of the [openapi-generator-maven-plugin](https://mvnrepository.com/artifact/org.openapitools/openapi-generator-maven-plugin) artifact available on maven central.
|
||||||
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md)
|
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.adoc)
|
||||||
|
|
||||||
**Gradle plugin:**
|
**Gradle plugin:**
|
||||||
```xml
|
```xml
|
||||||
@@ -145,16 +137,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
|||||||
|
|
||||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||||
|
|
||||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar`
|
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar`
|
||||||
|
|
||||||
For **Mac/Linux** users:
|
For **Mac/Linux** users:
|
||||||
```sh
|
```sh
|
||||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar -O openapi-generator-cli.jar
|
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar -O openapi-generator-cli.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||||
```
|
```
|
||||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar
|
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||||
@@ -201,6 +193,22 @@ To reinstall with the latest master, run `brew reinstall --HEAD openapi-generato
|
|||||||
- [https://hub.docker.com/r/openapitools/openapi-generator-cli/](https://hub.docker.com/r/openapitools/openapi-generator-cli/) (official CLI)
|
- [https://hub.docker.com/r/openapitools/openapi-generator-cli/](https://hub.docker.com/r/openapitools/openapi-generator-cli/) (official CLI)
|
||||||
- [https://hub.docker.com/r/openapitools/openapi-generator-online/](https://hub.docker.com/r/openapitools/openapi-generator-online/) (official web service)
|
- [https://hub.docker.com/r/openapitools/openapi-generator-online/](https://hub.docker.com/r/openapitools/openapi-generator-online/) (official web service)
|
||||||
|
|
||||||
|
#### Docker tags
|
||||||
|
|
||||||
|
`lastest` Tag contains the continuously built version from our `master` branch.
|
||||||
|
|
||||||
|
`v0.0.0` Tags correspond to a released version in this git repository. Examples:
|
||||||
|
|
||||||
|
* `v3.0.0` Tag
|
||||||
|
* `v3.0.1` Tag
|
||||||
|
* `v3.0.2` Tag
|
||||||
|
|
||||||
|
`0.0.x` Tags correspond to continuously built versions (after each commit), regardless of the branch it is built from. Examples:
|
||||||
|
|
||||||
|
* `3.0.x` Tag: contains first `3.0.2-SNAPSHOT` and after the `3.0.2` release it contains `3.0.3-SNAPSHOT` and so on.
|
||||||
|
* `3.1.x` Tag: contains first `3.1.0-SNAPSHOT` and after the `3.1.0` release it contains `3.1.1-SNAPSHOT` and so on.
|
||||||
|
* `4.0.x` Tag: contains first `4.0.0-SNAPSHOT` and after the `4.0.0` release it contains `4.0.1-SNAPSHOT` and so on.
|
||||||
|
|
||||||
|
|
||||||
#### OpenAPI Generator CLI Docker Image
|
#### OpenAPI Generator CLI Docker Image
|
||||||
|
|
||||||
@@ -424,6 +432,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
|
|
||||||
## [5 - Presentations/Videos/Tutorials/Books](#table-of-contents)
|
## [5 - Presentations/Videos/Tutorials/Books](#table-of-contents)
|
||||||
|
|
||||||
|
- 2018/04/12 - [Generate Angular API clients with Swagger](https://angular.schule/blog/2018-04-swagger-codegen) by [JohannesHoppe](https://github.com/JohannesHoppe)
|
||||||
- 2018/05/12 - [OpenAPI Generator - community drivenで成長するコードジェネレータ](https://ackintosh.github.io/blog/2018/05/12/openapi-generator/) by [中野暁人](https://github.com/ackintosh)
|
- 2018/05/12 - [OpenAPI Generator - community drivenで成長するコードジェネレータ](https://ackintosh.github.io/blog/2018/05/12/openapi-generator/) by [中野暁人](https://github.com/ackintosh)
|
||||||
- 2018/05/15 - [Starting a new open-source project](http://jmini.github.io/blog/2018/2018-05-15_new-open-source-project.html) by [Jeremie Bresson](https://github.com/jmini)
|
- 2018/05/15 - [Starting a new open-source project](http://jmini.github.io/blog/2018/2018-05-15_new-open-source-project.html) by [Jeremie Bresson](https://github.com/jmini)
|
||||||
- 2018/05/15 - [REST API仕様からAPIクライアントやスタブサーバを自動生成する「OpenAPI Generator」オープンソースで公開。Swagger Codegenからのフォーク](https://www.publickey1.jp/blog/18/rest_apiapiopenapi_generatorswagger_generator.html) by [Publickey](https://www.publickey1.jp)
|
- 2018/05/15 - [REST API仕様からAPIクライアントやスタブサーバを自動生成する「OpenAPI Generator」オープンソースで公開。Swagger Codegenからのフォーク](https://www.publickey1.jp/blog/18/rest_apiapiopenapi_generatorswagger_generator.html) by [Publickey](https://www.publickey1.jp)
|
||||||
@@ -577,7 +586,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
|||||||
| Elixir | |
|
| Elixir | |
|
||||||
| Elm | |
|
| Elm | |
|
||||||
| Erlang | @tsloughter (2017/11) |
|
| Erlang | @tsloughter (2017/11) |
|
||||||
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) |
|
| Go | @antihax (2017/11) @bvwells (2017/12) |
|
||||||
| Groovy | |
|
| Groovy | |
|
||||||
| Haskell | |
|
| Haskell | |
|
||||||
| Java | @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
|
| Java | @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
|
||||||
@@ -586,7 +595,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
|||||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||||
| ObjC | |
|
| ObjC | |
|
||||||
| Perl | @wing328 (2017/07) |
|
| Perl | @wing328 (2017/07) |
|
||||||
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) @ybelenko (2018/07) |
|
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) |
|
||||||
| PowerShell | |
|
| PowerShell | |
|
||||||
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11)|
|
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11)|
|
||||||
| R | |
|
| R | |
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ install:
|
|||||||
- cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
- cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
||||||
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
||||||
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
|
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
|
||||||
- cmd: java -version
|
|
||||||
- cmd: dir/w
|
- cmd: dir/w
|
||||||
- git clone https://github.com/wing328/swagger-samples
|
- git clone https://github.com/wing328/swagger-samples
|
||||||
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
|
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ then
|
|||||||
mvn -B clean package
|
mvn -B clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing files and folders under samples/client/petstore/go/go-petstore-withXml"
|
|
||||||
rm -rf samples/client/petstore/go/go-petstore-withXml
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/go -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g go -o samples/client/petstore/go/go-petstore-withXml -DpackageName=petstore,withXml=true $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/go -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g go -o samples/client/petstore/go/go-petstore-withXml -DpackageName=petstore,withXml=true $@"
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ then
|
|||||||
mvn -B clean package
|
mvn -B clean package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing files and folders under samples/client/petstore/go/go-petstore"
|
|
||||||
rm -rf samples/client/petstore/go/go-petstore
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/go -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g go -o samples/client/petstore/go/go-petstore -DpackageName=petstore $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/go -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g go -o samples/client/petstore/go/go-petstore -DpackageName=petstore $@"
|
||||||
|
|||||||
@@ -32,8 +32,4 @@ ags="generate --artifact-id petstore-jersey2-java6 -i modules/openapi-generator/
|
|||||||
echo "Removing files and folders under samples/client/petstore/java/jersey2-java6/src/main"
|
echo "Removing files and folders under samples/client/petstore/java/jersey2-java6/src/main"
|
||||||
rm -rf samples/client/petstore/java/jersey2-java6/src/main
|
rm -rf samples/client/petstore/java/jersey2-java6/src/main
|
||||||
find samples/client/petstore/java/jersey2-java6 -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
find samples/client/petstore/java/jersey2-java6 -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||||
|
|
||||||
echo "Restoring build.gradle ... "
|
|
||||||
cp CI/samples.ci/client/petstore/java/jersey2-java6/build.gradle samples/client/petstore/java/jersey2-java6/
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-on-rails-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/ruby-on-rails $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/rails5 -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/rails5 $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
32
bin/openapi3/sinatra-petstore-server.sh
Executable file
32
bin/openapi3/sinatra-petstore-server.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/sinatra -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/sinatra $@"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# update python petstore clients
|
|
||||||
|
|
||||||
./bin/python-asyncio-petstore.sh
|
|
||||||
./bin/python-petstore.sh
|
|
||||||
./bin/python-tornado-petstore.sh
|
|
||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-on-rails-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/ruby-on-rails $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/rails5 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/rails5 $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
while [ -h "$SCRIPT" ] ; do
|
|
||||||
ls=`ls -ld "$SCRIPT"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
SCRIPT="$link"
|
|
||||||
else
|
|
||||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "${APP_DIR}" ]; then
|
|
||||||
APP_DIR=`dirname "$SCRIPT"`/..
|
|
||||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
|
||||||
fi
|
|
||||||
|
|
||||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
|
||||||
|
|
||||||
if [ ! -f "$executable" ]
|
|
||||||
then
|
|
||||||
mvn -B clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-sinatra-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/ruby-sinatra $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-sinatra-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/ruby-sinatra $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
32
bin/sinatra-petstore-server.sh
Executable file
32
bin/sinatra-petstore-server.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/sinatra -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/sinatra $@"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
@@ -17,19 +17,14 @@ sleep 5
|
|||||||
./bin/kotlin-client-petstore.sh > /dev/null 2>&1
|
./bin/kotlin-client-petstore.sh > /dev/null 2>&1
|
||||||
./bin/kotlin-client-string.sh > /dev/null 2>&1
|
./bin/kotlin-client-string.sh > /dev/null 2>&1
|
||||||
./bin/kotlin-client-threetenbp.sh > /dev/null 2>&1
|
./bin/kotlin-client-threetenbp.sh > /dev/null 2>&1
|
||||||
./bin/kotlin-server-petstore.sh > /dev/null 2>&1
|
./bin/kotlin-server-petstore.shl> /dev/null 2>&1
|
||||||
./bin/php-petstore.sh > /dev/null 2>&1
|
./bin/php-petstore.sh > /dev/null 2>&1
|
||||||
./bin/php-silex-petstore-server.sh > /dev/null 2>&1
|
./bin/php-silex-petstore-server.shj> /dev/null 2>&1
|
||||||
./bin/php-symfony-petstore.sh > /dev/null 2>&1
|
./bin/php-symfony-petstore.sh > /dev/null 2>&1
|
||||||
./bin/php-lumen-petstore-server.sh > /dev/null 2>&1
|
./bin/php-lumen-petstore-server.sh > /dev/null 2>&1
|
||||||
./bin/php-slim-server-petstore.sh > /dev/null 2>&1
|
./bin/php-slim-petstore-server.sh > /dev/null 2>&1
|
||||||
./bin/php-ze-ph-petstore-server.sh > /dev/null 2>&1
|
./bin/php-ze-ph-petstore-server.sh > /dev/null 2>&1
|
||||||
./bin/openapi3/php-petstore.sh > /dev/null 2>&1
|
./bin/openapi3/php-petstore.sh > /dev/null 2>&1
|
||||||
./bin/typescript-angular-petstore-all.sh > /dev/null 2>&1
|
|
||||||
./bin/typescript-fetch-petstore-all.sh > /dev/null 2>&1
|
|
||||||
./bin/typescript-node-petstore-all.sh > /dev/null 2>&1
|
|
||||||
./bin/typescript-inversify-petstore.sh > /dev/null 2>&1
|
|
||||||
|
|
||||||
|
|
||||||
# Check:
|
# Check:
|
||||||
if [ -n "$(git status --porcelain)" ]; then
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
|
|||||||
@@ -1,196 +0,0 @@
|
|||||||
#release_chekcout.rb
|
|
||||||
require 'rubygems'
|
|
||||||
require 'open-uri'
|
|
||||||
require 'net/http'
|
|
||||||
|
|
||||||
def check_homebrew
|
|
||||||
print "Checking homebrew forumla ... "
|
|
||||||
|
|
||||||
url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/openapi-generator.rb"
|
|
||||||
new_maven_url = "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
|
|
||||||
open(url) do |f|
|
|
||||||
content = f.read
|
|
||||||
if !content.nil? && content.include?(new_maven_url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not yet updated with #{new_maven_url}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_online_docker
|
|
||||||
print "Checking openapi-generator-online docker ... "
|
|
||||||
|
|
||||||
url = "https://hub.docker.com/r/openapitools/openapi-generator-online/tags/"
|
|
||||||
docker_tag = "v#{$version}"
|
|
||||||
open(url) do |f|
|
|
||||||
content = f.read
|
|
||||||
if !content.nil? && content.include?(docker_tag)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} does not have tag #{docker_tag}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_cli_docker
|
|
||||||
print "Checking openapi-generator-cli docker ... "
|
|
||||||
|
|
||||||
url = "https://hub.docker.com/r/openapitools/openapi-generator-cli/tags/"
|
|
||||||
docker_tag = "v#{$version}"
|
|
||||||
open(url) do |f|
|
|
||||||
content = f.read
|
|
||||||
if !content.nil? && content.include?(docker_tag)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} does not have tag #{docker_tag}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_readme
|
|
||||||
print "Checking openapi-generator README.md ... "
|
|
||||||
|
|
||||||
url = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/README.md"
|
|
||||||
matches = ["[#{$version}](https://github.com/OpenAPITools/openapi-generator/releases/tag/v#{$version})",
|
|
||||||
"JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar`",
|
|
||||||
"wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar -O openapi-generator-cli.jar",
|
|
||||||
"Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"]
|
|
||||||
open(url) do |f|
|
|
||||||
content = f.read
|
|
||||||
has_outdated = false
|
|
||||||
not_matched = []
|
|
||||||
matches.each do |match|
|
|
||||||
if !content.nil? && content.include?(match)
|
|
||||||
# matched
|
|
||||||
else
|
|
||||||
has_outdated = true
|
|
||||||
not_matched << match
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if has_outdated
|
|
||||||
puts "[ERROR]"
|
|
||||||
not_matched.each do |str|
|
|
||||||
puts "> '#{str}' not found in README.md"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
puts "[OK]"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_jar
|
|
||||||
print "Checking openapi-generator JAR ... "
|
|
||||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator/#{$version}/openapi-generator-#{$version}.jar"
|
|
||||||
|
|
||||||
if check_url(url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not found"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def check_openapi_generator_cli_jar
|
|
||||||
print "Checking openapi-generator-cli JAR ... "
|
|
||||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
|
|
||||||
|
|
||||||
if check_url(url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not found"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_maven_plugin_jar
|
|
||||||
print "Checking openapi-generator-maven-plugin JAR ... "
|
|
||||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-maven-plugin/#{$version}/openapi-generator-maven-plugin-#{$version}.jar"
|
|
||||||
|
|
||||||
if check_url(url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not found"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_gradle_plugin_jar
|
|
||||||
print "Checking openapi-generator-gradle-plugin JAR ... "
|
|
||||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-gradle-plugin/#{$version}/openapi-generator-gradle-plugin-#{$version}.jar"
|
|
||||||
|
|
||||||
if check_url(url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not found"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_online_jar
|
|
||||||
print "Checking openapi-generator-online JAR ... "
|
|
||||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-online/#{$version}/openapi-generator-online-#{$version}.jar"
|
|
||||||
|
|
||||||
if check_url(url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not found"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_openapi_generator_project_pom
|
|
||||||
print "Checking openapi-generator-project pom.xml ... "
|
|
||||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-project/#{$version}/openapi-generator-project-#{$version}.pom"
|
|
||||||
|
|
||||||
if check_url(url)
|
|
||||||
puts "[OK]"
|
|
||||||
else
|
|
||||||
puts "[ERROR]"
|
|
||||||
puts "> #{url} not found"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_url url
|
|
||||||
content = Net::HTTP.get(URI.parse(url))
|
|
||||||
url = URI.parse(url)
|
|
||||||
req = Net::HTTP.new(url.host, url.port)
|
|
||||||
res = req.request_head(url.path)
|
|
||||||
if res.code == "200"
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def usage
|
|
||||||
puts "ERROR!! Version (e.g. 3.0.2) missing"
|
|
||||||
puts "Usage example: ruby #{$0} 3.0.2"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if (!ARGV[0])
|
|
||||||
usage
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
$version = ARGV[0]
|
|
||||||
|
|
||||||
puts "Running checkout on OpenAPI Generator release #{$version}"
|
|
||||||
|
|
||||||
check_homebrew
|
|
||||||
check_openapi_generator_jar
|
|
||||||
check_openapi_generator_cli_jar
|
|
||||||
check_openapi_generator_maven_plugin_jar
|
|
||||||
check_openapi_generator_gradle_plugin_jar
|
|
||||||
check_openapi_generator_online_jar
|
|
||||||
check_openapi_generator_project_pom
|
|
||||||
check_readme
|
|
||||||
check_openapi_generator_online_docker
|
|
||||||
check_openapi_generator_cli_docker
|
|
||||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v2\with-interfaces -D withInterfaces=true --additional-properties ngVersion=2
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -c bin\typescript-petstore-npm.json -g typescript-angular -o samples\client\petstore\typescript-angular-v2\with-interfaces -D withInterfaces=true --additional-properties ngVersion=2
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ If Not Exist %executable% (
|
|||||||
mvn clean package
|
mvn clean package
|
||||||
)
|
)
|
||||||
|
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm --additional-properties ngVersion=6.0.0
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default --additional-properties ngVersion=6.0.0
|
||||||
|
REM it is same like like setting -D providedInRoot=true
|
||||||
|
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm -D providedInRoot=true --additional-properties ngVersion=6.0.0
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ If Not Exist %executable% (
|
|||||||
mvn clean package
|
mvn clean package
|
||||||
)
|
)
|
||||||
|
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default --additional-properties ngVersion=6.0.0
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default --additional-properties ngVersion=6.0.0
|
||||||
|
REM it is same like like setting -D providedInRoot=true
|
||||||
|
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default -D providedInRoot=true --additional-properties ngVersion=6.0.0
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
|
||||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
If Not Exist %executable% (
|
If Not Exist %executable% (
|
||||||
@@ -5,6 +7,8 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-inversify -o samples\client\petstore\typescript-inversify
|
|
||||||
|
echo
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-inversify -o samples\client\petstore\typescript-inversify\builds\default
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|||||||
10
bin/windows/typescript-inversify.bat
Executable file
10
bin/windows/typescript-inversify.bat
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
|
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-inversify -o samples\client\petstore\typescript-inversify
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
call .\bin\windows\typescript-node-petstore.bat
|
|
||||||
call .\bin\windows\typescript-node-petstore-with-npm.bat
|
|
||||||
45
circle.yml
45
circle.yml
@@ -12,13 +12,6 @@ jobs:
|
|||||||
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
||||||
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
||||||
steps:
|
steps:
|
||||||
# Restore the dependency cache
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
# Default branch if not
|
|
||||||
- source-v1-{{ .Branch }}-{{ .Revision }}
|
|
||||||
- source-v1-{{ .Branch }}-
|
|
||||||
- source-v1-
|
|
||||||
# Machine Setup
|
# Machine Setup
|
||||||
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||||
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
|
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
|
||||||
@@ -38,6 +31,13 @@ jobs:
|
|||||||
' | sudo tee -a /etc/hosts
|
' | sudo tee -a /etc/hosts
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# This would typically go in either a build or a build-and-test job when using workflows
|
# This would typically go in either a build or a build-and-test job when using workflows
|
||||||
|
# Restore the dependency cache
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
# This branch if available
|
||||||
|
- v1-dep-{{ .Branch }}-
|
||||||
|
# Default branch if not
|
||||||
|
- v1-dep-master-
|
||||||
# This is based on your 1.0 configuration file or project settings
|
# This is based on your 1.0 configuration file or project settings
|
||||||
- run: sudo add-apt-repository ppa:duggan/bats --yes
|
- run: sudo add-apt-repository ppa:duggan/bats --yes
|
||||||
- run: sudo apt-get update -qq
|
- run: sudo apt-get update -qq
|
||||||
@@ -67,22 +67,9 @@ jobs:
|
|||||||
- run: cat /etc/hosts
|
- run: cat /etc/hosts
|
||||||
# This is based on your 1.0 configuration file or project settings
|
# This is based on your 1.0 configuration file or project settings
|
||||||
- run: cp CI/pom.xml.circleci pom.xml
|
- run: cp CI/pom.xml.circleci pom.xml
|
||||||
# Test
|
|
||||||
# This would typically be a build job when using workflows, possibly combined with build
|
|
||||||
# This is based on your 1.0 configuration file or project settings
|
|
||||||
#- run: java -version
|
|
||||||
- run: mvn --quiet clean install
|
|
||||||
- run: mvn --quiet verify -Psamples
|
|
||||||
- run: if [ $? -ne 0 ]; then exit 1; fi
|
|
||||||
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
|
||||||
- run: java -version
|
|
||||||
- run: cp CI/pom.xml.circleci.java7 pom.xml
|
|
||||||
- run: mvn --quiet clean install
|
|
||||||
- run: mvn --quiet verify -Psamples
|
|
||||||
- run: if [ $? -ne 0 ]; then exit 1; fi
|
|
||||||
# Save dependency cache
|
# Save dependency cache
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: source-v1-{{ .Branch }}-{{ .Revision }}
|
key: v1-dep-{{ .Branch }}
|
||||||
paths:
|
paths:
|
||||||
# This is a broad list of cache paths to include many possible development environments
|
# This is a broad list of cache paths to include many possible development environments
|
||||||
# You can probably delete some of these entries
|
# You can probably delete some of these entries
|
||||||
@@ -94,7 +81,21 @@ jobs:
|
|||||||
- ~/.go_workspace
|
- ~/.go_workspace
|
||||||
- ~/.gradle
|
- ~/.gradle
|
||||||
- ~/.cache/bower
|
- ~/.cache/bower
|
||||||
- ".git"
|
# These cache paths were specified in the 1.0 config
|
||||||
|
- ~/.sbt
|
||||||
|
# Test
|
||||||
|
# This would typically be a build job when using workflows, possibly combined with build
|
||||||
|
# This is based on your 1.0 configuration file or project settings
|
||||||
|
- run: java -version
|
||||||
|
- run: mvn --quiet clean install
|
||||||
|
- run: mvn --quiet verify -Psamples
|
||||||
|
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||||
|
- run: java -version
|
||||||
|
- run: cp CI/pom.xml.circleci.java7 pom.xml
|
||||||
|
- run: mvn --quiet clean install
|
||||||
|
- run: mvn --quiet verify -Psamples
|
||||||
|
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||||
# Teardown
|
# Teardown
|
||||||
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||||
# Save test results
|
# Save test results
|
||||||
|
|||||||
@@ -246,8 +246,8 @@ If your API client is using named parameters in the function call (e.g. Perl req
|
|||||||
|
|
||||||
The following gnereators are not yet fully migrated and tested
|
The following gnereators are not yet fully migrated and tested
|
||||||
|
|
||||||
- ~~rust-server~~ (migrated)
|
- `rust-server`
|
||||||
- `apex` (migration scheduled in Jul/Aug 2018)
|
- `apex`
|
||||||
|
|
||||||
and we welcome contributions from the community to help with the migration
|
and we welcome contributions from the community to help with the migration
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,3 @@ Swagger is a trademark owned by SmartBear and the use of the term "Swagger" foun
|
|||||||
|
|
||||||
OpenAPI Generator is based on Swagger Codegen 2.4.0-SNAPSHOT version so the migration should be easy, straightforward and almost seamless. Please refer to the [migration guide](migration-from-swagger-codegen.md) for more information.
|
OpenAPI Generator is based on Swagger Codegen 2.4.0-SNAPSHOT version so the migration should be easy, straightforward and almost seamless. Please refer to the [migration guide](migration-from-swagger-codegen.md) for more information.
|
||||||
|
|
||||||
#### May I know who maintains this Q&A page?
|
|
||||||
|
|
||||||
This Q&A page is maintained by the [core team members](../README.md#openapi-generator-core-team). It's not maintained by a single person nor do these Q&As represent the view of an individual.
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.openapitools.codegen;
|
|||||||
|
|
||||||
import io.airlift.airline.Cli;
|
import io.airlift.airline.Cli;
|
||||||
import io.airlift.airline.Help;
|
import io.airlift.airline.Help;
|
||||||
import io.airlift.airline.ParseArgumentsUnexpectedException;
|
|
||||||
import io.airlift.airline.ParseOptionMissingException;
|
import io.airlift.airline.ParseOptionMissingException;
|
||||||
import io.airlift.airline.ParseOptionMissingValueException;
|
import io.airlift.airline.ParseOptionMissingValueException;
|
||||||
import org.openapitools.codegen.cmd.*;
|
import org.openapitools.codegen.cmd.*;
|
||||||
@@ -68,9 +67,6 @@ public class OpenAPIGenerator {
|
|||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
} catch (ParseArgumentsUnexpectedException e) {
|
|
||||||
System.err.printf("[error] %s%n%nSee 'openapi-generator-cli help' for usage.%n", e.getMessage());
|
|
||||||
System.exit(1);
|
|
||||||
} catch (ParseOptionMissingException | ParseOptionMissingValueException e) {
|
} catch (ParseOptionMissingException | ParseOptionMissingValueException e) {
|
||||||
System.err.printf("[error] %s%n", e.getMessage());
|
System.err.printf("[error] %s%n", e.getMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
|||||||
@@ -23,41 +23,18 @@ import org.openapitools.codegen.CliOption;
|
|||||||
import org.openapitools.codegen.CodegenConfig;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import org.openapitools.codegen.CodegenConfigLoader;
|
import org.openapitools.codegen.CodegenConfigLoader;
|
||||||
import org.openapitools.codegen.GeneratorNotFoundException;
|
import org.openapitools.codegen.GeneratorNotFoundException;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
|
||||||
|
|
||||||
@Command(name = "config-help", description = "Config help for chosen lang")
|
@Command(name = "config-help", description = "Config help for chosen lang")
|
||||||
public class ConfigHelp implements Runnable {
|
public class ConfigHelp implements Runnable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
|
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||||
|
|
||||||
@Option(name = {"-l", "--lang"}, title = "language",
|
|
||||||
description = "language to get config help for")
|
description = "language to get config help for")
|
||||||
private String lang;
|
private String lang;
|
||||||
|
|
||||||
@Option(name = {"-g", "--generator-name"}, title = "generator name",
|
|
||||||
description = "generator to get config help for")
|
|
||||||
private String generatorName;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang.
|
|
||||||
if (isEmpty(generatorName)) {
|
|
||||||
if (isNotEmpty(lang)) {
|
|
||||||
LOGGER.warn("The '--lang' and '-l' are deprecated and may reference language names only in the next major release (4.0). Please use --generator-name /-g instead.");
|
|
||||||
generatorName = lang;
|
|
||||||
} else {
|
|
||||||
System.err.println("[error] A generator name (--generator-name / -g) is required.");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
|
CodegenConfig config = CodegenConfigLoader.forName(lang);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("CONFIG OPTIONS");
|
System.out.println("CONFIG OPTIONS");
|
||||||
for (CliOption langCliOption : config.cliOptions()) {
|
for (CliOption langCliOption : config.cliOptions()) {
|
||||||
@@ -72,4 +49,4 @@ public class ConfigHelp implements Runnable {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.1.1"
|
classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
openApiGeneratorVersion=3.1.1
|
openApiGeneratorVersion=3.1.0-SNAPSHOT
|
||||||
|
|
||||||
# BEGIN placeholders
|
# BEGIN placeholders
|
||||||
# these are just placeholders to allow contributors to build directly
|
# these are just placeholders to allow contributors to build directly
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ gradle buildGoSdk
|
|||||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gradle -PopenApiGeneratorVersion=3.1.1 openApiValidate
|
gradle -PopenApiGeneratorVersion=3.0.3 openApiValidate
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
openApiGeneratorVersion=3.1.1
|
openApiGeneratorVersion=3.0.1
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.0.3</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine
|
|||||||
|
|
||||||
WORKDIR /generator
|
WORKDIR /generator
|
||||||
|
|
||||||
COPY target/openapi-generator-online-3.1.1.jar /generator/openapi-generator-online.jar
|
COPY target/openapi-generator-online-3.1.0-SNAPSHOT.jar /generator/openapi-generator-online.jar
|
||||||
|
|
||||||
ENV GENERATOR_HOST=http://localhost
|
ENV GENERATOR_HOST=http://localhost
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>openapi-generator-online</artifactId>
|
<artifactId>openapi-generator-online</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -198,16 +198,31 @@
|
|||||||
<guava-version>20.0</guava-version>
|
<guava-version>20.0</guava-version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
|
<artifactId>swagger-models</artifactId>
|
||||||
|
<version>${swagger-core-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger.core.v3</groupId>
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
<artifactId>swagger-core</artifactId>
|
<artifactId>swagger-core</artifactId>
|
||||||
<version>${swagger-core-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger.parser.v3</groupId>
|
<groupId>io.swagger.parser.v3</groupId>
|
||||||
<artifactId>swagger-parser</artifactId>
|
<artifactId>swagger-parser-core</artifactId>
|
||||||
<version>${swagger-parser-version}</version>
|
<version>${swagger-parser-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.parser.v3</groupId>
|
||||||
|
<artifactId>swagger-parser-v3</artifactId>
|
||||||
|
<version>${swagger-parser-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.parser.v3</groupId>
|
||||||
|
<artifactId>swagger-parser</artifactId>
|
||||||
|
<version>${swagger-parser-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.samskivert</groupId>
|
<groupId>com.samskivert</groupId>
|
||||||
<artifactId>jmustache</artifactId>
|
<artifactId>jmustache</artifactId>
|
||||||
|
|||||||
@@ -213,9 +213,6 @@ public class CodegenConstants {
|
|||||||
public static final String EXCLUDE_TESTS = "excludeTests";
|
public static final String EXCLUDE_TESTS = "excludeTests";
|
||||||
public static final String EXCLUDE_TESTS_DESC = "Specifies that no tests are to be generated.";
|
public static final String EXCLUDE_TESTS_DESC = "Specifies that no tests are to be generated.";
|
||||||
|
|
||||||
public static final String SOURCECODEONLY_GENERATION = "generateSourceCodeOnly";
|
|
||||||
public static final String SOURCECODEONLY_GENERATION_DESC = "Specifies that only a library source code is to be generated.";
|
|
||||||
|
|
||||||
// Not user-configurable. System provided for use in templates.
|
// Not user-configurable. System provided for use in templates.
|
||||||
|
|
||||||
public static final String GENERATE_APIS = "generateApis";
|
public static final String GENERATE_APIS = "generateApis";
|
||||||
|
|||||||
@@ -1110,7 +1110,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* Return the example value of the parameter.
|
* Return the example value of the parameter.
|
||||||
*
|
*
|
||||||
* @param codegenParameter Codegen parameter
|
* @param codegenParameter Codegen parameter
|
||||||
* @param parameter Parameter
|
* @param parameter Parameter
|
||||||
*/
|
*/
|
||||||
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
|
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
|
||||||
if (parameter.getExample() != null) {
|
if (parameter.getExample() != null) {
|
||||||
@@ -1120,7 +1120,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
|
if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
|
||||||
Example example = parameter.getExamples().values().iterator().next();
|
Example example = parameter.getExamples().values().iterator().next();
|
||||||
if (example.getValue() != null) {
|
if(example.getValue() != null) {
|
||||||
codegenParameter.example = example.getValue().toString();
|
codegenParameter.example = example.getValue().toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1139,7 +1139,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* Return the example value of the parameter.
|
* Return the example value of the parameter.
|
||||||
*
|
*
|
||||||
* @param codegenParameter Codegen parameter
|
* @param codegenParameter Codegen parameter
|
||||||
* @param requestBody Request body
|
* @param requestBody Request body
|
||||||
*/
|
*/
|
||||||
public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) {
|
public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) {
|
||||||
Content content = requestBody.getContent();
|
Content content = requestBody.getContent();
|
||||||
@@ -1157,7 +1157,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty()) {
|
if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty()) {
|
||||||
Example example = mediaType.getExamples().values().iterator().next();
|
Example example = mediaType.getExamples().values().iterator().next();
|
||||||
if (example.getValue() != null) {
|
if(example.getValue() != null) {
|
||||||
codegenParameter.example = example.getValue().toString();
|
codegenParameter.example = example.getValue().toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1614,7 +1614,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
m.isInteger = Boolean.TRUE;
|
m.isInteger = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ModelUtils.isStringSchema(schema)) {
|
if (ModelUtils.isStringSchema(schema)){
|
||||||
m.isString = Boolean.TRUE;
|
m.isString = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4373,33 +4373,19 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
if (schema.getAdditionalProperties() != null) {// http body is map
|
if (schema.getAdditionalProperties() != null) {// http body is map
|
||||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||||
} else if (codegenProperty != null) {
|
} else if (codegenProperty != null) {
|
||||||
String codegenModelName, codegenModelDescription;
|
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
||||||
|
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
||||||
|
"A correct 'consumes' for form parameters should be " +
|
||||||
|
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
||||||
|
LOGGER.warn("schema: " + schema);
|
||||||
|
LOGGER.warn("Defaulting baseType to UNKNOWN_BASE_TYPE");
|
||||||
|
codegenProperty.baseType = "UNKNOWN_BASE_TYPE";
|
||||||
|
|
||||||
if (codegenModel != null) {
|
codegenParameter.baseName = codegenProperty.baseType;
|
||||||
codegenModelName = codegenModel.classname;
|
codegenParameter.baseType = codegenProperty.baseType;
|
||||||
codegenModelDescription = codegenModel.description;
|
codegenParameter.dataType = codegenProperty.dataType;
|
||||||
} else {
|
codegenParameter.description = codegenProperty.description;
|
||||||
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
codegenParameter.paramName = toParamName(codegenProperty.baseType);
|
||||||
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
|
||||||
"A correct 'consumes' for form parameters should be " +
|
|
||||||
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
|
||||||
LOGGER.warn("schema: " + schema);
|
|
||||||
LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE");
|
|
||||||
codegenModelName = "UNKNOWN_BASE_TYPE";
|
|
||||||
codegenModelDescription = "UNKNOWN_DESCRIPTION";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
|
||||||
codegenParameter.baseName = codegenModelName;
|
|
||||||
} else {
|
|
||||||
codegenParameter.baseName = bodyParameterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
|
||||||
codegenParameter.baseType = codegenModelName;
|
|
||||||
codegenParameter.dataType = getTypeDeclaration(codegenModelName);
|
|
||||||
codegenParameter.description = codegenModelDescription;
|
|
||||||
imports.add(codegenParameter.baseType);
|
|
||||||
|
|
||||||
if (codegenProperty.complexType != null) {
|
if (codegenProperty.complexType != null) {
|
||||||
imports.add(codegenProperty.complexType);
|
imports.add(codegenProperty.complexType);
|
||||||
@@ -4482,6 +4468,6 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDataTypeString(String dataType) {
|
public boolean isDataTypeString(String dataType) {
|
||||||
return "String".equals(dataType);
|
return "String".equals(dataType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,15 +265,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
// Not using the supertype invocation, because we want to UpperCamelize
|
// Not using the supertype invocation, because we want to UpperCamelize
|
||||||
// the type.
|
// the type.
|
||||||
String openAPIType = getSchemaType(p);
|
String openAPIType = getSchemaType(p);
|
||||||
String ref = p.get$ref();
|
|
||||||
if(ref != null && !ref.isEmpty()) {
|
|
||||||
String tryRefV2 = "#/definitions/" + openAPIType;
|
|
||||||
String tryRefV3 = "#/components/schemas/" + openAPIType;
|
|
||||||
if(ref.equals(tryRefV2) || ref.equals(tryRefV3)) {
|
|
||||||
return toModelName(openAPIType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeMapping.containsKey(openAPIType)) {
|
if (typeMapping.containsKey(openAPIType)) {
|
||||||
return typeMapping.get(openAPIType);
|
return typeMapping.get(openAPIType);
|
||||||
}
|
}
|
||||||
@@ -292,12 +283,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
@Override
|
@Override
|
||||||
public String getSchemaType(Schema p) {
|
public String getSchemaType(Schema p) {
|
||||||
String openAPIType = super.getSchemaType(p);
|
String openAPIType = super.getSchemaType(p);
|
||||||
String ref = p.get$ref();
|
|
||||||
String type = null;
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(openAPIType)) {
|
||||||
if(ref != null && !ref.isEmpty()) {
|
|
||||||
type = openAPIType;
|
|
||||||
} else if (typeMapping.containsKey(openAPIType)) {
|
|
||||||
type = typeMapping.get(openAPIType);
|
type = typeMapping.get(openAPIType);
|
||||||
if (languageSpecificPrimitives.contains(type))
|
if (languageSpecificPrimitives.contains(type))
|
||||||
return (type);
|
return (type);
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
typeMapping.put("string", "string");
|
typeMapping.put("string", "string");
|
||||||
typeMapping.put("byte", "int");
|
typeMapping.put("byte", "int");
|
||||||
typeMapping.put("boolean", "bool");
|
typeMapping.put("boolean", "bool");
|
||||||
typeMapping.put("date", "\\DateTime");
|
|
||||||
typeMapping.put("Date", "\\DateTime");
|
typeMapping.put("Date", "\\DateTime");
|
||||||
typeMapping.put("DateTime", "\\DateTime");
|
typeMapping.put("DateTime", "\\DateTime");
|
||||||
typeMapping.put("file", "\\SplFileObject");
|
typeMapping.put("file", "\\SplFileObject");
|
||||||
@@ -171,25 +170,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||||
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
||||||
|
|
||||||
// Update the invokerPackage for the default apiPackage and modelPackage
|
|
||||||
apiPackage = invokerPackage + "\\" + apiDirName;
|
|
||||||
modelPackage = invokerPackage + "\\" + modelDirName;
|
|
||||||
} else {
|
} else {
|
||||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
|
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
|
||||||
// Update model package to contain the specified model package name and the invoker package
|
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||||
modelPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE);
|
|
||||||
}
|
}
|
||||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
|
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
|
||||||
// Update api package to contain the specified api package name and the invoker package
|
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
apiPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.API_PACKAGE);
|
|
||||||
}
|
}
|
||||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
|
||||||
|
|
||||||
// if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
|
// if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
|
||||||
// this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
// this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
||||||
@@ -338,7 +329,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
} else if (ModelUtils.isMapSchema(p)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
Schema inner = (Schema) p.getAdditionalProperties();
|
Schema inner = (Schema) p.getAdditionalProperties();
|
||||||
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||||
} else if (StringUtils.isNotBlank(p.get$ref())) { // model
|
} else if (!StringUtils.isEmpty(p.get$ref())) { // model
|
||||||
String type = super.getTypeDeclaration(p);
|
String type = super.getTypeDeclaration(p);
|
||||||
return (!languageSpecificPrimitives.contains(type))
|
return (!languageSpecificPrimitives.contains(type))
|
||||||
? "\\" + modelPackage + "\\" + type : type;
|
? "\\" + modelPackage + "\\" + type : type;
|
||||||
@@ -551,11 +542,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
type = p.dataType;
|
type = p.dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("String".equalsIgnoreCase(type) || p.isString) {
|
if ("String".equalsIgnoreCase(type)) {
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
example = "'" + p.paramName + "_example'";
|
example = p.paramName + "_example";
|
||||||
}
|
}
|
||||||
example = escapeText(example);
|
example = "\"" + escapeText(example) + "\"";
|
||||||
} else if ("Integer".equals(type) || "int".equals(type)) {
|
} else if ("Integer".equals(type) || "int".equals(type)) {
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
example = "56";
|
example = "56";
|
||||||
@@ -568,23 +559,21 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
if (example == null) {
|
if (example == null) {
|
||||||
example = "True";
|
example = "True";
|
||||||
}
|
}
|
||||||
} else if ("\\SplFileObject".equalsIgnoreCase(type) || p.isFile) {
|
} else if ("\\SplFileObject".equalsIgnoreCase(type)) {
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
example = "/path/to/file.txt";
|
example = "/path/to/file";
|
||||||
}
|
}
|
||||||
example = "\"" + escapeText(example) + "\"";
|
example = "\"" + escapeText(example) + "\"";
|
||||||
} else if ("\\Date".equalsIgnoreCase(type)) {
|
} else if ("Date".equalsIgnoreCase(type)) {
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
example = "2013-10-20";
|
example = "2013-10-20";
|
||||||
}
|
}
|
||||||
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||||
} else if ("\\DateTime".equalsIgnoreCase(type)) {
|
} else if ("DateTime".equalsIgnoreCase(type)) {
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
example = "2013-10-20T19:20:30+01:00";
|
example = "2013-10-20T19:20:30+01:00";
|
||||||
}
|
}
|
||||||
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||||
} else if ("object".equals(type)) {
|
|
||||||
example = "new \\stdClass";
|
|
||||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||||
// type is a model class, e.g. User
|
// type is a model class, e.g. User
|
||||||
example = "new " + getTypeDeclaration(type) + "()";
|
example = "new " + getTypeDeclaration(type) + "()";
|
||||||
@@ -642,8 +631,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
enumName = enumName.replaceFirst("^_", "");
|
enumName = enumName.replaceFirst("^_", "");
|
||||||
enumName = enumName.replaceFirst("_$", "");
|
enumName = enumName.replaceFirst("_$", "");
|
||||||
|
|
||||||
if (isReservedWord(enumName) || enumName.matches("\\d.*")) { // reserved word or starts with number
|
if (enumName.matches("\\d.*")) { // starts with number
|
||||||
return escapeReservedWord(enumName);
|
return "_" + enumName;
|
||||||
} else {
|
} else {
|
||||||
return enumName;
|
return enumName;
|
||||||
}
|
}
|
||||||
@@ -653,9 +642,6 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
public String toEnumName(CodegenProperty property) {
|
public String toEnumName(CodegenProperty property) {
|
||||||
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
||||||
|
|
||||||
// remove [] for array or map of enum
|
|
||||||
enumName = enumName.replace("[]", "");
|
|
||||||
|
|
||||||
if (enumName.matches("\\d.*")) { // starts with number
|
if (enumName.matches("\\d.*")) { // starts with number
|
||||||
return "_" + enumName;
|
return "_" + enumName;
|
||||||
} else {
|
} else {
|
||||||
@@ -674,8 +660,6 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation op : operationList) {
|
for (CodegenOperation op : operationList) {
|
||||||
// for API test method name
|
|
||||||
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
|
|
||||||
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
|
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
|
||||||
}
|
}
|
||||||
return objs;
|
return objs;
|
||||||
@@ -689,17 +673,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeUnsafeCharacters(String input) {
|
public String escapeUnsafeCharacters(String input) {
|
||||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
return input.replace("*/", "");
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeText(String input) {
|
|
||||||
if (input == null) {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trim the string to avoid leading and trailing spaces.
|
|
||||||
return super.escapeText(input).trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String extractSimpleName(String phpClassName) {
|
protected String extractSimpleName(String phpClassName) {
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
|
||||||
* Copyright 2018 SmartBear Software
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
|
||||||
import org.openapitools.codegen.*;
|
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConfig {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRubyCodegen.class);
|
|
||||||
|
|
||||||
AbstractRubyCodegen() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
setReservedWordsLowerCase(
|
|
||||||
Arrays.asList(
|
|
||||||
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
|
||||||
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
|
||||||
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
|
||||||
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
|
||||||
"if", "not", "return", "undef", "yield")
|
|
||||||
);
|
|
||||||
|
|
||||||
languageSpecificPrimitives.clear();
|
|
||||||
languageSpecificPrimitives.add("String");
|
|
||||||
languageSpecificPrimitives.add("Integer");
|
|
||||||
languageSpecificPrimitives.add("Float");
|
|
||||||
languageSpecificPrimitives.add("Date");
|
|
||||||
languageSpecificPrimitives.add("DateTime");
|
|
||||||
languageSpecificPrimitives.add("Array");
|
|
||||||
languageSpecificPrimitives.add("Hash");
|
|
||||||
languageSpecificPrimitives.add("File");
|
|
||||||
languageSpecificPrimitives.add("Object");
|
|
||||||
|
|
||||||
typeMapping.clear();
|
|
||||||
typeMapping.put("string", "String");
|
|
||||||
typeMapping.put("char", "String");
|
|
||||||
typeMapping.put("int", "Integer");
|
|
||||||
typeMapping.put("integer", "Integer");
|
|
||||||
typeMapping.put("long", "Integer");
|
|
||||||
typeMapping.put("short", "Integer");
|
|
||||||
typeMapping.put("float", "Float");
|
|
||||||
typeMapping.put("double", "Float");
|
|
||||||
typeMapping.put("number", "Float");
|
|
||||||
typeMapping.put("date", "Date");
|
|
||||||
typeMapping.put("DateTime", "DateTime");
|
|
||||||
typeMapping.put("array", "Array");
|
|
||||||
typeMapping.put("List", "Array");
|
|
||||||
typeMapping.put("map", "Hash");
|
|
||||||
typeMapping.put("object", "Object");
|
|
||||||
typeMapping.put("file", "File");
|
|
||||||
typeMapping.put("binary", "String");
|
|
||||||
typeMapping.put("ByteArray", "String");
|
|
||||||
typeMapping.put("UUID", "String");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeReservedWord(String name) {
|
|
||||||
if (this.reservedWordsMappings().containsKey(name)) {
|
|
||||||
return this.reservedWordsMappings().get(name);
|
|
||||||
}
|
|
||||||
return "_" + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeDeclaration(Schema schema) {
|
|
||||||
if (ModelUtils.isArraySchema(schema)) {
|
|
||||||
Schema inner = ((ArraySchema) schema).getItems();
|
|
||||||
return getSchemaType(schema) + "<" + getTypeDeclaration(inner) + ">";
|
|
||||||
} else if (ModelUtils.isMapSchema(schema)) {
|
|
||||||
Schema inner = (Schema) schema.getAdditionalProperties();
|
|
||||||
return getSchemaType(schema) + "<String, " + getTypeDeclaration(inner) + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getTypeDeclaration(schema);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toDefaultValue(Schema p) {
|
|
||||||
if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
|
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return p.getDefault().toString();
|
|
||||||
}
|
|
||||||
} else if (ModelUtils.isStringSchema(p)) {
|
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return "'" + escapeText((String) p.getDefault()) + "'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toVarName(String name) {
|
|
||||||
// sanitize name
|
|
||||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
|
||||||
// if it's all uppper case, convert to lower case
|
|
||||||
if (name.matches("^[A-Z_]*$")) {
|
|
||||||
name = name.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
// camelize (lower first character) the variable name
|
|
||||||
// petId => pet_id
|
|
||||||
name = underscore(name);
|
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
|
||||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
|
||||||
name = escapeReservedWord(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toParamName(String name) {
|
|
||||||
// should be the same as variable name
|
|
||||||
return toVarName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toOperationId(String operationId) {
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
|
||||||
if (isReservedWord(operationId)) {
|
|
||||||
String newOperationId = underscore("call_" + operationId);
|
|
||||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
|
||||||
return newOperationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return underscore(operationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeQuotationMark(String input) {
|
|
||||||
// remove ' to avoid code injection
|
|
||||||
return input.replace("'", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeUnsafeCharacters(String input) {
|
|
||||||
return input.replace("=end", "=_end").replace("=begin", "=_begin");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -300,7 +300,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
return getSchemaType(p) + "<utility::string_t, " + getTypeDeclaration(inner) + ">";
|
return getSchemaType(p) + "<utility::string_t, " + getTypeDeclaration(inner) + ">";
|
||||||
} else if (ModelUtils.isStringSchema(p)
|
} else if (ModelUtils.isStringSchema(p)
|
||||||
|| ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)
|
|| ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)
|
||||||
|| ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p)
|
|| ModelUtils.isFileSchema(p)
|
||||||
|| languageSpecificPrimitives.contains(openAPIType)) {
|
|| languageSpecificPrimitives.contains(openAPIType)) {
|
||||||
return toModelName(openAPIType);
|
return toModelName(openAPIType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,18 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
public NodeJSServerCodegen() {
|
public NodeJSServerCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
StringBuilder message = new StringBuilder();
|
||||||
|
message.append(System.lineSeparator()).append(System.lineSeparator())
|
||||||
|
.append("=======================================================================================")
|
||||||
|
.append(System.lineSeparator())
|
||||||
|
.append("Currently, Node.js server doesn't work as its dependency doesn't support OpenAPI Spec3.")
|
||||||
|
.append(System.lineSeparator())
|
||||||
|
.append("For further details, see https://github.com/OpenAPITools/openapi-generator/issues/34")
|
||||||
|
.append(System.lineSeparator())
|
||||||
|
.append("=======================================================================================")
|
||||||
|
.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
|
LOGGER.warn(message.toString());
|
||||||
|
|
||||||
// set the output folder here
|
// set the output folder here
|
||||||
outputFolder = "generated-code/nodejs";
|
outputFolder = "generated-code/nodejs";
|
||||||
|
|
||||||
@@ -298,18 +310,6 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
StringBuilder message = new StringBuilder();
|
|
||||||
message.append(System.lineSeparator()).append(System.lineSeparator())
|
|
||||||
.append("=======================================================================================")
|
|
||||||
.append(System.lineSeparator())
|
|
||||||
.append("Currently, Node.js server doesn't work as its dependency doesn't support OpenAPI Spec3.")
|
|
||||||
.append(System.lineSeparator())
|
|
||||||
.append("For further details, see https://github.com/OpenAPITools/openapi-generator/issues/34")
|
|
||||||
.append(System.lineSeparator())
|
|
||||||
.append("=======================================================================================")
|
|
||||||
.append(System.lineSeparator()).append(System.lineSeparator());
|
|
||||||
LOGGER.warn(message.toString());
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(GOOGLE_CLOUD_FUNCTIONS)) {
|
if (additionalProperties.containsKey(GOOGLE_CLOUD_FUNCTIONS)) {
|
||||||
setGoogleCloudFunctions(
|
setGoogleCloudFunctions(
|
||||||
Boolean.valueOf(additionalProperties.get(GOOGLE_CLOUD_FUNCTIONS).toString()));
|
Boolean.valueOf(additionalProperties.get(GOOGLE_CLOUD_FUNCTIONS).toString()));
|
||||||
|
|||||||
@@ -18,28 +18,57 @@
|
|||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import org.openapitools.codegen.CliOption;
|
import org.openapitools.codegen.CliOption;
|
||||||
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
|
import org.openapitools.codegen.CodegenOperation;
|
||||||
|
import org.openapitools.codegen.CodegenParameter;
|
||||||
|
import org.openapitools.codegen.CodegenProperty;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.Operation;
|
||||||
|
import io.swagger.v3.oas.models.media.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class PhpClientCodegen extends AbstractPhpCodegen {
|
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhpClientCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PhpClientCodegen.class);
|
||||||
|
|
||||||
|
public static final String VARIABLE_NAMING_CONVENTION = "variableNamingConvention";
|
||||||
|
public static final String PACKAGE_PATH = "packagePath";
|
||||||
|
public static final String SRC_BASE_PATH = "srcBasePath";
|
||||||
public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
|
public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
|
||||||
public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
|
public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
|
||||||
|
protected String invokerPackage = "OpenAPI\\Client";
|
||||||
protected String composerVendorName = null;
|
protected String composerVendorName = null;
|
||||||
protected String composerProjectName = null;
|
protected String composerProjectName = null;
|
||||||
|
protected String packagePath = "OpenAPIClient-php";
|
||||||
|
protected String artifactVersion = null;
|
||||||
|
protected String srcBasePath = "lib";
|
||||||
|
protected String testBasePath = "test";
|
||||||
|
protected String docsBasePath = "docs";
|
||||||
|
protected String apiDirName = "Api";
|
||||||
|
protected String modelDirName = "Model";
|
||||||
|
protected String variableNamingConvention = "snake_case";
|
||||||
|
protected String apiDocPath = docsBasePath + "/" + apiDirName;
|
||||||
|
protected String modelDocPath = docsBasePath + "/" + modelDirName;
|
||||||
|
|
||||||
public PhpClientCodegen() {
|
public PhpClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@@ -48,30 +77,144 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
|||||||
// at the moment
|
// at the moment
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
|
|
||||||
setInvokerPackage("OpenAPI\\Client");
|
|
||||||
setApiPackage(getInvokerPackage() + "\\" + apiDirName);
|
|
||||||
setModelPackage(getInvokerPackage() + "\\" + modelDirName);
|
|
||||||
setPackagePath("OpenAPIClient-php");
|
|
||||||
supportsInheritance = true;
|
supportsInheritance = true;
|
||||||
setOutputDir("generated-code" + File.separator + "php");
|
outputFolder = "generated-code" + File.separator + "php";
|
||||||
|
modelTemplateFiles.put("model.mustache", ".php");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".php");
|
||||||
modelTestTemplateFiles.put("model_test.mustache", ".php");
|
modelTestTemplateFiles.put("model_test.mustache", ".php");
|
||||||
|
apiTestTemplateFiles.put("api_test.mustache", ".php");
|
||||||
embeddedTemplateDir = templateDir = "php";
|
embeddedTemplateDir = templateDir = "php";
|
||||||
|
apiPackage = invokerPackage + "\\" + apiDirName;
|
||||||
|
modelPackage = invokerPackage + "\\" + modelDirName;
|
||||||
|
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
// default HIDE_GENERATION_TIMESTAMP to true
|
// default HIDE_GENERATION_TIMESTAMP to true
|
||||||
hideGenerationTimestamp = Boolean.TRUE;
|
hideGenerationTimestamp = Boolean.TRUE;
|
||||||
|
|
||||||
|
setReservedWordsLowerCase(
|
||||||
|
Arrays.asList(
|
||||||
|
// local variables used in api methods (endpoints)
|
||||||
|
"resourcePath", "httpBody", "queryParams", "headerParams",
|
||||||
|
"formParams", "_header_accept", "_tempBody",
|
||||||
|
|
||||||
|
// PHP reserved words
|
||||||
|
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
|
||||||
|
);
|
||||||
|
|
||||||
|
// ref: http://php.net/manual/en/language.types.intro.php
|
||||||
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"bool",
|
||||||
|
"boolean",
|
||||||
|
"int",
|
||||||
|
"integer",
|
||||||
|
"double",
|
||||||
|
"float",
|
||||||
|
"string",
|
||||||
|
"object",
|
||||||
|
"DateTime",
|
||||||
|
"mixed",
|
||||||
|
"number",
|
||||||
|
"void",
|
||||||
|
"byte")
|
||||||
|
);
|
||||||
|
|
||||||
|
instantiationTypes.put("array", "array");
|
||||||
|
instantiationTypes.put("map", "map");
|
||||||
|
|
||||||
|
|
||||||
// provide primitives to mustache template
|
// provide primitives to mustache template
|
||||||
List sortedLanguageSpecificPrimitives = new ArrayList(languageSpecificPrimitives);
|
List sortedLanguageSpecificPrimitives = new ArrayList(languageSpecificPrimitives);
|
||||||
Collections.sort(sortedLanguageSpecificPrimitives);
|
Collections.sort(sortedLanguageSpecificPrimitives);
|
||||||
String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'";
|
String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'";
|
||||||
additionalProperties.put("primitives", primitives);
|
additionalProperties.put("primitives", primitives);
|
||||||
|
|
||||||
|
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
|
||||||
|
typeMapping = new HashMap<String, String>();
|
||||||
|
typeMapping.put("integer", "int");
|
||||||
|
typeMapping.put("long", "int");
|
||||||
|
typeMapping.put("number", "float");
|
||||||
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("double", "double");
|
||||||
|
typeMapping.put("string", "string");
|
||||||
|
typeMapping.put("byte", "int");
|
||||||
|
typeMapping.put("boolean", "bool");
|
||||||
|
typeMapping.put("date", "\\DateTime");
|
||||||
|
typeMapping.put("Date", "\\DateTime");
|
||||||
|
typeMapping.put("DateTime", "\\DateTime");
|
||||||
|
typeMapping.put("file", "\\SplFileObject");
|
||||||
|
typeMapping.put("map", "map");
|
||||||
|
typeMapping.put("array", "array");
|
||||||
|
typeMapping.put("list", "array");
|
||||||
|
typeMapping.put("object", "object");
|
||||||
|
typeMapping.put("binary", "\\SplFileObject");
|
||||||
|
typeMapping.put("ByteArray", "string");
|
||||||
|
typeMapping.put("UUID", "string");
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
||||||
|
cliOptions.add(new CliOption(VARIABLE_NAMING_CONVENTION, "naming convention of variable name, e.g. camelCase.")
|
||||||
|
.defaultValue("snake_case"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets"));
|
||||||
|
cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
|
||||||
|
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
|
||||||
cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next openapi-generator release"));
|
cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next openapi-generator release"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
|
||||||
cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next openapi-generator release"));
|
cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next openapi-generator release"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC)
|
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC)
|
||||||
.defaultValue(Boolean.TRUE.toString()));
|
.defaultValue(Boolean.TRUE.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPackagePath() {
|
||||||
|
return packagePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toPackagePath(String packageName, String basePath) {
|
||||||
|
return (getPackagePath() + File.separatorChar + toSrcPath(packageName, basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toSrcPath(String packageName, String basePath) {
|
||||||
|
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
if (basePath != null && basePath.length() > 0) {
|
||||||
|
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
}
|
||||||
|
|
||||||
|
String regFirstPathSeparator;
|
||||||
|
if ("/".equals(File.separator)) { // for mac, linux
|
||||||
|
regFirstPathSeparator = "^/";
|
||||||
|
} else { // for windows
|
||||||
|
regFirstPathSeparator = "^\\\\";
|
||||||
|
}
|
||||||
|
|
||||||
|
String regLastPathSeparator;
|
||||||
|
if ("/".equals(File.separator)) { // for mac, linux
|
||||||
|
regLastPathSeparator = "/$";
|
||||||
|
} else { // for windows
|
||||||
|
regLastPathSeparator = "\\\\$";
|
||||||
|
}
|
||||||
|
|
||||||
|
return (basePath
|
||||||
|
// Replace period, backslash, forward slash with file separator in package name
|
||||||
|
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
|
||||||
|
// Trim prefix file separators from package path
|
||||||
|
.replaceAll(regFirstPathSeparator, ""))
|
||||||
|
// Trim trailing file separators from the overall path
|
||||||
|
.replaceAll(regLastPathSeparator + "$", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeText(String input) {
|
||||||
|
if (input != null) {
|
||||||
|
// Trim the string to avoid leading and trailing spaces.
|
||||||
|
return super.escapeText(input).trim();
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.CLIENT;
|
return CodegenType.CLIENT;
|
||||||
@@ -91,18 +234,89 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
|||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(PACKAGE_PATH)) {
|
||||||
|
this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(PACKAGE_PATH, packagePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(SRC_BASE_PATH)) {
|
||||||
|
this.setSrcBasePath((String) additionalProperties.get(SRC_BASE_PATH));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(SRC_BASE_PATH, srcBasePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||||
|
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
||||||
|
|
||||||
|
// Update the invokerPackage for the default apiPackage and modelPackage
|
||||||
|
apiPackage = invokerPackage + "\\" + apiDirName;
|
||||||
|
modelPackage = invokerPackage + "\\" + modelDirName;
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
|
||||||
|
// Update model package to contain the specified model package name and the invoker package
|
||||||
|
modelPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE);
|
||||||
|
}
|
||||||
|
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
|
||||||
|
// Update model package to contain the specified model package name and the invoker package
|
||||||
|
apiPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.API_PACKAGE);
|
||||||
|
}
|
||||||
|
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
|
|
||||||
if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
|
if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
|
||||||
this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
||||||
} else {
|
} else {
|
||||||
additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
|
additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.GIT_USER_ID)) {
|
||||||
|
this.setGitUserId((String) additionalProperties.get(CodegenConstants.GIT_USER_ID));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.GIT_USER_ID, gitUserId);
|
||||||
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
|
if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
|
||||||
this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
|
this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
|
||||||
} else {
|
} else {
|
||||||
additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
|
additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.GIT_REPO_ID)) {
|
||||||
|
this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.GIT_REPO_ID, gitRepoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
|
||||||
|
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(VARIABLE_NAMING_CONVENTION)) {
|
||||||
|
this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
||||||
|
|
||||||
|
// make api and model src path available in mustache template
|
||||||
|
additionalProperties.put("apiSrcPath", "./" + toSrcPath(apiPackage, srcBasePath));
|
||||||
|
additionalProperties.put("modelSrcPath", "./" + toSrcPath(modelPackage, srcBasePath));
|
||||||
|
additionalProperties.put("apiTestPath", "./" + testBasePath + "/" + apiDirName);
|
||||||
|
additionalProperties.put("modelTestPath", "./" + testBasePath + "/" + modelDirName);
|
||||||
|
|
||||||
|
// make api and model doc path available in mustache template
|
||||||
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
|
// make test path available in mustache template
|
||||||
|
additionalProperties.put("testBasePath", testBasePath);
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("ApiException.mustache", toPackagePath(invokerPackage, srcBasePath), "ApiException.php"));
|
supportingFiles.add(new SupportingFile("ApiException.mustache", toPackagePath(invokerPackage, srcBasePath), "ApiException.php"));
|
||||||
supportingFiles.add(new SupportingFile("Configuration.mustache", toPackagePath(invokerPackage, srcBasePath), "Configuration.php"));
|
supportingFiles.add(new SupportingFile("Configuration.mustache", toPackagePath(invokerPackage, srcBasePath), "Configuration.php"));
|
||||||
supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", toPackagePath(invokerPackage, srcBasePath), "ObjectSerializer.php"));
|
supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", toPackagePath(invokerPackage, srcBasePath), "ObjectSerializer.php"));
|
||||||
@@ -116,6 +330,124 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
if (this.reservedWordsMappings().containsKey(name)) {
|
||||||
|
return this.reservedWordsMappings().get(name);
|
||||||
|
}
|
||||||
|
return "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiFileFolder() {
|
||||||
|
return (outputFolder + "/" + toPackagePath(apiPackage, srcBasePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelFileFolder() {
|
||||||
|
return (outputFolder + "/" + toPackagePath(modelPackage, srcBasePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiTestFileFolder() {
|
||||||
|
return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + apiDirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelTestFileFolder() {
|
||||||
|
return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + modelDirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + getPackagePath() + "/" + apiDocPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + getPackagePath() + "/" + modelDocPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelDocFilename(String name) {
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiDocFilename(String name) {
|
||||||
|
return toApiName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Schema p) {
|
||||||
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
|
ArraySchema ap = (ArraySchema) p;
|
||||||
|
Schema inner = ap.getItems();
|
||||||
|
return getTypeDeclaration(inner) + "[]";
|
||||||
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
|
Schema inner = (Schema) p.getAdditionalProperties();
|
||||||
|
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (StringUtils.isNotBlank(p.get$ref())) {
|
||||||
|
String type = super.getTypeDeclaration(p);
|
||||||
|
return (!languageSpecificPrimitives.contains(type))
|
||||||
|
? "\\" + modelPackage + "\\" + type : type;
|
||||||
|
}
|
||||||
|
return super.getTypeDeclaration(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(String name) {
|
||||||
|
if (!languageSpecificPrimitives.contains(name)) {
|
||||||
|
return "\\" + modelPackage + "\\" + name;
|
||||||
|
}
|
||||||
|
return super.getTypeDeclaration(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSchemaType(Schema p) {
|
||||||
|
String openAPIType = super.getSchemaType(p);
|
||||||
|
|
||||||
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(openAPIType)) {
|
||||||
|
type = typeMapping.get(openAPIType);
|
||||||
|
if (languageSpecificPrimitives.contains(type)) {
|
||||||
|
return type;
|
||||||
|
} else if (instantiationTypes.containsKey(type)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
type = openAPIType;
|
||||||
|
}
|
||||||
|
if (type == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return toModelName(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInvokerPackage() {
|
||||||
|
return invokerPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvokerPackage(String invokerPackage) {
|
||||||
|
this.invokerPackage = invokerPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtifactVersion(String artifactVersion) {
|
||||||
|
this.artifactVersion = artifactVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackagePath(String packagePath) {
|
||||||
|
this.packagePath = packagePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSrcBasePath(String srcBasePath) {
|
||||||
|
this.srcBasePath = srcBasePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameterNamingConvention(String variableNamingConvention) {
|
||||||
|
this.variableNamingConvention = variableNamingConvention;
|
||||||
|
}
|
||||||
|
|
||||||
public void setComposerVendorName(String composerVendorName) {
|
public void setComposerVendorName(String composerVendorName) {
|
||||||
this.composerVendorName = composerVendorName;
|
this.composerVendorName = composerVendorName;
|
||||||
}
|
}
|
||||||
@@ -123,4 +455,291 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
|||||||
public void setComposerProjectName(String composerProjectName) {
|
public void setComposerProjectName(String composerProjectName) {
|
||||||
this.composerProjectName = composerProjectName;
|
this.composerProjectName = composerProjectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// sanitize name
|
||||||
|
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
|
if ("camelCase".equals(variableNamingConvention)) {
|
||||||
|
// return the name in camelCase style
|
||||||
|
// phone_number => phoneNumber
|
||||||
|
name = camelize(name, true);
|
||||||
|
} else { // default to snake case
|
||||||
|
// return the name in underscore style
|
||||||
|
// PhoneNumber => phone_number
|
||||||
|
name = underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parameter name starting with number won't compile
|
||||||
|
// need to escape it by appending _ at the beginning
|
||||||
|
if (name.matches("^\\d.*")) {
|
||||||
|
name = "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// should be the same as variable name
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelName(String name) {
|
||||||
|
// remove [
|
||||||
|
name = name.replaceAll("\\]", "");
|
||||||
|
|
||||||
|
// Note: backslash ("\\") is allowed for e.g. "\\DateTime"
|
||||||
|
name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
|
// remove dollar sign
|
||||||
|
name = name.replaceAll("$", "");
|
||||||
|
|
||||||
|
// model name cannot use reserved keyword
|
||||||
|
if (isReservedWord(name)) {
|
||||||
|
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||||
|
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// model name starts with number
|
||||||
|
if (name.matches("^\\d.*")) {
|
||||||
|
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||||
|
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// add prefix and/or suffic only if name does not start wth \ (e.g. \DateTime)
|
||||||
|
if (!name.matches("^\\\\.*")) {
|
||||||
|
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||||
|
name = modelNamePrefix + "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||||
|
name = name + "_" + modelNameSuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
return camelize(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
// should be the same as the model name
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelTestFilename(String name) {
|
||||||
|
// should be the same as the model name
|
||||||
|
return toModelName(name) + "Test";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
// throw exception if method name is empty
|
||||||
|
if (StringUtils.isEmpty(operationId)) {
|
||||||
|
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// method name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(operationId)) {
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||||
|
operationId = "call_" + operationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return camelize(sanitizeName(operationId), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default value of the property
|
||||||
|
*
|
||||||
|
* @param p property schema
|
||||||
|
* @return string presentation of the default value of the property
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Schema p) {
|
||||||
|
if (ModelUtils.isBooleanSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isDateSchema(p)) {
|
||||||
|
// TODO
|
||||||
|
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||||
|
// TODO
|
||||||
|
} else if (ModelUtils.isNumberSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isStringSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return "'" + p.getDefault() + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameterExampleValue(CodegenParameter p) {
|
||||||
|
String example;
|
||||||
|
|
||||||
|
if (p.defaultValue == null) {
|
||||||
|
example = p.example;
|
||||||
|
} else {
|
||||||
|
example = p.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type = p.baseType;
|
||||||
|
if (type == null) {
|
||||||
|
type = p.dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("String".equalsIgnoreCase(type) || p.isString) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "'" + p.paramName + "_example'";
|
||||||
|
}
|
||||||
|
example = escapeText(example);
|
||||||
|
} else if ("Integer".equals(type) || "int".equals(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "56";
|
||||||
|
}
|
||||||
|
} else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "3.4";
|
||||||
|
}
|
||||||
|
} else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "True";
|
||||||
|
}
|
||||||
|
} else if ("\\SplFileObject".equalsIgnoreCase(type) || p.isFile) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "/path/to/file.txt";
|
||||||
|
}
|
||||||
|
example = "\"" + escapeText(example) + "\"";
|
||||||
|
} else if ("\\Date".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "2013-10-20";
|
||||||
|
}
|
||||||
|
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||||
|
} else if ("\\DateTime".equalsIgnoreCase(type)) {
|
||||||
|
if (example == null) {
|
||||||
|
example = "2013-10-20T19:20:30+01:00";
|
||||||
|
}
|
||||||
|
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||||
|
} else if ("object".equals(type)) {
|
||||||
|
example = "new \\stdClass";
|
||||||
|
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||||
|
// type is a model class, e.g. User
|
||||||
|
example = "new " + getTypeDeclaration(type) + "()";
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (example == null) {
|
||||||
|
example = "NULL";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||||
|
example = "array(" + example + ")";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||||
|
example = "array('key' => " + example + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
p.example = example;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumValue(String value, String datatype) {
|
||||||
|
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return "\'" + escapeText(value) + "\'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumDefaultValue(String value, String datatype) {
|
||||||
|
return datatype + "_" + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumVarName(String name, String datatype) {
|
||||||
|
if (name.length() == 0) {
|
||||||
|
return "EMPTY";
|
||||||
|
}
|
||||||
|
|
||||||
|
// number
|
||||||
|
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||||
|
String varName = name;
|
||||||
|
varName = varName.replaceAll("-", "MINUS_");
|
||||||
|
varName = varName.replaceAll("\\+", "PLUS_");
|
||||||
|
varName = varName.replaceAll("\\.", "_DOT_");
|
||||||
|
return varName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for symbol, e.g. $, #
|
||||||
|
if (getSymbolName(name) != null) {
|
||||||
|
return getSymbolName(name).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// string
|
||||||
|
String enumName = sanitizeName(underscore(name).toUpperCase());
|
||||||
|
enumName = enumName.replaceFirst("^_", "");
|
||||||
|
enumName = enumName.replaceFirst("_$", "");
|
||||||
|
|
||||||
|
if (isReservedWord(enumName) || enumName.matches("\\d.*")) { // reserved word or starts with number
|
||||||
|
return escapeReservedWord(enumName);
|
||||||
|
} else {
|
||||||
|
return enumName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toEnumName(CodegenProperty property) {
|
||||||
|
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
||||||
|
|
||||||
|
// remove [] for array or map of enum
|
||||||
|
enumName = enumName.replace("[]", "");
|
||||||
|
|
||||||
|
if (enumName.matches("\\d.*")) { // starts with number
|
||||||
|
return "_" + enumName;
|
||||||
|
} else {
|
||||||
|
return enumName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
// process enum in models
|
||||||
|
return postProcessModelsEnum(objs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
for (CodegenOperation op : operationList) {
|
||||||
|
// for API test method name
|
||||||
|
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
|
||||||
|
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
|
||||||
|
}
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
// remove ' to avoid code injection
|
||||||
|
return input.replace("'", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,21 +48,26 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
|||||||
variableNamingConvention = "camelCase";
|
variableNamingConvention = "camelCase";
|
||||||
artifactVersion = "1.0.0";
|
artifactVersion = "1.0.0";
|
||||||
packagePath = ""; // empty packagePath (top folder)
|
packagePath = ""; // empty packagePath (top folder)
|
||||||
setInvokerPackage("OpenAPIServer");
|
invokerPackage = camelize("OpenAPIServer");
|
||||||
apiPackage = invokerPackage + "\\" + apiDirName;
|
modelPackage = packagePath + "\\Models";
|
||||||
modelPackage = invokerPackage + "\\" + modelDirName;
|
apiPackage = packagePath;
|
||||||
outputFolder = "generated-code" + File.separator + "slim";
|
outputFolder = "generated-code" + File.separator + "slim";
|
||||||
|
|
||||||
modelTestTemplateFiles.put("model_test.mustache", ".php");
|
// no api files
|
||||||
|
apiTemplateFiles.clear();
|
||||||
|
// no test files
|
||||||
|
apiTestTemplateFiles.clear();
|
||||||
// no doc files
|
// no doc files
|
||||||
modelDocTemplateFiles.clear();
|
modelDocTemplateFiles.clear();
|
||||||
apiDocTemplateFiles.clear();
|
apiDocTemplateFiles.clear();
|
||||||
|
|
||||||
embeddedTemplateDir = templateDir = "php-slim-server";
|
embeddedTemplateDir = templateDir = "php-slim-server";
|
||||||
|
|
||||||
|
// additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||||
|
// additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||||
|
|
||||||
// override cliOptions from AbstractPhpCodegen
|
// override cliOptions from AbstractPhpCodegen
|
||||||
for (CliOption co : cliOptions) {
|
for (CliOption co : cliOptions) {
|
||||||
if (co.getOpt().equals(AbstractPhpCodegen.VARIABLE_NAMING_CONVENTION)) {
|
if (co.getOpt().equals(AbstractPhpCodegen.VARIABLE_NAMING_CONVENTION)) {
|
||||||
@@ -71,6 +76,12 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
|
||||||
|
supportingFiles.add(new SupportingFile("index.mustache", packagePath.replace('/', File.separatorChar), "index.php"));
|
||||||
|
supportingFiles.add(new SupportingFile(".htaccess", packagePath.replace('/', File.separatorChar), ".htaccess"));
|
||||||
|
supportingFiles.add(new SupportingFile(".gitignore", packagePath.replace('/', File.separatorChar), ".gitignore"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,38 +99,6 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
|||||||
return "Generates a PHP Slim Framework server library.";
|
return "Generates a PHP Slim Framework server library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String apiFileFolder() {
|
|
||||||
if (apiPackage.matches("^" + invokerPackage + "\\\\*(.+)")) {
|
|
||||||
// need to strip out invokerPackage from path
|
|
||||||
return (outputFolder + File.separator + toPackagePath(apiPackage.replaceFirst("^" + invokerPackage + "\\\\*(.+)", "$1"), srcBasePath));
|
|
||||||
}
|
|
||||||
return (outputFolder + File.separator + toPackagePath(apiPackage, srcBasePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String modelFileFolder() {
|
|
||||||
if (modelPackage.matches("^" + invokerPackage + "\\\\*(.+)")) {
|
|
||||||
// need to strip out invokerPackage from path
|
|
||||||
return (outputFolder + File.separator + toPackagePath(modelPackage.replaceFirst("^" + invokerPackage + "\\\\*(.+)", "$1"), srcBasePath));
|
|
||||||
}
|
|
||||||
return (outputFolder + File.separator + toPackagePath(modelPackage, srcBasePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processOpts() {
|
|
||||||
super.processOpts();
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md"));
|
|
||||||
supportingFiles.add(new SupportingFile("composer.mustache", getPackagePath(), "composer.json"));
|
|
||||||
supportingFiles.add(new SupportingFile("index.mustache", getPackagePath(), "index.php"));
|
|
||||||
supportingFiles.add(new SupportingFile(".htaccess", getPackagePath(), ".htaccess"));
|
|
||||||
supportingFiles.add(new SupportingFile(".gitignore", getPackagePath(), ".gitignore"));
|
|
||||||
supportingFiles.add(new SupportingFile("AbstractApiController.mustache", toSrcPath(invokerPackage, srcBasePath), "AbstractApiController.php"));
|
|
||||||
supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php"));
|
|
||||||
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", getPackagePath(), "phpunit.xml.dist"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
|||||||
@@ -159,8 +159,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
|
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||||
.defaultValue(Boolean.TRUE.toString()));
|
.defaultValue(Boolean.TRUE.toString()));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.SOURCECODEONLY_GENERATION, CodegenConstants.SOURCECODEONLY_GENERATION_DESC)
|
|
||||||
.defaultValue(Boolean.FALSE.toString()));
|
|
||||||
|
|
||||||
supportedLibraries.put("urllib3", "urllib3-based client");
|
supportedLibraries.put("urllib3", "urllib3-based client");
|
||||||
supportedLibraries.put("asyncio", "Asyncio-based client (python 3.5+)");
|
supportedLibraries.put("asyncio", "Asyncio-based client (python 3.5+)");
|
||||||
@@ -200,22 +198,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
setPackageVersion("1.0.0");
|
setPackageVersion("1.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean generateSourceCodeOnly = false;
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) {
|
|
||||||
generateSourceCodeOnly = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||||
|
|
||||||
if (generateSourceCodeOnly) {
|
|
||||||
// tests in <package>/test
|
|
||||||
testFolder = packageName + File.separatorChar + testFolder;
|
|
||||||
// api/model docs in <package>/docs
|
|
||||||
apiDocPath = packageName + File.separatorChar + apiDocPath;
|
|
||||||
modelDocPath = packageName + File.separatorChar + modelDocPath;
|
|
||||||
}
|
|
||||||
// make api and model doc path available in mustache template
|
// make api and model doc path available in mustache template
|
||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
@@ -224,24 +210,12 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
setPackageUrl((String) additionalProperties.get(PACKAGE_URL));
|
setPackageUrl((String) additionalProperties.get(PACKAGE_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
String readmePath ="README.md";
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
String readmeTemplate = "README.mustache";
|
|
||||||
if (generateSourceCodeOnly) {
|
|
||||||
readmePath = packageName + "_" + readmePath;
|
|
||||||
readmeTemplate = "README_onlypackage.mustache";
|
|
||||||
}
|
|
||||||
supportingFiles.add(new SupportingFile(readmeTemplate, "", readmePath));
|
|
||||||
|
|
||||||
if (!generateSourceCodeOnly){
|
supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini"));
|
||||||
supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini"));
|
supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
|
||||||
supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
|
supportingFiles.add(new SupportingFile("requirements.mustache", "", "requirements.txt"));
|
||||||
supportingFiles.add(new SupportingFile("requirements.mustache", "", "requirements.txt"));
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
|
||||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
|
||||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
|
||||||
supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py"));
|
|
||||||
}
|
|
||||||
supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "configuration.py"));
|
supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "configuration.py"));
|
||||||
supportingFiles.add(new SupportingFile("__init__package.mustache", packageName, "__init__.py"));
|
supportingFiles.add(new SupportingFile("__init__package.mustache", packageName, "__init__.py"));
|
||||||
supportingFiles.add(new SupportingFile("__init__model.mustache", packageName + File.separatorChar + modelPackage, "__init__.py"));
|
supportingFiles.add(new SupportingFile("__init__model.mustache", packageName + File.separatorChar + modelPackage, "__init__.py"));
|
||||||
@@ -250,7 +224,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
if (Boolean.FALSE.equals(excludeTests)) {
|
if (Boolean.FALSE.equals(excludeTests)) {
|
||||||
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
|
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
|
||||||
}
|
}
|
||||||
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
|
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||||
|
supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py"));
|
||||||
supportingFiles.add(new SupportingFile("api_client.mustache", packageName, "api_client.py"));
|
supportingFiles.add(new SupportingFile("api_client.mustache", packageName, "api_client.py"));
|
||||||
|
|
||||||
if ("asyncio".equals(getLibrary())) {
|
if ("asyncio".equals(getLibrary())) {
|
||||||
|
|||||||
@@ -18,11 +18,14 @@
|
|||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import org.openapitools.codegen.CliOption;
|
import org.openapitools.codegen.CliOption;
|
||||||
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
import org.openapitools.codegen.CodegenParameter;
|
import org.openapitools.codegen.CodegenParameter;
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
import org.openapitools.codegen.CodegenProperty;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -34,7 +37,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class RubyClientCodegen extends AbstractRubyCodegen {
|
public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
|
||||||
public static final String GEM_NAME = "gemName";
|
public static final String GEM_NAME = "gemName";
|
||||||
public static final String MODULE_NAME = "moduleName";
|
public static final String MODULE_NAME = "moduleName";
|
||||||
@@ -78,7 +81,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
apiTemplateFiles.put("api.mustache", ".rb");
|
apiTemplateFiles.put("api.mustache", ".rb");
|
||||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
embeddedTemplateDir = templateDir = "ruby-client";
|
embeddedTemplateDir = templateDir = "ruby";
|
||||||
|
|
||||||
modelTestTemplateFiles.put("model_test.mustache", ".rb");
|
modelTestTemplateFiles.put("model_test.mustache", ".rb");
|
||||||
apiTestTemplateFiles.put("api_test.mustache", ".rb");
|
apiTestTemplateFiles.put("api_test.mustache", ".rb");
|
||||||
@@ -86,13 +89,21 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
// default HIDE_GENERATION_TIMESTAMP to true
|
// default HIDE_GENERATION_TIMESTAMP to true
|
||||||
hideGenerationTimestamp = Boolean.TRUE;
|
hideGenerationTimestamp = Boolean.TRUE;
|
||||||
|
|
||||||
// local variable names used in API methods (endpoints)
|
setReservedWordsLowerCase(
|
||||||
for (String word : Arrays.asList(
|
Arrays.asList(
|
||||||
"local_var_path", "query_params", "header_params", "_header_accept", "_header_accept_result",
|
// local variable names used in API methods (endpoints)
|
||||||
"_header_content_type", "form_params", "post_body", "auth_names")) {
|
"local_var_path", "query_params", "header_params", "_header_accept", "_header_accept_result",
|
||||||
reservedWords.add(word.toLowerCase());
|
"_header_content_type", "form_params", "post_body", "auth_names",
|
||||||
}
|
// ruby reserved keywords
|
||||||
|
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
||||||
|
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
||||||
|
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
||||||
|
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
||||||
|
"if", "not", "return", "undef", "yield")
|
||||||
|
);
|
||||||
|
|
||||||
|
typeMapping.clear();
|
||||||
|
languageSpecificPrimitives.clear();
|
||||||
|
|
||||||
// primitives in ruby lang
|
// primitives in ruby lang
|
||||||
languageSpecificPrimitives.add("int");
|
languageSpecificPrimitives.add("int");
|
||||||
@@ -100,8 +111,37 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
languageSpecificPrimitives.add("map");
|
languageSpecificPrimitives.add("map");
|
||||||
languageSpecificPrimitives.add("string");
|
languageSpecificPrimitives.add("string");
|
||||||
// primitives in the typeMapping
|
// primitives in the typeMapping
|
||||||
|
languageSpecificPrimitives.add("String");
|
||||||
|
languageSpecificPrimitives.add("Integer");
|
||||||
|
languageSpecificPrimitives.add("Float");
|
||||||
|
languageSpecificPrimitives.add("Date");
|
||||||
|
languageSpecificPrimitives.add("DateTime");
|
||||||
languageSpecificPrimitives.add("BOOLEAN");
|
languageSpecificPrimitives.add("BOOLEAN");
|
||||||
|
languageSpecificPrimitives.add("Array");
|
||||||
|
languageSpecificPrimitives.add("Hash");
|
||||||
|
languageSpecificPrimitives.add("File");
|
||||||
|
languageSpecificPrimitives.add("Object");
|
||||||
|
|
||||||
|
typeMapping.put("string", "String");
|
||||||
|
typeMapping.put("char", "String");
|
||||||
|
typeMapping.put("int", "Integer");
|
||||||
|
typeMapping.put("integer", "Integer");
|
||||||
|
typeMapping.put("long", "Integer");
|
||||||
|
typeMapping.put("short", "Integer");
|
||||||
|
typeMapping.put("float", "Float");
|
||||||
|
typeMapping.put("double", "Float");
|
||||||
|
typeMapping.put("number", "Float");
|
||||||
|
typeMapping.put("date", "Date");
|
||||||
|
typeMapping.put("DateTime", "DateTime");
|
||||||
typeMapping.put("boolean", "BOOLEAN");
|
typeMapping.put("boolean", "BOOLEAN");
|
||||||
|
typeMapping.put("array", "Array");
|
||||||
|
typeMapping.put("List", "Array");
|
||||||
|
typeMapping.put("map", "Hash");
|
||||||
|
typeMapping.put("object", "Object");
|
||||||
|
typeMapping.put("file", "File");
|
||||||
|
typeMapping.put("binary", "String");
|
||||||
|
typeMapping.put("ByteArray", "String");
|
||||||
|
typeMapping.put("UUID", "String");
|
||||||
|
|
||||||
// remove modelPackage and apiPackage added by default
|
// remove modelPackage and apiPackage added by default
|
||||||
Iterator<CliOption> itr = cliOptions.iterator();
|
Iterator<CliOption> itr = cliOptions.iterator();
|
||||||
@@ -268,6 +308,14 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
return underscore(moduleName.replaceAll("[^\\w]+", ""));
|
return underscore(moduleName.replaceAll("[^\\w]+", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
if (this.reservedWordsMappings().containsKey(name)) {
|
||||||
|
return this.reservedWordsMappings().get(name);
|
||||||
|
}
|
||||||
|
return "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + libFolder + File.separator + gemName + File.separator + apiPackage.replace("/", File.separator);
|
return outputFolder + File.separator + libFolder + File.separator + gemName + File.separator + apiPackage.replace("/", File.separator);
|
||||||
@@ -298,6 +346,34 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Schema schema) {
|
||||||
|
if (ModelUtils.isArraySchema(schema)) {
|
||||||
|
Schema inner = ((ArraySchema) schema).getItems();
|
||||||
|
return getSchemaType(schema) + "<" + getTypeDeclaration(inner) + ">";
|
||||||
|
} else if (ModelUtils.isMapSchema(schema)) {
|
||||||
|
Schema inner = (Schema) schema.getAdditionalProperties();
|
||||||
|
return getSchemaType(schema) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getTypeDeclaration(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Schema p) {
|
||||||
|
if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return p.getDefault().toString();
|
||||||
|
}
|
||||||
|
} else if (ModelUtils.isStringSchema(p)) {
|
||||||
|
if (p.getDefault() != null) {
|
||||||
|
return "'" + escapeText((String) p.getDefault()) + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSchemaType(Schema schema) {
|
public String getSchemaType(Schema schema) {
|
||||||
String openAPIType = super.getSchemaType(schema);
|
String openAPIType = super.getSchemaType(schema);
|
||||||
@@ -318,6 +394,33 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
return toModelName(type);
|
return toModelName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// sanitize name
|
||||||
|
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
// if it's all uppper case, convert to lower case
|
||||||
|
if (name.matches("^[A-Z_]*$")) {
|
||||||
|
name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize (lower first character) the variable name
|
||||||
|
// petId => pet_id
|
||||||
|
name = underscore(name);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// should be the same as variable name
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelName(String name) {
|
public String toModelName(String name) {
|
||||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
@@ -581,4 +684,16 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
//
|
//
|
||||||
//return super.shouldOverwrite(filename) && !filename.endsWith("_spec.rb");
|
//return super.shouldOverwrite(filename) && !filename.endsWith("_spec.rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
// remove ' to avoid code injection
|
||||||
|
return input.replace("'", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input.replace("=end", "=_end").replace("=begin", "=_begin");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,19 +18,30 @@
|
|||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import org.openapitools.codegen.CodegenType;
|
import org.openapitools.codegen.CodegenType;
|
||||||
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.Operation;
|
||||||
import io.swagger.v3.oas.models.media.*;
|
import io.swagger.v3.oas.models.media.*;
|
||||||
|
import io.swagger.v3.core.util.Yaml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubyOnRailsServerCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(RubyOnRailsServerCodegen.class);
|
||||||
private static final SimpleDateFormat MIGRATE_FILE_NAME_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
|
private static final SimpleDateFormat MIGRATE_FILE_NAME_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
@@ -74,16 +85,35 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
modelPackage = "app/models";
|
modelPackage = "app/models";
|
||||||
modelTemplateFiles.put("model.mustache", ".rb");
|
modelTemplateFiles.put("model.mustache", ".rb");
|
||||||
|
|
||||||
embeddedTemplateDir = templateDir = "ruby-on-rails-server";
|
embeddedTemplateDir = templateDir = "rails5";
|
||||||
|
|
||||||
|
typeMapping.clear();
|
||||||
|
languageSpecificPrimitives.clear();
|
||||||
|
|
||||||
|
setReservedWordsLowerCase(
|
||||||
|
Arrays.asList(
|
||||||
|
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
||||||
|
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
||||||
|
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
||||||
|
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
||||||
|
"if", "not", "return", "undef", "yield")
|
||||||
|
);
|
||||||
|
|
||||||
// In order to adapt to DB migrate script, overwrite typeMapping
|
|
||||||
typeMapping.put("string", "string");
|
typeMapping.put("string", "string");
|
||||||
|
typeMapping.put("char", "string");
|
||||||
typeMapping.put("int", "integer");
|
typeMapping.put("int", "integer");
|
||||||
typeMapping.put("integer", "integer");
|
typeMapping.put("integer", "integer");
|
||||||
typeMapping.put("long", "integer");
|
typeMapping.put("long", "integer");
|
||||||
typeMapping.put("short", "integer");
|
typeMapping.put("short", "integer");
|
||||||
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("double", "decimal");
|
||||||
|
typeMapping.put("number", "float");
|
||||||
|
typeMapping.put("date", "date");
|
||||||
typeMapping.put("DateTime", "datetime");
|
typeMapping.put("DateTime", "datetime");
|
||||||
typeMapping.put("boolean", "boolean");
|
typeMapping.put("boolean", "boolean");
|
||||||
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("ByteArray", "string");
|
||||||
|
typeMapping.put("UUID", "string");
|
||||||
|
|
||||||
// remove modelPackage and apiPackage added by default
|
// remove modelPackage and apiPackage added by default
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
@@ -173,11 +203,59 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
return "Generates a Ruby on Rails (v5) server library.";
|
return "Generates a Ruby on Rails (v5) server library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
if(this.reservedWordsMappings().containsKey(name)) {
|
||||||
|
return this.reservedWordsMappings().get(name);
|
||||||
|
}
|
||||||
|
return "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + apiPackage.replace("/", File.separator);
|
return outputFolder + File.separator + apiPackage.replace("/", File.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Schema p) {
|
||||||
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
|
ArraySchema ap = (ArraySchema) p;
|
||||||
|
Schema inner = ap.getItems();
|
||||||
|
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
|
Schema inner = (Schema) p.getAdditionalProperties();
|
||||||
|
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||||
|
}
|
||||||
|
return super.getTypeDeclaration(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Schema p) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
|
// if it's all uppper case, convert to lower case
|
||||||
|
if (name.matches("^[A-Z_]*$")) {
|
||||||
|
name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize (lower first character) the variable name
|
||||||
|
// petId => pet_id
|
||||||
|
name = underscore(name);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSchemaType(Schema p) {
|
public String getSchemaType(Schema p) {
|
||||||
String openAPIType = super.getSchemaType(p);
|
String openAPIType = super.getSchemaType(p);
|
||||||
@@ -188,6 +266,12 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
return "string";
|
return "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// should be the same as variable name
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelName(String name) {
|
public String toModelName(String name) {
|
||||||
// model name cannot use reserved keyword, e.g. return
|
// model name cannot use reserved keyword, e.g. return
|
||||||
@@ -234,9 +318,32 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
return camelize(name) + "Controller";
|
return camelize(name) + "Controller";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
// method name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(operationId)) {
|
||||||
|
String newOperationId = underscore("call_" + operationId);
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||||
|
return newOperationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return underscore(operationId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||||
generateYAMLSpecFile(objs);
|
generateYAMLSpecFile(objs);
|
||||||
return super.postProcessSupportingFileData(objs);
|
return super.postProcessSupportingFileData(objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
// remove ' to avoid code injection
|
||||||
|
return input.replace("'", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input.replace("=end", "=_end").replace("=begin", "=_begin");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,18 +17,29 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import org.openapitools.codegen.CodegenType;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
|
import org.openapitools.codegen.CodegenType;
|
||||||
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.Operation;
|
||||||
import io.swagger.v3.oas.models.media.*;
|
import io.swagger.v3.oas.models.media.*;
|
||||||
|
import io.swagger.v3.core.util.Yaml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubySinatraServerCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(RubySinatraServerCodegen.class);
|
||||||
|
|
||||||
@@ -45,7 +56,36 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
|||||||
// no model
|
// no model
|
||||||
modelTemplateFiles.clear();
|
modelTemplateFiles.clear();
|
||||||
apiTemplateFiles.put("api.mustache", ".rb");
|
apiTemplateFiles.put("api.mustache", ".rb");
|
||||||
embeddedTemplateDir = templateDir = "ruby-sinatra-server";
|
embeddedTemplateDir = templateDir = "sinatra";
|
||||||
|
|
||||||
|
typeMapping.clear();
|
||||||
|
languageSpecificPrimitives.clear();
|
||||||
|
|
||||||
|
setReservedWordsLowerCase(
|
||||||
|
Arrays.asList(
|
||||||
|
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
||||||
|
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
||||||
|
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
||||||
|
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
||||||
|
"if", "not", "return", "undef", "yield")
|
||||||
|
);
|
||||||
|
|
||||||
|
languageSpecificPrimitives.add("int");
|
||||||
|
languageSpecificPrimitives.add("array");
|
||||||
|
languageSpecificPrimitives.add("map");
|
||||||
|
languageSpecificPrimitives.add("string");
|
||||||
|
languageSpecificPrimitives.add("DateTime");
|
||||||
|
|
||||||
|
typeMapping.put("long", "int");
|
||||||
|
typeMapping.put("integer", "int");
|
||||||
|
typeMapping.put("Array", "array");
|
||||||
|
typeMapping.put("String", "string");
|
||||||
|
typeMapping.put("List", "array");
|
||||||
|
typeMapping.put("map", "map");
|
||||||
|
//TODO binary should be mapped to byte array
|
||||||
|
// mapped to String as a workaround
|
||||||
|
typeMapping.put("binary", "string");
|
||||||
|
typeMapping.put("UUID", "string");
|
||||||
|
|
||||||
// remove modelPackage and apiPackage added by default
|
// remove modelPackage and apiPackage added by default
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
@@ -82,11 +122,32 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
|||||||
return "Generates a Ruby Sinatra server library.";
|
return "Generates a Ruby Sinatra server library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
if (this.reservedWordsMappings().containsKey(name)) {
|
||||||
|
return this.reservedWordsMappings().get(name);
|
||||||
|
}
|
||||||
|
return "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + apiPackage.replace("/", File.separator);
|
return outputFolder + File.separator + apiPackage.replace("/", File.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Schema p) {
|
||||||
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
|
ArraySchema ap = (ArraySchema) p;
|
||||||
|
Schema inner = ap.getItems();
|
||||||
|
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
|
Schema inner = (Schema) p.getAdditionalProperties();
|
||||||
|
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||||
|
}
|
||||||
|
return super.getTypeDeclaration(p);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSchemaType(Schema p) {
|
public String getSchemaType(Schema p) {
|
||||||
String openAPIType = super.getSchemaType(p);
|
String openAPIType = super.getSchemaType(p);
|
||||||
@@ -105,6 +166,39 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Schema p) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
|
// if it's all uppper case, convert to lower case
|
||||||
|
if (name.matches("^[A-Z_]*$")) {
|
||||||
|
name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize (lower first character) the variable name
|
||||||
|
// petId => pet_id
|
||||||
|
name = underscore(name);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// should be the same as variable name
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelName(String name) {
|
public String toModelName(String name) {
|
||||||
// model name cannot use reserved keyword, e.g. return
|
// model name cannot use reserved keyword, e.g. return
|
||||||
@@ -149,9 +243,32 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
|||||||
return camelize(name) + "Api";
|
return camelize(name) + "Api";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
// method name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(operationId)) {
|
||||||
|
String newOperationId = underscore("call_" + operationId);
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||||
|
return newOperationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return underscore(operationId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||||
generateYAMLSpecFile(objs);
|
generateYAMLSpecFile(objs);
|
||||||
return super.postProcessSupportingFileData(objs);
|
return super.postProcessSupportingFileData(objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
// remove ' to avoid code injection
|
||||||
|
return input.replace("'", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input.replace("=end", "=_end").replace("=begin", "=_begin");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -576,9 +576,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
allParams.add(p);
|
allParams.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!allParams.isEmpty()) {
|
allParams.get(allParams.size()-1).hasMore =false;
|
||||||
allParams.get(allParams.size()-1).hasMore =false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -135,21 +135,9 @@ public class URLPathUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String sanitizeUrl(String url) {
|
private static String sanitizeUrl(String url) {
|
||||||
if (url.startsWith("//")) {
|
if (url.startsWith("/")) {
|
||||||
url = "http:" + url;
|
LOGGER.warn("'host' not defined in the spec (2.0). Default to " + LOCAL_HOST);
|
||||||
LOGGER.warn("'scheme' not defined in the spec (2.0). Default to [http] for server URL [{}]", url);
|
|
||||||
} else if (url.startsWith("/")) {
|
|
||||||
url = LOCAL_HOST + url;
|
url = LOCAL_HOST + url;
|
||||||
LOGGER.warn("'host' not defined in the spec (2.0). Default to [{}] for server URL [{}]", LOCAL_HOST, url);
|
|
||||||
} else if (!url.matches("[a-zA-Z][0-9a-zA-Z.+\\-]+://.+")) {
|
|
||||||
// Add http scheme for urls without a scheme.
|
|
||||||
// 2.0 spec is restricted to the following schemes: "http", "https", "ws", "wss"
|
|
||||||
// 3.0 spec does not have an enumerated list of schemes
|
|
||||||
// This regex attempts to capture all schemes in IANA example schemes which
|
|
||||||
// can have alpha-numeric characters and [.+-]. Examples are here:
|
|
||||||
// https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
|
|
||||||
url = "http://" + url;
|
|
||||||
LOGGER.warn("'scheme' not defined in the spec (2.0). Default to [http] for server URL [{}]", url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Building the API client library requires:
|
Building the API client library requires:
|
||||||
1. Java {{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}+
|
1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+
|
||||||
2. Maven/Gradle
|
2. Maven/Gradle
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -31,11 +31,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -44,7 +39,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -89,11 +83,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@@ -102,7 +91,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -90,20 +84,8 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
{{#supportJava6}}
|
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
|
||||||
{{/java8}}
|
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -291,7 +291,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
|
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<swagger-core-version>1.5.18</swagger-core-version>
|
<swagger-core-version>1.5.18</swagger-core-version>
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -90,11 +84,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@@ -103,7 +92,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -139,11 +139,6 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
{{#supportJava6}}
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
@@ -152,7 +147,6 @@
|
|||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -709,12 +709,12 @@ public class ApiClient {
|
|||||||
Map<String, List<String>> responseHeaders = buildResponseHeaders(response);
|
Map<String, List<String>> responseHeaders = buildResponseHeaders(response);
|
||||||
|
|
||||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||||
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders);
|
return new ApiResponse<>(statusCode, responseHeaders);
|
||||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||||
if (returnType == null)
|
if (returnType == null)
|
||||||
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders);
|
return new ApiResponse<>(statusCode, responseHeaders);
|
||||||
else
|
else
|
||||||
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders, deserialize(response, returnType));
|
return new ApiResponse<>(statusCode, responseHeaders, deserialize(response, returnType));
|
||||||
} else {
|
} else {
|
||||||
String message = "error";
|
String message = "error";
|
||||||
String respBody = null;
|
String respBody = null;
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -89,11 +83,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@@ -102,7 +91,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
@@ -117,20 +105,17 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.5.20"
|
swagger_annotations_version = "1.5.17"
|
||||||
jackson_version = "2.9.6"
|
jackson_version = "2.8.9"
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
jersey_version = "2.6"
|
jersey_version = "2.6"
|
||||||
commons_io_version=2.5
|
commons_io_version=2.5
|
||||||
commons_lang3_version=3.6
|
commons_lang3_version=3.6
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
{{^supportJava6}}
|
{{^supportJava6}}
|
||||||
jersey_version = "2.27"
|
jersey_version = "2.25.1"
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
{{#threetenbp}}
|
|
||||||
threetenbp_version = "2.6.4"
|
|
||||||
{{/threetenbp}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -142,17 +127,17 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
compile "commons-io:commons-io:$commons_io_version"
|
compile "commons-io:commons-io:$commons_io_version"
|
||||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
{{#threetenbp}}
|
{{#threetenbp}}
|
||||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
{{^java8}}
|
{{^java8}}
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ lazy val root = (project in file(".")).
|
|||||||
publishArtifact in (Compile, packageDoc) := false,
|
publishArtifact in (Compile, packageDoc) := false,
|
||||||
resolvers += Resolver.mavenLocal,
|
resolvers += Resolver.mavenLocal,
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"io.swagger" % "swagger-annotations" % "1.5.20",
|
"io.swagger" % "swagger-annotations" % "1.5.17",
|
||||||
"org.glassfish.jersey.core" % "jersey-client" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
"org.glassfish.jersey.core" % "jersey-client" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||||
"org.glassfish.jersey.media" % "jersey-media-multipart" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
"org.glassfish.jersey.media" % "jersey-media-multipart" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||||
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.8.9" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.8.9" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.8.9" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.8.9" % "compile",
|
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.8.9" % "compile",
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
|||||||
@@ -139,11 +139,6 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
{{#supportJava6}}
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
@@ -152,7 +147,6 @@
|
|||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -276,7 +270,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.joschi.jackson</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
<version>${threetenbp-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
{{^java8}}
|
{{^java8}}
|
||||||
@@ -318,19 +312,16 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<swagger-core-version>1.5.20</swagger-core-version>
|
<swagger-core-version>1.5.18</swagger-core-version>
|
||||||
{{^supportJava6}}
|
{{^supportJava6}}
|
||||||
<jersey-version>2.27</jersey-version>
|
<jersey-version>2.25.1</jersey-version>
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
<jersey-version>2.6</jersey-version>
|
<jersey-version>2.6</jersey-version>
|
||||||
<commons_io_version>2.5</commons_io_version>
|
<commons_io_version>2.5</commons_io_version>
|
||||||
<commons_lang3_version>3.6</commons_lang3_version>
|
<commons_lang3_version>3.6</commons_lang3_version>
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
<jackson-version>2.8.9</jackson-version>
|
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
|
||||||
{{#threetenbp}}
|
|
||||||
<threetenbp-version>2.6.4</threetenbp-version>
|
|
||||||
{{/threetenbp}}
|
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -90,20 +84,8 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
{{#supportJava6}}
|
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
|
||||||
{{/java8}}
|
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -267,7 +267,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
|
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<gson-fire-version>1.8.0</gson-fire-version>
|
<gson-fire-version>1.8.0</gson-fire-version>
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -89,11 +83,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@@ -102,7 +91,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -120,11 +120,6 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
{{#supportJava6}}
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
@@ -133,7 +128,6 @@
|
|||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -90,11 +84,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@@ -103,7 +92,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -139,11 +139,6 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
{{#supportJava6}}
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
@@ -152,7 +147,6 @@
|
|||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
|
|||||||
@@ -139,20 +139,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
{{#supportJava6}}
|
<source>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</source>
|
||||||
<source>1.6</source>
|
<target>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</target>
|
||||||
<target>1.6</target>
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
<source>1.7</source>
|
|
||||||
<target>1.7</target>
|
|
||||||
{{/java8}}
|
|
||||||
{{/supportJava6}}
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -45,7 +40,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@@ -90,20 +84,8 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
{{#supportJava6}}
|
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||||
targetCompatibility = JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
|
||||||
{{/java8}}
|
|
||||||
{{/supportJava6}}
|
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
public ApiClient() {
|
public ApiClient() {
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}
|
authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}
|
||||||
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
|
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
|
||||||
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
|
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
|
||||||
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
|
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
|
||||||
@@ -57,8 +57,8 @@ public class ApiClient {
|
|||||||
basePath = basePath + "/";
|
basePath = basePath + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
|
Map<String, String> extraHeaders = new HashMap<>();
|
||||||
List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>();
|
List<Pair> extraQueryParams = new ArrayList<>();
|
||||||
|
|
||||||
for (String authName : authentications.keySet()) {
|
for (String authName : authentications.keySet()) {
|
||||||
Authentication auth = authentications.get(authName);
|
Authentication auth = authentications.get(authName);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
public ApiClient() {
|
public ApiClient() {
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}
|
authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}
|
||||||
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
|
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
|
||||||
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
|
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
|
||||||
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
|
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
|
||||||
@@ -57,8 +57,8 @@ public class ApiClient {
|
|||||||
basePath = basePath + "/";
|
basePath = basePath + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
|
Map<String, String> extraHeaders = new HashMap<>();
|
||||||
List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>();
|
List<Pair> extraQueryParams = new ArrayList<>();
|
||||||
|
|
||||||
for (String authName : authentications.keySet()) {
|
for (String authName : authentications.keySet()) {
|
||||||
Authentication auth = authentications.get(authName);
|
Authentication auth = authentications.get(authName);
|
||||||
|
|||||||
@@ -327,7 +327,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
|
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<gson-fire-version>1.8.0</gson-fire-version>
|
<gson-fire-version>1.8.0</gson-fire-version>
|
||||||
|
|||||||
@@ -139,11 +139,6 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
{{#supportJava6}}
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
@@ -152,7 +147,6 @@
|
|||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -206,8 +206,8 @@
|
|||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
<beanvalidation-version>1.1.0.Final</beanvalidation-version>
|
<beanvalidation-version>1.1.0.Final</beanvalidation-version>
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
<cxf-version>3.2.5</cxf-version>
|
<cxf-version>3.2.1</cxf-version>
|
||||||
<jackson-jaxrs-version>2.9.6</jackson-jaxrs-version>
|
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -263,8 +263,8 @@
|
|||||||
{{#generateSpringBootApplication}}
|
{{#generateSpringBootApplication}}
|
||||||
<spring.boot-version>1.5.9.RELEASE</spring.boot-version>
|
<spring.boot-version>1.5.9.RELEASE</spring.boot-version>
|
||||||
{{/generateSpringBootApplication}}
|
{{/generateSpringBootApplication}}
|
||||||
<cxf-version>3.2.5</cxf-version>
|
<cxf-version>3.2.1</cxf-version>
|
||||||
<jackson-jaxrs-version>2.9.6</jackson-jaxrs-version>
|
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -56,11 +56,6 @@ android {
|
|||||||
{{/androidSdkVersion}}
|
{{/androidSdkVersion}}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -69,7 +64,6 @@ android {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ android {
|
|||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
{{#supportJava6}}
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
|
||||||
{{/supportJava6}}
|
|
||||||
{{^supportJava6}}
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -48,7 +43,6 @@ android {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{/supportJava6}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
|
|||||||
@@ -67,10 +67,9 @@ type {{{nickname}}}Opts struct {
|
|||||||
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) {
|
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 (
|
var (
|
||||||
localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
|
localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
|
||||||
localVarPostBody interface{}
|
localVarPostBody interface{}
|
||||||
localVarFormFileName string
|
localVarFileName string
|
||||||
localVarFileName string
|
localVarFileBytes []byte
|
||||||
localVarFileBytes []byte
|
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
localVarReturnValue {{{returnType}}}
|
localVarReturnValue {{{returnType}}}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
@@ -178,7 +177,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
|||||||
{{#hasFormParams}}
|
{{#hasFormParams}}
|
||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
{{#isFile}}
|
{{#isFile}}
|
||||||
localVarFormFileName = "{{baseName}}"
|
|
||||||
{{#required}}
|
{{#required}}
|
||||||
localVarFile := {{paramName}}
|
localVarFile := {{paramName}}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
@@ -256,7 +254,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
|||||||
|
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
|
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,8 +142,6 @@ func parameterToString(obj interface{}, collectionFormat string) string {
|
|||||||
|
|
||||||
if reflect.TypeOf(obj).Kind() == reflect.Slice {
|
if reflect.TypeOf(obj).Kind() == reflect.Slice {
|
||||||
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
|
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
|
||||||
} else if t, ok := obj.(time.Time); ok {
|
|
||||||
return t.Format(time.RFC3339)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%v", obj)
|
return fmt.Sprintf("%v", obj)
|
||||||
@@ -167,7 +165,6 @@ func (c *APIClient) prepareRequest(
|
|||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams url.Values,
|
queryParams url.Values,
|
||||||
formParams url.Values,
|
formParams url.Values,
|
||||||
formFileName string,
|
|
||||||
fileName string,
|
fileName string,
|
||||||
fileBytes []byte) (localVarRequest *http.Request, err error) {
|
fileBytes []byte) (localVarRequest *http.Request, err error) {
|
||||||
|
|
||||||
@@ -210,7 +207,7 @@ func (c *APIClient) prepareRequest(
|
|||||||
if len(fileBytes) > 0 && fileName != "" {
|
if len(fileBytes) > 0 && fileName != "" {
|
||||||
w.Boundary()
|
w.Boundary()
|
||||||
//_, fileNm := filepath.Split(fileName)
|
//_, fileNm := filepath.Split(fileName)
|
||||||
part, err := w.CreateFormFile(formFileName, filepath.Base(fileName))
|
part, err := w.CreateFormFile("file", filepath.Base(fileName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -430,9 +427,8 @@ func CacheExpires(r *http.Response) time.Time {
|
|||||||
lifetime, err := time.ParseDuration(maxAge + "s")
|
lifetime, err := time.ParseDuration(maxAge + "s")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
expires = now
|
expires = now
|
||||||
} else {
|
|
||||||
expires = now.Add(lifetime)
|
|
||||||
}
|
}
|
||||||
|
expires = now.Add(lifetime)
|
||||||
} else {
|
} else {
|
||||||
expiresHeader := r.Header.Get("Expires")
|
expiresHeader := r.Header.Get("Expires")
|
||||||
if expiresHeader != "" {
|
if expiresHeader != "" {
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Abstract Api Controller
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{invokerPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
{{#appName}}
|
|
||||||
* {{{appName}}}
|
|
||||||
*
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
* {{{appDescription}}}
|
|
||||||
{{/appDescription}}
|
|
||||||
{{#version}}
|
|
||||||
* OpenAPI spec version: {{{version}}}
|
|
||||||
{{/version}}
|
|
||||||
{{#infoEmail}}
|
|
||||||
* Contact: {{{infoEmail}}}
|
|
||||||
{{/infoEmail}}
|
|
||||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: This class is auto generated by the openapi generator program.
|
|
||||||
* https://github.com/openapitools/openapi-generator
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
namespace {{invokerPackage}};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ApiServer Class Doc Comment
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{invokerPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
abstract class AbstractApiController {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
|
||||||
*/
|
|
||||||
protected $container;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route Controller constructor receives container
|
|
||||||
*
|
|
||||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
|
||||||
*/
|
|
||||||
public function __construct($container) {
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SlimRouter
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{invokerPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**{{#apiInfo}}{{#appName}}
|
|
||||||
* {{{appName}}}
|
|
||||||
*
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
* {{{appDescription}}}
|
|
||||||
{{/appDescription}}
|
|
||||||
{{#version}}
|
|
||||||
* OpenAPI spec version: {{{version}}}
|
|
||||||
{{/version}}
|
|
||||||
{{#infoEmail}}
|
|
||||||
* Contact: {{{infoEmail}}}
|
|
||||||
{{/infoEmail}}
|
|
||||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: This class is auto generated by the openapi generator program.
|
|
||||||
* https://github.com/openapitools/openapi-generator
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
namespace {{invokerPackage}};
|
|
||||||
|
|
||||||
{{#apis}}
|
|
||||||
use {{apiPackage}}\{{classname}};
|
|
||||||
{{/apis}}
|
|
||||||
use Slim\App;
|
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use InvalidArgumentException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SlimRouter Class Doc Comment
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{apiPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
class SlimRouter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var $slimApp Slim\App instance
|
|
||||||
*/
|
|
||||||
private $slimApp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class constructor
|
|
||||||
*
|
|
||||||
* @param ContainerInterface|array $container Either a ContainerInterface or an associative array of app settings
|
|
||||||
* @throws InvalidArgumentException when no container is provided that implements ContainerInterface
|
|
||||||
*/
|
|
||||||
public function __construct($container = []) {
|
|
||||||
$app = new App($container);
|
|
||||||
|
|
||||||
{{#apis}}
|
|
||||||
{{#operations}}
|
|
||||||
{{#operation}}
|
|
||||||
$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', {{classname}}::class . ':{{operationId}}');
|
|
||||||
{{/operation}}
|
|
||||||
{{/operations}}
|
|
||||||
{{/apis}}
|
|
||||||
|
|
||||||
$this->slimApp = $app;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Slim Framework instance
|
|
||||||
* @return App
|
|
||||||
*/
|
|
||||||
public function getSlimApp() {
|
|
||||||
return $this->slimApp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{/apiInfo}}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* {{classname}}
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{apiPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
{{#appName}}
|
|
||||||
* {{{appName}}}
|
|
||||||
*
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
* {{{appDescription}}}
|
|
||||||
{{/appDescription}}
|
|
||||||
{{#version}}
|
|
||||||
* OpenAPI spec version: {{{version}}}
|
|
||||||
{{/version}}
|
|
||||||
{{#infoEmail}}
|
|
||||||
* Contact: {{{infoEmail}}}
|
|
||||||
{{/infoEmail}}
|
|
||||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: This class is auto generated by the openapi generator program.
|
|
||||||
* https://github.com/openapitools/openapi-generator
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
namespace {{apiPackage}};
|
|
||||||
|
|
||||||
use {{invokerPackage}}\AbstractApiController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {{classname}} Class Doc Comment
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{apiPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
class {{classname}} extends AbstractApiController {
|
|
||||||
|
|
||||||
{{#operations}}
|
|
||||||
{{#operation}}
|
|
||||||
/**
|
|
||||||
* {{httpMethod}} {{operationId}}
|
|
||||||
* Summary: {{summary}}
|
|
||||||
* Notes: {{notes}}
|
|
||||||
{{#hasProduces}}
|
|
||||||
* Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
|
||||||
{{/hasProduces}}
|
|
||||||
*
|
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
|
||||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
|
||||||
* @param array|null $args Path arguments
|
|
||||||
*/
|
|
||||||
public function {{operationId}}($request, $response, $args) {
|
|
||||||
{{#hasHeaderParams}}
|
|
||||||
$headers = $request->getHeaders();
|
|
||||||
{{#headerParams}}
|
|
||||||
${{paramName}} = $request->hasHeader('{{baseName}}') ? $headers['{{baseName}}'] : null;
|
|
||||||
{{/headerParams}}
|
|
||||||
{{/hasHeaderParams}}
|
|
||||||
{{#hasPathParams}}
|
|
||||||
{{#pathParams}}
|
|
||||||
${{paramName}} = $args['{{baseName}}'];
|
|
||||||
{{/pathParams}}
|
|
||||||
{{/hasPathParams}}
|
|
||||||
{{#hasQueryParams}}
|
|
||||||
$queryParams = $request->getQueryParams();
|
|
||||||
{{#queryParams}}
|
|
||||||
${{paramName}} = $request->getQueryParam('{{baseName}}');
|
|
||||||
{{/queryParams}}
|
|
||||||
{{/hasQueryParams}}
|
|
||||||
{{#hasFormParams}}
|
|
||||||
{{#formParams}}
|
|
||||||
{{^isFile}}
|
|
||||||
${{paramName}} = $request->getParsedBodyParam('{{baseName}}');
|
|
||||||
{{/isFile}}
|
|
||||||
{{#isFile}}
|
|
||||||
${{paramName}} = (key_exists('{{baseName}}', $request->getUploadedFiles())) ? $request->getUploadedFiles()['{{baseName}}'] : null;
|
|
||||||
{{/isFile}}
|
|
||||||
{{/formParams}}
|
|
||||||
{{/hasFormParams}}
|
|
||||||
{{#hasBodyParam}}
|
|
||||||
$body = $request->getParsedBody();
|
|
||||||
{{/hasBodyParam}}
|
|
||||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
{{#hasMore}}{{/hasMore}}
|
|
||||||
{{/operation}}
|
|
||||||
{{/operations}}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* {{classname}}Test
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @package {{apiPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
{{#appName}}
|
|
||||||
* {{{appName}}}
|
|
||||||
*
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
* {{{appDescription}}}
|
|
||||||
{{/appDescription}}
|
|
||||||
{{#version}}
|
|
||||||
* OpenAPI spec version: {{{version}}}
|
|
||||||
{{/version}}
|
|
||||||
{{#infoEmail}}
|
|
||||||
* Contact: {{{infoEmail}}}
|
|
||||||
{{/infoEmail}}
|
|
||||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: This class is auto generated by the openapi generator program.
|
|
||||||
* https://github.com/openapitools/openapi-generator
|
|
||||||
* Please update the test case below to test the endpoint.
|
|
||||||
*/
|
|
||||||
namespace {{apiPackage}};
|
|
||||||
|
|
||||||
use {{apiPackage}}\{{classname}};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {{classname}}Test Class Doc Comment
|
|
||||||
*
|
|
||||||
* @category Class
|
|
||||||
* @description {{#description}}{{description}}{{/description}}{{^description}}{{classname}}{{/description}}
|
|
||||||
* @package {{apiPackage}}
|
|
||||||
* @author OpenAPI Generator team
|
|
||||||
* @link https://github.com/openapitools/openapi-generator
|
|
||||||
* @coversDefaultClass \{{modelPackage}}\{{classname}}
|
|
||||||
*/
|
|
||||||
{{#operations}}class {{classname}}Test extends \PHPUnit_Framework_TestCase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup before running any test cases
|
|
||||||
*/
|
|
||||||
public static function setUpBeforeClass() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup before running each test case
|
|
||||||
*/
|
|
||||||
public function setUp() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up after running each test case
|
|
||||||
*/
|
|
||||||
public function tearDown() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up after running all test cases
|
|
||||||
*/
|
|
||||||
public static function tearDownAfterClass() {
|
|
||||||
|
|
||||||
}
|
|
||||||
{{#operation}}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test case for {{{operationId}}}
|
|
||||||
*
|
|
||||||
* {{{summary}}}.
|
|
||||||
* @covers ::{{{operationId}}}
|
|
||||||
*/
|
|
||||||
public function test{{operationIdCamelCase}}() {
|
|
||||||
|
|
||||||
}
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
{{/operations}}
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"minimum-stability": "RC",
|
||||||
|
"require": {
|
||||||
|
"slim/slim": "3.*"
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user