mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-04 07:56:08 +00:00
Compare commits
48 Commits
travis_tes
...
v3.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
761799abf5 | ||
|
|
7c9d40016f | ||
|
|
1d53ed5095 | ||
|
|
6d6ef0f120 | ||
|
|
afb238814d | ||
|
|
a055dc0351 | ||
|
|
84ef98f067 | ||
|
|
925ae68167 | ||
|
|
d863c3e5f4 | ||
|
|
5a0a8f6a87 | ||
|
|
df815344d1 | ||
|
|
a6e15d7569 | ||
|
|
791f836e3d | ||
|
|
cd854b2130 | ||
|
|
26e70fe642 | ||
|
|
6c14b4271f | ||
|
|
19fd48e33b | ||
|
|
93832340a5 | ||
|
|
a0936bec02 | ||
|
|
a18a50b7a4 | ||
|
|
d17bdd2658 | ||
|
|
84129a7da1 | ||
|
|
0d952b79db | ||
|
|
0a2131d2d3 | ||
|
|
86a0445984 | ||
|
|
837b10aab5 | ||
|
|
9103ddb7fa | ||
|
|
96e86ac03e | ||
|
|
950c584485 | ||
|
|
6d05ea5716 | ||
|
|
79fafda012 | ||
|
|
a14e757059 | ||
|
|
b380e8f2a9 | ||
|
|
0d959a254c | ||
|
|
4797c7b42c | ||
|
|
4b6fb504a2 | ||
|
|
100ec449fe | ||
|
|
790f3d46aa | ||
|
|
7404ecb11e | ||
|
|
a714bf4720 | ||
|
|
9eeedede49 | ||
|
|
3408866b79 | ||
|
|
804094bf51 | ||
|
|
869b17fe29 | ||
|
|
867aaa4c27 | ||
|
|
d43801a9b7 | ||
|
|
7eb2acaf71 | ||
|
|
0bffdf2463 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -83,6 +83,9 @@ samples/client/petstore/scala/build/
|
||||
samples/client/petstore/java/resttemplate/hello.txt
|
||||
samples/client/petstore/java/retrofit2/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
|
||||
samples/client/petstore/php/OpenAPIToolsClient-php/composer.lock
|
||||
@@ -158,6 +161,9 @@ samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt
|
||||
samples/client/petstore/python/.coverage
|
||||
samples/client/petstore/python/.projectile
|
||||
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
|
||||
samples/client/petstore/typescript-node/npm/node_modules
|
||||
|
||||
73
.travis.yml
73
.travis.yml
@@ -41,13 +41,29 @@ addons:
|
||||
- petstore.swagger.io
|
||||
|
||||
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
|
||||
- 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 ps -a
|
||||
# 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
|
||||
#- 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
|
||||
@@ -77,38 +93,41 @@ install:
|
||||
|
||||
script:
|
||||
# fail fast
|
||||
- set -ev
|
||||
- set -e
|
||||
# fail if templates/generators contain carriage return '\r'
|
||||
- /bin/bash ./bin/utils/detect_carriage_return.sh
|
||||
# fail if generators contain merge conflicts
|
||||
- /bin/bash ./bin/utils/detect_merge_conflict.sh
|
||||
# fail if generators contain tab '\t'
|
||||
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
|
||||
- mvn verify
|
||||
# run integration tests defined in maven pom.xml
|
||||
- mvn --quiet clean install
|
||||
- mvn --quiet verify -Psamples
|
||||
after_success:
|
||||
## docker build and push images to DockerHub (openapi-generator-online, openapi-generator-cli)
|
||||
- set -ev
|
||||
- read -r MVN_VERSION_FOR_DOCKER_TAG < target/ci/version-for-docker-tag.txt
|
||||
- echo "Tag for Docker derived from maven version -> $MVN_VERSION_FOR_DOCKER_TAG"; sleep 5;
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then
|
||||
echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin;
|
||||
if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online;
|
||||
docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli;
|
||||
elif [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
docker build -t $DOCKER_GENERATOR_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online;
|
||||
docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli;
|
||||
else
|
||||
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online;
|
||||
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli;
|
||||
fi;
|
||||
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && ([ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "3.1.x" ] || [ "$TRAVIS_BRANCH" == "4.0.x" ]); then
|
||||
docker push $DOCKER_GENERATOR_IMAGE_NAME;
|
||||
echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME";
|
||||
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME;
|
||||
echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
|
||||
fi;
|
||||
# push to maven repo
|
||||
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
if [ "$TRAVIS_BRANCH" = "master" ]; then
|
||||
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
cd modules/openapi-generator-gradle-plugin;
|
||||
./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;
|
||||
echo "Finished ./gradlew uploadArchives";
|
||||
popd;
|
||||
elif ([ "$TRAVIS_BRANCH" == "3.1.x" ] || [ "$TRAVIS_BRANCH" == "4.0.x" ]) ; then
|
||||
mvn clean deploy --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
cd modules/openapi-generator-gradle-plugin;
|
||||
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
||||
echo "Finished ./gradlew uploadArchives";
|
||||
popd;
|
||||
fi;
|
||||
fi;
|
||||
sleep 5;
|
||||
## docker: build and push openapi-generator-online to DockerHub
|
||||
- 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:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
|
||||
|
||||
29
CI/.travis.yml.jdk6
Normal file
29
CI/.travis.yml.jdk6
Normal file
@@ -0,0 +1,29 @@
|
||||
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>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<url>https://github.com/openapi-tools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x
|
||||
122
CI/samples.ci/client/petstore/java/jersey2-java6/build.gradle
Normal file
122
CI/samples.ci/client/petstore/java/jersey2-java6/build.gradle
Normal file
@@ -0,0 +1,122 @@
|
||||
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,11 +2,16 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.1.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.1.1`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`3.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)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
@@ -81,7 +86,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
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)
|
||||
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.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.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.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
|
||||
@@ -120,7 +128,7 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
</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.
|
||||
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.adoc)
|
||||
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md)
|
||||
|
||||
**Gradle plugin:**
|
||||
```xml
|
||||
@@ -137,16 +145,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
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
|
||||
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
|
||||
```
|
||||
|
||||
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.0.3/openapi-generator-cli-3.0.3.jar
|
||||
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
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -193,22 +201,6 @@ 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-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
|
||||
|
||||
@@ -432,7 +424,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
|
||||
## [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/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)
|
||||
@@ -586,7 +577,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Elixir | |
|
||||
| Elm | |
|
||||
| Erlang | @tsloughter (2017/11) |
|
||||
| Go | @antihax (2017/11) @bvwells (2017/12) |
|
||||
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) |
|
||||
| Groovy | |
|
||||
| Haskell | |
|
||||
| Java | @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
|
||||
@@ -595,7 +586,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) |
|
||||
| ObjC | |
|
||||
| Perl | @wing328 (2017/07) |
|
||||
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) |
|
||||
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) @ybelenko (2018/07) |
|
||||
| PowerShell | |
|
||||
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11)|
|
||||
| R | |
|
||||
|
||||
@@ -18,6 +18,7 @@ install:
|
||||
- cmd: SET MAVEN_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: java -version
|
||||
- cmd: dir/w
|
||||
- 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"
|
||||
|
||||
@@ -25,6 +25,9 @@ then
|
||||
mvn -B clean package
|
||||
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.
|
||||
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 $@"
|
||||
|
||||
@@ -25,6 +25,9 @@ then
|
||||
mvn -B clean package
|
||||
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.
|
||||
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 $@"
|
||||
|
||||
@@ -32,4 +32,8 @@ 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"
|
||||
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 {} +
|
||||
|
||||
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
|
||||
|
||||
@@ -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/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
|
||||
32
bin/openapi3/ruby-client-petstore.sh
Executable file
32
bin/openapi3/ruby-client-petstore.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/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.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
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 $@"
|
||||
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 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -27,6 +27,6 @@ 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 -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 $@"
|
||||
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 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
6
bin/python-petstore-all.sh
Executable file
6
bin/python-petstore-all.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# update python petstore clients
|
||||
|
||||
./bin/python-asyncio-petstore.sh
|
||||
./bin/python-petstore.sh
|
||||
./bin/python-tornado-petstore.sh
|
||||
32
bin/ruby-client-petstore.sh
Executable file
32
bin/ruby-client-petstore.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/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.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
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 $@"
|
||||
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 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -27,6 +27,6 @@ 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/rails5 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/rails5 $@"
|
||||
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 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -27,6 +27,6 @@ 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 $@"
|
||||
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 $@"
|
||||
|
||||
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/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,14 +17,19 @@ sleep 5
|
||||
./bin/kotlin-client-petstore.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-server-petstore.shl> /dev/null 2>&1
|
||||
./bin/kotlin-server-petstore.sh > /dev/null 2>&1
|
||||
./bin/php-petstore.sh > /dev/null 2>&1
|
||||
./bin/php-silex-petstore-server.shj> /dev/null 2>&1
|
||||
./bin/php-silex-petstore-server.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-slim-petstore-server.sh > /dev/null 2>&1
|
||||
./bin/php-slim-server-petstore.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/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:
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
|
||||
196
bin/utils/release_checkout.rb
Executable file
196
bin/utils/release_checkout.rb
Executable file
@@ -0,0 +1,196 @@
|
||||
#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
|
||||
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
|
||||
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
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,9 +4,6 @@ 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 -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
|
||||
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
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,9 +4,6 @@ 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 -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
|
||||
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
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
@@ -7,8 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
|
||||
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
|
||||
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,10 +0,0 @@
|
||||
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%
|
||||
2
bin/windows/typescript-node-petstore-all.bat
Normal file
2
bin/windows/typescript-node-petstore-all.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
call .\bin\windows\typescript-node-petstore.bat
|
||||
call .\bin\windows\typescript-node-petstore-with-npm.bat
|
||||
45
circle.yml
45
circle.yml
@@ -12,6 +12,13 @@ jobs:
|
||||
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
||||
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
||||
steps:
|
||||
# Restore the dependency cache
|
||||
- restore_cache:
|
||||
keys:
|
||||
# Default branch if not
|
||||
- source-v1-{{ .Branch }}-{{ .Revision }}
|
||||
- source-v1-{{ .Branch }}-
|
||||
- source-v1-
|
||||
# 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
|
||||
# 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.
|
||||
@@ -31,13 +38,6 @@ jobs:
|
||||
' | sudo tee -a /etc/hosts
|
||||
# Dependencies
|
||||
# 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
|
||||
- run: sudo add-apt-repository ppa:duggan/bats --yes
|
||||
- run: sudo apt-get update -qq
|
||||
@@ -67,9 +67,22 @@ jobs:
|
||||
- run: cat /etc/hosts
|
||||
# This is based on your 1.0 configuration file or project settings
|
||||
- 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_cache:
|
||||
key: v1-dep-{{ .Branch }}
|
||||
key: source-v1-{{ .Branch }}-{{ .Revision }}
|
||||
paths:
|
||||
# This is a broad list of cache paths to include many possible development environments
|
||||
# You can probably delete some of these entries
|
||||
@@ -81,21 +94,7 @@ jobs:
|
||||
- ~/.go_workspace
|
||||
- ~/.gradle
|
||||
- ~/.cache/bower
|
||||
# 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
|
||||
- ".git"
|
||||
# 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
|
||||
# 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
|
||||
|
||||
- `rust-server`
|
||||
- `apex`
|
||||
- ~~rust-server~~ (migrated)
|
||||
- `apex` (migration scheduled in Jul/Aug 2018)
|
||||
|
||||
and we welcome contributions from the community to help with the migration
|
||||
|
||||
|
||||
@@ -37,3 +37,6 @@ 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.
|
||||
|
||||
#### 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>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.openapitools.codegen;
|
||||
|
||||
import io.airlift.airline.Cli;
|
||||
import io.airlift.airline.Help;
|
||||
import io.airlift.airline.ParseArgumentsUnexpectedException;
|
||||
import io.airlift.airline.ParseOptionMissingException;
|
||||
import io.airlift.airline.ParseOptionMissingValueException;
|
||||
import org.openapitools.codegen.cmd.*;
|
||||
@@ -67,6 +68,9 @@ public class OpenAPIGenerator {
|
||||
if (args.length == 0) {
|
||||
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) {
|
||||
System.err.printf("[error] %s%n", e.getMessage());
|
||||
System.exit(1);
|
||||
|
||||
@@ -23,18 +23,41 @@ import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
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")
|
||||
public class ConfigHelp implements Runnable {
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language",
|
||||
description = "language to get config help for")
|
||||
private String lang;
|
||||
|
||||
@Option(name = {"-g", "--generator-name"}, title = "generator name",
|
||||
description = "generator to get config help for")
|
||||
private String generatorName;
|
||||
|
||||
@Override
|
||||
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 {
|
||||
CodegenConfig config = CodegenConfigLoader.forName(lang);
|
||||
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
|
||||
System.out.println();
|
||||
System.out.println("CONFIG OPTIONS");
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
@@ -49,4 +72,4 @@ public class ConfigHelp implements Runnable {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.3"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
openApiGeneratorVersion=3.1.0-SNAPSHOT
|
||||
openApiGeneratorVersion=3.1.1
|
||||
|
||||
# BEGIN placeholders
|
||||
# these are just placeholders to allow contributors to build directly
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<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:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=3.0.3 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=3.1.1 openApiValidate
|
||||
```
|
||||
|
||||
@@ -1 +1 @@
|
||||
openApiGeneratorVersion=3.0.1
|
||||
openApiGeneratorVersion=3.1.1
|
||||
|
||||
@@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine
|
||||
|
||||
WORKDIR /generator
|
||||
|
||||
COPY target/openapi-generator-online-3.1.0-SNAPSHOT.jar /generator/openapi-generator-online.jar
|
||||
COPY target/openapi-generator-online-3.1.1.jar /generator/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-online</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>3.1.1</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -198,31 +198,16 @@
|
||||
<guava-version>20.0</guava-version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-core</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.parser.v3</groupId>
|
||||
<artifactId>swagger-parser-core</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
</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>
|
||||
<groupId>io.swagger.parser.v3</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.samskivert</groupId>
|
||||
<artifactId>jmustache</artifactId>
|
||||
|
||||
@@ -213,6 +213,9 @@ public class CodegenConstants {
|
||||
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 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.
|
||||
|
||||
public static final String GENERATE_APIS = "generateApis";
|
||||
|
||||
@@ -1110,7 +1110,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* Return the example value of the parameter.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param parameter Parameter
|
||||
* @param parameter Parameter
|
||||
*/
|
||||
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
|
||||
if (parameter.getExample() != null) {
|
||||
@@ -1120,7 +1120,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
|
||||
Example example = parameter.getExamples().values().iterator().next();
|
||||
if(example.getValue() != null) {
|
||||
if (example.getValue() != null) {
|
||||
codegenParameter.example = example.getValue().toString();
|
||||
return;
|
||||
}
|
||||
@@ -1139,7 +1139,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* Return the example value of the parameter.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param requestBody Request body
|
||||
* @param requestBody Request body
|
||||
*/
|
||||
public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) {
|
||||
Content content = requestBody.getContent();
|
||||
@@ -1157,7 +1157,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty()) {
|
||||
Example example = mediaType.getExamples().values().iterator().next();
|
||||
if(example.getValue() != null) {
|
||||
if (example.getValue() != null) {
|
||||
codegenParameter.example = example.getValue().toString();
|
||||
return;
|
||||
}
|
||||
@@ -1614,7 +1614,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.isInteger = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isStringSchema(schema)){
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
m.isString = Boolean.TRUE;
|
||||
}
|
||||
|
||||
@@ -4373,19 +4373,33 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (schema.getAdditionalProperties() != null) {// http body is map
|
||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||
} else if (codegenProperty != null) {
|
||||
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";
|
||||
String codegenModelName, codegenModelDescription;
|
||||
|
||||
codegenParameter.baseName = codegenProperty.baseType;
|
||||
codegenParameter.baseType = codegenProperty.baseType;
|
||||
codegenParameter.dataType = codegenProperty.dataType;
|
||||
codegenParameter.description = codegenProperty.description;
|
||||
codegenParameter.paramName = toParamName(codegenProperty.baseType);
|
||||
if (codegenModel != null) {
|
||||
codegenModelName = codegenModel.classname;
|
||||
codegenModelDescription = codegenModel.description;
|
||||
} else {
|
||||
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("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) {
|
||||
imports.add(codegenProperty.complexType);
|
||||
@@ -4468,6 +4482,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
public boolean isDataTypeString(String dataType) {
|
||||
return "String".equals(dataType);
|
||||
return "String".equals(dataType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +265,15 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// Not using the supertype invocation, because we want to UpperCamelize
|
||||
// the type.
|
||||
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)) {
|
||||
return typeMapping.get(openAPIType);
|
||||
}
|
||||
@@ -283,8 +292,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
String ref = p.get$ref();
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
|
||||
if(ref != null && !ref.isEmpty()) {
|
||||
type = openAPIType;
|
||||
} else if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return (type);
|
||||
|
||||
@@ -127,6 +127,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
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");
|
||||
@@ -170,17 +171,25 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
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)) {
|
||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||
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)) {
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
|
||||
// Update api package to contain the specified api 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)) {
|
||||
// this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
||||
@@ -329,7 +338,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
} else if (!StringUtils.isEmpty(p.get$ref())) { // model
|
||||
} else if (StringUtils.isNotBlank(p.get$ref())) { // model
|
||||
String type = super.getTypeDeclaration(p);
|
||||
return (!languageSpecificPrimitives.contains(type))
|
||||
? "\\" + modelPackage + "\\" + type : type;
|
||||
@@ -542,11 +551,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
type = p.dataType;
|
||||
}
|
||||
|
||||
if ("String".equalsIgnoreCase(type)) {
|
||||
if ("String".equalsIgnoreCase(type) || p.isString) {
|
||||
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)) {
|
||||
if (example == null) {
|
||||
example = "56";
|
||||
@@ -559,21 +568,23 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
if (example == null) {
|
||||
example = "True";
|
||||
}
|
||||
} else if ("\\SplFileObject".equalsIgnoreCase(type)) {
|
||||
} else if ("\\SplFileObject".equalsIgnoreCase(type) || p.isFile) {
|
||||
if (example == null) {
|
||||
example = "/path/to/file";
|
||||
example = "/path/to/file.txt";
|
||||
}
|
||||
example = "\"" + escapeText(example) + "\"";
|
||||
} else if ("Date".equalsIgnoreCase(type)) {
|
||||
} else if ("\\Date".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "2013-10-20";
|
||||
}
|
||||
example = "new \\DateTime(\"" + escapeText(example) + "\")";
|
||||
} else if ("DateTime".equalsIgnoreCase(type)) {
|
||||
} 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) + "()";
|
||||
@@ -631,8 +642,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
if (isReservedWord(enumName) || enumName.matches("\\d.*")) { // reserved word or starts with number
|
||||
return escapeReservedWord(enumName);
|
||||
} else {
|
||||
return enumName;
|
||||
}
|
||||
@@ -642,6 +653,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
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 {
|
||||
@@ -660,6 +674,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
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;
|
||||
@@ -673,7 +689,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "");
|
||||
return input.replace("*/", "*_/").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) {
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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) + ">";
|
||||
} else if (ModelUtils.isStringSchema(p)
|
||||
|| ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)
|
||||
|| ModelUtils.isFileSchema(p)
|
||||
|| ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p)
|
||||
|| languageSpecificPrimitives.contains(openAPIType)) {
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
|
||||
@@ -57,18 +57,6 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
public NodeJSServerCodegen() {
|
||||
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
|
||||
outputFolder = "generated-code/nodejs";
|
||||
|
||||
@@ -310,6 +298,18 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
public void 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)) {
|
||||
setGoogleCloudFunctions(
|
||||
Boolean.valueOf(additionalProperties.get(GOOGLE_CLOUD_FUNCTIONS).toString()));
|
||||
|
||||
@@ -18,57 +18,28 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
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.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
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.LoggerFactory;
|
||||
|
||||
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public class PhpClientCodegen extends AbstractPhpCodegen {
|
||||
@SuppressWarnings("hiding")
|
||||
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_PROJECT_NAME = "composerProjectName";
|
||||
protected String invokerPackage = "OpenAPI\\Client";
|
||||
protected String composerVendorName = 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() {
|
||||
super();
|
||||
@@ -77,144 +48,30 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
setInvokerPackage("OpenAPI\\Client");
|
||||
setApiPackage(getInvokerPackage() + "\\" + apiDirName);
|
||||
setModelPackage(getInvokerPackage() + "\\" + modelDirName);
|
||||
setPackagePath("OpenAPIClient-php");
|
||||
supportsInheritance = true;
|
||||
outputFolder = "generated-code" + File.separator + "php";
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
apiTemplateFiles.put("api.mustache", ".php");
|
||||
setOutputDir("generated-code" + File.separator + "php");
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".php");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".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
|
||||
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
|
||||
List sortedLanguageSpecificPrimitives = new ArrayList(languageSpecificPrimitives);
|
||||
Collections.sort(sortedLanguageSpecificPrimitives);
|
||||
String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'";
|
||||
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(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(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)
|
||||
.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
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
@@ -234,89 +91,18 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void 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)) {
|
||||
this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
|
||||
} else {
|
||||
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)) {
|
||||
this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
|
||||
} else {
|
||||
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("Configuration.mustache", toPackagePath(invokerPackage, srcBasePath), "Configuration.php"));
|
||||
supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", toPackagePath(invokerPackage, srcBasePath), "ObjectSerializer.php"));
|
||||
@@ -330,124 +116,6 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
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) {
|
||||
this.composerVendorName = composerVendorName;
|
||||
}
|
||||
@@ -455,291 +123,4 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void setComposerProjectName(String 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,26 +48,21 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
variableNamingConvention = "camelCase";
|
||||
artifactVersion = "1.0.0";
|
||||
packagePath = ""; // empty packagePath (top folder)
|
||||
invokerPackage = camelize("OpenAPIServer");
|
||||
modelPackage = packagePath + "\\Models";
|
||||
apiPackage = packagePath;
|
||||
setInvokerPackage("OpenAPIServer");
|
||||
apiPackage = invokerPackage + "\\" + apiDirName;
|
||||
modelPackage = invokerPackage + "\\" + modelDirName;
|
||||
outputFolder = "generated-code" + File.separator + "slim";
|
||||
|
||||
// no api files
|
||||
apiTemplateFiles.clear();
|
||||
// no test files
|
||||
apiTestTemplateFiles.clear();
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".php");
|
||||
// no doc files
|
||||
modelDocTemplateFiles.clear();
|
||||
apiDocTemplateFiles.clear();
|
||||
|
||||
embeddedTemplateDir = templateDir = "php-slim-server";
|
||||
|
||||
// additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||
// additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
|
||||
|
||||
// override cliOptions from AbstractPhpCodegen
|
||||
for (CliOption co : cliOptions) {
|
||||
if (co.getOpt().equals(AbstractPhpCodegen.VARIABLE_NAMING_CONVENTION)) {
|
||||
@@ -76,12 +71,6 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
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
|
||||
@@ -99,6 +88,38 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
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
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
|
||||
@@ -159,6 +159,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.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("asyncio", "Asyncio-based client (python 3.5+)");
|
||||
@@ -198,10 +200,22 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
setPackageVersion("1.0.0");
|
||||
}
|
||||
|
||||
Boolean generateSourceCodeOnly = false;
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) {
|
||||
generateSourceCodeOnly = true;
|
||||
}
|
||||
|
||||
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
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
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
@@ -210,12 +224,24 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
setPackageUrl((String) additionalProperties.get(PACKAGE_URL));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
String readmePath ="README.md";
|
||||
String readmeTemplate = "README.mustache";
|
||||
if (generateSourceCodeOnly) {
|
||||
readmePath = packageName + "_" + readmePath;
|
||||
readmeTemplate = "README_onlypackage.mustache";
|
||||
}
|
||||
supportingFiles.add(new SupportingFile(readmeTemplate, "", readmePath));
|
||||
|
||||
supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini"));
|
||||
supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("requirements.mustache", "", "requirements.txt"));
|
||||
if (!generateSourceCodeOnly){
|
||||
supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini"));
|
||||
supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-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("__init__package.mustache", packageName, "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__model.mustache", packageName + File.separatorChar + modelPackage, "__init__.py"));
|
||||
@@ -224,10 +250,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (Boolean.FALSE.equals(excludeTests)) {
|
||||
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"));
|
||||
|
||||
if ("asyncio".equals(getLibrary())) {
|
||||
|
||||
@@ -18,14 +18,11 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -37,7 +34,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
|
||||
public static final String GEM_NAME = "gemName";
|
||||
public static final String MODULE_NAME = "moduleName";
|
||||
@@ -81,7 +78,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
apiTemplateFiles.put("api.mustache", ".rb");
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
embeddedTemplateDir = templateDir = "ruby";
|
||||
embeddedTemplateDir = templateDir = "ruby-client";
|
||||
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".rb");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".rb");
|
||||
@@ -89,21 +86,13 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// default HIDE_GENERATION_TIMESTAMP to true
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
"local_var_path", "query_params", "header_params", "_header_accept", "_header_accept_result",
|
||||
"_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")
|
||||
);
|
||||
// local variable names used in API methods (endpoints)
|
||||
for (String word : Arrays.asList(
|
||||
"local_var_path", "query_params", "header_params", "_header_accept", "_header_accept_result",
|
||||
"_header_content_type", "form_params", "post_body", "auth_names")) {
|
||||
reservedWords.add(word.toLowerCase());
|
||||
}
|
||||
|
||||
typeMapping.clear();
|
||||
languageSpecificPrimitives.clear();
|
||||
|
||||
// primitives in ruby lang
|
||||
languageSpecificPrimitives.add("int");
|
||||
@@ -111,37 +100,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
languageSpecificPrimitives.add("map");
|
||||
languageSpecificPrimitives.add("string");
|
||||
// primitives in the typeMapping
|
||||
languageSpecificPrimitives.add("String");
|
||||
languageSpecificPrimitives.add("Integer");
|
||||
languageSpecificPrimitives.add("Float");
|
||||
languageSpecificPrimitives.add("Date");
|
||||
languageSpecificPrimitives.add("DateTime");
|
||||
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("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
|
||||
Iterator<CliOption> itr = cliOptions.iterator();
|
||||
@@ -308,14 +268,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return underscore(moduleName.replaceAll("[^\\w]+", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + libFolder + File.separator + gemName + File.separator + apiPackage.replace("/", File.separator);
|
||||
@@ -346,34 +298,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
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
|
||||
public String getSchemaType(Schema schema) {
|
||||
String openAPIType = super.getSchemaType(schema);
|
||||
@@ -394,33 +318,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
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
|
||||
public String toModelName(String name) {
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
@@ -684,16 +581,4 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
//
|
||||
//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,30 +18,19 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
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.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.core.util.Yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubyOnRailsServerCodegen.class);
|
||||
private static final SimpleDateFormat MIGRATE_FILE_NAME_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
@@ -85,35 +74,16 @@ public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenC
|
||||
modelPackage = "app/models";
|
||||
modelTemplateFiles.put("model.mustache", ".rb");
|
||||
|
||||
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")
|
||||
);
|
||||
embeddedTemplateDir = templateDir = "ruby-on-rails-server";
|
||||
|
||||
// In order to adapt to DB migrate script, overwrite typeMapping
|
||||
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", "decimal");
|
||||
typeMapping.put("number", "float");
|
||||
typeMapping.put("date", "date");
|
||||
typeMapping.put("DateTime", "datetime");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
// remove modelPackage and apiPackage added by default
|
||||
cliOptions.clear();
|
||||
@@ -203,59 +173,11 @@ public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenC
|
||||
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
|
||||
public String apiFileFolder() {
|
||||
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
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
@@ -266,12 +188,6 @@ public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenC
|
||||
return "string";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
@@ -318,32 +234,9 @@ public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenC
|
||||
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
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateYAMLSpecFile(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,29 +17,18 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
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.core.util.Yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubySinatraServerCodegen.class);
|
||||
|
||||
@@ -56,36 +45,7 @@ public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenC
|
||||
// no model
|
||||
modelTemplateFiles.clear();
|
||||
apiTemplateFiles.put("api.mustache", ".rb");
|
||||
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");
|
||||
embeddedTemplateDir = templateDir = "ruby-sinatra-server";
|
||||
|
||||
// remove modelPackage and apiPackage added by default
|
||||
cliOptions.clear();
|
||||
@@ -122,32 +82,11 @@ public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenC
|
||||
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
|
||||
public String apiFileFolder() {
|
||||
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 getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
@@ -166,39 +105,6 @@ public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenC
|
||||
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
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
@@ -243,32 +149,9 @@ public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenC
|
||||
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
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateYAMLSpecFile(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,7 +576,9 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
allParams.add(p);
|
||||
}
|
||||
}
|
||||
allParams.get(allParams.size()-1).hasMore =false;
|
||||
if (!allParams.isEmpty()) {
|
||||
allParams.get(allParams.size()-1).hasMore =false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -135,9 +135,21 @@ public class URLPathUtils {
|
||||
}
|
||||
|
||||
private static String sanitizeUrl(String url) {
|
||||
if (url.startsWith("/")) {
|
||||
LOGGER.warn("'host' not defined in the spec (2.0). Default to " + LOCAL_HOST);
|
||||
if (url.startsWith("//")) {
|
||||
url = "http:" + url;
|
||||
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;
|
||||
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;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
## Requirements
|
||||
|
||||
Building the API client library requires:
|
||||
1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+
|
||||
1. Java {{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}+
|
||||
2. Maven/Gradle
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -31,6 +31,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -39,6 +44,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -83,6 +89,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@@ -91,6 +102,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -84,8 +90,20 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
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 {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -291,7 +291,7 @@
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<swagger-core-version>1.5.18</swagger-core-version>
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -84,6 +90,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@@ -92,6 +103,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -139,6 +139,11 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
{{#supportJava6}}
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -147,6 +152,7 @@
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -709,12 +709,12 @@ public class ApiClient {
|
||||
Map<String, List<String>> responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return new ApiResponse<>(statusCode, responseHeaders);
|
||||
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders);
|
||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||
if (returnType == null)
|
||||
return new ApiResponse<>(statusCode, responseHeaders);
|
||||
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders);
|
||||
else
|
||||
return new ApiResponse<>(statusCode, responseHeaders, deserialize(response, returnType));
|
||||
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders, deserialize(response, returnType));
|
||||
} else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -83,6 +89,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@@ -91,6 +102,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
@@ -105,17 +117,20 @@ if(hasProperty('target') && target == 'android') {
|
||||
}
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.17"
|
||||
jackson_version = "2.8.9"
|
||||
swagger_annotations_version = "1.5.20"
|
||||
jackson_version = "2.9.6"
|
||||
{{#supportJava6}}
|
||||
jersey_version = "2.6"
|
||||
commons_io_version=2.5
|
||||
commons_lang3_version=3.6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
jersey_version = "2.25.1"
|
||||
jersey_version = "2.27"
|
||||
{{/supportJava6}}
|
||||
junit_version = "4.12"
|
||||
{{#threetenbp}}
|
||||
threetenbp_version = "2.6.4"
|
||||
{{/threetenbp}}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -127,17 +142,17 @@ dependencies {
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||
{{#joda}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
{{/joda}}
|
||||
{{#java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||
{{/java8}}
|
||||
{{#supportJava6}}
|
||||
compile "commons-io:commons-io:$commons_io_version"
|
||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||
{{/supportJava6}}
|
||||
{{#threetenbp}}
|
||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
||||
{{/threetenbp}}
|
||||
{{^java8}}
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
|
||||
@@ -9,13 +9,13 @@ lazy val root = (project in file(".")).
|
||||
publishArtifact in (Compile, packageDoc) := false,
|
||||
resolvers += Resolver.mavenLocal,
|
||||
libraryDependencies ++= Seq(
|
||||
"io.swagger" % "swagger-annotations" % "1.5.17",
|
||||
"io.swagger" % "swagger-annotations" % "1.5.20",
|
||||
"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-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.8.9" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.8.9" % "compile",
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.8.9" % "compile",
|
||||
{{#joda}}
|
||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.8.9" % "compile",
|
||||
{{/joda}}
|
||||
|
||||
@@ -139,6 +139,11 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
{{#supportJava6}}
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -147,6 +152,7 @@
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -270,7 +276,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.joschi.jackson</groupId>
|
||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
<version>${threetenbp-version}</version>
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
{{^java8}}
|
||||
@@ -312,16 +318,19 @@
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<swagger-core-version>1.5.18</swagger-core-version>
|
||||
<swagger-core-version>1.5.20</swagger-core-version>
|
||||
{{^supportJava6}}
|
||||
<jersey-version>2.25.1</jersey-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
{{/supportJava6}}
|
||||
{{#supportJava6}}
|
||||
<jersey-version>2.6</jersey-version>
|
||||
<commons_io_version>2.5</commons_io_version>
|
||||
<commons_lang3_version>3.6</commons_lang3_version>
|
||||
<jersey-version>2.6</jersey-version>
|
||||
<commons_io_version>2.5</commons_io_version>
|
||||
<commons_lang3_version>3.6</commons_lang3_version>
|
||||
{{/supportJava6}}
|
||||
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
{{#threetenbp}}
|
||||
<threetenbp-version>2.6.4</threetenbp-version>
|
||||
{{/threetenbp}}
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
</properties>
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -84,8 +90,20 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
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 {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -267,7 +267,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<gson-fire-version>1.8.0</gson-fire-version>
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 23
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -83,6 +89,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@@ -91,6 +102,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -120,6 +120,11 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
{{#supportJava6}}
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -128,6 +133,7 @@
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -84,6 +90,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@@ -92,6 +103,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -139,6 +139,11 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
{{#supportJava6}}
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -147,6 +152,7 @@
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
|
||||
@@ -139,8 +139,20 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</source>
|
||||
<target>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</target>
|
||||
{{#supportJava6}}
|
||||
<source>1.6</source>
|
||||
<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>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
@@ -84,8 +90,20 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
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 {
|
||||
repositories.mavenInstaller {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ApiClient {
|
||||
|
||||
public ApiClient() {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}
|
||||
authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}
|
||||
// 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 OAuth());{{/isOAuth}}{{/authMethods}}
|
||||
@@ -57,8 +57,8 @@ public class ApiClient {
|
||||
basePath = basePath + "/";
|
||||
}
|
||||
|
||||
Map<String, String> extraHeaders = new HashMap<>();
|
||||
List<Pair> extraQueryParams = new ArrayList<>();
|
||||
Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
|
||||
List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>();
|
||||
|
||||
for (String authName : authentications.keySet()) {
|
||||
Authentication auth = authentications.get(authName);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ApiClient {
|
||||
|
||||
public ApiClient() {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}
|
||||
authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}
|
||||
// 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 OAuth());{{/isOAuth}}{{/authMethods}}
|
||||
@@ -57,8 +57,8 @@ public class ApiClient {
|
||||
basePath = basePath + "/";
|
||||
}
|
||||
|
||||
Map<String, String> extraHeaders = new HashMap<>();
|
||||
List<Pair> extraQueryParams = new ArrayList<>();
|
||||
Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
|
||||
List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>();
|
||||
|
||||
for (String authName : authentications.keySet()) {
|
||||
Authentication auth = authentications.get(authName);
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<gson-fire-version>1.8.0</gson-fire-version>
|
||||
|
||||
@@ -139,6 +139,11 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
{{#supportJava6}}
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -147,6 +152,7 @@
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -206,8 +206,8 @@
|
||||
{{#useBeanValidation}}
|
||||
<beanvalidation-version>1.1.0.Final</beanvalidation-version>
|
||||
{{/useBeanValidation}}
|
||||
<cxf-version>3.2.1</cxf-version>
|
||||
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
|
||||
<cxf-version>3.2.5</cxf-version>
|
||||
<jackson-jaxrs-version>2.9.6</jackson-jaxrs-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -263,8 +263,8 @@
|
||||
{{#generateSpringBootApplication}}
|
||||
<spring.boot-version>1.5.9.RELEASE</spring.boot-version>
|
||||
{{/generateSpringBootApplication}}
|
||||
<cxf-version>3.2.1</cxf-version>
|
||||
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
|
||||
<cxf-version>3.2.5</cxf-version>
|
||||
<jackson-jaxrs-version>2.9.6</jackson-jaxrs-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -56,6 +56,11 @@ android {
|
||||
{{/androidSdkVersion}}
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -64,6 +69,7 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
|
||||
@@ -35,6 +35,11 @@ android {
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
{{#supportJava6}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
{{/supportJava6}}
|
||||
{{^supportJava6}}
|
||||
{{#java8}}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -43,6 +48,7 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{{/java8}}
|
||||
{{/supportJava6}}
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
|
||||
@@ -67,9 +67,10 @@ 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) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
{{#returnType}}
|
||||
localVarReturnValue {{{returnType}}}
|
||||
{{/returnType}}
|
||||
@@ -177,6 +178,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
||||
{{#hasFormParams}}
|
||||
{{#formParams}}
|
||||
{{#isFile}}
|
||||
localVarFormFileName = "{{baseName}}"
|
||||
{{#required}}
|
||||
localVarFile := {{paramName}}
|
||||
{{/required}}
|
||||
@@ -254,7 +256,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
||||
|
||||
{{/isApiKey}}
|
||||
{{/authMethods}}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
|
||||
}
|
||||
|
||||
@@ -142,6 +142,8 @@ func parameterToString(obj interface{}, collectionFormat string) string {
|
||||
|
||||
if reflect.TypeOf(obj).Kind() == reflect.Slice {
|
||||
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)
|
||||
@@ -165,6 +167,7 @@ func (c *APIClient) prepareRequest(
|
||||
headerParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams url.Values,
|
||||
formFileName string,
|
||||
fileName string,
|
||||
fileBytes []byte) (localVarRequest *http.Request, err error) {
|
||||
|
||||
@@ -207,7 +210,7 @@ func (c *APIClient) prepareRequest(
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
w.Boundary()
|
||||
//_, fileNm := filepath.Split(fileName)
|
||||
part, err := w.CreateFormFile("file", filepath.Base(fileName))
|
||||
part, err := w.CreateFormFile(formFileName, filepath.Base(fileName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -427,8 +430,9 @@ func CacheExpires(r *http.Response) time.Time {
|
||||
lifetime, err := time.ParseDuration(maxAge + "s")
|
||||
if err != nil {
|
||||
expires = now
|
||||
} else {
|
||||
expires = now.Add(lifetime)
|
||||
}
|
||||
expires = now.Add(lifetime)
|
||||
} else {
|
||||
expiresHeader := r.Header.Get("Expires")
|
||||
if expiresHeader != "" {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?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}}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?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}}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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}}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"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