forked from loafle/openapi-generator-original
Compare commits
10 Commits
v3.2.0
...
travis_tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2177039d7c | ||
|
|
8544382d53 | ||
|
|
151017b672 | ||
|
|
6095a0676c | ||
|
|
d3153a8eae | ||
|
|
f2f10b429e | ||
|
|
f7d31a3eab | ||
|
|
72f6bda2f7 | ||
|
|
3e99d2df73 | ||
|
|
44caf2e7cf |
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
|
||||
- [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\bin\windows\`.
|
||||
- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.0.x`. Default: `master`.
|
||||
- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `3.1.x`, `4.0.x`. Default: `master`.
|
||||
- [ ] Copied the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language.
|
||||
|
||||
### Description of the PR
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -83,9 +83,6 @@ 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
|
||||
@@ -99,8 +96,6 @@ samples/client/petstore/silex/SwaggerServer/venodr/
|
||||
samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/cache/
|
||||
samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/logs/
|
||||
|
||||
#PHP-laravel
|
||||
samples/server/petstore/php-laravel/node_modules
|
||||
|
||||
# Perl
|
||||
samples/client/petstore/perl/deep_module_test/
|
||||
@@ -163,9 +158,6 @@ 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
|
||||
|
||||
90
.travis.yml
90
.travis.yml
@@ -30,46 +30,24 @@ cache:
|
||||
- $HOME/perl5
|
||||
- $HOME/.cargo
|
||||
- $HOME/.stack
|
||||
- $HOME/samples/server/petstore/cpp-pistache/pistache
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
# comment out the host table change to use the public petstore server
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-5
|
||||
chrome: stable
|
||||
hosts:
|
||||
- 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
|
||||
@@ -92,51 +70,45 @@ before_install:
|
||||
|
||||
install:
|
||||
# Add Godeps dependencies to GOPATH and PATH
|
||||
#- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
|
||||
#- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
|
||||
- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$HOME/.cargo/bin:$PATH"
|
||||
#- go version
|
||||
- gcc -v
|
||||
- echo $CC
|
||||
- echo $CXX
|
||||
- go version
|
||||
|
||||
script:
|
||||
# fail fast
|
||||
- set -e
|
||||
- set -ev
|
||||
# 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
|
||||
# run integration tests defined in maven pom.xml
|
||||
- mvn --quiet clean install
|
||||
- mvn --quiet verify -Psamples
|
||||
- mvn verify
|
||||
after_success:
|
||||
# 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" == "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;
|
||||
## 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;
|
||||
fi;
|
||||
## 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
|
||||
|
||||
sleep 5;
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
language: java
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- openjdk-6-jdk
|
||||
jdk: openjdk6
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
- $HOME/.ivy2
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
||||
|
||||
install:
|
||||
- jdk_switcher use openjdk6
|
||||
- java -version
|
||||
- curl -s "https://get.sdkman.io" | bash
|
||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
- sdk version
|
||||
- sdk install gradle 2.9
|
||||
- sdk list gradle
|
||||
- sdk version
|
||||
- gradle --version
|
||||
|
||||
script:
|
||||
- cd samples/client/petstore/java/jersey2-java6 && gradle test
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
NODE_INDEX=${CIRCLE_NODE_INDEX:-0}
|
||||
|
||||
|
||||
if [ "$NODE_INDEX" = "1" ]; then
|
||||
echo "Running node $NODE_INDEX to test CI/pom.xml.circleci ..."
|
||||
cp CI/pom.xml.circleci pom.xml
|
||||
java -version
|
||||
mvn --quiet verify -Psamples
|
||||
else
|
||||
echo "Running node $NODE_INDEX to test CI/pom.xml.circleci.java7 ..."
|
||||
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||
java -version
|
||||
cp CI/pom.xml.circleci.java7 pom.xml
|
||||
mvn --quiet verify -Psamples
|
||||
fi
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<url>https://github.com/openapi-tools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
|
||||
@@ -920,7 +920,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-parser-version>2.0.2-OpenAPITools.org-1</swagger-parser-version>
|
||||
<swagger-parser-version>2.0.1</swagger-parser-version>
|
||||
<swagger-core-version>2.0.1</swagger-core-version>
|
||||
<scala-version>2.11.1</scala-version>
|
||||
<felix-version>3.3.0</felix-version>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -844,12 +844,10 @@
|
||||
<module>samples/client/petstore/java/feign</module>
|
||||
<module>samples/client/petstore/java/jersey1</module>
|
||||
<module>samples/client/petstore/java/jersey2</module>
|
||||
<module>samples/client/petstore/java/jersey2-java8</module>
|
||||
<module>samples/client/petstore/java/okhttp-gson</module>
|
||||
<module>samples/client/petstore/java/retrofit</module>
|
||||
<module>samples/client/petstore/java/retrofit2</module>
|
||||
<module>samples/client/petstore/java/retrofit2rx</module>
|
||||
<module>samples/client/petstore/java/retrofit2-play25</module>
|
||||
<module>samples/client/petstore/jaxrs-cxf-client</module>
|
||||
<module>samples/client/petstore/java/resttemplate</module>
|
||||
<module>samples/client/petstore/java/resttemplate-withXml</module>
|
||||
@@ -976,7 +974,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-parser-version>2.0.2-OpenAPITools.org-1</swagger-parser-version>
|
||||
<swagger-parser-version>2.0.1</swagger-parser-version>
|
||||
<swagger-core-version>2.0.1</swagger-core-version>
|
||||
<scala-version>2.11.1</scala-version>
|
||||
<felix-version>3.3.0</felix-version>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -852,6 +852,9 @@
|
||||
<module>samples/client/petstore/java/resteasy</module>
|
||||
<module>samples/client/petstore/java/google-api-client</module>
|
||||
<module>samples/client/petstore/kotlin/</module>
|
||||
<!-- test non-java projects -->
|
||||
<!--<module>samples/client/petstore/go</module>-->
|
||||
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/java-vertx/rx</module>
|
||||
<module>samples/server/petstore/java-vertx/async</module>
|
||||
@@ -948,7 +951,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-parser-version>2.0.2-OpenAPITools.org-1</swagger-parser-version>
|
||||
<swagger-parser-version>2.0.1</swagger-parser-version>
|
||||
<swagger-core-version>2.0.1</swagger-core-version>
|
||||
<scala-version>2.11.1</scala-version>
|
||||
<felix-version>3.3.0</felix-version>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -928,7 +928,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-parser-version>2.0.2-OpenAPITools.org-1</swagger-parser-version>
|
||||
<swagger-parser-version>2.0.1</swagger-parser-version>
|
||||
<swagger-core-version>2.0.1</swagger-core-version>
|
||||
<scala-version>2.11.1</scala-version>
|
||||
<felix-version>3.3.0</felix-version>
|
||||
|
||||
1
CI/resources/version-for-docker-tag.txt
Normal file
1
CI/resources/version-for-docker-tag.txt
Normal file
@@ -0,0 +1 @@
|
||||
${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x
|
||||
@@ -1,122 +0,0 @@
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
group = 'org.openapitools'
|
||||
version = '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter {
|
||||
url "http://jcenter.bintray.com/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.+'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter {
|
||||
url "http://jcenter.bintray.com/"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '25.0.2'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_6
|
||||
targetCompatibility JavaVersion.VERSION_1_6
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
provided 'javax.annotation:jsr250-api:1.0'
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'petstore-jersey2-java6'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.20"
|
||||
jackson_version = "2.9.6"
|
||||
jersey_version = "2.6"
|
||||
commons_io_version=2.5
|
||||
commons_lang3_version=3.6
|
||||
junit_version = "4.12"
|
||||
threetenbp_version = "2.6.4"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
|
||||
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
|
||||
compile "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||
compile "commons-io:commons-io:$commons_io_version"
|
||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
@@ -14,9 +14,8 @@ COPY ./LICENSE ${GEN_DIR}
|
||||
COPY ./google_checkstyle.xml ${GEN_DIR}
|
||||
|
||||
# Modules are copied individually here to allow for caching of docker layers between major.minor versions
|
||||
COPY ./modules/openapi-generator-gradle-plugin ${GEN_DIR}/modules/openapi-generator-gradle-plugin
|
||||
# NOTE: openapi-generator-online is not included here
|
||||
COPY ./modules/openapi-generator-maven-plugin ${GEN_DIR}/modules/openapi-generator-maven-plugin
|
||||
COPY ./modules/openapi-generator-online ${GEN_DIR}/modules/openapi-generator-online
|
||||
COPY ./modules/openapi-generator-cli ${GEN_DIR}/modules/openapi-generator-cli
|
||||
COPY ./modules/openapi-generator ${GEN_DIR}/modules/openapi-generator
|
||||
COPY ./pom.xml ${GEN_DIR}
|
||||
|
||||
100
README.md
100
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.2.1`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.1.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
@@ -16,8 +16,6 @@
|
||||
<div align="center">
|
||||
|
||||
[](https://gitter.im/OpenAPITools/openapi-generator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22)
|
||||
[](https://twitter.com/oas_generator)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -83,10 +81,7 @@ 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.2.1 (current master, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.2.1-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
|
||||
[3.1.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.2) | 25.07.2018 | 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.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.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
|
||||
@@ -125,7 +120,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.md)
|
||||
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.adoc)
|
||||
|
||||
**Gradle plugin:**
|
||||
```xml
|
||||
@@ -142,16 +137,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.2/openapi-generator-cli-3.1.2.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.2/openapi-generator-cli-3.1.2.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.2/openapi-generator-cli-3.1.2.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.3/openapi-generator-cli-3.0.3.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -162,49 +157,6 @@ export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
|
||||
export PATH=${JAVA_HOME}/bin:$PATH
|
||||
```
|
||||
|
||||
### Launcher Script
|
||||
|
||||
One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator.cli.sh) which resolves this issue.
|
||||
|
||||
To install the launcher script, copy the contents of the script to a location on your path and make the script executable.
|
||||
|
||||
An example of setting this up (NOTE: Always evaluate scripts curled from external systems before executing them).
|
||||
|
||||
```
|
||||
mkdir -p ~/bin/openapitools
|
||||
curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator.cli.sh > ~/bin/openapitools/openapi-generator-cli
|
||||
chmod u+x ~/bin/openapitools/openapi-generator-cli
|
||||
export PATH=$PATH:~/bin/openapitools/
|
||||
```
|
||||
|
||||
Now, `openapi-generator-cli` is "installed". On invocation, it will query the GitHub repository for the most recently released version. If this matches the last downloaded jar,
|
||||
it will execute as normal. If a newer version is found, the script will download the latest release and execute it.
|
||||
|
||||
If you need to invoke an older version of the generator, you can define the variable `OPENAPI_GENERATOR_VERSION` either ad hoc or globally. You can export this variable if you'd like to persist a specific release version.
|
||||
|
||||
Examples:
|
||||
|
||||
```
|
||||
# Execute latest released openapi-generator-cli
|
||||
openapi-generator-cli version
|
||||
|
||||
# Execute version 3.1.0 for the current invocation, regardless of the latest released version
|
||||
OPENAPI_GENERATOR_VERSION=3.1.0 openapi-generator-cli version
|
||||
|
||||
# Execute version 3.1.0-SNAPSHOT for the current invocation
|
||||
OPENAPI_GENERATOR_VERSION=3.1.0-SNAPSHOT openapi-generator-cli version
|
||||
|
||||
# Execute version 3.0.2 for every invocation in the current shell session
|
||||
export OPENAPI_GENERATOR_VERSION=3.0.2
|
||||
openapi-generator-cli version # is 3.0.2
|
||||
openapi-generator-cli version # is also 3.0.2
|
||||
|
||||
# To "install" a specific version, set the variable in .bashrc/.bash_profile
|
||||
echo "export OPENAPI_GENERATOR_VERSION=3.0.2" >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
openapi-generator-cli version # is always 3.0.2, unless any of the above overrides are done ad hoc
|
||||
```
|
||||
|
||||
### [1.4 - Build Projects](#table-of-contents)
|
||||
|
||||
To build from source, you need the following installed and available in your `$PATH:`
|
||||
@@ -241,6 +193,22 @@ To reinstall with the latest master, run `brew reinstall --HEAD openapi-generato
|
||||
- [https://hub.docker.com/r/openapitools/openapi-generator-cli/](https://hub.docker.com/r/openapitools/openapi-generator-cli/) (official CLI)
|
||||
- [https://hub.docker.com/r/openapitools/openapi-generator-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
|
||||
|
||||
@@ -317,20 +285,6 @@ Once built, `run-in-docker.sh` will act as an executable for openapi-generator-c
|
||||
-g go -o /gen/out/go-petstore -DpackageName=petstore # generates go client, outputs locally to ./out/go-petstore
|
||||
```
|
||||
|
||||
##### Troubleshooting
|
||||
|
||||
If an error like this occurs, just execute the **mvn clean install -U** command:
|
||||
|
||||
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project openapi-generator: A type incompatibility occurred while executing org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test: java.lang.ExceptionInInitializerError cannot be cast to java.io.IOException
|
||||
|
||||
```sh
|
||||
./run-in-docker.sh mvn clean install -U
|
||||
```
|
||||
|
||||
> Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project openapi-generator-gradle-plugin-mvn-wrapper: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.7-bin.zip'
|
||||
|
||||
Right now: no solution for this one :|
|
||||
|
||||
#### Run Docker in Vagrant
|
||||
Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
|
||||
```sh
|
||||
@@ -471,20 +425,20 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Bithost GmbH](https://www.bithost.ch)
|
||||
- [GMO Pepabo](https://pepabo.com/en/)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
- [REST United](https://restunited.com)
|
||||
- [Telstra](https://dev.telstra.com)
|
||||
- [unblu inc.](https://www.unblu.com/)
|
||||
|
||||
|
||||
## [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)
|
||||
- 2018/06/08 - [Swagger Codegen is now OpenAPI Generator](https://angular.schule/blog/2018-06-swagger-codegen-is-now-openapi-generator) by [JohannesHoppe](https://github.com/JohannesHoppe)
|
||||
- 2018/06/21 - [Connect your JHipster apps to the world of APIs with OpenAPI and gRPC](https://fr.slideshare.net/chbornet/jhipster-conf-2018-connect-your-jhipster-apps-to-the-world-of-apis-with-openapi-and-grpc) by [Christophe Bornet](https://github.com/cbornet) at [JHipster Conf 2018](https://jhipster-conf.github.io/)
|
||||
- 2018/06/27 - [Lessons Learned from Leading an Open-Source Project Supporting 30+ Programming Languages](https://speakerdeck.com/wing328/lessons-learned-from-leading-an-open-source-project-supporting-30-plus-programming-languages) - [William Cheng](https://github.com/wing328) at [LinuxCon + ContainerCon + CloudOpen China 2018](https://www.lfasiallc.com/events/lc3-2018/)
|
||||
- 2018/07/19 - [OpenAPI Generator Contribution Quickstart - RingCentral Go SDK](https://medium.com/ringcentral-developers/openapi-generator-for-go-contribution-quickstart-8cc72bf37b53) by [John Wang](https://github.com/grokify)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -559,7 +513,6 @@ Here is a list of template creators:
|
||||
* Ada: @stcarrez
|
||||
* C# ASP.NET5: @jimschubert
|
||||
* C# NancyFX: @mstefaniuk
|
||||
* C++ (Qt5 QHttpEngine): @etherealjoy
|
||||
* C++ Pistache: @sebymiano
|
||||
* C++ Restbed: @stkrwork
|
||||
* Erlang Server: @galaxie
|
||||
@@ -575,7 +528,6 @@ Here is a list of template creators:
|
||||
* JAX-RS CXF (CDI): @nickcmaynard
|
||||
* JAX-RS RestEasy (JBoss EAP): @jfiala
|
||||
* Kotlin: @jimschubert
|
||||
* PHP Laravel: @renepardon
|
||||
* PHP Lumen: @abcsun
|
||||
* PHP Slim: @jfastnacht
|
||||
* PHP Symfony: @ksm2
|
||||
@@ -634,7 +586,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) @grokify (2018/07) |
|
||||
| Go | @antihax (2017/11) @bvwells (2017/12) |
|
||||
| Groovy | |
|
||||
| Haskell | |
|
||||
| Java | @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
|
||||
@@ -643,7 +595,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||
| ObjC | |
|
||||
| Perl | @wing328 (2017/07) |
|
||||
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) @ybelenko (2018/07) |
|
||||
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) |
|
||||
| PowerShell | |
|
||||
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11)|
|
||||
| R | |
|
||||
|
||||
@@ -18,7 +18,6 @@ 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"
|
||||
|
||||
@@ -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 -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties addExternalLibs=true -o samples/server/petstore/cpp-pistache $@"
|
||||
ags="generate -g cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
|
||||
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/cpp-qt5-qhttpengine-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-qt5-qhttpengine-server -o samples/server/petstore/cpp-qt5-qhttpengine-server $@"
|
||||
|
||||
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 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/client/petstore/elm $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g elm -o samples/client/petstore/elm $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -25,11 +25,8 @@ 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,withGoCodegenComment=true $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/go -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g go -o samples/client/petstore/go/go-petstore-withXml -DpackageName=petstore,withXml=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -25,9 +25,6 @@ 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 $@"
|
||||
|
||||
@@ -27,7 +27,7 @@ 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 --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1 --additional-properties useNullForUnknownEnumValue=true $@"
|
||||
ags="generate --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1 $@"
|
||||
|
||||
echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main"
|
||||
rm -rf samples/client/petstore/java/jersey1/src/main
|
||||
|
||||
@@ -32,8 +32,4 @@ ags="generate --artifact-id petstore-jersey2-java6 -i modules/openapi-generator/
|
||||
echo "Removing files and folders under samples/client/petstore/java/jersey2-java6/src/main"
|
||||
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,7 +1,4 @@
|
||||
{
|
||||
"library": "jersey2",
|
||||
"artifactId": "petstore-jersey2",
|
||||
"additionalProperties" : {
|
||||
"useNullForUnknownEnumValue" : true
|
||||
}
|
||||
"artifactId": "petstore-jersey2"
|
||||
}
|
||||
|
||||
@@ -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 -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
ags="generate -g cpp-pistache-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
|
||||
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/cpp-qt5-qhttpengine-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-qt5-qhttpengine-server -o samples/client/petstore/cpp-qt5-qhttpengine-server $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
# Make sure that the working directory is the root dir
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd "${SCRIPT_DIR}/../"
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
# Make sure that we are regenerating the sample by removing any existing target directory
|
||||
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-laravel"
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf $TARGET_DIR
|
||||
fi
|
||||
|
||||
executable="$SCRIPT_DIR/../../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 $SCRIPT_DIR/../../modules/openapi-generator/src/main/resources/php-laravel -i $SCRIPT_DIR/../../modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php-laravel -o $TARGET_DIR $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -33,6 +33,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/php -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/openapi3/client/petstore/php/OpenAPIClient-php $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/openapi3/client/petstore/php $@"
|
||||
|
||||
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/php-silex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex/OpenAPIServer $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
||||
fi
|
||||
|
||||
# Make sure that we are regenerating the sample by removing any existing target directory
|
||||
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony/SymfonyBundle-php"
|
||||
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony"
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf $TARGET_DIR
|
||||
fi
|
||||
|
||||
@@ -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-sinatra-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/ruby-sinatra $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/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
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
32
bin/openapi3/sinatra-petstore-server.sh
Executable file
32
bin/openapi3/sinatra-petstore-server.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/sinatra -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/sinatra $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -33,6 +33,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/php -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/client/petstore/php/OpenAPIClient-php $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/client/petstore/php $@"
|
||||
|
||||
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/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex/OpenAPIServer $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
|
||||
fi
|
||||
|
||||
# Make sure that we are regenerating the sample by removing any existing target directory
|
||||
TARGET_DIR="$SCRIPT_DIR/../samples/server/petstore/php-symfony/SymfonyBundle-php"
|
||||
TARGET_DIR="$SCRIPT_DIR/../samples/server/petstore/php-symfony"
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf $TARGET_DIR
|
||||
fi
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
# update python petstore clients
|
||||
|
||||
./bin/python-asyncio-petstore.sh
|
||||
./bin/python-petstore.sh
|
||||
./bin/python-tornado-petstore.sh
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-sinatra-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/ruby-sinatra $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/rails5 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/rails5 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby-on-rails-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/ruby-on-rails $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -25,10 +25,8 @@ then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
for spec_path in modules/openapi-generator/src/test/resources/2_0/rust-server/* ; do
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
spec=$(basename "$spec_path" | sed 's/.yaml//')
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/rust-server -i $spec_path -g rust-server -o samples/server/petstore/rust-server/output/$spec -DpackageName=$spec --additional-properties hideGenerationTimestamp=true $@"
|
||||
# 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/rust-server -i modules/openapi-generator/src/test/resources/2_0/rust-server/petstore-with-fake-endpoints-models-for-testing.yaml -g rust-server -o samples/server/petstore/rust-server -DpackageName=petstore_api --additional-properties hideGenerationTimestamp=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
done
|
||||
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-on-rails-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/ruby-on-rails $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -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/php-laravel -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php-laravel -o samples/server/petstore/php-laravel $@"
|
||||
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,20 +17,14 @@ 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.sh > /dev/null 2>&1
|
||||
./bin/kotlin-server-petstore.shl> /dev/null 2>&1
|
||||
./bin/php-petstore.sh > /dev/null 2>&1
|
||||
./bin/php-silex-petstore-server.sh > /dev/null 2>&1
|
||||
./bin/php-silex-petstore-server.shj> /dev/null 2>&1
|
||||
./bin/php-symfony-petstore.sh > /dev/null 2>&1
|
||||
./bin/php-lumen-petstore-server.sh > /dev/null 2>&1
|
||||
./bin/php-slim-server-petstore.sh > /dev/null 2>&1
|
||||
./bin/php-slim-petstore-server.sh > /dev/null 2>&1
|
||||
./bin/php-ze-ph-petstore-server.sh > /dev/null 2>&1
|
||||
./bin/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
|
||||
./bin/rust-server-petstore.sh > /dev/null 2>&1
|
||||
./bin/openapi3/haskell-http-client-petstore.sh > /dev/null 2>&1
|
||||
|
||||
# Check:
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
####
|
||||
# Save as openapi-generator-cli on your PATH. chmod u+x. Enjoy.
|
||||
#
|
||||
# This script will query github on every invocation to pull the latest released version
|
||||
# of openapi-generator.
|
||||
#
|
||||
# If you want repeatable executions, you can explicitly set a version via
|
||||
# OPENAPI_GENERATOR_VERSION
|
||||
# e.g. (in Bash)
|
||||
# export OPENAPI_GENERATOR_VERSION=3.1.0
|
||||
# openapi-generator-cli.sh
|
||||
# or
|
||||
# OPENAPI_GENERATOR_VERSION=3.1.0 openapi-generator-cli.sh
|
||||
#
|
||||
# This is also helpful, for example, if you want want to evaluate a SNAPSHOT version.
|
||||
#
|
||||
# NOTE: Jars are downloaded on demand from maven into the same directory as this script
|
||||
# for every 'latest' version pulled from github. Consider putting this under its own directory.
|
||||
####
|
||||
set -o pipefail
|
||||
|
||||
for cmd in {mvn,python,curl}; do
|
||||
if ! command -v ${cmd} > /dev/null; then
|
||||
>&2 echo "This script requires '${cmd}' to be installed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
function latest.tag {
|
||||
local uri="https://api.github.com/repos/${1}/tags"
|
||||
curl -s ${uri} | python -c "import sys, json; print json.load(sys.stdin)[0]['name'][1:]"
|
||||
}
|
||||
|
||||
ghrepo=openapitools/openapi-generator
|
||||
groupid=org.openapitools
|
||||
artifactid=openapi-generator-cli
|
||||
ver=${OPENAPI_GENERATOR_VERSION:-$(latest.tag $ghrepo)}
|
||||
|
||||
jar=${artifactid}-${ver}.jar
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [ ! -f ${DIR}/${jar} ]; then
|
||||
repo="central::default::https://repo1.maven.apache.org/maven2"
|
||||
if [[ ${ver} =~ ^.*-SNAPSHOT$ ]]; then
|
||||
repo="central::default::https://oss.sonatype.org/content/repositories/snapshots"
|
||||
fi
|
||||
mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:get \
|
||||
-DremoteRepositories=${repo} \
|
||||
-Dartifact=${groupid}:${artifactid}:${ver} \
|
||||
-Dtransitive=false \
|
||||
-Ddest=${DIR}/${jar}
|
||||
fi
|
||||
|
||||
java -ea \
|
||||
${JAVA_OPTS} \
|
||||
-Xms512M \
|
||||
-Xmx1024M \
|
||||
-server \
|
||||
-jar ${DIR}/${jar} "$@"
|
||||
@@ -1,196 +0,0 @@
|
||||
#release_chekcout.rb
|
||||
require 'rubygems'
|
||||
require 'open-uri'
|
||||
require 'net/http'
|
||||
|
||||
def check_homebrew
|
||||
print "Checking homebrew forumla ... "
|
||||
|
||||
url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/openapi-generator.rb"
|
||||
new_maven_url = "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
|
||||
open(url) do |f|
|
||||
content = f.read
|
||||
if !content.nil? && content.include?(new_maven_url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not yet updated with #{new_maven_url}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_online_docker
|
||||
print "Checking openapi-generator-online docker ... "
|
||||
|
||||
url = "https://hub.docker.com/r/openapitools/openapi-generator-online/tags/"
|
||||
docker_tag = "v#{$version}"
|
||||
open(url) do |f|
|
||||
content = f.read
|
||||
if !content.nil? && content.include?(docker_tag)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} does not have tag #{docker_tag}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_cli_docker
|
||||
print "Checking openapi-generator-cli docker ... "
|
||||
|
||||
url = "https://hub.docker.com/r/openapitools/openapi-generator-cli/tags/"
|
||||
docker_tag = "v#{$version}"
|
||||
open(url) do |f|
|
||||
content = f.read
|
||||
if !content.nil? && content.include?(docker_tag)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} does not have tag #{docker_tag}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_readme
|
||||
print "Checking openapi-generator README.md ... "
|
||||
|
||||
url = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/README.md"
|
||||
matches = ["[#{$version}](https://github.com/OpenAPITools/openapi-generator/releases/tag/v#{$version})",
|
||||
"JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar`",
|
||||
"wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar -O openapi-generator-cli.jar",
|
||||
"Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"]
|
||||
open(url) do |f|
|
||||
content = f.read
|
||||
has_outdated = false
|
||||
not_matched = []
|
||||
matches.each do |match|
|
||||
if !content.nil? && content.include?(match)
|
||||
# matched
|
||||
else
|
||||
has_outdated = true
|
||||
not_matched << match
|
||||
end
|
||||
end
|
||||
|
||||
if has_outdated
|
||||
puts "[ERROR]"
|
||||
not_matched.each do |str|
|
||||
puts "> '#{str}' not found in README.md"
|
||||
end
|
||||
else
|
||||
puts "[OK]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_jar
|
||||
print "Checking openapi-generator JAR ... "
|
||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator/#{$version}/openapi-generator-#{$version}.jar"
|
||||
|
||||
if check_url(url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not found"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def check_openapi_generator_cli_jar
|
||||
print "Checking openapi-generator-cli JAR ... "
|
||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
|
||||
|
||||
if check_url(url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_maven_plugin_jar
|
||||
print "Checking openapi-generator-maven-plugin JAR ... "
|
||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-maven-plugin/#{$version}/openapi-generator-maven-plugin-#{$version}.jar"
|
||||
|
||||
if check_url(url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_gradle_plugin_jar
|
||||
print "Checking openapi-generator-gradle-plugin JAR ... "
|
||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-gradle-plugin/#{$version}/openapi-generator-gradle-plugin-#{$version}.jar"
|
||||
|
||||
if check_url(url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_online_jar
|
||||
print "Checking openapi-generator-online JAR ... "
|
||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-online/#{$version}/openapi-generator-online-#{$version}.jar"
|
||||
|
||||
if check_url(url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def check_openapi_generator_project_pom
|
||||
print "Checking openapi-generator-project pom.xml ... "
|
||||
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-project/#{$version}/openapi-generator-project-#{$version}.pom"
|
||||
|
||||
if check_url(url)
|
||||
puts "[OK]"
|
||||
else
|
||||
puts "[ERROR]"
|
||||
puts "> #{url} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def check_url url
|
||||
content = Net::HTTP.get(URI.parse(url))
|
||||
url = URI.parse(url)
|
||||
req = Net::HTTP.new(url.host, url.port)
|
||||
res = req.request_head(url.path)
|
||||
if res.code == "200"
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def usage
|
||||
puts "ERROR!! Version (e.g. 3.0.2) missing"
|
||||
puts "Usage example: ruby #{$0} 3.0.2"
|
||||
end
|
||||
|
||||
|
||||
if (!ARGV[0])
|
||||
usage
|
||||
exit
|
||||
end
|
||||
|
||||
$version = ARGV[0]
|
||||
|
||||
puts "Running checkout on OpenAPI Generator release #{$version}"
|
||||
|
||||
check_homebrew
|
||||
check_openapi_generator_jar
|
||||
check_openapi_generator_cli_jar
|
||||
check_openapi_generator_maven_plugin_jar
|
||||
check_openapi_generator_gradle_plugin_jar
|
||||
check_openapi_generator_online_jar
|
||||
check_openapi_generator_project_pom
|
||||
check_readme
|
||||
check_openapi_generator_online_docker
|
||||
check_openapi_generator_cli_docker
|
||||
@@ -40,13 +40,16 @@ declare -a files=("CI/pom.xml.bash"
|
||||
"CI/pom.xml.circleci.java7"
|
||||
"CI/pom.xml.ios"
|
||||
"modules/openapi-generator-cli/pom.xml"
|
||||
"modules/openapi-generator-gradle-plugin/README.adoc"
|
||||
"modules/openapi-generator-gradle-plugin/gradle.properties"
|
||||
"modules/openapi-generator-gradle-plugin/pom.xml"
|
||||
"modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle"
|
||||
"modules/openapi-generator-maven-plugin/pom.xml"
|
||||
"modules/openapi-generator-online/pom.xml"
|
||||
"modules/openapi-generator/pom.xml"
|
||||
"modules/openapi-generator-online/Dockerfile"
|
||||
"pom.xml")
|
||||
"pom.xml"
|
||||
"README.md")
|
||||
|
||||
for filename in "${files[@]}"; do
|
||||
# e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# usage: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1
|
||||
#
|
||||
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
if [[ "$1" != "" ]]; then
|
||||
FROM="$1"
|
||||
else
|
||||
echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [[ "$2" != "" ]]; then
|
||||
TO="$2"
|
||||
else
|
||||
echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
echo "IMPORTANT: this script works on Mac only"
|
||||
echo "Release preparation: replacing $FROM with $TO in different files"
|
||||
|
||||
declare -a files=("modules/openapi-generator-maven-plugin/README.md"
|
||||
"modules/openapi-generator-maven-plugin/examples/java-client.xml"
|
||||
"modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
|
||||
"modules/openapi-generator-maven-plugin/examples/non-java.xml"
|
||||
"modules/openapi-generator-gradle-plugin/README.adoc"
|
||||
"modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
|
||||
"modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle"
|
||||
"modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"
|
||||
"README.md")
|
||||
|
||||
for filename in "${files[@]}"; do
|
||||
# e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash
|
||||
#echo "Running command: sed -i '' "s/$FROM/$TO/g" $filename"
|
||||
if sed -i '' "s/$FROM/$TO/g" $filename; then
|
||||
echo "Updated $filename successfully!"
|
||||
else
|
||||
echo "ERROR: Failed to update $filename with the following command"
|
||||
echo "sed -i '' \"s/$FROM/$TO/g\" $filename"
|
||||
fi
|
||||
done
|
||||
@@ -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 -g php -o samples\client\petstore\php\OpenAPIClient-php
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php -o samples\client\petstore\php
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -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 -g php-silex -o samples\server\petstore\php-silex\OpenAPIServer
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-silex -o samples\server\petstore\php-silex
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -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 -g php-symfony -o samples\server\petstore\php-symfony\SymfonyBundle-php
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-symfony -o samples\server\petstore\php-symfony
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -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 -g typescript-angular -o samples\client\petstore\typescript-angular-v2\with-interfaces -D withInterfaces=true --additional-properties ngVersion=2
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -c bin\typescript-petstore-npm.json -g typescript-angular -o samples\client\petstore\typescript-angular-v2\with-interfaces -D withInterfaces=true --additional-properties ngVersion=2
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,6 +4,9 @@ If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm --additional-properties ngVersion=6.0.0
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default --additional-properties ngVersion=6.0.0
|
||||
REM it is same like like setting -D providedInRoot=true
|
||||
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm -D providedInRoot=true --additional-properties ngVersion=6.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,6 +4,9 @@ If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default --additional-properties ngVersion=6.0.0
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default --additional-properties ngVersion=6.0.0
|
||||
REM it is same like like setting -D providedInRoot=true
|
||||
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default -D providedInRoot=true --additional-properties ngVersion=6.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
@@ -5,6 +7,8 @@ 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 -g typescript-inversify -o samples\client\petstore\typescript-inversify
|
||||
|
||||
echo
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-inversify -o samples\client\petstore\typescript-inversify\builds\default
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
2
bin/windows/cpp-qt5-qhttpengine-server-petstore.bat → bin/windows/typescript-inversify.bat
Normal file → Executable file
2
bin/windows/cpp-qt5-qhttpengine-server-petstore.bat → bin/windows/typescript-inversify.bat
Normal file → Executable file
@@ -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 -g cpp-qt5-qhttpengine-server -o samples\server\petstore\cpp-qt5-qhttpengine-server
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-inversify -o samples\client\petstore\typescript-inversify
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -1,2 +0,0 @@
|
||||
call .\bin\windows\typescript-node-petstore.bat
|
||||
call .\bin\windows\typescript-node-petstore-with-npm.bat
|
||||
51
circle.yml
51
circle.yml
@@ -1,16 +1,10 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
# docker:
|
||||
# #- image: openapitools/openapi-generator
|
||||
# - image: swaggerapi/petstore
|
||||
# environment:
|
||||
# SWAGGER_HOST=http://petstore.swagger.io
|
||||
# SWAGGER_BASE_PATH=/v2
|
||||
machine:
|
||||
docker_layer_caching: true
|
||||
working_directory: ~/OpenAPITools/openapi-generator
|
||||
parallelism: 2
|
||||
parallelism: 1
|
||||
shell: /bin/bash --login
|
||||
environment:
|
||||
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
||||
@@ -18,13 +12,6 @@ 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.
|
||||
@@ -43,6 +30,19 @@ jobs:
|
||||
printf '127.0.0.1 petstore.swagger.io
|
||||
' | 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
|
||||
- run: sudo apt-get install -qq bats
|
||||
- run: sudo apt-get install -qq curl
|
||||
# Install latest stable node for angular 6
|
||||
- run:
|
||||
name: Install node@stable (for angular 6)
|
||||
@@ -65,12 +65,11 @@ jobs:
|
||||
- run: docker ps -a
|
||||
- run: sleep 30
|
||||
- run: cat /etc/hosts
|
||||
# Test
|
||||
- run: mvn --quiet clean install
|
||||
- run: ./CI/circle_parallel.sh
|
||||
# This is based on your 1.0 configuration file or project settings
|
||||
- run: cp CI/pom.xml.circleci pom.xml
|
||||
# Save dependency cache
|
||||
- save_cache:
|
||||
key: source-v1-{{ .Branch }}-{{ .Revision }}
|
||||
key: v1-dep-{{ .Branch }}
|
||||
paths:
|
||||
# This is a broad list of cache paths to include many possible development environments
|
||||
# You can probably delete some of these entries
|
||||
@@ -82,7 +81,21 @@ jobs:
|
||||
- ~/.go_workspace
|
||||
- ~/.gradle
|
||||
- ~/.cache/bower
|
||||
- ".git"
|
||||
# These cache paths were specified in the 1.0 config
|
||||
- ~/.sbt
|
||||
# Test
|
||||
# This would typically be a build job when using workflows, possibly combined with build
|
||||
# This is based on your 1.0 configuration file or project settings
|
||||
- run: java -version
|
||||
- run: mvn --quiet clean install
|
||||
- run: mvn --quiet verify -Psamples
|
||||
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||
- run: java -version
|
||||
- run: cp CI/pom.xml.circleci.java7 pom.xml
|
||||
- run: mvn --quiet clean install
|
||||
- run: mvn --quiet verify -Psamples
|
||||
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||
# Teardown
|
||||
# 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~~ (migrated)
|
||||
- `apex` (migration scheduled in Jul/Aug 2018)
|
||||
- `rust-server`
|
||||
- `apex`
|
||||
|
||||
and we welcome contributions from the community to help with the migration
|
||||
|
||||
|
||||
@@ -11,42 +11,6 @@ Another approach to find breaking changes is to look at issue and pull requests
|
||||
* link:https://github.com/OpenAPITools/openapi-generator/labels/Breaking%20change%20%28with%20fallback%29[Breaking change (with fallback)]
|
||||
* link:https://github.com/OpenAPITools/openapi-generator/labels/Breaking%20change%20%28without%20fallback%29[Breaking change (without fallback)]
|
||||
|
||||
=== From 3.1.x to 3.2.0
|
||||
|
||||
Version `3.2.0` is a minor version of OpenAPI-Generator, in comparison to `3.1.x` it contains some breaking changes, but with the possibility to fallback to the old behavior.
|
||||
The default value of some options might change.
|
||||
Projects relying on generated code might need to be adapted.
|
||||
|
||||
==== Validate spec on generation by default
|
||||
|
||||
The default is to validate the spec during generation. If the spec has errors,
|
||||
they will appear as errors or warnings to the user. This prevent generation of the project.
|
||||
|
||||
If you want to switch back to the `3.1.x` behavior you can use:
|
||||
|
||||
* Set the `validateSpec` option to `false` if you are using the Maven or Gradle plugin
|
||||
* Use the command line option `--skip-validate-spec` if you are using the CLI
|
||||
|
||||
|
||||
==== Model (all languages)
|
||||
|
||||
In `CodegenModel` and in `CodegenOperation` we use now our own class `org.openapitools.codegen.CodegenDiscriminator` instead of `io.swagger.v3.oas.models.media.Discriminator`.
|
||||
|
||||
For the templates, this is not an API change, because the same values are available.
|
||||
|
||||
If you have your own `Codegen` class (to support your own generator for example) then you might get some compile error due to the change.
|
||||
|
||||
==== Java
|
||||
|
||||
Schema with enum values are mapped to java enum in the generated code.
|
||||
In previous version, when an unknown value was deserialized, the value was set to `null`.
|
||||
|
||||
With `3.2.0` a new option is introduced: `useNullForUnknownEnumValue`.
|
||||
|
||||
* When set to `false` (default value), an Exception (`IllegalArgumentException`) is thrown when the value not available in the enum.
|
||||
* When set to `true`, unknown values are mapped to `null` as it was the case in previous versions.
|
||||
|
||||
|
||||
=== From 3.0.x to 3.1.0
|
||||
|
||||
Version `3.1.0` is the first minor version of OpenAPI-Generator, in comparison to `3.0.3` it contains some breaking changes, but with the possibility to fallback to the old behavior.
|
||||
|
||||
42
docs/qna.md
42
docs/qna.md
@@ -2,40 +2,38 @@
|
||||
|
||||
#### What is the governance structure of the OpenAPI Generator project?
|
||||
|
||||
OpenAPI generator (openapi-generator) is managed by the members of the [core team](../README.md#openapi-generator-core-team).
|
||||
|
||||
|
||||
#### What is the difference between Swagger Codegen and OpenAPI Generator?
|
||||
|
||||
Swagger Codegen is driven by SmartBear while OpenAPI Generator is driven by the community. More than 40 top contributors and template creators of Swagger Codegen have joined OpenAPI Generator as the founding team members.
|
||||
|
||||
Swagger is a trademark owned by SmartBear and the use of the term "Swagger" in this project is for demo (reference) purposes only.
|
||||
OpenAPI generator (openapi-generator) is managed by the [core team members](../README.md#openapi-generator-core-team).
|
||||
|
||||
|
||||
#### Why was it decided to fork Swagger Codegen and to maintain a community-driven version?
|
||||
|
||||
There are several reasons:
|
||||
|
||||
1. The founding members came to the conclusion that Swagger Codegen 3.0.0 beta contains too many breaking changes. They also strongly believe the 3.0.0 release should only focus on one thing: OpenAPI 3.0 support.
|
||||
1. The founding members had concerns about the development practices, which seemed to be contributing to an unstable and insufficiently tested codebase.
|
||||
1. There was a disagreement on the evolutionary strategy for Swagger Codegen. The founding members felt it was important to move forward with OpenAPI 3.0 support, while maintaining backward compatibility with OpenAPI 2.0 in the same codebase.
|
||||
1. The founding members found that the enhancements and bug fixes submitted for Swagger Codegen 2.x need to be submitted again for Swagger Codegen 3.0.0 branch (otherwise, these changes would not appear in the 3.0.0 branch. Having to do the pull request twice is not the best use of community resources).
|
||||
1. The community-driven version has a more rapid [release cycle](https://github.com/OpenAPITools/openapi-generator/releases/) (weekly patch release, monthly minor release) so users do not need to wait for several months to get a stable release.
|
||||
1. Having a community-driven version _can_ bring the project to the next level with reliable releases and a clear [roadmap](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/roadmap.adoc).
|
||||
1. The founding members came to the conclusion that Swagger Codegen 3.0.0 beta contains too many breaking changes while they strongly believe 3.0.0 release should only focus on one thing: OpenAPI specification 3.0 support.
|
||||
1. Swagger Codegen 3.0.0 beta was evaluated as unstable. Changes made directly to 3.0.0 branch without reviews or tests, were breaking the builds from time to time (e.g. a simple `mvn clean package` failed).
|
||||
1. Reviews of code changes in the 3.0.0 branch highlighted a lot of code block removal without any reason. This might produce regressions for edge cases discovered previously.
|
||||
1. Most of the test cases in the generators have been commented out as part of the migration to support OpenAPI 3.0. Test cases are the most valuable assets of the project and should be maintained to ensure a good quality.
|
||||
1. According to SmartBear, [Swagger Codegen 2.x and 3.x should be supported in parallel for a while](https://github.com/swagger-api/swagger-codegen/issues/7754#issuecomment-375039048) without the possibility to work with git branches to merge the fixes from one branch to the next. Having to implement everything twice is not a good idea and the best use of the Swagger Codegen community resources.
|
||||
1. Having a community-driven version can bring the project to the next level.
|
||||
|
||||
#### Was anything done to attempt to address the issues before deciding to fork Swagger Codegen and maintain a community-driven version?
|
||||
UPDATE: After the public launch of OpenAPI Generator, some of the core team members were contacted by Ron (SmartBear) and we explained to him the reasons of the fork as explained above. We also asked him to contact team@openapitools.org if he wants to discuss further but so far we don't see any email from him to team@openapitools.org.
|
||||
|
||||
There were several conversations with the project owners of Swagger Codegen via emails, Gitter, Skype call and GitHub issues to discuss the state of Swagger Codegen 3.0.0.
|
||||
#### Has anything been done in attempt to address the issues before deciding to fork Swagger Codegen and maintain a community-driven version?
|
||||
|
||||
There were several conversations with SmartBear (Ron, Hugo) via emails, gitter, Skype call and GitHub issues.
|
||||
But there was no consensus on the next steps and on the direction for Swagger Codegen 3.0.0.
|
||||
|
||||
#### Are there any changes to the project license?
|
||||
#### Is there any change to the project license?
|
||||
|
||||
No, OpenAPI Generator is still using the [Apache license (version 2)](https://www.apache.org/licenses/LICENSE-2.0).
|
||||
No, OpenAPI Generator is still using [Apache license (version 2)](https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
||||
#### I am currently using Swagger Codegen 2.x. How can I upgrade the generator to OpenAPI Generator?
|
||||
#### What is the difference between Swagger Codegen and OpenAPI Generator?
|
||||
|
||||
OpenAPI Generator is based on Swagger Codegen `2.4.0-SNAPSHOT` version so the migration should be relatively straightforward. Refer to the [migration guide](migration-from-swagger-codegen.md) for more information.
|
||||
Swagger Codegen is driven by SmartBear while OpenAPI Generator is driven by the community. More than 40 top contributors and template creators of Swagger Codegen have joined OpenAPI Generator as the founding team members.
|
||||
|
||||
#### Who maintains this Q&A page?
|
||||
Swagger is a trademark owned by SmartBear and the use of the term "Swagger" found in this project is for demo purpose (reference) only.
|
||||
|
||||
#### I’m currently using Swagger Codegen 2.x. How can I upgrade the generator to OpenAPI Generator?
|
||||
|
||||
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.
|
||||
|
||||
This Q&A page is maintained by the [core team members](../README.md#openapi-generator-core-team). It is not maintained by a single person nor do these Q&As represent the views of any individual or person.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -19,7 +19,6 @@ 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.*;
|
||||
@@ -68,9 +67,6 @@ 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,41 +23,18 @@ 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 {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language",
|
||||
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||
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(generatorName);
|
||||
CodegenConfig config = CodegenConfigLoader.forName(lang);
|
||||
System.out.println();
|
||||
System.out.println("CONFIG OPTIONS");
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
|
||||
@@ -194,11 +194,6 @@ public class Generate implements Runnable {
|
||||
description = CodegenConstants.REMOVE_OPERATION_ID_PREFIX_DESC)
|
||||
private Boolean removeOperationIdPrefix;
|
||||
|
||||
@Option(name = {"--skip-validate-spec"},
|
||||
title = "skip spec validation",
|
||||
description = "Skips the default behavior of validating an input specification.")
|
||||
private Boolean skipValidateSpec;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -212,10 +207,6 @@ public class Generate implements Runnable {
|
||||
}
|
||||
|
||||
// now override with any specified parameters
|
||||
if (skipValidateSpec != null) {
|
||||
configurator.setValidateSpec(false);
|
||||
}
|
||||
|
||||
if (verbose != null) {
|
||||
configurator.setVerbose(verbose);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.1.2"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,6 @@ The gradle plugin is not currently published to https://plugins.gradle.org/m2/.
|
||||
|false
|
||||
|The verbosity of generation
|
||||
|
||||
|validateSpec
|
||||
|Boolean
|
||||
|true
|
||||
|Whether or not we should validate the input spec before generation. Invalid specs result in an error.
|
||||
|
||||
|generatorName
|
||||
|String
|
||||
|None
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
openApiGeneratorVersion=3.2.0
|
||||
openApiGeneratorVersion=3.1.0-SNAPSHOT
|
||||
|
||||
# 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.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -11,11 +11,10 @@ gradle openApiGenerate
|
||||
gradle openApiMeta
|
||||
gradle openApiValidate
|
||||
gradle buildGoSdk
|
||||
gradle generateGoWithInvalidSpec
|
||||
```
|
||||
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=3.1.2 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=3.0.3 openApiValidate
|
||||
```
|
||||
|
||||
@@ -54,16 +54,3 @@ task buildGoSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTas
|
||||
dateLibrary: "threetenp"
|
||||
]
|
||||
}
|
||||
|
||||
task generateGoWithInvalidSpec(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
|
||||
validateSpec = true
|
||||
generatorName = "go"
|
||||
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
|
||||
additionalProperties = [
|
||||
packageName: "petstore"
|
||||
]
|
||||
outputDir = "$buildDir/go".toString()
|
||||
configOptions = [
|
||||
dateLibrary: "threetenp"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
openApiGeneratorVersion=3.1.2
|
||||
openApiGeneratorVersion=3.0.1
|
||||
|
||||
@@ -80,7 +80,6 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
description = "Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents."
|
||||
|
||||
verbose.set(generate.verbose)
|
||||
validateSpec.set(generate.validateSpec)
|
||||
generatorName.set(generate.generatorName)
|
||||
outputDir.set(generate.outputDir)
|
||||
inputSpec.set(generate.inputSpec)
|
||||
|
||||
@@ -32,11 +32,6 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val verbose = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* Whether or not an input specification should be validated upon generation.
|
||||
*/
|
||||
val validateSpec = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
||||
*/
|
||||
@@ -267,11 +262,6 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
val configOptions = project.objects.property<Map<String, String>>()
|
||||
|
||||
init {
|
||||
applyDefaults()
|
||||
}
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun applyDefaults(){
|
||||
releaseNote.set("Minor update")
|
||||
modelNamePrefix.set("")
|
||||
modelNameSuffix.set("")
|
||||
@@ -281,6 +271,5 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
generateApiDocumentation.set(true)
|
||||
withXml.set(false)
|
||||
configOptions.set(mapOf())
|
||||
validateSpec.set(true)
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.gradle.kotlin.dsl.property
|
||||
import org.openapitools.codegen.CodegenConstants
|
||||
import org.openapitools.codegen.DefaultGenerator
|
||||
import org.openapitools.codegen.config.CodegenConfigurator
|
||||
import org.openapitools.codegen.config.CodegenConfiguratorUtils.*
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,12 +48,6 @@ open class GenerateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
val verbose = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* Whether or not an input specification should be validated upon generation.
|
||||
*/
|
||||
@get:Internal
|
||||
val validateSpec = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
||||
*/
|
||||
@@ -387,10 +382,6 @@ open class GenerateTask : DefaultTask() {
|
||||
configurator.isVerbose = value
|
||||
}
|
||||
|
||||
validateSpec.ifNotEmpty { value ->
|
||||
configurator.isValidateSpec = value
|
||||
}
|
||||
|
||||
skipOverwrite.ifNotEmpty { value ->
|
||||
configurator.isSkipOverwrite = value ?: false
|
||||
}
|
||||
@@ -537,7 +528,8 @@ open class GenerateTask : DefaultTask() {
|
||||
|
||||
out.println("Successfully generated code to ${configurator.outputDir}")
|
||||
} catch (e: RuntimeException) {
|
||||
throw GradleException("Code generation failed.", e)
|
||||
logger.error(e.message)
|
||||
throw GradleException("Code generation failed.")
|
||||
}
|
||||
} finally {
|
||||
originalEnvironmentVariables.forEach { entry ->
|
||||
|
||||
@@ -31,7 +31,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
fun `openApiGenerate should create an expected file structure from DSL config`() {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
)
|
||||
withProject(defaultBuildGradle, projectFiles)
|
||||
|
||||
|
||||
@@ -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.1.2</version>
|
||||
<version>3.0.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -38,7 +38,6 @@ mvn clean compile
|
||||
### General Configuration parameters
|
||||
|
||||
- `inputSpec` - OpenAPI Spec file path
|
||||
- `validateSpec` - Whether or not to validate the input spec prior to generation. Invalid specifications will result in an error.
|
||||
- `language` - target generation language (deprecated, replaced by `generatorName` as values here don't represent only 'language' any longer)
|
||||
- `generatorName` - target generator name
|
||||
- `output` - target output path (default is `${project.build.directory}/generated-sources/swagger`)
|
||||
@@ -103,8 +102,4 @@ Specifying a custom generator is a bit different. It doesn't support the classpa
|
||||
|
||||
### Sample configuration
|
||||
|
||||
Please see [an example configuration](examples) for using the plugin. To run these examples, explicitly pass the file to maven. Example:
|
||||
|
||||
```bash
|
||||
mvn -f non-java.xml compile
|
||||
```
|
||||
- Please see [an example configuration](examples) for using the plugin
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -20,7 +20,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- specify the swagger yaml -->
|
||||
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
|
||||
<inputSpec>swagger.yaml</inputSpec>
|
||||
|
||||
<!-- target to generate java client code -->
|
||||
<generatorName>java</generatorName>
|
||||
@@ -39,22 +39,13 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- dependencies are needed for the client being generated -->
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${swagger-annotations-version}</version>
|
||||
</dependency>
|
||||
@@ -64,8 +55,13 @@
|
||||
|
||||
<!-- HTTP client: jersey-client -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -73,11 +69,6 @@
|
||||
<artifactId>jersey-media-multipart</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON processing: jackson -->
|
||||
<dependency>
|
||||
@@ -105,7 +96,7 @@
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Joda time: if you use it -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
@@ -116,19 +107,19 @@
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<!-- Base64 encoding that works in both JVM and Android -->
|
||||
<dependency>
|
||||
<groupId>com.brsanthu</groupId>
|
||||
<artifactId>migbase64</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||
<jersey-version>2.27</jersey-version>
|
||||
<jersey-version>2.22.2</jersey-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>sample-project</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>sample-project</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- activate the plugin -->
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<validateSpec>false</validateSpec>
|
||||
<inputSpec>${project.basedir}/petstore-v3.0-invalid.yaml</inputSpec>
|
||||
<generatorName>aspnetcore</generatorName>
|
||||
<configOptions>
|
||||
<additional-properties>optionalProjectFile=true</additional-properties>
|
||||
</configOptions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -12,14 +12,14 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
|
||||
<inputSpec>swagger.yaml</inputSpec>
|
||||
<generatorName>aspnetcore</generatorName>
|
||||
<configOptions>
|
||||
<additional-properties>optionalProjectFile=true</additional-properties>
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
openapi: "3.0.0"
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v1
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
summary: List all pets
|
||||
operationId: listPets
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
description: How many items to return at one time (max 100)
|
||||
required: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
'200':
|
||||
description: A paged array of pets
|
||||
headers:
|
||||
x-next:
|
||||
description: A link to the next page of responses
|
||||
schema:
|
||||
type: string
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
post:
|
||||
summary: Create a pet
|
||||
tags:
|
||||
- pets
|
||||
responses:
|
||||
'201':
|
||||
description: Null response
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
/pets/{petId}:
|
||||
get:
|
||||
summary: Info for a specific pet
|
||||
operationId: showPetById
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
required: true
|
||||
description: The id of the pet to retrieve
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Expected response to a valid request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
Pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
Error:
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
|
||||
@@ -60,9 +60,6 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CodeGenMojo.class);
|
||||
|
||||
@Parameter(name="validateSpec", required = false, defaultValue = "true")
|
||||
private Boolean validateSpec;
|
||||
|
||||
@Parameter(name = "verbose", required = false, defaultValue = "false")
|
||||
private boolean verbose;
|
||||
|
||||
@@ -351,11 +348,6 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
configurator.setVerbose(verbose);
|
||||
|
||||
// now override with any specified parameters
|
||||
if (validateSpec != null) {
|
||||
configurator.setValidateSpec(validateSpec);
|
||||
}
|
||||
|
||||
if (skipOverwrite != null) {
|
||||
configurator.setSkipOverwrite(skipOverwrite);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine
|
||||
|
||||
WORKDIR /generator
|
||||
|
||||
COPY target/openapi-generator-online-3.2.0.jar /generator/openapi-generator-online.jar
|
||||
COPY target/openapi-generator-online-3.1.0-SNAPSHOT.jar /generator/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</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.2.0</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -198,16 +198,31 @@
|
||||
<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>org.openapitools.swagger.parser</groupId>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>com.samskivert</groupId>
|
||||
<artifactId>jmustache</artifactId>
|
||||
|
||||
@@ -230,10 +230,6 @@ public interface CodegenConfig {
|
||||
|
||||
String getHttpUserAgent();
|
||||
|
||||
void setDocExtension(String docExtension);
|
||||
|
||||
String getDocExtension();
|
||||
|
||||
String getCommonTemplateDir();
|
||||
|
||||
void setIgnoreFilePathOverride(String ignoreFileOverride);
|
||||
|
||||
@@ -56,9 +56,6 @@ public class CodegenConstants {
|
||||
public static final String PYTHON_PACKAGE_NAME = "pythonPackageName";
|
||||
public static final String PYTHON_PACKAGE_NAME_DESC = "package name for generated python code";
|
||||
|
||||
public static final String WITH_GO_CODEGEN_COMMENT = "withGoCodegenComment";
|
||||
public static final String WITH_GO_CODEGEN_COMMENT_DESC = "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs";
|
||||
|
||||
public static final String GROUP_ID = "groupId";
|
||||
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
|
||||
|
||||
@@ -216,9 +213,6 @@ 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";
|
||||
@@ -254,11 +248,4 @@ public class CodegenConstants {
|
||||
|
||||
public static final String STRIP_PACKAGE_NAME = "stripPackageName";
|
||||
public static final String STRIP_PACKAGE_NAME_DESC = "Whether to strip leading dot-separated packages from generated model classes";
|
||||
|
||||
public static final String DOCEXTENSION = "docExtension";
|
||||
public static final String DOCEXTENSION_DESC = "The extension of the generated documentation files, defaults to markdown, .md";
|
||||
|
||||
public static final String DATABASE_ADAPTER = "databaseAdapter";
|
||||
public static final String DATABASE_ADAPTER_DESC = "The adapter for database (e.g. mysql, sqlite). Default: sqlite";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenDiscriminator {
|
||||
private String propertyName;
|
||||
private Map<String, String> mapping;
|
||||
private Set<MappedModel> mappedModels = new LinkedHashSet<>();
|
||||
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
public void setPropertyName(String propertyName) {
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
public Map<String, String> getMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public void setMapping(Map<String, String> mapping) {
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
public Set<MappedModel> getMappedModels() {
|
||||
return mappedModels;
|
||||
}
|
||||
|
||||
public void setMappedModels(Set<MappedModel> mappedModels) {
|
||||
this.mappedModels = mappedModels;
|
||||
}
|
||||
|
||||
public static class MappedModel {
|
||||
private String mappingName;
|
||||
private String modelName;
|
||||
|
||||
public MappedModel(String mappingName, String modelName) {
|
||||
this.mappingName = mappingName;
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public String getMappingName() {
|
||||
return mappingName;
|
||||
}
|
||||
|
||||
public void setMappingName(String mappingName) {
|
||||
this.mappingName = mappingName;
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MappedModel that = (MappedModel) o;
|
||||
return Objects.equals(mappingName, that.mappingName) &&
|
||||
Objects.equals(modelName, that.modelName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mappingName, modelName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CodegenDiscriminator that = (CodegenDiscriminator) o;
|
||||
return Objects.equals(propertyName, that.propertyName) &&
|
||||
Objects.equals(mapping, that.mapping) &&
|
||||
Objects.equals(mappedModels, that.mappedModels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(propertyName, mapping, mappedModels);
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,15 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.media.Discriminator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CodegenModel {
|
||||
public String parent, parentSchema;
|
||||
@@ -39,7 +40,7 @@ public class CodegenModel {
|
||||
public String name, classname, title, description, classVarName, modelJson, dataType, xmlPrefix, xmlNamespace, xmlName;
|
||||
public String classFilename; // store the class file name, mainly used for import
|
||||
public String unescapedDescription;
|
||||
public CodegenDiscriminator discriminator;
|
||||
public Discriminator discriminator;
|
||||
public String defaultValue;
|
||||
public String arrayModelType;
|
||||
public boolean isAlias; // Is this effectively an alias of another simple type
|
||||
@@ -348,7 +349,7 @@ public class CodegenModel {
|
||||
this.unescapedDescription = unescapedDescription;
|
||||
}
|
||||
|
||||
public CodegenDiscriminator getDiscriminator() {
|
||||
public Discriminator getDiscriminator() {
|
||||
return discriminator;
|
||||
}
|
||||
|
||||
@@ -356,7 +357,7 @@ public class CodegenModel {
|
||||
return discriminator == null ? null : discriminator.getPropertyName();
|
||||
}
|
||||
|
||||
public void setDiscriminator(CodegenDiscriminator discriminator) {
|
||||
public void setDiscriminator(Discriminator discriminator) {
|
||||
this.discriminator = discriminator;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,17 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.media.Discriminator;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.tags.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CodegenOperation {
|
||||
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
|
||||
@@ -38,7 +40,7 @@ public class CodegenOperation {
|
||||
isRestful, isDeprecated;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse;
|
||||
public CodegenDiscriminator discriminator;
|
||||
public Discriminator discriminator;
|
||||
public List<Map<String, String>> consumes, produces, prioritizedContentTypes;
|
||||
public CodegenParameter bodyParam;
|
||||
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CodegenProperty implements Cloneable {
|
||||
public boolean exclusiveMinimum;
|
||||
public boolean exclusiveMaximum;
|
||||
public boolean hasMore, required, secondaryParam;
|
||||
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
|
||||
public boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
||||
public boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid;
|
||||
public boolean isListContainer, isMapContainer;
|
||||
|
||||
@@ -26,12 +26,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.examples.Example;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.ComposedSchema;
|
||||
import io.swagger.v3.oas.models.media.Content;
|
||||
import io.swagger.v3.oas.models.media.MediaType;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.CookieParameter;
|
||||
import io.swagger.v3.oas.models.parameters.HeaderParameter;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
@@ -48,7 +43,6 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -72,7 +66,6 @@ import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
||||
@@ -121,8 +114,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// When a model is an alias for a simple type
|
||||
protected Map<String, String> typeAliases = null;
|
||||
protected Boolean prependFormOrBodyParameters = false;
|
||||
// The extension of the generated documentation files (defaults to markdown .md)
|
||||
protected String docExtension;
|
||||
|
||||
protected String ignoreFilePathOverride;
|
||||
|
||||
@@ -181,11 +172,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.setRemoveOperationIdPrefix(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.DOCEXTENSION)){
|
||||
this.setDocExtension(String.valueOf(additionalProperties
|
||||
.get(CodegenConstants.DOCEXTENSION).toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@@ -768,8 +754,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public String toVarName(String name) {
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains( "" + ((char) character)))) {
|
||||
return escapeSpecialCharacters(name, null, null);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
@@ -786,8 +770,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains( "" + ((char) character)))) {
|
||||
return escapeSpecialCharacters(name, null, null);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -826,32 +808,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
throw new RuntimeException("reserved word " + name + " not allowed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name with escaped characters.
|
||||
*
|
||||
* @param name the name to be escaped
|
||||
* @param charactersToAllow characters that are not escaped
|
||||
* @param appdendixToReplacement String to append to replaced characters.
|
||||
* @return the escaped word
|
||||
* <p>
|
||||
* throws Runtime exception as word is not escaped properly.
|
||||
*/
|
||||
public String escapeSpecialCharacters(String name, List<String> charactersToAllow, String appdendixToReplacement) {
|
||||
String result = (String) ((CharSequence) name).chars().mapToObj(c -> {
|
||||
String character = "" + (char) c;
|
||||
if (charactersToAllow != null && charactersToAllow.contains(character)) {
|
||||
return character;
|
||||
} else if (specialCharReplacements.containsKey(character)) {
|
||||
return specialCharReplacements.get(character) + (appdendixToReplacement != null ? appdendixToReplacement: "");
|
||||
} else {
|
||||
return character;
|
||||
}
|
||||
}).reduce( (c1, c2) -> "" + c1 + c2).orElse(null);
|
||||
|
||||
if (result != null) return result;
|
||||
throw new RuntimeException("Word '" + name + "' could not be escaped.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fully-qualified "Model" name for import
|
||||
*
|
||||
@@ -1154,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) {
|
||||
@@ -1164,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;
|
||||
}
|
||||
@@ -1183,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();
|
||||
@@ -1201,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;
|
||||
}
|
||||
@@ -1513,10 +1469,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// unalias schema
|
||||
schema = ModelUtils.unaliasSchema(allDefinitions, schema);
|
||||
if (schema == null) {
|
||||
LOGGER.warn("Schema {} not found", name);
|
||||
return null;
|
||||
}
|
||||
|
||||
CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL);
|
||||
|
||||
@@ -1537,7 +1489,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.getVendorExtensions().putAll(schema.getExtensions());
|
||||
}
|
||||
m.isAlias = typeAliases.containsKey(name);
|
||||
m.discriminator = createDiscriminator(name, schema, allDefinitions);
|
||||
m.discriminator = schema.getDiscriminator();
|
||||
|
||||
if (schema.getXml() != null) {
|
||||
m.xmlPrefix = schema.getXml().getPrefix();
|
||||
@@ -1564,7 +1516,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
int modelImplCnt = 0; // only one inline object allowed in a ComposedModel
|
||||
for (Schema innerModel : composed.getAllOf()) {
|
||||
if (m.discriminator == null) {
|
||||
m.discriminator = createDiscriminator(name, schema, allDefinitions);
|
||||
m.discriminator = schema.getDiscriminator();
|
||||
}
|
||||
if (innerModel.getXml() != null) {
|
||||
m.xmlPrefix = innerModel.getXml().getPrefix();
|
||||
@@ -1662,7 +1614,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.isInteger = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
if (ModelUtils.isStringSchema(schema)){
|
||||
m.isString = Boolean.TRUE;
|
||||
}
|
||||
|
||||
@@ -1679,34 +1631,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return m;
|
||||
}
|
||||
|
||||
private CodegenDiscriminator createDiscriminator(String schemaName, Schema schema, Map<String, Schema> allDefinitions) {
|
||||
if(schema.getDiscriminator() == null) {
|
||||
return null;
|
||||
}
|
||||
CodegenDiscriminator discriminator = new CodegenDiscriminator();
|
||||
discriminator.setPropertyName(schema.getDiscriminator().getPropertyName());
|
||||
discriminator.setMapping(schema.getDiscriminator().getMapping());
|
||||
if(schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
|
||||
for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) {
|
||||
String name = ModelUtils.getSimpleRef(e.getValue());
|
||||
discriminator.getMappedModels().add(new MappedModel(e.getKey(), name));
|
||||
}
|
||||
} else {
|
||||
allDefinitions.forEach((childName, child) -> {
|
||||
if (child instanceof ComposedSchema && ((ComposedSchema) child).getAllOf() != null) {
|
||||
Set<String> parentSchemas = ((ComposedSchema) child).getAllOf().stream()
|
||||
.filter(s -> s.get$ref() != null)
|
||||
.map(s -> ModelUtils.getSimpleRef(s.get$ref()))
|
||||
.collect(Collectors.toSet());
|
||||
if (parentSchemas.contains(schemaName)) {
|
||||
discriminator.getMappedModels().add(new MappedModel(childName, childName));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return discriminator;
|
||||
}
|
||||
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
addParentContainer(codegenModel, codegenModel.name, schema);
|
||||
}
|
||||
@@ -2390,13 +2314,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
CodegenParameter p = fromParameter(param, imports);
|
||||
|
||||
// ensure unique params
|
||||
if (ensureUniqueParams) {
|
||||
if (!isParameterNameUnique(p, allParams)) {
|
||||
p.paramName = generateNextName(p.paramName);
|
||||
}
|
||||
}
|
||||
|
||||
allParams.add(p);
|
||||
|
||||
if (param instanceof QueryParameter || "query".equalsIgnoreCase(param.getIn())) {
|
||||
@@ -2425,6 +2342,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// ensure unique parameter name
|
||||
for (CodegenParameter cp : allParams) {
|
||||
if (ensureUniqueParams) {
|
||||
if (isParameterNameUnique(cp, allParams)) {
|
||||
continue;
|
||||
} else {
|
||||
cp.paramName = generateNextName(cp.paramName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create optional, required parameters
|
||||
for (CodegenParameter cp : allParams) {
|
||||
if (cp.required) { //required parameters
|
||||
@@ -3487,8 +3415,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return the API documentation file name with full path
|
||||
*/
|
||||
public String apiDocFilename(String templateName, String tag) {
|
||||
String docExtension = getDocExtension();
|
||||
String suffix = docExtension != null ? docExtension: apiDocTemplateFiles().get(templateName);
|
||||
String suffix = apiDocTemplateFiles().get(templateName);
|
||||
return apiDocFileFolder() + File.separator + toApiDocFilename(tag) + suffix;
|
||||
}
|
||||
|
||||
@@ -3625,25 +3552,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return releaseNote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Documentation files extension
|
||||
*
|
||||
* @return Documentation files extension
|
||||
*/
|
||||
public String getDocExtension() {
|
||||
return docExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Documentation files extension
|
||||
*
|
||||
* @param userDocExtension documentation files extension
|
||||
*/
|
||||
public void setDocExtension(String userDocExtension) {
|
||||
this.docExtension = userDocExtension;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set HTTP user agent.
|
||||
*
|
||||
@@ -4423,11 +4331,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||
if(StringUtils.isEmpty(mostInnerItem.complexType)) {
|
||||
codegenParameter.baseName = "request_body";
|
||||
} else {
|
||||
codegenParameter.baseName = mostInnerItem.complexType;
|
||||
}
|
||||
codegenParameter.baseName = mostInnerItem.complexType;
|
||||
} else {
|
||||
codegenParameter.baseName = bodyParameterName;
|
||||
}
|
||||
@@ -4469,33 +4373,19 @@ 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) {
|
||||
String codegenModelName, codegenModelDescription;
|
||||
LOGGER.warn("The following schema has undefined (null) baseType. " +
|
||||
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
|
||||
"A correct 'consumes' for form parameters should be " +
|
||||
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
|
||||
LOGGER.warn("schema: " + schema);
|
||||
LOGGER.warn("Defaulting baseType to UNKNOWN_BASE_TYPE");
|
||||
codegenProperty.baseType = "UNKNOWN_BASE_TYPE";
|
||||
|
||||
if (codegenModel != null) {
|
||||
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);
|
||||
codegenParameter.baseName = codegenProperty.baseType;
|
||||
codegenParameter.baseType = codegenProperty.baseType;
|
||||
codegenParameter.dataType = codegenProperty.dataType;
|
||||
codegenParameter.description = codegenProperty.description;
|
||||
codegenParameter.paramName = toParamName(codegenProperty.baseType);
|
||||
|
||||
if (codegenProperty.complexType != null) {
|
||||
imports.add(codegenProperty.complexType);
|
||||
@@ -4578,6 +4468,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
public boolean isDataTypeString(String dataType) {
|
||||
return "String".equals(dataType);
|
||||
return "String".equals(dataType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
/**
|
||||
* Programmatically disable the output of .openapi-generator/VERSION, .openapi-generator-ignore,
|
||||
* or other metadata files used by OpenAPI Generator.
|
||||
* or other metadata files used by Swagger Codegen.
|
||||
*
|
||||
* @param generateMetadata true: enable outputs, false: disable outputs
|
||||
*/
|
||||
@@ -193,14 +193,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
contextPath = config.escapeText(url.getPath());
|
||||
basePathWithoutHost = contextPath; // for backward compatibility
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI));
|
||||
if ("/".equals(basePath.substring(basePath.length() - 1))) {
|
||||
// remove trailing "/"
|
||||
// https://host.example.com/ => https://host.example.com
|
||||
basePath = basePath.substring(0, basePath.length() - 1);
|
||||
}
|
||||
|
||||
basePathWithoutHost = contextPath; // for backward compatibility
|
||||
}
|
||||
|
||||
private void configureOpenAPIInfo() {
|
||||
@@ -284,8 +278,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
private void generateModelDocumentation(List<File> files, Map<String, Object> models, String modelName) throws IOException {
|
||||
for (String templateName : config.modelDocTemplateFiles().keySet()) {
|
||||
String docExtension = config.getDocExtension();
|
||||
String suffix = docExtension!=null ? docExtension : config.modelDocTemplateFiles().get(templateName);
|
||||
String suffix = config.modelDocTemplateFiles().get(templateName);
|
||||
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(modelName) + suffix;
|
||||
if (!config.shouldOverwrite(filename)) {
|
||||
LOGGER.info("Skipped overwriting " + filename);
|
||||
@@ -902,8 +895,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if (path.getParameters() != null) {
|
||||
for (Parameter parameter : path.getParameters()) {
|
||||
//skip propagation if a parameter with the same name is already defined at the operation level
|
||||
if (!operationParameters.contains(generateParameterId(parameter))) {
|
||||
operation.addParametersItem(parameter);
|
||||
if (!operationParameters.contains(generateParameterId(parameter)) && operation.getParameters() != null) {
|
||||
operation.getParameters().add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class SpecValidationException extends RuntimeException {
|
||||
|
||||
private Set<String> errors;
|
||||
private Set<String> warnings;
|
||||
|
||||
/**
|
||||
* Constructs a new runtime exception with {@code null} as its
|
||||
* detail message. The cause is not initialized, and may subsequently be
|
||||
* initialized by a call to {@link #initCause}.
|
||||
*/
|
||||
public SpecValidationException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new runtime exception with the specified detail message.
|
||||
* The cause is not initialized, and may subsequently be initialized by a
|
||||
* call to {@link #initCause}.
|
||||
*
|
||||
* @param message the detail message. The detail message is saved for
|
||||
* later retrieval by the {@link #getMessage()} method.
|
||||
*/
|
||||
public SpecValidationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new runtime exception with the specified detail message and
|
||||
* cause. <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this runtime exception's detail message.
|
||||
*
|
||||
* @param message the detail message (which is saved for later retrieval
|
||||
* by the {@link #getMessage()} method).
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||
* permitted, and indicates that the cause is nonexistent or
|
||||
* unknown.)
|
||||
* @since 1.4
|
||||
*/
|
||||
public SpecValidationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new runtime exception with the specified cause and a
|
||||
* detail message of <tt>(cause==null ? null : cause.toString())</tt>
|
||||
* (which typically contains the class and detail message of
|
||||
* <tt>cause</tt>). This constructor is useful for runtime exceptions
|
||||
* that are little more than wrappers for other throwables.
|
||||
*
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||
* permitted, and indicates that the cause is nonexistent or
|
||||
* unknown.)
|
||||
* @since 1.4
|
||||
*/
|
||||
public SpecValidationException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new runtime exception with the specified detail
|
||||
* message, cause, suppression enabled or disabled, and writable
|
||||
* stack trace enabled or disabled.
|
||||
*
|
||||
* @param message the detail message.
|
||||
* @param cause the cause. (A {@code null} value is permitted,
|
||||
* and indicates that the cause is nonexistent or unknown.)
|
||||
* @param enableSuppression whether or not suppression is enabled
|
||||
* or disabled
|
||||
* @param writableStackTrace whether or not the stack trace should
|
||||
* be writable
|
||||
* @since 1.7
|
||||
*/
|
||||
public SpecValidationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public Set<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public Set<String> getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
|
||||
public void setErrors(Set<String> errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
public void setWarnings(Set<String> warnings) {
|
||||
this.warnings = warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the detail message string of this throwable.
|
||||
*
|
||||
* @return the detail message string of this {@code Throwable} instance
|
||||
* (which may be {@code null}).
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
int errorCount = 0;
|
||||
if (errors != null) {
|
||||
errorCount = errors.size();
|
||||
}
|
||||
int warningCount = 0;
|
||||
if (warnings != null) {
|
||||
warningCount = warnings.size();
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(System.lineSeparator())
|
||||
.append("Errors: ")
|
||||
.append(System.lineSeparator());
|
||||
errors.forEach(msg ->
|
||||
sb.append("\t-").append(msg).append(System.lineSeparator())
|
||||
);
|
||||
|
||||
if (!warnings.isEmpty()) {
|
||||
sb.append("Warnings: ").append(System.lineSeparator());
|
||||
warnings.forEach(msg ->
|
||||
sb.append("\t-").append(msg).append(System.lineSeparator())
|
||||
);
|
||||
}
|
||||
return super.getMessage() + " | " +
|
||||
"Error count: " + errorCount + ", Warning count: " + warningCount + sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,12 @@ package org.openapitools.codegen.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.auth.AuthParser;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
@@ -29,7 +33,6 @@ import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import io.swagger.v3.parser.core.models.SwaggerParseResult;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.openapitools.codegen.languages.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -77,7 +80,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
private boolean verbose;
|
||||
private boolean skipOverwrite;
|
||||
private boolean removeOperationIdPrefix;
|
||||
private boolean validateSpec;
|
||||
private String templateDir;
|
||||
private String auth;
|
||||
private String apiPackage;
|
||||
@@ -106,7 +108,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
private final Map<String, Object> dynamicProperties = new HashMap<String, Object>(); //the map that holds the JsonAnySetter/JsonAnyGetter values
|
||||
|
||||
public CodegenConfigurator() {
|
||||
this.validateSpec = true;
|
||||
this.setOutputDir(".");
|
||||
}
|
||||
|
||||
@@ -210,15 +211,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isValidateSpec() {
|
||||
return validateSpec;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setValidateSpec(final boolean validateSpec) {
|
||||
this.validateSpec = validateSpec;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSkipOverwrite() {
|
||||
return skipOverwrite;
|
||||
}
|
||||
@@ -522,48 +514,8 @@ public class CodegenConfigurator implements Serializable {
|
||||
options.setResolve(true);
|
||||
options.setFlatten(true);
|
||||
SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options);
|
||||
|
||||
Set<String> validationMessages = new HashSet<>(result.getMessages());
|
||||
OpenAPI specification = result.getOpenAPI();
|
||||
|
||||
// NOTE: We will only expose errors+warnings if there are already errors in the spec.
|
||||
if (validationMessages.size() > 0) {
|
||||
Set<String> warnings = new HashSet<>();
|
||||
if (specification != null) {
|
||||
List<String> unusedModels = ModelUtils.getUnusedSchemas(specification);
|
||||
if (unusedModels != null) unusedModels.forEach(name -> warnings.add("Unused model: " + name));
|
||||
}
|
||||
|
||||
if (this.isValidateSpec()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).");
|
||||
sb.append(System.lineSeparator());
|
||||
SpecValidationException ex = new SpecValidationException(sb.toString());
|
||||
ex.setErrors(validationMessages);
|
||||
ex.setWarnings(warnings);
|
||||
throw ex;
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("There were issues with the specification, but validation has been explicitly disabled.");
|
||||
sb.append(System.lineSeparator());
|
||||
|
||||
sb.append("Errors: ").append(System.lineSeparator());
|
||||
validationMessages.forEach(msg ->
|
||||
sb.append("\t-").append(msg).append(System.lineSeparator())
|
||||
);
|
||||
|
||||
if (!warnings.isEmpty()) {
|
||||
sb.append("Warnings: ").append(System.lineSeparator());
|
||||
warnings.forEach(msg ->
|
||||
sb.append("\t-").append(msg).append(System.lineSeparator())
|
||||
);
|
||||
}
|
||||
LOGGER.warn(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
input.opts(new ClientOpts())
|
||||
.openAPI(specification);
|
||||
.openAPI(result.getOpenAPI());
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -191,13 +191,7 @@ public class ExampleGenerator {
|
||||
Schema innerType = ((ArraySchema) property).getItems();
|
||||
if (innerType != null) {
|
||||
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
|
||||
if (arrayLength == Integer.MAX_VALUE) {
|
||||
// swagger-jersey2-jaxrs generated spec may contain maxItem = 2147483647
|
||||
// semantically this means there is no upper limit
|
||||
// treating this as if the property was not present at all
|
||||
LOGGER.warn("The max items allowed in property {} of {} equals Integer.MAX_VALUE. Treating this as if no max items has been specified.", property, arrayLength);
|
||||
arrayLength = 2;
|
||||
} else if (arrayLength > 1024) {
|
||||
if (arrayLength > 1024) {
|
||||
LOGGER.warn("The max items allowed in property {} is too large ({} items), restricting it to 1024 items", property, arrayLength);
|
||||
arrayLength = 1024;
|
||||
}
|
||||
|
||||
@@ -1,680 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.base.Strings;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractApexCodegen.class);
|
||||
|
||||
protected Boolean serializableModel = false;
|
||||
|
||||
public AbstractApexCodegen() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "apex";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates an Apex API client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sanitizeName(String name) {
|
||||
name = super.sanitizeName(name);
|
||||
if (name.contains("__")) { // Preventing namespacing
|
||||
name.replaceAll("__", "_");
|
||||
}
|
||||
if (name.matches("^\\d.*")) { // Prevent named credentials with leading number
|
||||
name.replaceAll("^\\d.*", "");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@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 (name.toLowerCase().matches("^_*class$")) {
|
||||
return "propertyClass";
|
||||
}
|
||||
|
||||
if ("_".equals(name)) {
|
||||
name = "_u";
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
if (startsWithTwoUppercaseLetters(name)) {
|
||||
name = name.substring(0, 2).toLowerCase() + name.substring(2);
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private boolean startsWithTwoUppercaseLetters(String name) {
|
||||
boolean startsWithTwoUppercaseLetters = false;
|
||||
if (name.length() > 1) {
|
||||
startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase());
|
||||
}
|
||||
return startsWithTwoUppercaseLetters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// to avoid conflicts with 'callback' parameter for async call
|
||||
if ("callback".equals(name)) {
|
||||
return "paramCallback";
|
||||
}
|
||||
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(final String name) {
|
||||
|
||||
final String sanitizedName = sanitizeName(name);
|
||||
|
||||
String nameWithPrefixSuffix = sanitizedName;
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
// add '_' so that model name can be camelized correctly
|
||||
nameWithPrefixSuffix = modelNamePrefix + "_" + nameWithPrefixSuffix;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
// add '_' so that model name can be camelized correctly
|
||||
nameWithPrefixSuffix = nameWithPrefixSuffix + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
final String modelName = "Model" + camelizedName;
|
||||
LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (camelizedName.matches("^\\d.*")) {
|
||||
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
return camelizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined");
|
||||
// TODO maybe better defaulting to StringProperty than returning null
|
||||
return null;
|
||||
}
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
|
||||
if (inner == null) {
|
||||
LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined");
|
||||
// TODO maybe better defaulting to StringProperty than returning null
|
||||
return null;
|
||||
}
|
||||
return getSchemaType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlias(String name) {
|
||||
if (typeAliases != null && typeAliases.containsKey(name)) {
|
||||
return typeAliases.get(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final ArraySchema ap = (ArraySchema) p;
|
||||
final String pattern = "new ArrayList<%s>()";
|
||||
if (ap.getItems() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(pattern, getTypeDeclaration(ap.getItems()));
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final MapSchema ap = (MapSchema) p;
|
||||
final String pattern = "new HashMap<%s>()";
|
||||
if (ap.getAdditionalProperties() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(pattern, String.format("String, %s", getTypeDeclaration((Schema) ap.getAdditionalProperties())));
|
||||
} else if (ModelUtils.isLongSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "l";
|
||||
}
|
||||
return "null";
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
return "null";
|
||||
} else if (ModelUtils.isFloatSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "f";
|
||||
}
|
||||
return "null";
|
||||
} else if (ModelUtils.isDoubleSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "d";
|
||||
}
|
||||
return "null";
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
return "null";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
String _default = (String) p.getDefault();
|
||||
if (p.getEnum() == null) {
|
||||
return "\"" + escapeText(_default) + "\"";
|
||||
} else {
|
||||
// convert to enum var name later in postProcessModels
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameterExampleValue(CodegenParameter p) {
|
||||
|
||||
if (Boolean.TRUE.equals(p.isLong)) {
|
||||
p.example = "2147483648L";
|
||||
} else if (Boolean.TRUE.equals(p.isFile)) {
|
||||
p.example = "Blob.valueOf('Sample text file\\nContents')";
|
||||
} else if (Boolean.TRUE.equals(p.isDate)) {
|
||||
p.example = "Date.newInstance(1960, 2, 17)";
|
||||
} else if (Boolean.TRUE.equals(p.isDateTime)) {
|
||||
p.example = "Datetime.newInstanceGmt(2013, 11, 12, 3, 3, 3)";
|
||||
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
if (p.items != null && p.items.example != null) {
|
||||
p.example = "new " + p.dataType + "{" + p.items.example + "}";
|
||||
}
|
||||
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||
if (p.items != null && p.items.example != null) {
|
||||
p.example = "new " + p.dataType + "{" + p.items.example + "}";
|
||||
}
|
||||
} else if (Boolean.TRUE.equals(p.isString)) {
|
||||
p.example = "'" + p.example + "'";
|
||||
} else if ("".equals(p.example) || p.example == null && p.dataType != "Object") {
|
||||
// Get an example object from the generated model
|
||||
if (!isReservedWord(p.dataType.toLowerCase())) {
|
||||
p.example = p.dataType + ".getExample()";
|
||||
}
|
||||
} else {
|
||||
p.example = "''";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toExampleValue(Schema p) {
|
||||
if (p == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Object obj = p.getExample();
|
||||
String example = obj == null ? "" : obj.toString();
|
||||
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
example = "new " + getTypeDeclaration(p) + "{" + toExampleValue(
|
||||
((ArraySchema) p).getItems()) + "}";
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
example = String.valueOf(!"false".equals(example));
|
||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||
if (example.isEmpty()) {
|
||||
example = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu";
|
||||
}
|
||||
((ByteArraySchema) p).setExample(example);
|
||||
example = "EncodingUtil.base64Decode('" + example + "')";
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
if (example.matches("^\\d{4}(-\\d{2}){2}")) {
|
||||
example = example.substring(0, 10).replaceAll("-0?", ", ");
|
||||
} else if (example.isEmpty()) {
|
||||
example = "2000, 1, 23";
|
||||
} else {
|
||||
LOGGER.warn(String.format("The example provided for property '%s' is not a valid RFC3339 date. Defaulting to '2000-01-23'. [%s]", p
|
||||
.getName(), example));
|
||||
example = "2000, 1, 23";
|
||||
}
|
||||
example = "Date.newInstance(" + example + ")";
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
if (example.matches("^\\d{4}([-T:]\\d{2}){5}.+")) {
|
||||
example = example.substring(0, 19).replaceAll("[-T:]0?", ", ");
|
||||
} else if (example.isEmpty()) {
|
||||
example = "2000, 1, 23, 4, 56, 7";
|
||||
} else {
|
||||
LOGGER.warn(String.format("The example provided for property '%s' is not a valid RFC3339 datetime. Defaulting to '2000-01-23T04-56-07Z'. [%s]", p
|
||||
.getName(), example));
|
||||
example = "2000, 1, 23, 4, 56, 7";
|
||||
}
|
||||
example = "Datetime.newInstanceGmt(" + example + ")";
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
example = example.replaceAll("[^-0-9.]", "");
|
||||
example = example.isEmpty() ? "1.3579" : example;
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
if (example.isEmpty()) {
|
||||
example = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu";
|
||||
p.setExample(example);
|
||||
}
|
||||
example = "EncodingUtil.base64Decode(" + example + ")";
|
||||
} else if (ModelUtils.isEmailSchema(p)) {
|
||||
if (example.isEmpty()) {
|
||||
example = "example@example.com";
|
||||
p.setExample(example);
|
||||
}
|
||||
example = "'" + example + "'";
|
||||
} else if (ModelUtils.isLongSchema(p)) {
|
||||
example = example.isEmpty() ? "123456789L" : example + "L";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
example = "new " + getTypeDeclaration(p) + "{'key'=>" + toExampleValue((Schema) p.getAdditionalProperties()) + "}";
|
||||
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
example = example.isEmpty() ? "password123" : escapeText(example);
|
||||
p.setExample(example);
|
||||
example = "'" + example + "'";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
List<String> enums = p.getEnum();
|
||||
if (enums != null && example.isEmpty()) {
|
||||
example = enums.get(0);
|
||||
p.setExample(example);
|
||||
} else if (example.isEmpty()) {
|
||||
example = "";
|
||||
} else {
|
||||
example = escapeText(example);
|
||||
p.setExample(example);
|
||||
}
|
||||
example = "'" + example + "'";
|
||||
} else if (ModelUtils.isUUIDSchema(p)) {
|
||||
example = example.isEmpty()
|
||||
? "'046b6c7f-0b8a-43b9-b35d-6489e6daee91'"
|
||||
: "'" + escapeText(example) + "'";
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
example = example.matches("^-?\\d+$") ? example : "0";
|
||||
} else if (ModelUtils.isObjectSchema(p)) {
|
||||
example = example.isEmpty() ? "null" : example;
|
||||
} else {
|
||||
example = getTypeDeclaration(p) + ".getExample()";
|
||||
}
|
||||
return example;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String schemaType = super.getSchemaType(p);
|
||||
|
||||
schemaType = getAlias(schemaType);
|
||||
|
||||
// don't apply renaming on types from the typeMapping
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
return typeMapping.get(schemaType);
|
||||
}
|
||||
|
||||
if (null == schemaType) {
|
||||
LOGGER.error("No Type defined for Property " + p);
|
||||
}
|
||||
return toModelName(schemaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return operationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) {
|
||||
CodegenModel cm = super.fromModel(name, model, allDefinitions);
|
||||
|
||||
// TODO Check enum model handling
|
||||
if (cm.interfaces == null) {
|
||||
cm.interfaces = new ArrayList<String>();
|
||||
}
|
||||
|
||||
Boolean hasDefaultValues = false;
|
||||
|
||||
// for (de)serializing properties renamed for Apex (e.g. reserved words)
|
||||
List<Map<String, String>> propertyMappings = new ArrayList<>();
|
||||
for (CodegenProperty p : cm.allVars) {
|
||||
hasDefaultValues |= p.defaultValue != null;
|
||||
if (!p.baseName.equals(p.name)) {
|
||||
Map<String, String> mapping = new HashMap<>();
|
||||
mapping.put("externalName", p.baseName);
|
||||
mapping.put("internalName", p.name);
|
||||
propertyMappings.add(mapping);
|
||||
}
|
||||
}
|
||||
|
||||
cm.vendorExtensions.put("hasPropertyMappings", !propertyMappings.isEmpty());
|
||||
cm.vendorExtensions.put("hasDefaultValues", hasDefaultValues);
|
||||
cm.vendorExtensions.put("propertyMappings", propertyMappings);
|
||||
|
||||
if (!propertyMappings.isEmpty()) {
|
||||
cm.interfaces.add("OAS.MappedProperties");
|
||||
}
|
||||
return cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
if (parameter.isBodyParam && parameter.isListContainer) {
|
||||
// items of array bodyParams are being nested an extra level too deep for some reason
|
||||
parameter.items = parameter.items.items;
|
||||
setParameterExampleValue(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
/* the following function is not used anywhere in this class so we'll remove it later
|
||||
private static String getAccept(Operation operation) {
|
||||
String accepts = null;
|
||||
String defaultContentType = "application/json";
|
||||
if (operation.getProduces() != null && !operation.getProduces().isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String produces : operation.getProduces()) {
|
||||
if (defaultContentType.equalsIgnoreCase(produces)) {
|
||||
accepts = defaultContentType;
|
||||
break;
|
||||
} else {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(produces);
|
||||
}
|
||||
}
|
||||
if (accepts == null) {
|
||||
accepts = sb.toString();
|
||||
}
|
||||
} else {
|
||||
accepts = defaultContentType;
|
||||
}
|
||||
|
||||
return accepts;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected boolean needToImport(String type) {
|
||||
return super.needToImport(type) && type.indexOf(".") < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
if (value.length() == 0) {
|
||||
return "EMPTY";
|
||||
}
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return getSymbolName(value).toUpperCase();
|
||||
}
|
||||
|
||||
// number
|
||||
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
|
||||
"Float".equals(datatype) || "Double".equals(datatype)) {
|
||||
String varName = "NUMBER_" + value;
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
varName = varName.replaceAll("\\+", "PLUS_");
|
||||
varName = varName.replaceAll("\\.", "_DOT_");
|
||||
return varName;
|
||||
}
|
||||
|
||||
// string
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase();
|
||||
if (var.matches("\\d.*")) {
|
||||
return "_" + var;
|
||||
} else {
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if ("Integer".equals(datatype) || "Double".equals(datatype)) {
|
||||
return value;
|
||||
} else if ("Long".equals(datatype)) {
|
||||
// add l to number, e.g. 2048 => 2048l
|
||||
return value + "l";
|
||||
} else if ("Float".equals(datatype)) {
|
||||
// add f to number, e.g. 3.14 => 3.14f
|
||||
return value + "f";
|
||||
} else {
|
||||
return "\"" + escapeText(value) + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Schema> definitions, OpenAPI openAPI) {
|
||||
|
||||
CodegenOperation op = super.fromOperation(
|
||||
path, httpMethod, operation, definitions, openAPI);
|
||||
|
||||
if (op.getHasExamples()) {
|
||||
// prepare examples for Apex test classes
|
||||
ApiResponse apiResponse = findMethodResponse(operation.getResponses());
|
||||
final Schema responseSchema = ModelUtils.getSchemaFromResponse(apiResponse);
|
||||
String deserializedExample = toExampleValue(responseSchema);
|
||||
for (Map<String, String> example : op.examples) {
|
||||
example.put("example", escapeText(example.get("example")));
|
||||
example.put("deserializedExample", deserializedExample);
|
||||
}
|
||||
}
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
|
||||
// This generator uses inline classes to define enums, which breaks when
|
||||
// dealing with models that have subTypes. To clean this up, we will analyze
|
||||
// the parent and child models, look for enums that match, and remove
|
||||
// them from the child models and leave them in the parent.
|
||||
// Because the child models extend the parents, the enums will be available via the parent.
|
||||
|
||||
// Only bother with reconciliation if the parent model has enums.
|
||||
if (!parentCodegenModel.hasEnums) {
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
// Get the properties for the parent and child models
|
||||
final List<CodegenProperty> parentModelCodegenProperties = parentCodegenModel.vars;
|
||||
List<CodegenProperty> codegenProperties = codegenModel.vars;
|
||||
|
||||
// Iterate over all of the parent model properties
|
||||
boolean removedChildEnum = false;
|
||||
for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) {
|
||||
// Look for enums
|
||||
if (parentModelCodegenPropery.isEnum) {
|
||||
// Now that we have found an enum in the parent class,
|
||||
// and search the child class for the same enum.
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) {
|
||||
// We found an enum in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
removedChildEnum = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (removedChildEnum) {
|
||||
// If we removed an entry from this model's vars, we need to ensure hasMore is updated
|
||||
int count = 0, numVars = codegenProperties.size();
|
||||
for (CodegenProperty codegenProperty : codegenProperties) {
|
||||
count += 1;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : false;
|
||||
}
|
||||
codegenModel.vars = codegenProperties;
|
||||
}
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
private static String sanitizePackageName(String packageName) {
|
||||
packageName = packageName.trim(); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_");
|
||||
if (Strings.isNullOrEmpty(packageName)) {
|
||||
return "invalidPackageName";
|
||||
}
|
||||
return packageName;
|
||||
}
|
||||
|
||||
|
||||
public void setSerializableModel(Boolean serializableModel) {
|
||||
this.serializableModel = serializableModel;
|
||||
}
|
||||
|
||||
private String sanitizePath(String p) {
|
||||
//prefer replace a ", instead of a fuLL URL encode for readability
|
||||
return p.replaceAll("\"", "%22");
|
||||
}
|
||||
|
||||
public String toRegularExpression(String pattern) {
|
||||
return escapeText(pattern);
|
||||
}
|
||||
|
||||
public boolean convertPropertyToBoolean(String propertyKey) {
|
||||
boolean booleanValue = false;
|
||||
if (additionalProperties.containsKey(propertyKey)) {
|
||||
booleanValue = Boolean.valueOf(additionalProperties.get(propertyKey).toString());
|
||||
}
|
||||
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
public void writePropertyBack(String propertyKey, boolean value) {
|
||||
additionalProperties.put(propertyKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sanitizeTag(String tag) {
|
||||
return camelize(sanitizeName(tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return toModelName(name) + "Test";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -603,12 +603,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user