forked from loafle/openapi-generator-original
Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74914b6313 | ||
|
|
30d10213ec | ||
|
|
c51986d657 | ||
|
|
97bab928bd | ||
|
|
75171b4672 | ||
|
|
7c49bdd953 | ||
|
|
c607ea8b31 | ||
|
|
53d9878cf2 | ||
|
|
798bf61fde | ||
|
|
e5635d236d | ||
|
|
6c996a7d1a | ||
|
|
5630746794 | ||
|
|
680a2bc3ec | ||
|
|
f8e61ac914 | ||
|
|
24104dac35 | ||
|
|
7126074f49 | ||
|
|
91d6d77a09 | ||
|
|
f964873a2d | ||
|
|
6f6a4a1013 | ||
|
|
49b8ece776 | ||
|
|
299527370e | ||
|
|
55f9e31f81 | ||
|
|
2ff81caef6 | ||
|
|
9930f610a7 | ||
|
|
d2016d8e0a | ||
|
|
defedf6e2b | ||
|
|
8ae1c814d5 | ||
|
|
0453e64fa6 | ||
|
|
0a479f77f6 | ||
|
|
2392a09eeb | ||
|
|
f5f00069bd | ||
|
|
640fd87e3b | ||
|
|
43b60e667e | ||
|
|
a2c27ba8a6 | ||
|
|
f5708218ea | ||
|
|
276afefc85 | ||
|
|
36d1ec364e | ||
|
|
dbbeffa712 | ||
|
|
0adfd9f8e9 | ||
|
|
178949038f | ||
|
|
5a332f3c57 | ||
|
|
f72059e7ac | ||
|
|
992afd51eb | ||
|
|
8de5c62cf2 | ||
|
|
ebaa7021a4 | ||
|
|
51437af1cd | ||
|
|
c45dba1691 | ||
|
|
fbe9626b7e | ||
|
|
cf657f1c7b | ||
|
|
f65193e6fb | ||
|
|
7a1945e154 | ||
|
|
f4c66d9e53 | ||
|
|
0fb1ffa88b | ||
|
|
69a3852ef7 | ||
|
|
d649c1311e | ||
|
|
f7eacbb0c5 | ||
|
|
3e928fff2d | ||
|
|
967cc5bd3b | ||
|
|
b8f1e5afa1 | ||
|
|
fe04a0e347 | ||
|
|
0e4d3e7815 | ||
|
|
e631c16b96 | ||
|
|
501245d0c2 | ||
|
|
df55ab3efb | ||
|
|
1e5e1d4458 |
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: 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
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
||||
out/
|
||||
*.ipr
|
||||
*.iws
|
||||
*.gpg
|
||||
classpath.txt
|
||||
version.properties
|
||||
!modules/openapi-generator-cli/src/main/resources/version.properties
|
||||
|
||||
38
.travis.yml
38
.travis.yml
@@ -9,8 +9,9 @@ cache:
|
||||
- $HOME/.ivy2
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
||||
- $HOME/samples/client/petstore/javascript/node_modules
|
||||
- $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor
|
||||
- $HOME/samples/client/petstore/ruby/venodr/bundle
|
||||
- $HOME/samples/client/petstore/ruby/vendor/bundle
|
||||
- $HOME/samples/client/petstore/python/.venv/
|
||||
- $HOME/samples/client/petstore/typescript-node/npm/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-node/npm/typings/
|
||||
@@ -24,7 +25,10 @@ cache:
|
||||
- $HOME/samples/client/petstore/typescript-fetch/npm/with-npm-version/typings
|
||||
- $HOME/samples/client/petstore/typescript-angular/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-angular/typings
|
||||
- $HOME/samples/server/petstore/rust-server/target
|
||||
- $HOME/perl5
|
||||
- $HOME/.cargo
|
||||
- $HOME/.stack
|
||||
|
||||
services:
|
||||
- docker
|
||||
@@ -40,7 +44,7 @@ before_install:
|
||||
- stack upgrade
|
||||
- stack --version
|
||||
# install rust
|
||||
- curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
||||
- 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
|
||||
@@ -72,12 +76,17 @@ before_install:
|
||||
- cat /etc/hosts
|
||||
# show java version
|
||||
- java -version
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
openssl aes-256-cbc -K $encrypted_6e2c8bba47c6_key -iv $encrypted_6e2c8bba47c6_iv -in sec.gpg.enc -out sec.gpg -d ;
|
||||
gpg --keyserver keyserver.ubuntu.com --recv-key $SIGNING_KEY ;
|
||||
gpg --check-trustdb ;
|
||||
fi;
|
||||
|
||||
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"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$HOME/.cargo/bin:$PATH"
|
||||
- go version
|
||||
|
||||
script:
|
||||
@@ -93,10 +102,25 @@ script:
|
||||
- mvn --quiet clean install
|
||||
- mvn --quiet verify -Psamples
|
||||
after_success:
|
||||
# push a snapshot version to maven repo
|
||||
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_BRANCH" = "master" ]; then
|
||||
mvn clean deploy --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
# 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;
|
||||
else
|
||||
mvn clean deploy --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
cd modules/openapi-generator-gradle-plugin;
|
||||
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
||||
echo "Finished ./gradlew uploadArchives";
|
||||
popd;
|
||||
fi;
|
||||
fi;
|
||||
## 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
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<url>https://github.com/openapi-tools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
|
||||
@@ -214,12 +214,13 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<source>1.8</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<maxmemory>1g</maxmemory>
|
||||
<failOnWarnings>true</failOnWarnings>
|
||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -218,12 +218,13 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<source>1.8</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<maxmemory>1g</maxmemory>
|
||||
<failOnWarnings>true</failOnWarnings>
|
||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
@@ -832,6 +833,8 @@
|
||||
</activation>
|
||||
<modules>
|
||||
<!-- clients -->
|
||||
<!-- test non-java projects -->
|
||||
<module>samples/client/petstore/go</module>
|
||||
<!-- test java-related projects -->
|
||||
<module>samples/client/petstore/akka-scala</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
@@ -854,8 +857,6 @@
|
||||
<module>samples/client/petstore/kotlin/</module>
|
||||
<module>samples/client/petstore/kotlin-threetenbp/</module>
|
||||
<module>samples/client/petstore/kotlin-string/</module>
|
||||
<!-- test non-java projects -->
|
||||
<module>samples/client/petstore/go</module>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/java-vertx/rx</module>
|
||||
<module>samples/server/petstore/java-vertx/async</module>
|
||||
@@ -872,9 +873,10 @@
|
||||
<module>samples/server/petstore/java-play-framework-api-package-override</module>
|
||||
<module>samples/server/petstore/undertow</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey1</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey2</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey1-useTags</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey2-useTags</module>
|
||||
<!-- move to other CI as the following fails often in CircleCI
|
||||
<module>samples/server/petstore/jaxrs/jersey2</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey2-useTags</module> -->
|
||||
<module>samples/server/petstore/jaxrs-datelib-j8</module>
|
||||
<module>samples/server/petstore/jaxrs-resteasy/default</module>
|
||||
<module>samples/server/petstore/jaxrs-resteasy/eap</module>
|
||||
@@ -882,9 +884,10 @@
|
||||
<module>samples/server/petstore/jaxrs-resteasy/eap-java8</module>
|
||||
<module>samples/server/petstore/jaxrs-resteasy/joda</module>
|
||||
<!--<module>samples/server/petstore/kotlin-server/ktor</module>-->
|
||||
<!-- move to other CI as the following fails often in CircleCI
|
||||
<module>samples/server/petstore/spring-mvc</module>
|
||||
<module>samples/server/petstore/spring-mvc-j8-async</module>
|
||||
<module>samples/server/petstore/spring-mvc-j8-localdatetime</module>
|
||||
<module>samples/server/petstore/spring-mvc-j8-localdatetime</module>-->
|
||||
<module>samples/client/petstore/spring-cloud</module>
|
||||
<module>samples/server/petstore/springboot</module>
|
||||
<module>samples/server/petstore/springboot-beanvalidation</module>
|
||||
@@ -897,6 +900,7 @@
|
||||
<module>samples/server/petstore/jaxrs-spec-interface</module>
|
||||
<module>samples/server/petstore/scala-lagom-server</module>
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<module>samples/server/petstore/finch</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -218,12 +218,13 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<source>1.8</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<maxmemory>1g</maxmemory>
|
||||
<failOnWarnings>true</failOnWarnings>
|
||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -214,12 +214,13 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<source>1.8</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<maxmemory>1g</maxmemory>
|
||||
<failOnWarnings>true</failOnWarnings>
|
||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -1,946 +0,0 @@
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.0.0</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:openapitools/openapi-generator.git</developerConnection>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
</scm>
|
||||
<developers>
|
||||
<!-- original author of the project -->
|
||||
<developer>
|
||||
<id>fehguy</id>
|
||||
<name>Tony Tam</name>
|
||||
<email>fehguy@gmail.com</email>
|
||||
</developer>
|
||||
<!-- openapi-generator core team -->
|
||||
<developer>
|
||||
<id>wing328</id>
|
||||
<name>William Cheng</name>
|
||||
<email>wing328hk@gmail.com</email>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jimschubert</id>
|
||||
<name>Jim Schubert</name>
|
||||
<email>james.schubert@gmail.com</email>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>cbornet</id>
|
||||
<name>Christophe Bornet</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jaz-ah</id>
|
||||
<name>Joseph Zuromski</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>ackintosh</id>
|
||||
<name>Akihito Nakano</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>JFCote</id>
|
||||
<name>Jean-François Côté</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jmini</id>
|
||||
<name>Jérémie Bresson</name>
|
||||
<email>dev@jmini.fr</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<issueManagement>
|
||||
<system>github</system>
|
||||
<url>https://github.com/openapitools/openapi-generator/issues</url>
|
||||
</issueManagement>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<outputDirectory>target/classes</outputDirectory>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.jvnet.wagon-svn</groupId>
|
||||
<artifactId>wagon-svn</artifactId>
|
||||
<version>1.8</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-6</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-webdav</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<directory>target</directory>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<!-- Uncomment this to format before checkstyle -->
|
||||
<!-- <executions>
|
||||
<execution>
|
||||
<id>format</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>format</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions> -->
|
||||
<configuration>
|
||||
<compilerSource>1.8</compilerSource>
|
||||
<compilerCompliance>1.8</compilerCompliance>
|
||||
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||
<lineEnding>LF</lineEnding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<configuration>
|
||||
<configLocation>../google_checkstyle.xml</configLocation>
|
||||
<!-- Don't include generated sources a la http://stackoverflow.com/a/30406454 -->
|
||||
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
|
||||
<encoding>UTF-8</encoding>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<failsOnError>true</failsOnError>
|
||||
<linkXRef>false</linkXRef>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>6.19</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire-version}</version>
|
||||
<configuration>
|
||||
<testNGArtifactName>none:none</testNGArtifactName>
|
||||
<argLine>-XX:+StartAttachListener</argLine>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-testng</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<junitArtifactName>none:none</junitArtifactName>
|
||||
<testNGArtifactName>org.testng:testng</testNGArtifactName>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<mode>development</mode>
|
||||
<url>${project.url}</url>
|
||||
<implementation-version>${project.version}</implementation-version>
|
||||
<package>org.openapitools</package>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<source>1.8</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<maxmemory>1g</maxmemory>
|
||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-versions</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>3.2.5</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>0.5.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release-profile</id>
|
||||
<properties>
|
||||
<skipTests>true</skipTests>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration/>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/main/scala</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release-sign-artifacts</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>performRelease</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<!-- Samples -->
|
||||
<profile>
|
||||
<id>android-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/android/volley</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>bash-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/bash</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>clojure-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>clojure</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/clojure</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>haskell-http-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>haskell-http-client</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<!--<module>../samples/client/petstore/haskell-http-client</module>-->
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>haskell-http-client-integration-test</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>haskell-http-client</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/haskell-http-client/tests-integration</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-jersey1</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/jersey1</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-jersey2</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/jersey2</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-jersey2-java6</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/jersey2-java6</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-okhttp-gson</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/okhttp-gson</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-okhttp-gson-parcelable</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/okhttp-gson/parcelableModel</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-retrofit</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/retrofit</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-retrofit2</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/retrofit2</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-retrofit2-rx</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/retrofit2rx</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-client-feign</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/java/feign</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>javascript-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>javascript</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/javascript</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>scala-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>scala</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/scala</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-msf4j-server</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/java-msf4/</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-cxf-server</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs-cxf</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-resteasy-server</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs-resteasy/default</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-resteasy-server-joda</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs-resteasy/joda</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-resteasy-eap-server</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs-resteasy/eap</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-resteasy-eap-server-joda</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs-resteasy/eap-joda</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-server</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs/jersey2</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-server-jersey1</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/jaxrs/jersey1</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>typescript-fetch-client-tests-default</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/typescript-fetch/tests/default</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>typescript-fetch-client-builds-default</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/typescript-fetch/builds/default</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>typescript-fetch-client-builds-es6-target</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/typescript-fetch/builds/es6-target</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>typescript-fetch-client-builds-with-npm-version</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>typescript-angularjs-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/typescript-angularjs/npm</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>typescript-node-npm-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/typescript-node/npm</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>python-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/python</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>ruby-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/ruby</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>go-client</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/go</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>spring-mvc</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/spring-mvc</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>springboot-beanvalidation</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/springboot-beanvalidation</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>springboot-reactive</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/springboot-reactive</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>springboot</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/springboot</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>spring-cloud</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/client/petstore/spring-cloud</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>scalatra-server</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/scalatra</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-inflector</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/java-inflector</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java-undertowr</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>java</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>../samples/server/petstore/undertow</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>samples</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>samples</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<!-- clients -->
|
||||
<module>../samples/client/petstore/elixir</module>
|
||||
<!--<module>../samples/client/petstore/haskell-http-client</module>-->
|
||||
<module>../samples/client/petstore/erlang-client</module>
|
||||
<!-- servers -->
|
||||
<module>../samples/server/petstore/erlang-server</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
<modules>
|
||||
<module>../modules/openapi-generator</module>
|
||||
<module>../modules/openapi-generator-cli</module>
|
||||
<module>../modules/openapi-generator-maven-plugin</module>
|
||||
<module>../modules/openapi-generator-online</module>
|
||||
</modules>
|
||||
<reporting>
|
||||
<outputDirectory>target/site</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<version>${scala-maven-plugin-version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>project-team</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<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>
|
||||
<commons-io-version>2.4</commons-io-version>
|
||||
<commons-cli-version>1.2</commons-cli-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<commons-lang-version>3.4</commons-lang-version>
|
||||
<slf4j-version>1.7.12</slf4j-version>
|
||||
<scala-maven-plugin-version>3.2.1</scala-maven-plugin-version>
|
||||
<jmustache-version>1.12</jmustache-version>
|
||||
<testng-version>6.9.6</testng-version>
|
||||
<surefire-version>2.19.1</surefire-version>
|
||||
<jmockit-version>1.25</jmockit-version>
|
||||
<reflections-version>0.9.10</reflections-version>
|
||||
<spring-boot-version>2.0.2.RELEASE</spring-boot-version>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -10,9 +10,27 @@
|
||||
<username>${env.SONATYPE_USERNAME}</username>
|
||||
<password>${env.SONATYPE_PASSWORD}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>ossrh</id>
|
||||
<username>${env.SONATYPE_USERNAME}</username>
|
||||
<password>${env.SONATYPE_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<mirrors/>
|
||||
<proxies/>
|
||||
<profiles/>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<gpg.executable>gpg</gpg.executable>
|
||||
<gpg.keyname>${env.SIGNING_KEY}</gpg.keyname>
|
||||
<gpg.passphrase>${env.SIGNING_PASSPHRASE}</gpg.passphrase>
|
||||
<gpg.secretKeyring>${env.TRAVIS_BUILD_DIR}/sec.gpg</gpg.secretKeyring>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles/>
|
||||
</settings>
|
||||
|
||||
@@ -22,6 +22,10 @@ If you're new to git, you may find the following FAQs useful:
|
||||
|
||||
https://github.com/openapitools/openapi-generator/wiki/FAQ#git
|
||||
|
||||
### Branches
|
||||
|
||||
Please file the pull request against the correct branch, e.g. `master` for non-breaking changes. See the [Git Branches](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches) page for more information.
|
||||
|
||||
### Code generators
|
||||
|
||||
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
|
||||
|
||||
99
README.md
99
README.md
@@ -2,11 +2,20 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
Master (3.0.0): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.0.2`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator/dashboard)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`3.1.x`](https://github.com/OpenAPITools/openapi-generator/tree/3.1.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`4.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
@@ -47,10 +56,11 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [1 - Installation](#1---installation)
|
||||
- [1.1 - Compatibility](#11---compatibility)
|
||||
- [1.2 - Download JAR](#12---download-jar)
|
||||
- [1.3 - Build Projects](#13---build-projects)
|
||||
- [1.4 - Homebrew](#14---homebrew)
|
||||
- [1.5 - Docker](#15---docker)
|
||||
- [1.2 - Artifacts on Maven Central](#12---artifacts-on-maven-central)
|
||||
- [1.3 - Download JAR](#13---download-jar)
|
||||
- [1.4 - Build Projects](#14---build-projects)
|
||||
- [1.5 - Homebrew](#15---homebrew)
|
||||
- [1.6 - Docker](#16---docker)
|
||||
- [2 - Getting Started](#2---getting-started)
|
||||
- [3 - Usage](#3---usage)
|
||||
- [3.1 - Customization](#31---customization)
|
||||
@@ -73,12 +83,59 @@ 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) | TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes (no fallback)
|
||||
3.1.0 (upcoming minor release) | TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
|
||||
3.0.0 (current master, upcoming release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.0.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | First release with breaking changes
|
||||
4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes (no fallback)
|
||||
3.1.0 (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.2 (current master, upcoming release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.0.2/)| TBD | 1.0, 1.1, 1.2,
|
||||
[3.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.1) | 11.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.0.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.0) | 01.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | First release with breaking changes
|
||||
|
||||
### [1.2 - Artifacts on Maven Central](#table-of-contents)
|
||||
|
||||
### [1.2 - Download JAR](#table-of-contents)
|
||||
You can find our released artefacts on maven central:
|
||||
|
||||
**Core:**
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator</artifactId>
|
||||
<version>${openapi-generator-version}</version>
|
||||
</dependency>
|
||||
```
|
||||
See the different versions of the [openapi-generator](https://mvnrepository.com/artifact/org.openapitools/openapi-generator) artifact available on maven central.
|
||||
|
||||
**Cli:**
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-cli</artifactId>
|
||||
<version>${openapi-generator-version}</version>
|
||||
</dependency>
|
||||
```
|
||||
See the different versions of the [openapi-generator-cli](https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli) artifact available on maven central.
|
||||
|
||||
**Maven plugin:**
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>${openapi-generator-version}</version>
|
||||
</dependency>
|
||||
```
|
||||
* See the different versions of the [openapi-generator-maven-plugin](https://mvnrepository.com/artifact/org.openapitools/openapi-generator-maven-plugin) artifact available on maven central.
|
||||
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.adoc)
|
||||
|
||||
**Gradle plugin:**
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-gradle-plugin</artifactId>
|
||||
<version>${openapi-generator-version}</version>
|
||||
</dependency>
|
||||
```
|
||||
* See the different versions of the [openapi-generator-gradle-plugin](https://mvnrepository.com/artifact/org.openapitools/openapi-generator-gradle-plugin) artifact available on maven central.
|
||||
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc)
|
||||
|
||||
### [1.3 - Download JAR](#table-of-contents)
|
||||
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
@@ -86,12 +143,12 @@ JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generato
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.0/openapi-generator-cli-3.0.0.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.1/openapi-generator-cli-3.0.1.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.0/openapi-generator-cli-3.0.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.1/openapi-generator-cli-3.0.1.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -102,7 +159,7 @@ export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
|
||||
export PATH=${JAVA_HOME}/bin:$PATH
|
||||
```
|
||||
|
||||
### [1.3 - Build Projects](#table-of-contents)
|
||||
### [1.4 - Build Projects](#table-of-contents)
|
||||
|
||||
To build from source, you need the following installed and available in your `$PATH:`
|
||||
|
||||
@@ -120,7 +177,7 @@ If you don't have maven installed, you may directly use the included [maven wrap
|
||||
./mvnw clean install
|
||||
```
|
||||
|
||||
### [1.4 - Homebrew](#table-of-contents)
|
||||
### [1.5 - Homebrew](#table-of-contents)
|
||||
|
||||
To install, run `brew install openapi-generator`
|
||||
|
||||
@@ -129,7 +186,9 @@ Here is an example usage to generate a Ruby client:
|
||||
openapi-generator generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby -o /tmp/test/
|
||||
```
|
||||
|
||||
### [1.5 - Docker](#table-of-contents)
|
||||
To reinstall with the latest master, run `brew reinstall --HEAD openapi-generator`
|
||||
|
||||
### [1.6 - Docker](#table-of-contents)
|
||||
|
||||
#### Public Pre-built Docker images
|
||||
|
||||
@@ -346,15 +405,23 @@ The OpenAPI Generator project is intended as a benefit for users of the Open API
|
||||
When code is generated from this project, it shall be considered **AS IS** and owned by the user of the software. There are no warranties--expressed or implied--for generated code. You can do what you wish with it, and once generated, the code is your responsibility and subject to the licensing terms that you deem appropriate.
|
||||
|
||||
## [4 - Companies/Projects using OpenAPI Generator](#table-of-contents)
|
||||
Here are some companies/projects using OpenAPI Generator in production. To add your company/project to the list, please visit [README.md](README.md) and click on the icon to edit the page.
|
||||
Here are some companies/projects (alphabetical order) using OpenAPI Generator in production. To add your company/project to the list, please visit [README.md](README.md) and click on the icon to edit the page.
|
||||
|
||||
- [Angular.Schule](https://angular.schule/)
|
||||
- [Bithost GmbH](https://www.bithost.ch)
|
||||
- [GMO Pepabo](https://pepabo.com/en/)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [REST United](https://restunited.com)
|
||||
- [unblu inc.](https://www.unblu.com/)
|
||||
|
||||
|
||||
## [5 - Presentations/Videos/Tutorials/Books](#table-of-contents)
|
||||
|
||||
- 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/04/12 - [Generate Angular API clients with Swagger](https://angular.schule/blog/2018-04-swagger-codegen) by [JohannesHoppe](https://github.com/JohannesHoppe)
|
||||
- 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)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
|
||||
@@ -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 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/pistache-server $@"
|
||||
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
|
||||
@@ -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/cpprest -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-restsdk -o samples/client/petstore/cpprest $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-qt5 -o samples/client/petstore/cpp-qt5 $@"
|
||||
|
||||
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 -g cpp-restbed-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/restbed $@"
|
||||
ags="generate -g cpp-restbed-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/cpp-restbed $@"
|
||||
|
||||
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/tizen -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-tizen -o samples/client/petstore/tizen $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-rest-sdk-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-restsdk -o samples/client/petstore/cpp-restsdk $@"
|
||||
|
||||
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/qt5cpp -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-qt5 -o samples/client/petstore/qt5cpp $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-tizen-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-tizen -o samples/client/petstore/cpp-tizen $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
# this bash script run the scripts for the 'mature' generators
|
||||
# it ensures that all changes are commited into the 'samples/' folder
|
||||
|
||||
echo "# START SCRIPT: $0"
|
||||
|
||||
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) to ensure that the 'samples/' folder is up to date."
|
||||
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
|
||||
|
||||
sleep 5
|
||||
|
||||
# LIST OF SCRIPTS:
|
||||
./bin/ruby-petstore.sh
|
||||
./bin/java-petstore-all.sh
|
||||
./bin/spring-all-pestore.sh
|
||||
./bin/kotlin-client-petstore.sh
|
||||
./bin/kotlin-client-string.sh
|
||||
./bin/kotlin-client-threetenbp.sh
|
||||
./bin/kotlin-server-petstore.sh
|
||||
./bin/php-petstore.sh
|
||||
./bin/php-silex-petstore-server.sh
|
||||
./bin/php-symfony-petstore.sh
|
||||
./bin/php-lumen-petstore-server.sh
|
||||
./bin/php-slim-petstore-server.sh
|
||||
./bin/php-ze-ph-petstore-server.sh
|
||||
./bin/openapi3/php-petstore.sh
|
||||
|
||||
# Check:
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "UNCOMMITTED CHANGES ERROR"
|
||||
echo "There are uncommitted changes in working tree after execution of 'bin/ensure-up-to-date'"
|
||||
git status
|
||||
echo "Please run 'bin/ensure-up-to-date' locally and commit changes"
|
||||
exit 1
|
||||
else
|
||||
echo "Git working tree is clean"
|
||||
fi
|
||||
19
bin/java-jaxrs-petstore-server-all.sh
Executable file
19
bin/java-jaxrs-petstore-server-all.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# script to run all generators extending AbstractJavaJAXRSServerCodegen
|
||||
|
||||
./bin/jaxrs-petstore-server-datelib-j8.sh
|
||||
./bin/jaxrs-cxf-cdi-petstore-server.sh
|
||||
./bin/jaxrs-cxf-petstore-server-annotated-base-path.sh
|
||||
./bin/jaxrs-cxf-petstore-server-non-spring-application.sh
|
||||
./bin/jaxrs-cxf-petstore-server.sh
|
||||
./bin/jaxrs-jersey1-petstore-server.sh
|
||||
./bin/jaxrs-jersey1-usetags-petstore-server.sh
|
||||
./bin/jaxrs-petstore-server.sh
|
||||
./bin/jaxrs-resteasy-eap-java8-petstore-server.sh
|
||||
./bin/jaxrs-resteasy-eap-joda-petstore-server.sh
|
||||
./bin/jaxrs-resteasy-eap-petstore-server.sh
|
||||
./bin/jaxrs-resteasy-joda-petstore-server.sh
|
||||
./bin/jaxrs-resteasy-petstore-server.sh
|
||||
./bin/jaxrs-spec-petstore-server-interface.sh
|
||||
./bin/jaxrs-spec-petstore-server.sh
|
||||
./bin/jaxrs-usetags-petstore-server.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 -g cpp-pistache-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/pistache-server $@"
|
||||
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
|
||||
@@ -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/qt5cpp -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-qt5 -o samples/client/petstore/qt5cpp $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-qt5 -o samples/client/petstore/cpp-qt5 $@"
|
||||
|
||||
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 -g cpp-restbed-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/restbed $@"
|
||||
ags="generate -g cpp-restbed-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/cpp-restbed $@"
|
||||
|
||||
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/tizen -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-tizen -o samples/client/petstore/tizen $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-tizen-client -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-tizen -o samples/client/petstore/cpp-tizen $@"
|
||||
|
||||
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/rust-server -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g rust-server -o samples/server/petstore/rust-server -DpackageName=petstore_api $@"
|
||||
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
|
||||
|
||||
@@ -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/qt5cpp -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g cpp-qt5 -o samples/client/petstore-security-test/qt5cpp $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g cpp-qt5 -o samples/client/petstore-security-test/cpp-qt5 $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -t modules/openapi-generator/src/main/resources/qt5cpp -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g qt5cpp -o samples\client\petstore-security-test\qt5cpp
|
||||
set ags=generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g qt5cpp -o samples\client\petstore-security-test\qt5cpp
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
41
bin/utils/ensure-up-to-date
Executable file
41
bin/utils/ensure-up-to-date
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# this bash script run the scripts for the 'mature' generators
|
||||
# it ensures that all changes are committed into the 'samples/' folder
|
||||
|
||||
echo "# START SCRIPT: $0"
|
||||
|
||||
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) to ensure that the 'samples/' folder is up to date."
|
||||
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
|
||||
|
||||
sleep 5
|
||||
|
||||
# LIST OF SCRIPTS:
|
||||
./bin/ruby-petstore.sh > /dev/null 2>&1
|
||||
./bin/java-petstore-all.sh > /dev/null 2>&1
|
||||
./bin/java-jaxrs-petstore-server-all.sh > /dev/null 2>&1
|
||||
./bin/spring-all-pestore.sh > /dev/null 2>&1
|
||||
./bin/kotlin-client-petstore.sh > /dev/null 2>&1
|
||||
./bin/kotlin-client-string.sh > /dev/null 2>&1
|
||||
./bin/kotlin-client-threetenbp.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.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-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
|
||||
|
||||
# Check:
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "UNCOMMITTED CHANGES ERROR"
|
||||
echo "There are uncommitted changes in working tree after execution of 'bin/ensure-up-to-date'"
|
||||
echo "Perform git diff"
|
||||
git --no-pager diff
|
||||
echo "Perform git status"
|
||||
git status
|
||||
echo "Please run 'bin/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
|
||||
exit 1
|
||||
else
|
||||
echo "Git working tree is clean"
|
||||
fi
|
||||
63
bin/utils/release_version_update.sh
Executable file
63
bin/utils/release_version_update.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/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=("CI/pom.xml.bash"
|
||||
"CI/pom.xml.circleci"
|
||||
"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"
|
||||
"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 -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-pistache-server -o samples\server\petstore\pistache-server\
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-pistache-server -o samples\server\petstore\cpp-pistache\
|
||||
|
||||
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 cpp-qt5 -o samples\client\petstore\qt5cpp
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-qt5 -o samples\client\petstore\cpp-qt5
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-restbed-server -o samples\server\petstore\restbed\
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-restbed-server -o samples\server\petstore\cpp-restbed\
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-restsdk -o samples\client\petstore\cpprest
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-restsdk -o samples\client\petstore\cpp-restsdk
|
||||
|
||||
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 cpp-tizen -o samples\client\petstore\tizen
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-tizen -o samples\client\petstore\cpp-tizen
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
147
circle.yml
147
circle.yml
@@ -1,54 +1,93 @@
|
||||
# Java-related client, server tests
|
||||
machine:
|
||||
java:
|
||||
version: openjdk8
|
||||
services:
|
||||
- docker
|
||||
# Override /etc/hosts
|
||||
hosts:
|
||||
petstore.swagger.io: 127.0.0.1
|
||||
environment:
|
||||
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
||||
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
||||
|
||||
dependencies:
|
||||
cache_directories:
|
||||
- "~/.m2"
|
||||
- "~/.sbt"
|
||||
- "~/.ivy2/cache"
|
||||
|
||||
pre:
|
||||
- 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
|
||||
# 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
|
||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||
- cat /etc/hosts
|
||||
override:
|
||||
- cp CI/pom.xml.circleci pom.xml
|
||||
|
||||
test:
|
||||
override:
|
||||
## test with jdk8
|
||||
- java -version
|
||||
- mvn --quiet clean install
|
||||
- mvn --quiet verify -Psamples
|
||||
# skip the rest if previous mvn task fails
|
||||
- if [ $? -ne 0 ]; then exit 1; fi
|
||||
## test with jdk7
|
||||
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||
- java -version
|
||||
- cp CI/pom.xml.circleci.java7 pom.xml # use jdk7 pom
|
||||
- mvn --quiet clean install
|
||||
- mvn --quiet verify -Psamples
|
||||
# skip the rest if previous mvn task fails
|
||||
- if [ $? -ne 0 ]; then exit 1; fi
|
||||
## docker push done in Travis instead
|
||||
## docker: build generator image and push to Docker Hub
|
||||
#- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/opeanapi-generator && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
|
||||
### docker: build cli image and push to Docker Hub
|
||||
#- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
machine:
|
||||
docker_layer_caching: true
|
||||
working_directory: ~/OpenAPITools/openapi-generator
|
||||
parallelism: 1
|
||||
shell: /bin/bash --login
|
||||
environment:
|
||||
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
||||
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
|
||||
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
||||
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
||||
steps:
|
||||
# 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.
|
||||
- checkout
|
||||
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
|
||||
# In many cases you can simplify this from what is generated here.
|
||||
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
|
||||
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
|
||||
# This is based on your 1.0 configuration file or project settings
|
||||
- run:
|
||||
command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV
|
||||
- run:
|
||||
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
|
||||
- run:
|
||||
command: |-
|
||||
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
|
||||
# - run: docker pull openapitools/openapi-petstore
|
||||
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
|
||||
- run: docker pull swaggerapi/petstore
|
||||
- run: docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||
- run: docker ps -a
|
||||
- run: sleep 30
|
||||
- run: cat /etc/hosts
|
||||
# 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: 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
|
||||
- vendor/bundle
|
||||
- ~/virtualenvs
|
||||
- ~/.m2
|
||||
- ~/.ivy2
|
||||
- ~/.bundle
|
||||
- ~/.go_workspace
|
||||
- ~/.gradle
|
||||
- ~/.cache/bower
|
||||
# These cache paths were specified in the 1.0 config
|
||||
- ~/.sbt
|
||||
# Test
|
||||
# This would typically be a build job when using workflows, possibly combined with build
|
||||
# This is based on your 1.0 configuration file or project settings
|
||||
- run: java -version
|
||||
- run: mvn --quiet clean install
|
||||
- run: mvn --quiet verify -Psamples
|
||||
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||
- run: java -version
|
||||
- run: cp CI/pom.xml.circleci.java7 pom.xml
|
||||
- run: mvn --quiet clean install
|
||||
- run: mvn --quiet verify -Psamples
|
||||
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||
# 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
|
||||
- store_test_results:
|
||||
path: /tmp/circleci-test-results
|
||||
# Save artifacts
|
||||
- store_artifacts:
|
||||
path: /tmp/circleci-artifacts
|
||||
- store_artifacts:
|
||||
path: /tmp/circleci-test-results
|
||||
|
||||
@@ -8,11 +8,19 @@ JAVA_OPTS=${JAVA_OPTS:-"-Xmx1024M -DloggerPath=conf/log4j.properties"}
|
||||
|
||||
cli="${GEN_DIR}/modules/openapi-generator-cli"
|
||||
codegen="${cli}/target/openapi-generator-cli.jar"
|
||||
cmdsrc="${cli}/src/main/java/org/openapitools/codegen/cmd"
|
||||
|
||||
pattern="@Command(name = \"$1\""
|
||||
if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java || expr "$1" = 'help' > /dev/null; then
|
||||
# If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built
|
||||
# We code in a list of commands here as source processing is potentially buggy (requires undocumented conventional use of annotations).
|
||||
# A list of known commands helps us determine if we should compile CLI. There's an edge-case where a new command not added to this
|
||||
# list won't be considered a "real" command. We can get around that a bit by checking CLI completions beforehand if it exists.
|
||||
commands="list,generate,meta,langs,help,config-help,validate,version"
|
||||
|
||||
# if CLI jar exists, check $1 against completions available in the CLI
|
||||
if [[ -f "${codegen}" && -n "$(java ${JAVA_OPTS} -jar "${codegen}" completion | grep "^$1\$" )" ]]; then
|
||||
command=$1
|
||||
shift
|
||||
exec java ${JAVA_OPTS} -jar "${codegen}" "${command}" "$@"
|
||||
elif [[ -n "$(echo commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
|
||||
# If CLI jar does not exist, and $1 is a known CLI command, build the CLI jar and run that command.
|
||||
if [[ ! -f "${codegen}" ]]; then
|
||||
(cd "${GEN_DIR}" && exec mvn -am -pl "modules/openapi-generator-cli" -Duser.home=$(dirname $MAVEN_CONFIG) package)
|
||||
fi
|
||||
@@ -20,5 +28,6 @@ if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*
|
||||
shift
|
||||
exec java ${JAVA_OPTS} -jar "${codegen}" "${command}" "$@"
|
||||
else
|
||||
# Pass args as linux commands. This allows us to do something like: docker run -it (-e…, -v…) image ls -la
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
@@ -166,7 +166,7 @@ cf8d8d56f [PHP] Fix code example from README. Variable name was missing when usi
|
||||
76907cacd [PHP] declare property headerSelector
|
||||
|
||||
### Python
|
||||
7184f1ec6 [python] asyncio supports _preload_content; remove unsed imports (#107)
|
||||
7184f1ec6 [python] asyncio supports _preload_content; remove unused imports (#107)
|
||||
d74d2ba03 fix: python clients
|
||||
8e0a0ebd6 Fix python / tornado body handling
|
||||
b39c35c76 Fix inconsistency between model name and file name in python client
|
||||
@@ -250,7 +250,7 @@ ce930e7a6 [Jaxrs-cxf] Add bean-level cascaded beanvalidation for pojos (@Valid)
|
||||
ff1178ad7 [Java][Spring] fix missing optional query params
|
||||
2103fadab Fix package declaration for play-framework
|
||||
2c6380c84 fix inner item (list, map) for play framework
|
||||
e33b350c8 Fix an issue in Play Framework generator where a CSV is empty and transfered to the controllerImp with an empty item.
|
||||
e33b350c8 Fix an issue in Play Framework generator where a CSV is empty and transferred to the controllerImp with an empty item.
|
||||
99fc27246 [JAX-RS][Spec] Removes throws Exception.
|
||||
fe2a44339 Fixes issue (SpringCodeGen dateLibrary "java8-localdatetime" option is ignored).
|
||||
d890d733f [JaxRS][Java] issue with implFolder on windows, and required fields generation for containers (#88)
|
||||
|
||||
@@ -1,38 +1,58 @@
|
||||
## Customization
|
||||
### Modifying the client library format
|
||||
|
||||
Don't like the default client syntax? Want a different language supported? No problem! OpenAPI Generator processes mustache templates with the [jmustache](https://github.com/samskivert/jmustache) engine. You can modify our templates or make your own.
|
||||
### Modifying a template
|
||||
|
||||
You can look at `modules/openapi-generator/src/main/resources/${your-language}` for examples. To make your own templates, create your own files and use the `-t` flag to specify your template folder. It actually is that easy.
|
||||
Clone OpenAPI Generator and navigate to `modules/openapi-generator/src/main/resources/${template}`, where `${template}` is the name of the generator you wish to modify. For example, if you are looking for the C# template, it's named `csharp`. This directory contains all the templates used to generate your target client/server/doc output.
|
||||
|
||||
### Making your own codegen modules
|
||||
Templates consist of multiple mustache files. [Mustache](https://mustache.github.io/) is used as the templating language for these templates, and the specific engine used is [jmustache](https://github.com/samskivert/jmustache).
|
||||
|
||||
If you're starting a project with a new language and don't see what you need, openapi-generator can help you create a project to generate your own libraries:
|
||||
If you wish to modify one of these templates, copy and paste the template you're interested in to a templates directory you control. To let OpenAPI Generator know where this templates directory is, use the `-t` option (e.g: `-t ./templates/`).
|
||||
|
||||
To tie that all together (example for modifying ruby templates):
|
||||
|
||||
```sh
|
||||
mkdir templates
|
||||
export template=ruby
|
||||
cp -r modules/openapi-generator/src/main/resources/${template} templates/${template}
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
||||
-t ./templates/${template} -g ruby -i ./foo.yml -o ./out/ruby
|
||||
```
|
||||
|
||||
_**Note:** You cannot use this approach to create new templates, only override existing ones. If you'd like to create a new generator within the project, see `new.sh` in the repository root._
|
||||
|
||||
### Creating a new template
|
||||
|
||||
If none of the templates suit your needs, you can create a brand new template. OpenAPI Generator can help with this, using the `meta` command:
|
||||
|
||||
```sh
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar meta \
|
||||
-o output/myLibrary -n myClientCodegen -p com.my.company.codegen
|
||||
-o out/generators/my-codegen -n my-codegen -p com.my.company.codegen
|
||||
```
|
||||
|
||||
This will write, in the folder `output/myLibrary`, all the files you need to get started, including a `README.md. Once modified and compiled, you can load your library with the codegen and generate clients with your own, custom-rolled logic.
|
||||
This will create a new directory `out/generators/my-codegen`, with all the files you need to get started - including a `README.md`. Once modified and compiled, you can use your new codegen just like any other, with your own custom-rolled logic.
|
||||
|
||||
You would then compile your library in the `output/myLibrary` folder with `mvn package` and execute the codegen like such:
|
||||
These names can be anything you like. If you are building a client for the whitespace language, maybe you'd use the options `-o out/generators/whitespace -n whitespace`. They can be the same, or different, it doesn't matter. The `-n` value will be become the template name.
|
||||
|
||||
**NOTE** Convention is to use kebab casing for names passed to `-n`. Example, `scala-finatra` would become `ScalaFinatraGenerator`.
|
||||
|
||||
To compile your library, enter the `out/generators/my-codegen` directory, run `mvn package` and execute the generator:
|
||||
|
||||
```sh
|
||||
java -cp output/myLibrary/target/myClientCodegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar org.openapitools.codegen.OpenAPIGenerator
|
||||
java -cp out/generators/my-codegen/target/my-codegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar org.openapitools.codegen.OpenAPIGenerator
|
||||
```
|
||||
|
||||
For Windows users, you will need to use `;` instead of `:` in the classpath, e.g.
|
||||
```
|
||||
java -cp output/myLibrary/target/myClientCodegen-openapi-generator-1.0.0.jar;modules/openapi-generator-cli/target/openapi-generator-cli.jar org.openapitools.codegen.OpenAPIGenerator
|
||||
java -cp out/generators/my-codegen/target/my-codegen-openapi-generator-1.0.0.jar;modules/openapi-generator-cli/target/openapi-generator-cli.jar org.openapitools.codegen.OpenAPIGenerator
|
||||
```
|
||||
|
||||
Note the `myClientCodegen` is an option now, and you can use the usual arguments for generating your library:
|
||||
Note the `my-codegen` is an option for `-g` now, and you can use the usual arguments for generating your code:
|
||||
|
||||
```sh
|
||||
java -cp output/myLibrary/target/myClientCodegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
|
||||
io.openapitools.codegen.OpenAPIGenerator generate -g myClientCodegen\
|
||||
java -cp out/codegens/customCodegen/target/my-codegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
|
||||
io.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \
|
||||
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
|
||||
-o myClient
|
||||
-o ./out/myClient
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ You can find our released artefact on maven central:
|
||||
|
||||
Old:
|
||||
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen</artifactId>
|
||||
@@ -58,7 +58,7 @@ Old:
|
||||
|
||||
New:
|
||||
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator</artifactId>
|
||||
@@ -67,7 +67,7 @@ New:
|
||||
|
||||
**Cli:**
|
||||
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-cli</artifactId>
|
||||
@@ -76,7 +76,7 @@ New:
|
||||
|
||||
New:
|
||||
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-cli</artifactId>
|
||||
@@ -85,7 +85,7 @@ New:
|
||||
|
||||
**Maven plugin:**
|
||||
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
||||
@@ -94,7 +94,7 @@ New:
|
||||
|
||||
New:
|
||||
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
@@ -187,7 +187,7 @@ Example: `org.openapitools.codegen.DefaultGenerator`
|
||||
In OpenAPI spec v3, there's no body parameter, which is replaced by [Request Body Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#request-body-object). The parameter name for Request Body is named automatically based on the model name (e.g. User). To control how the "Request Body" parmaeter is named, please add the vendor extension `x-codegen-request-body-name` to the operation:
|
||||
|
||||
OpenAPI Spec v3:
|
||||
```
|
||||
```yaml
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
@@ -209,7 +209,7 @@ paths:
|
||||
```
|
||||
|
||||
OpenAPI Spec v2:
|
||||
```
|
||||
```yaml
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
|
||||
@@ -18,7 +18,7 @@ There are several reasons:
|
||||
|
||||
#### Has anything been done in attempt to address the issues before deciding to fork Swagger Codegen and maintain a community-driven version?
|
||||
|
||||
There was several conversations with SmartBear (Ron, Hugo) via emails, gitter, Skype call and GitHub issues.
|
||||
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.
|
||||
|
||||
#### Is there any change to the project license?
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -20,7 +20,6 @@
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>logback.xml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
@@ -78,6 +77,12 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--https://github.com/airlift/airline-->
|
||||
<dependency>
|
||||
@@ -91,9 +96,9 @@
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
|
||||
@@ -23,8 +23,6 @@ import io.airlift.airline.ParseOptionMissingException;
|
||||
import io.airlift.airline.ParseOptionMissingValueException;
|
||||
import org.openapitools.codegen.cmd.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* User: lanwen Date: 24.03.15 Time: 17:56
|
||||
* <p>
|
||||
@@ -52,21 +50,23 @@ public class OpenAPIGenerator {
|
||||
Help.class,
|
||||
ConfigHelp.class,
|
||||
Validate.class,
|
||||
Version.class
|
||||
Version.class,
|
||||
CompletionCommand.class
|
||||
);
|
||||
|
||||
// If CLI is run without a command, consider this an error.
|
||||
// We can check against empty args because unrecognized arguments/commands result in an exception.
|
||||
// This is useful to exit with status 1, for example, so that misconfigured scripts fail fast.
|
||||
// We don't want the default command to exit internally with status 1 because when the default command is something like "list",
|
||||
// it would prevent scripting using the command directly. Example:
|
||||
// java -jar cli.jar list --short | tr ',' '\n' | xargs -I{} echo "Doing something with {}"
|
||||
if (args.length == 0) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
builder.build().parse(args).run();
|
||||
|
||||
// If CLI is run without a command, consider this an error. This exists after initial parse/run
|
||||
// so we can present the configured "default command".
|
||||
// We can check against empty args because unrecognized arguments/commands result in an exception.
|
||||
// This is useful to exit with status 1, for example, so that misconfigured scripts fail fast.
|
||||
// We don't want the default command to exit internally with status 1 because when the default command is something like "list",
|
||||
// it would prevent scripting using the command directly. Example:
|
||||
// java -jar cli.jar list --short | tr ',' '\n' | xargs -I{} echo "Doing something with {}"
|
||||
if (args.length == 0) {
|
||||
System.exit(1);
|
||||
}
|
||||
} catch (ParseOptionMissingException | ParseOptionMissingValueException e) {
|
||||
System.err.printf("[error] %s%n", e.getMessage());
|
||||
System.exit(1);
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2010 the original author or authors.
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* NOTICE: File originally taken from:
|
||||
* https://github.com/airlift/airline/blob/fc7a55e34b6361cb97235de5a1b21cba9b508f4b/src/main/java/io/airlift/airline/SuggestCommand.java#L1
|
||||
* Modifications have been made to fit the needs of OpenAPI Tools CLI.
|
||||
*/
|
||||
package org.openapitools.codegen.cmd;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.airlift.airline.*;
|
||||
import io.airlift.airline.model.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static io.airlift.airline.ParserUtil.createInstance;
|
||||
|
||||
@Command(name = "completion", description = "Complete commands (for using in tooling such as Bash Completions).", hidden = true)
|
||||
public class CompletionCommand
|
||||
implements Runnable, Callable<Void> {
|
||||
private static final Map<Context, Class<? extends Suggester>> BUILTIN_SUGGESTERS = ImmutableMap.<Context, Class<? extends Suggester>>builder()
|
||||
.put(Context.GLOBAL, GlobalSuggester.class)
|
||||
.put(Context.GROUP, GroupSuggester.class)
|
||||
.put(Context.COMMAND, CommandSuggester.class)
|
||||
.build();
|
||||
|
||||
@Inject
|
||||
public GlobalMetadata metadata;
|
||||
|
||||
@Arguments
|
||||
public List<String> arguments = newArrayList();
|
||||
|
||||
@Override
|
||||
public Void call() {
|
||||
run();
|
||||
return null;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public Iterable<String> generateSuggestions() {
|
||||
Parser parser = new Parser();
|
||||
ParseState state = parser.parse(metadata, arguments);
|
||||
|
||||
Class<? extends Suggester> suggesterClass = BUILTIN_SUGGESTERS.get(state.getLocation());
|
||||
if (suggesterClass != null) {
|
||||
SuggesterMetadata suggesterMetadata = MetadataLoader.loadSuggester(suggesterClass);
|
||||
|
||||
if (suggesterMetadata != null) {
|
||||
ImmutableMap.Builder<Class<?>, Object> bindings = ImmutableMap.<Class<?>, Object>builder()
|
||||
.put(GlobalMetadata.class, metadata);
|
||||
|
||||
if (state.getGroup() != null) {
|
||||
bindings.put(CommandGroupMetadata.class, state.getGroup());
|
||||
}
|
||||
|
||||
if (state.getCommand() != null) {
|
||||
bindings.put(CommandMetadata.class, state.getCommand());
|
||||
}
|
||||
|
||||
Suggester suggester = createInstance(suggesterMetadata.getSuggesterClass(),
|
||||
ImmutableList.<OptionMetadata>of(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
suggesterMetadata.getMetadataInjections(),
|
||||
bindings.build());
|
||||
|
||||
return suggester.suggest();
|
||||
}
|
||||
}
|
||||
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(Joiner.on("\n").join(generateSuggestions()));
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,9 @@ import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.SwaggerParseResult;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -34,26 +36,58 @@ public class Validate implements Runnable {
|
||||
description = "location of the OpenAPI spec, as URL or file (required)")
|
||||
private String spec;
|
||||
|
||||
@Option(name = { "--recommend"}, title = "recommend spec improvements")
|
||||
private Boolean recommend;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Validating spec (" + spec + ")");
|
||||
|
||||
SwaggerParseResult result = new OpenAPIParser().readLocation(spec, null, null);
|
||||
List<String> messageList = result.getMessages();
|
||||
Set<String> messages = new HashSet<String>(messageList);
|
||||
Set<String> errors = new HashSet<String>(messageList);
|
||||
Set<String> warnings = new HashSet<String>();
|
||||
|
||||
if (messages.size() > 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(System.lineSeparator());
|
||||
for (String message : messages) {
|
||||
sb.append(String.format("\t- %s%s", message, System.lineSeparator()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
OpenAPI specification = result.getOpenAPI();
|
||||
|
||||
if (Boolean.TRUE.equals(recommend)) {
|
||||
if (specification != null) {
|
||||
// Add information about unused models to the warnings set.
|
||||
List<String> unusedModels = ModelUtils.getUnusedSchemas(specification);
|
||||
if (unusedModels != null) {
|
||||
unusedModels.forEach(name -> warnings.add("Unused model: " + name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.size() > 0) {
|
||||
sb.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())
|
||||
);
|
||||
}
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append("[error] Spec is invalid.");
|
||||
sb.append("[error] Spec has ").append(errors.size()).append(" errors.");
|
||||
System.err.println(sb.toString());
|
||||
System.exit(1);
|
||||
} else if (!warnings.isEmpty()) {
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append("[info] Spec has ").append(warnings.size()).append(" recommendation(s).");
|
||||
} else {
|
||||
System.out.println("No validation errors detected.");
|
||||
// we say "issues" here rather than "errors" to account for both errors and issues.
|
||||
sb.append("No validation issues detected.");
|
||||
}
|
||||
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
|
||||
</layout>
|
||||
<target>System.out</target>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>[%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>DENY</onMatch>
|
||||
<onMismatch>NEUTRAL</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
<logger name="io.swagger" level="debug"/>
|
||||
<root level="error">
|
||||
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<target>System.err</target>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>[%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
<logger name="io.swagger" level="warn">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="STDERR"/>
|
||||
</logger>
|
||||
<logger name="org.openapitools" level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="STDERR"/>
|
||||
</logger>
|
||||
<root level="error">
|
||||
<appender-ref ref="STDERR"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
||||
@@ -34,7 +34,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.0"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,12 @@ buildscript {
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
maven {
|
||||
url "https://oss.sonatype.org/content/repositories/releases/"
|
||||
}
|
||||
maven {
|
||||
url "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
@@ -21,9 +27,11 @@ This plugin supports common functionality found in Open API Generator CLI as a g
|
||||
This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x
|
||||
specifications as part of your build. Other tasks are available as command line tasks.
|
||||
"""
|
||||
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
|
||||
|
||||
apply plugin: 'java-gradle-plugin'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'signing'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: "org.gradle.kotlin.kotlin-dsl"
|
||||
|
||||
@@ -33,6 +41,12 @@ targetCompatibility = 1.8
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven {
|
||||
url "https://oss.sonatype.org/content/repositories/releases/"
|
||||
}
|
||||
maven {
|
||||
url "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -67,7 +81,6 @@ test {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
openApiGenerator {
|
||||
@@ -77,6 +90,87 @@ gradlePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// signing will require three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile.
|
||||
// These can be passed to the gradle command:
|
||||
// ./gradlew -Psigning.keyId=yourid
|
||||
// or stored as key=value pairs in ~/.gradle/gradle.properties
|
||||
// You can also apply them in CI via environment variables. See Gradle's docs for details.
|
||||
signing {
|
||||
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
|
||||
sign configurations.archives
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
from javadoc
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from sourceSets.main.allSource
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives javadocJar, sourcesJar
|
||||
}
|
||||
|
||||
def pomConfig = {
|
||||
description project.description
|
||||
name 'OpenAPI-Generator Contributors'
|
||||
url 'https://openapi-generator.tech'
|
||||
organization {
|
||||
name 'org.openapitools'
|
||||
url 'https://github.com/OpenAPITools'
|
||||
}
|
||||
licenses {
|
||||
license {
|
||||
name "The Apache Software License, Version 2.0"
|
||||
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||
distribution "repo"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id "openapitools"
|
||||
name "OpenAPI-Generator Contributors"
|
||||
email "team@openapitools.org"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url 'https://github.com/OpenAPITools/openapi-generator'
|
||||
connection 'scm:git:git://github.com/OpenAPITools/openapi-generator.git'
|
||||
developerConnection 'scm:git:ssh://git@github.com:OpenAPITools/openapi-generator.git'
|
||||
}
|
||||
issueManagement {
|
||||
system 'GitHub'
|
||||
url 'https://github.com/OpenAPITools/openapi-generator/issues'
|
||||
}
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
repositories {
|
||||
|
||||
// credentials here would need to be passed along with the gradle command:
|
||||
// ./gradlew -P ossrhUsername=yourUser
|
||||
// or stored in ~/.gradle/gradle.properties as key=value pairs
|
||||
mavenDeployer {
|
||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
|
||||
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||
}
|
||||
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
|
||||
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||
}
|
||||
|
||||
pom.withXml {
|
||||
def root = asNode()
|
||||
root.appendNode('description', project.description)
|
||||
root.children().last() + pomConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
@@ -86,4 +180,4 @@ compileTestKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
openApiGeneratorVersion=3.0.0
|
||||
openApiGeneratorVersion=3.0.2
|
||||
|
||||
# BEGIN placeholders
|
||||
# these are just placeholders to allow contributors to build directly
|
||||
ossrhUsername=user
|
||||
ossrhPassword=pass
|
||||
signing.keyId=unset
|
||||
signing.password=unset
|
||||
# signing.secretKeyRingFile=unset
|
||||
# END placeholders
|
||||
|
||||
@@ -3,14 +3,16 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>openapi-generator-gradle-plugin</artifactId>
|
||||
<artifactId>openapi-generator-gradle-plugin-mvn-wrapper</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-gradle-plugin (maven wrapper)</name>
|
||||
<description>This is a maven wrapper to call gradle during installation phase</description>
|
||||
|
||||
<name>openapi-generator-gradle-plugin (gradle-plugin)</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -24,7 +26,17 @@
|
||||
<plugins>
|
||||
|
||||
<!-- NOTE: Consider this temporary, as a way to cleanly hook into our pipeline.
|
||||
We've discussed moving the entire project to gradle, which would avoid this fitting. -->
|
||||
We've discussed moving the entire project to gradle https://github.com/OpenAPITools/openapi-generator/issues/200, which would avoid this fitting. -->
|
||||
<!-- 1) disable maven install. This wrapper is not needed. (gradle will install a jar and a pom into the local maven repo) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 2) run gradle -->
|
||||
<plugin>
|
||||
<groupId>org.fortasoft</groupId>
|
||||
<artifactId>gradle-maven-plugin</artifactId>
|
||||
@@ -44,15 +56,24 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<!-- calls "clean build publishToMavenLocal" -->
|
||||
<!-- calls "clean assemble install" -->
|
||||
<task>clean</task>
|
||||
<task>build</task>
|
||||
<task>publishToMavenLocal</task>
|
||||
<task>assemble</task>
|
||||
<task>install</task>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 3) disable maven deploy. This wrapper is not needed. -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This example assumes you have Gradle 4.7+ installed. No gradle wrapper is provided in samples.
|
||||
|
||||
First, publish the openapi-generator-gradle-plugin locally via `sh gradlew build publishToMavenLocal` in the module directory.
|
||||
First, publish the openapi-generator-gradle-plugin locally via `./gradlew assemble install` in the module directory.
|
||||
|
||||
Then, run the following tasks in this example directory.
|
||||
|
||||
@@ -12,3 +12,9 @@ gradle openApiMeta
|
||||
gradle openApiValidate
|
||||
gradle buildGoSdk
|
||||
```
|
||||
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=3.0.1 openApiValidate
|
||||
```
|
||||
|
||||
@@ -5,9 +5,16 @@ buildscript {
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
maven {
|
||||
url "https://oss.sonatype.org/content/repositories/releases/"
|
||||
}
|
||||
maven {
|
||||
url "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.0"
|
||||
// Updated version can be passed via command line arg as -PopenApiGeneratorVersion=VERSION
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:$openApiGeneratorVersion"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
openApiGeneratorVersion=3.0.1
|
||||
@@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>2.4.0-SNAPSHOT</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine
|
||||
|
||||
WORKDIR /generator
|
||||
|
||||
COPY target/openapi-generator-online-3.0.0.jar /generator/openapi-generator-online.jar
|
||||
COPY target/openapi-generator-online-3.0.2.jar /generator/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
|
||||
|
||||
@@ -10,6 +10,6 @@ This is an example of building a OpenAPI-enabled server in Java using the Spring
|
||||
|
||||
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
|
||||
|
||||
Start your server as an simple java application
|
||||
Start your server as a simple java application
|
||||
|
||||
Change default port value in application.properties
|
||||
Change default port value in application.properties
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-online</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>openapi-generator-online</name>
|
||||
<version>3.0.0</version>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -160,7 +160,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<debug>true</debug>
|
||||
@@ -243,11 +243,6 @@
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -108,7 +109,7 @@ public class CliOption {
|
||||
* @param opt Option name
|
||||
* @param description Option description
|
||||
* @param defaultValue the default value to use if option not specified
|
||||
* @return
|
||||
* @return the CliOption created
|
||||
*/
|
||||
public static CliOption newBoolean(String opt, String description, boolean defaultValue) {
|
||||
return new CliOption(opt, description, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(String.valueOf(defaultValue));
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CodegenSecurity {
|
||||
public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
|
||||
// ApiKey specific
|
||||
public String keyParamName;
|
||||
public Boolean isKeyInQuery, isKeyInHeader;
|
||||
public Boolean isKeyInQuery, isKeyInHeader, isKeyInCookie;
|
||||
// Oauth specific
|
||||
public String flow, authorizationUrl, tokenUrl;
|
||||
public List<Map<String, Object>> scopes;
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.google.common.base.CaseFormat;
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
@@ -47,6 +46,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -210,7 +210,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
for (String name : allModels.keySet()) {
|
||||
CodegenModel cm = allModels.get(name);
|
||||
CodegenModel parent = allModels.get(cm.getParent());
|
||||
// if a discriminator exists on the parent, don't add this child to the inheritance heirarchy
|
||||
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
|
||||
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
|
||||
while (parent != null) {
|
||||
if (parent.getChildren() == null) {
|
||||
@@ -1201,7 +1201,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
private static String getPrimitiveType(Schema schema) {
|
||||
if (schema == null) {
|
||||
throw new RuntimeException("schema cannnot be null in getPrimitiveType");
|
||||
throw new RuntimeException("schema cannot be null in getPrimitiveType");
|
||||
} else if (ModelUtils.isStringSchema(schema) && "number".equals(schema.getFormat())) {
|
||||
// special handle of type: string, format: number
|
||||
return "BigDecimal";
|
||||
@@ -1300,7 +1300,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Determine the type alias for the given type if it exists. This feature
|
||||
* was original developed for Java because the language does not have a aliasing
|
||||
* was originally developed for Java because the language does not have an aliasing
|
||||
* mechanism of its own but later extends to handle other languages
|
||||
*
|
||||
* @param name The type name.
|
||||
@@ -1535,36 +1535,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively look for a discriminator in the interface tree
|
||||
*
|
||||
* @param schema composed schema
|
||||
* @param allDefinitions all schema defintion
|
||||
* @return true if it's a discriminator
|
||||
*/
|
||||
private boolean isDiscriminatorInInterfaceTree(ComposedSchema schema, Map<String, Schema> allDefinitions) {
|
||||
if (schema == null || allDefinitions == null || allDefinitions.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (schema.getDiscriminator() != null) {
|
||||
return true;
|
||||
}
|
||||
final List<Schema> interfaces = getInterfaces(schema);
|
||||
if (interfaces == null) {
|
||||
return false;
|
||||
}
|
||||
for (Schema interfaceSchema : interfaces) {
|
||||
if (interfaceSchema.getDiscriminator() != null) {
|
||||
return true;
|
||||
}
|
||||
// TODO revise the logic below
|
||||
if (interfaceSchema instanceof ComposedSchema) {
|
||||
return isDiscriminatorInInterfaceTree((ComposedSchema) interfaceSchema, allDefinitions);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
addParentContainer(codegenModel, codegenModel.name, schema);
|
||||
}
|
||||
@@ -2085,7 +2055,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (operation == null)
|
||||
throw new RuntimeException("operation cannnot be null in fromOperation");
|
||||
throw new RuntimeException("operation cannot be null in fromOperation");
|
||||
|
||||
// store the original operationId for plug-in
|
||||
op.operationIdOriginal = operation.getOperationId();
|
||||
@@ -2801,12 +2771,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
cs.isApiKey = true;
|
||||
cs.keyParamName = securityScheme.getName();
|
||||
cs.isKeyInHeader = securityScheme.getIn() == SecurityScheme.In.HEADER;
|
||||
cs.isKeyInQuery = !cs.isKeyInHeader;
|
||||
cs.isKeyInQuery = securityScheme.getIn() == SecurityScheme.In.QUERY;
|
||||
cs.isKeyInCookie = securityScheme.getIn() == SecurityScheme.In.COOKIE; //it assumes a validation step prior to generation. (cookie-auth supported from OpenAPI 3.0.0)
|
||||
} else if (SecurityScheme.Type.HTTP.equals(securityScheme.getType())) {
|
||||
cs.isKeyInHeader = cs.isKeyInQuery = cs.isApiKey = cs.isOAuth = false;
|
||||
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isOAuth = false;
|
||||
cs.isBasic = true;
|
||||
} else if (SecurityScheme.Type.OAUTH2.equals(securityScheme.getType())) {
|
||||
cs.isKeyInHeader = cs.isKeyInQuery = cs.isApiKey = cs.isBasic = false;
|
||||
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isBasic = false;
|
||||
cs.isOAuth = true;
|
||||
final OAuthFlows flows = securityScheme.getFlows();
|
||||
if (securityScheme.getFlows() == null) {
|
||||
@@ -2958,20 +2929,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return objs;
|
||||
}
|
||||
|
||||
private static Map<String, Object> addHasMore(Map<String, Object> objs) {
|
||||
if (objs != null) {
|
||||
for (int i = 0; i < objs.size() - 1; i++) {
|
||||
if (i > 0) {
|
||||
objs.put("secondaryParam", true);
|
||||
}
|
||||
if (i < objs.size() - 1) {
|
||||
objs.put("hasMore", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add operation to group
|
||||
*
|
||||
@@ -3896,7 +3853,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody());
|
||||
|
||||
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
|
||||
return Collections.emptySet(); // return emtpy set
|
||||
return Collections.emptySet(); // return empty set
|
||||
}
|
||||
return requestBody.getContent().keySet();
|
||||
}
|
||||
@@ -3989,19 +3946,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return produces;
|
||||
}
|
||||
|
||||
protected Schema detectParent(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||
if (composedSchema.getAllOf() != null && !composedSchema.getAllOf().isEmpty()) {
|
||||
Schema schema = composedSchema.getAllOf().get(0);
|
||||
String ref = schema.get$ref();
|
||||
if (StringUtils.isBlank(ref)) {
|
||||
return null;
|
||||
}
|
||||
ref = ModelUtils.getSimpleRef(ref);
|
||||
return allSchemas.get(ref);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||
if (composedSchema.getAllOf() != null && !composedSchema.getAllOf().isEmpty()) {
|
||||
Schema schema = composedSchema.getAllOf().get(0);
|
||||
@@ -4033,12 +3977,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO do we still need the methdo below?
|
||||
protected static boolean hasSchemaProperties(Schema schema) {
|
||||
final Object additionalProperties = schema.getAdditionalProperties();
|
||||
return additionalProperties != null && additionalProperties instanceof Schema;
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
return null;
|
||||
}
|
||||
@@ -4311,7 +4249,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (schema.getAdditionalProperties() != null) {// http body is map
|
||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||
} else if (codegenProperty != null) {
|
||||
LOGGER.warn("The folowing schema has undefined (null) baseType. " +
|
||||
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'");
|
||||
@@ -4362,10 +4300,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description) {
|
||||
addOption(key, description, null);
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
@@ -4403,12 +4337,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
public void generateYAMLSpecFile(Map<String, Object> objs) {
|
||||
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
|
||||
if (openAPI != null) {
|
||||
try {
|
||||
objs.put("openapi-yaml", Yaml.mapper().writeValueAsString(openAPI));
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
String yaml = SerializerUtils.toYamlString(openAPI);
|
||||
if(yaml != null) {
|
||||
objs.put("openapi-yaml", yaml);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1012,7 +1012,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
for (String key : definitions.keySet()) {
|
||||
Schema schema = definitions.get(key);
|
||||
if (schema == null)
|
||||
throw new RuntimeException("schema cannnot be null in processMoels");
|
||||
throw new RuntimeException("schema cannot be null in processMoels");
|
||||
CodegenModel cm = config.fromModel(key, schema, allDefinitions);
|
||||
Map<String, Object> mo = new HashMap<String, Object>();
|
||||
mo.put("model", cm);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CodegenConfigurator implements Serializable {
|
||||
nameMigrationMap.put("scala", new ScalaHttpClientCodegen().getName());
|
||||
nameMigrationMap.put("jaxrs", new JavaJerseyServerCodegen().getName());
|
||||
nameMigrationMap.put("qt5cpp", new CppQt5ClientCodegen().getName());
|
||||
nameMigrationMap.put("cpprest", new CppRestClientCodegen().getName());
|
||||
nameMigrationMap.put("cpprest", new CppRestSdkClientCodegen().getName());
|
||||
nameMigrationMap.put("tizen", new CppTizenClientCodegen().getName());
|
||||
nameMigrationMap.put("sinatra", new RubySinatraServerCodegen().getName());
|
||||
nameMigrationMap.put("swift", new SwiftClientCodegen().getName());
|
||||
|
||||
@@ -51,9 +51,9 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
protected String packageName = "defaultPackage";
|
||||
protected String projectName = "defaultProject";
|
||||
protected List<Map<String, Object>> orderedModels;
|
||||
protected Map<String, List<String>> modelDepends;
|
||||
protected Map<String, String> nullableTypeMapping;
|
||||
protected HashMap<String, String> operationsScopes;
|
||||
protected final Map<String, List<String>> modelDepends;
|
||||
protected final Map<String, String> nullableTypeMapping;
|
||||
protected final HashMap<String, String> operationsScopes;
|
||||
protected int scopeIndex = 0;
|
||||
|
||||
public AbstractAdaCodegen() {
|
||||
@@ -153,14 +153,15 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
typeMapping.put("file", "Swagger.Http_Content_Type");
|
||||
typeMapping.put("binary", "Swagger.Binary");
|
||||
|
||||
// Mapping to convert an Ada required type to an optional type (nullable).
|
||||
nullableTypeMapping = new HashMap<String, String>();
|
||||
nullableTypeMapping.put("date", "Swagger.Nullable_Date");
|
||||
nullableTypeMapping.put("DateTime", "Swagger.Nullable_Date");
|
||||
nullableTypeMapping.put("string", "Swagger.Nullable_UString");
|
||||
nullableTypeMapping.put("integer", "Swagger.Nullable_Integer");
|
||||
nullableTypeMapping.put("long", "Swagger.Nullable_Long");
|
||||
nullableTypeMapping.put("boolean", "Swagger.Nullable_Boolean");
|
||||
nullableTypeMapping.put("object", "Swagger.Object");
|
||||
nullableTypeMapping.put("Swagger.Date", "Swagger.Nullable_Date");
|
||||
nullableTypeMapping.put("Swagger.Datetime", "Swagger.Nullable_Date");
|
||||
nullableTypeMapping.put("Swagger.UString", "Swagger.Nullable_UString");
|
||||
nullableTypeMapping.put("Integer", "Swagger.Nullable_Integer");
|
||||
nullableTypeMapping.put("Swagger.Long", "Swagger.Nullable_Long");
|
||||
nullableTypeMapping.put("Boolean", "Swagger.Nullable_Boolean");
|
||||
nullableTypeMapping.put("Swagger.Object", "Swagger.Object");
|
||||
|
||||
modelDepends = new HashMap<String, List<String>>();
|
||||
orderedModels = new ArrayList<Map<String, Object>>();
|
||||
@@ -336,13 +337,8 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return "Swagger." + name;
|
||||
}
|
||||
}
|
||||
// TODO need to revise/test the logic below to check "required"
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
if (p.getRequired() != null && p.getRequired().contains(p.getName())) {
|
||||
return typeMapping.get(schemaType);
|
||||
} else {
|
||||
return nullableTypeMapping.get(schemaType);
|
||||
}
|
||||
return typeMapping.get(schemaType);
|
||||
}
|
||||
// LOGGER.info("Swagger type " + schemaType);
|
||||
if (languageSpecificPrimitives.contains(schemaType)) {
|
||||
@@ -382,7 +378,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
/**
|
||||
* Post process the media types (produces and consumes) for Ada code generator.
|
||||
* <p>
|
||||
* For each media type, add a adaMediaType member that gives the Ada enum constant
|
||||
* For each media type, add an adaMediaType member that gives the Ada enum constant
|
||||
* for the corresponding type.
|
||||
*
|
||||
* @param types the list of media types.
|
||||
@@ -443,6 +439,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
if (p.isFormParam && p.isFile) {
|
||||
p.dataType = "Swagger.File_Part_Type";
|
||||
}
|
||||
// Convert optional parameters to use the Nullable_<T> type.
|
||||
if (!p.required && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
p.dataType = nullableTypeMapping.get(p.dataType);
|
||||
}
|
||||
}
|
||||
for (CodegenParameter p : op1.formParams) {
|
||||
if (p.isFile) {
|
||||
@@ -471,7 +471,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
if (last < 0) {
|
||||
break;
|
||||
}
|
||||
if (path.substring(pos, last - 1) == p.baseName) {
|
||||
if (path.substring(pos, last - 1).equals(p.baseName)) {
|
||||
break;
|
||||
}
|
||||
pos = last + 1;
|
||||
@@ -505,6 +505,11 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
isModel = true;
|
||||
}
|
||||
p.vendorExtensions.put("x-is-model-type", isModel);
|
||||
|
||||
// Convert optional members to use the Nullable_<T> type.
|
||||
if (!p.required && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
p.dataType = nullableTypeMapping.get(p.dataType);
|
||||
}
|
||||
}
|
||||
// let us work with fully qualified names only
|
||||
modelDepends.put(modelPackage + ".Models." + m.classname, d);
|
||||
@@ -518,7 +523,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
// cycle over orderedModels
|
||||
// if I find a model that has no dependencies, or all of its dependencies are in revisedOrderedModels, consider it the independentModel
|
||||
// put the independentModel at the end of revisedOrderedModels, and remove it from orderedModels
|
||||
//
|
||||
//
|
||||
List<Map<String, Object>> revisedOrderedModels = new ArrayList<Map<String, Object>>();
|
||||
List<String> collectedModelNames = new ArrayList<String>();
|
||||
int sizeOrderedModels = orderedModels.size();
|
||||
|
||||
@@ -341,7 +341,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("An property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
"You'll likely need to use a custom template, " +
|
||||
"see https://github.com/swagger-api/swagger-codegen#modifying-the-client-library-format. ");
|
||||
objs.put("_lambda", lambdas);
|
||||
|
||||
@@ -62,6 +62,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public static final String SUPPORT_ASYNC = "supportAsync";
|
||||
public static final String WITH_XML = "withXml";
|
||||
public static final String SUPPORT_JAVA6 = "supportJava6";
|
||||
public static final String DISABLE_HTML_ESCAPING = "disableHtmlEscaping";
|
||||
|
||||
protected String dateLibrary = "threetenbp";
|
||||
protected boolean supportAsync = false;
|
||||
@@ -93,7 +94,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected boolean serializeBigDecimalAsString = false;
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
protected boolean supportJava6 = false;
|
||||
protected boolean supportJava6= false;
|
||||
protected boolean disableHtmlEscaping = false;
|
||||
|
||||
public AbstractJavaCodegen() {
|
||||
super();
|
||||
@@ -185,6 +187,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
java8Mode.setEnum(java8ModeOptions);
|
||||
cliOptions.add(java8Mode);
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(DISABLE_HTML_ESCAPING, "Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,6 +199,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
additionalProperties.put(SUPPORT_JAVA6, supportJava6);
|
||||
|
||||
if (additionalProperties.containsKey(DISABLE_HTML_ESCAPING)) {
|
||||
this.setDisableHtmlEscaping(Boolean.valueOf(additionalProperties.get(DISABLE_HTML_ESCAPING).toString()));
|
||||
}
|
||||
additionalProperties.put(DISABLE_HTML_ESCAPING, disableHtmlEscaping);
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
||||
@@ -1222,6 +1229,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.supportAsync = enabled;
|
||||
}
|
||||
|
||||
public void setDisableHtmlEscaping(boolean disabled) {
|
||||
this.disableHtmlEscaping = disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
|
||||
@@ -325,11 +325,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
return UNDEFINED_VALUE;
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
NumberSchema dp = (NumberSchema) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString();
|
||||
}
|
||||
return UNDEFINED_VALUE;
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
return UNDEFINED_VALUE;
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
apiTemplateFiles.put("api-impl-source.mustache", ".cpp");
|
||||
apiTemplateFiles.put("main-api-server.mustache", ".cpp");
|
||||
|
||||
embeddedTemplateDir = templateDir = "pistache-server";
|
||||
embeddedTemplateDir = templateDir = "cpp-pistache-server";
|
||||
|
||||
cliOptions.clear();
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
* Template Location. This is the location which templates will be read from. The generator
|
||||
* will use the resource stream to attempt to read the templates.
|
||||
*/
|
||||
embeddedTemplateDir = templateDir = "qt5cpp";
|
||||
embeddedTemplateDir = templateDir = "cpp-qt5-client";
|
||||
|
||||
// CLI options
|
||||
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
|
||||
@@ -442,4 +442,9 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
public void setOptionalProjectFileFlag(boolean flag) {
|
||||
this.optionalProjectFileFlag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String str) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
public static final String DECLSPEC = "declspec";
|
||||
public static final String DEFAULT_INCLUDE = "defaultInclude";
|
||||
@@ -87,7 +87,7 @@ public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
return "Generates a C++ API client with C++ REST SDK (https://github.com/Microsoft/cpprestsdk).";
|
||||
}
|
||||
|
||||
public CppRestClientCodegen() {
|
||||
public CppRestSdkClientCodegen() {
|
||||
super();
|
||||
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
@@ -99,7 +99,7 @@ public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-source.mustache", ".cpp");
|
||||
|
||||
embeddedTemplateDir = templateDir = "cpprest";
|
||||
embeddedTemplateDir = templateDir = "cpp-rest-sdk-client";
|
||||
|
||||
cliOptions.clear();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-source.mustache", ".cpp");
|
||||
|
||||
embeddedTemplateDir = templateDir = "restbed";
|
||||
embeddedTemplateDir = templateDir = "cpp-restbed-server";
|
||||
|
||||
cliOptions.clear();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CppTizenClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
modelTemplateFiles.put("model-body.mustache", ".cpp");
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-body.mustache", ".cpp");
|
||||
embeddedTemplateDir = templateDir = "tizen";
|
||||
embeddedTemplateDir = templateDir = "cpp-tizen-client";
|
||||
modelPackage = "";
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
|
||||
@@ -110,6 +110,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
*/
|
||||
supportingFiles.add(new SupportingFile("openapi.mustache", "api", "openapi.yaml"));
|
||||
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
|
||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
|
||||
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
|
||||
supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go"));
|
||||
writeOptional(outputFolder, new SupportingFile("README.mustache", apiPath, "README.md"));
|
||||
|
||||
@@ -178,7 +178,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateJSONSpecFile(objs);
|
||||
generateYAMLSpecFile(objs);
|
||||
return super.postProcessSupportingFileData(objs);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
protected String apiTestPath = "api/";
|
||||
protected String modelTestPath = "model/";
|
||||
protected boolean useES6 = false; // default is ES5
|
||||
private String modelPropertyNaming = "camelCase";
|
||||
|
||||
public JavascriptClientCodegen() {
|
||||
super();
|
||||
@@ -206,6 +207,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
cliOptions.add(new CliOption(USE_ES6,
|
||||
"use JavaScript ES6 (ECMAScript 6) (beta). Default is ES5.")
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,6 +273,9 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
if (additionalProperties.containsKey(EMIT_JS_DOC)) {
|
||||
setEmitJSDoc(convertPropertyToBooleanAndWriteBack(EMIT_JS_DOC));
|
||||
}
|
||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
|
||||
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -492,6 +497,22 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return toModelName(name) + ".spec";
|
||||
}
|
||||
|
||||
public String getModelPropertyNaming() {
|
||||
return this.modelPropertyNaming;
|
||||
}
|
||||
|
||||
private String getNameUsingModelPropertyNaming(String name) {
|
||||
switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
|
||||
case original: return name;
|
||||
case camelCase: return camelize(name, true);
|
||||
case PascalCase: return camelize(name);
|
||||
case snake_case: return underscore(name);
|
||||
default: throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
@@ -508,7 +529,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
name = getNameUsingModelPropertyNaming(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -613,6 +634,17 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setModelPropertyNaming(String naming) {
|
||||
if ("original".equals(naming) || "camelCase".equals(naming) ||
|
||||
"PascalCase".equals(naming) || "snake_case".equals(naming)) {
|
||||
this.modelPropertyNaming = naming;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
naming + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValueWithParam(String name, Schema p) {
|
||||
String type = normalizeType(getTypeDeclaration(p));
|
||||
@@ -954,6 +986,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
String jsdocType = getJSDocType(operation);
|
||||
operation.vendorExtensions.put("x-jsdoc-type", jsdocType);
|
||||
|
||||
// Format the return type correctly
|
||||
if (operation.returnType != null) {
|
||||
operation.vendorExtensions.put("x-return-type", normalizeType(operation.returnType));
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
|
||||
@@ -229,7 +229,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("An property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
|
||||
"You'll likely need to use a custom template, " +
|
||||
"see https://github.com/swagger-api/swagger-codegen#modifying-the-client-library-format. "); // TODO: update the URL
|
||||
objs.put("_lambda", lambdas);
|
||||
|
||||
@@ -77,6 +77,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public RustServerCodegen() {
|
||||
super();
|
||||
|
||||
// Show the generation timestamp by default
|
||||
hideGenerationTimestamp = Boolean.FALSE;
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/rust-server";
|
||||
|
||||
@@ -529,19 +532,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
List<String> consumes = new ArrayList<String>();
|
||||
|
||||
/* comment out the following logic as there's no consume in operation/global definition
|
||||
if (consumes != null) {
|
||||
if (!consumes.isEmpty()) {
|
||||
// use consumes defined in the operation
|
||||
consumes = operation.getConsumes();
|
||||
}
|
||||
} else if (openAPI != null && openAPI.getConsumes() != null && swagger.getConsumes().size() > 0) {
|
||||
// use consumes defined globally
|
||||
consumes = swagger.getConsumes();
|
||||
LOGGER.debug("No consumes defined in operation. Using global consumes (" + swagger.getConsumes() + ") for " + op.operationId);
|
||||
}
|
||||
*/
|
||||
|
||||
boolean consumesPlainText = false;
|
||||
boolean consumesXml = false;
|
||||
// if "consumes" is defined (per operation or using global definition)
|
||||
@@ -569,19 +559,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
|
||||
List<String> produces = new ArrayList<String>(getProducesInfo(openAPI, operation));
|
||||
// if "consumes" is defined (per operation or using global definition)
|
||||
/*
|
||||
if (operation.getProduces() != null) {
|
||||
if (operation.getProduces().size() > 0) {
|
||||
// use produces defined in the operation
|
||||
produces = operation.getProduces();
|
||||
}
|
||||
} else if (swagger != null && swagger.getProduces() != null && swagger.getProduces().size() > 0) {
|
||||
// use produces defined globally
|
||||
produces = swagger.getProduces();
|
||||
LOGGER.debug("No produces defined in operation. Using global produces (" + swagger.getProduces() + ") for " + op.operationId);
|
||||
}
|
||||
*/
|
||||
|
||||
boolean producesXml = false;
|
||||
boolean producesPlainText = false;
|
||||
@@ -604,51 +581,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
op.hasProduces = true;
|
||||
}
|
||||
|
||||
|
||||
/* TODO move the following logic to postProcessOperations as there's no body/form parameter in OAS 3.0
|
||||
if (op.bodyParam != null) {
|
||||
if (paramHasXmlNamespace(op.bodyParam, definitions)) {
|
||||
op.bodyParam.vendorExtensions.put("has_namespace", "true");
|
||||
}
|
||||
for (String key : definitions.keySet()) {
|
||||
op.bodyParam.vendorExtensions.put("model_key", key);
|
||||
}
|
||||
|
||||
// Default to consuming json
|
||||
op.bodyParam.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase());
|
||||
if (consumesXml) {
|
||||
op.bodyParam.vendorExtensions.put("consumesXml", true);
|
||||
} else if (consumesPlainText) {
|
||||
op.bodyParam.vendorExtensions.put("consumesPlainText", true);
|
||||
} else {
|
||||
op.bodyParam.vendorExtensions.put("consumesJson", true);
|
||||
}
|
||||
|
||||
}
|
||||
for (CodegenParameter param : op.bodyParams) {
|
||||
processParam(param, op);
|
||||
|
||||
if (paramHasXmlNamespace(param, definitions)) {
|
||||
param.vendorExtensions.put("has_namespace", "true");
|
||||
}
|
||||
|
||||
param.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase());
|
||||
|
||||
// Default to producing json if nothing else is specified
|
||||
if (consumesXml) {
|
||||
param.vendorExtensions.put("consumesXml", true);
|
||||
} else if (consumesPlainText) {
|
||||
param.vendorExtensions.put("consumesPlainText", true);
|
||||
} else {
|
||||
param.vendorExtensions.put("consumesJson", true);
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.formParams) {
|
||||
processParam(param, op);
|
||||
}
|
||||
*/
|
||||
|
||||
for (CodegenParameter param : op.headerParams) {
|
||||
// If a header uses UUIDs, we need to import the UUID package.
|
||||
if (param.dataType.equals("uuid::Uuid")) {
|
||||
@@ -714,6 +646,77 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return op;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
boolean consumesPlainText = false;
|
||||
boolean consumesXml = false;
|
||||
|
||||
if (op.consumes != null) {
|
||||
for (Map<String, String> consume : op.consumes) {
|
||||
if (consume.get("mediaType") != null) {
|
||||
String mediaType = consume.get("mediaType");
|
||||
|
||||
if (isMimetypeXml(mediaType)) {
|
||||
additionalProperties.put("usesXml", true);
|
||||
consumesXml = true;
|
||||
} else if (isMimetypePlainText(mediaType)) {
|
||||
consumesPlainText = true;
|
||||
} else if (isMimetypeWwwFormUrlEncoded(mediaType)) {
|
||||
additionalProperties.put("usesUrlEncodedForm", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (op.bodyParam != null) {
|
||||
// Default to consuming json
|
||||
op.bodyParam.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase());
|
||||
if (consumesXml) {
|
||||
op.bodyParam.vendorExtensions.put("consumesXml", true);
|
||||
} else if (consumesPlainText) {
|
||||
op.bodyParam.vendorExtensions.put("consumesPlainText", true);
|
||||
} else {
|
||||
op.bodyParam.vendorExtensions.put("consumesJson", true);
|
||||
}
|
||||
|
||||
}
|
||||
for (CodegenParameter param : op.bodyParams) {
|
||||
processParam(param, op);
|
||||
|
||||
param.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase());
|
||||
|
||||
// Default to producing json if nothing else is specified
|
||||
if (consumesXml) {
|
||||
param.vendorExtensions.put("consumesXml", true);
|
||||
} else if (consumesPlainText) {
|
||||
param.vendorExtensions.put("consumesPlainText", true);
|
||||
} else {
|
||||
param.vendorExtensions.put("consumesJson", true);
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.formParams) {
|
||||
processParam(param, op);
|
||||
}
|
||||
|
||||
for (CodegenProperty header : op.responseHeaders) {
|
||||
if (header.dataType.equals("uuid::Uuid")) {
|
||||
additionalProperties.put("apiUsesUuid", true);
|
||||
}
|
||||
header.nameInCamelCase = toModelName(header.baseName);
|
||||
}
|
||||
|
||||
additionalProperties.put("apiHasFile", true);
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataTypeFile(final String dataType) {
|
||||
return dataType != null && dataType.equals(typeMapping.get("File").toString());
|
||||
@@ -726,26 +729,22 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Schema inner = ap.getItems();
|
||||
String innerType = getTypeDeclaration(inner);
|
||||
StringBuilder typeDeclaration = new StringBuilder(typeMapping.get("array")).append("<");
|
||||
if (!StringUtils.isEmpty(inner.get$ref())) {
|
||||
typeDeclaration.append("models::");
|
||||
}
|
||||
typeDeclaration.append(innerType).append(">");
|
||||
return typeDeclaration.toString();
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
String innerType = getTypeDeclaration(inner);
|
||||
StringBuilder typeDeclaration = new StringBuilder(typeMapping.get("map")).append("<").append(typeMapping.get("string")).append(", ");
|
||||
if (!StringUtils.isEmpty(inner.get$ref())) {
|
||||
typeDeclaration.append("models::");
|
||||
}
|
||||
typeDeclaration.append(innerType).append(">");
|
||||
return typeDeclaration.toString();
|
||||
} else if (!StringUtils.isEmpty(p.get$ref())) {
|
||||
String datatype;
|
||||
try {
|
||||
datatype = p.get$ref();
|
||||
if (datatype.indexOf("#/definitions/") == 0) {
|
||||
datatype = toModelName(datatype.substring("#/definitions/".length()));
|
||||
|
||||
if (datatype.indexOf("#/components/schemas/") == 0) {
|
||||
datatype = toModelName(datatype.substring("#/components/schemas/".length()));
|
||||
datatype = "models::" + datatype;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Error obtaining the datatype from schema (model):" + p + ". Datatype default to Object");
|
||||
@@ -756,50 +755,41 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
} else if (p instanceof FileSchema) {
|
||||
return typeMapping.get("File").toString();
|
||||
}
|
||||
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
|
||||
CodegenParameter parameter = super.fromParameter(param, imports);
|
||||
/* TODO need ot revise the logic below as there's no body parameter
|
||||
if (param instanceof BodyParameter) {
|
||||
BodyParameter bp = (BodyParameter) param;
|
||||
Model model = bp.getSchema();
|
||||
if (model instanceof RefModel) {
|
||||
String name = ((RefModel) model).getSimpleRef();
|
||||
name = toModelName(name);
|
||||
// We need to be able to look up the model in the model definitions later.
|
||||
parameter.vendorExtensions.put("uppercase_data_type", name.toUpperCase());
|
||||
if (!parameter.isString && !parameter.isNumeric && !parameter.isByteArray &&
|
||||
!parameter.isBinary && !parameter.isFile && !parameter.isBoolean &&
|
||||
!parameter.isDate && !parameter.isDateTime && !parameter.isUuid &&
|
||||
!parameter.isListContainer && !parameter.isMapContainer &&
|
||||
!languageSpecificPrimitives.contains(parameter.dataType)) {
|
||||
|
||||
name = "models::" + getTypeDeclaration(name);
|
||||
parameter.baseType = name;
|
||||
parameter.dataType = name;
|
||||
|
||||
String refName = ((RefModel) model).get$ref();
|
||||
if (refName.indexOf("#/definitions/") == 0) {
|
||||
refName = refName.substring("#/definitions/".length());
|
||||
}
|
||||
parameter.vendorExtensions.put("refName", refName);
|
||||
|
||||
} else if (model instanceof ModelImpl) {
|
||||
parameter.vendorExtensions.put("refName", ((ModelImpl) model).getName());
|
||||
}
|
||||
String name = "models::" + getTypeDeclaration(parameter.dataType);
|
||||
parameter.dataType = name;
|
||||
parameter.baseType = name;
|
||||
}
|
||||
*/
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty fromProperty(String name, Schema p) {
|
||||
CodegenProperty property = super.fromProperty(name, p);
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
// If this parameter is not a primitive type, prefix it with "models::"
|
||||
// to ensure it's namespaced correctly in the Rust code.
|
||||
if (!parameter.isString && !parameter.isNumeric && !parameter.isByteArray &&
|
||||
!parameter.isBinary && !parameter.isFile && !parameter.isBoolean &&
|
||||
!parameter.isDate && !parameter.isDateTime && !parameter.isUuid &&
|
||||
!parameter.isListContainer && !parameter.isMapContainer &&
|
||||
!languageSpecificPrimitives.contains(parameter.dataType)) {
|
||||
|
||||
/* need to revise the logic below. Is this for alias?
|
||||
if (p instanceof RefProperty) {
|
||||
property.datatype = "models::" + property.datatype;
|
||||
String name = "models::" + getTypeDeclaration(parameter.dataType);
|
||||
parameter.dataType = name;
|
||||
parameter.baseType = name;
|
||||
}
|
||||
*/
|
||||
return property;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1037,6 +1027,24 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
|
||||
if (cm.dataType != null && cm.dataType.equals("object")) {
|
||||
// Object isn't a sensible default. Instead, we set it to
|
||||
// 'null'. This ensures that we treat this model as a struct
|
||||
// with multiple parameters.
|
||||
cm.dataType = null;
|
||||
} else if (cm.dataType != null) {
|
||||
// We need to hack about with single-parameter models to get
|
||||
// them recognised correctly.
|
||||
cm.isAlias = false;
|
||||
cm.dataType = typeMapping.get(cm.dataType);
|
||||
}
|
||||
}
|
||||
return super.postProcessModelsEnum(objs);
|
||||
|
||||
}
|
||||
@@ -1061,7 +1069,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private void processParam(CodegenParameter param, CodegenOperation op) {
|
||||
String example = null;
|
||||
|
||||
if (param.isString) {
|
||||
if (param.isFile) {
|
||||
param.vendorExtensions.put("formatString", "{:?}");
|
||||
op.vendorExtensions.put("hasFile", true);
|
||||
additionalProperties.put("apiHasFile", true);
|
||||
example = "Box::new(stream::once(Ok(b\"hello\".to_vec()))) as Box<Stream<Item=_, Error=_> + Send>";
|
||||
} else if (param.isString) {
|
||||
if (param.dataFormat != null && param.dataFormat.equals("byte")) {
|
||||
param.vendorExtensions.put("formatString", "\\\"{:?}\\\"");
|
||||
example = "swagger::ByteArray(\"" + ((param.example != null) ? param.example : "") + "\".to_string().into_bytes())";
|
||||
@@ -1082,11 +1095,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
} else if (param.isListContainer) {
|
||||
param.vendorExtensions.put("formatString", "{:?}");
|
||||
example = (param.example != null) ? param.example : "&Vec::new()";
|
||||
} else if (param.isFile) {
|
||||
param.vendorExtensions.put("formatString", "{:?}");
|
||||
op.vendorExtensions.put("hasFile", true);
|
||||
additionalProperties.put("apiHasFile", true);
|
||||
example = "Box::new(stream::once(Ok(b\"hello\".to_vec()))) as Box<Stream<Item=_, Error=_> + Send>";
|
||||
} else {
|
||||
param.vendorExtensions.put("formatString", "{:?}");
|
||||
if (param.example != null) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
@@ -41,12 +42,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SpringCodegen extends AbstractJavaCodegen
|
||||
implements BeanValidationFeatures, OptionalFeatures {
|
||||
@@ -69,6 +67,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
|
||||
public static final String IMPLICIT_HEADERS = "implicitHeaders";
|
||||
public static final String OPENAPI_DOCKET_CONFIG = "swaggerDocketConfig";
|
||||
public static final String API_FIRST = "apiFirst";
|
||||
|
||||
protected String title = "OpenAPI Spring";
|
||||
protected String configPackage = "org.openapitools.configuration";
|
||||
@@ -85,6 +84,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
protected boolean useBeanValidation = true;
|
||||
protected boolean implicitHeaders = false;
|
||||
protected boolean openapiDocketConfig = false;
|
||||
protected boolean apiFirst = false;
|
||||
protected boolean useOptional = false;
|
||||
|
||||
public SpringCodegen() {
|
||||
@@ -103,18 +103,19 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||
cliOptions.add(new CliOption(BASE_PACKAGE, "base package (invokerPackage) for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.",interfaceOnly));
|
||||
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern",delegatePattern));
|
||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.",singleContentTypes));
|
||||
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface",java8));
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers",async));
|
||||
cliOptions.add(CliOption.newBoolean(REACTIVE, "wrap responses in Mono/Flux Reactor types (spring-boot only)",reactive));
|
||||
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.", interfaceOnly));
|
||||
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern", delegatePattern));
|
||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.", singleContentTypes));
|
||||
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface", java8));
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers", async));
|
||||
cliOptions.add(CliOption.newBoolean(REACTIVE, "wrap responses in Mono/Flux Reactor types (spring-boot only)", reactive));
|
||||
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames",useTags));
|
||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations",useBeanValidation));
|
||||
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.",implicitHeaders));
|
||||
cliOptions.add(CliOption.newBoolean(OPENAPI_DOCKET_CONFIG, "Generate Spring OpenAPI Docket configuration class.",openapiDocketConfig));
|
||||
cliOptions.add(CliOption.newBoolean(USE_OPTIONAL,"Use Optional container for optional parameters",useOptional));
|
||||
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames", useTags));
|
||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations", useBeanValidation));
|
||||
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.", implicitHeaders));
|
||||
cliOptions.add(CliOption.newBoolean(OPENAPI_DOCKET_CONFIG, "Generate Spring OpenAPI Docket configuration class.", openapiDocketConfig));
|
||||
cliOptions.add(CliOption.newBoolean(API_FIRST, "Generate the API from the OAI spec at server compile time (API first approach)", apiFirst));
|
||||
cliOptions.add(CliOption.newBoolean(USE_OPTIONAL,"Use Optional container for optional parameters", useOptional));
|
||||
|
||||
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application using the SpringFox integration.");
|
||||
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
||||
@@ -145,9 +146,19 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
@Override
|
||||
public void processOpts() {
|
||||
|
||||
List<Pair<String,String>> configOptions = additionalProperties.entrySet().stream()
|
||||
.filter(e -> !Arrays.asList(API_FIRST, "hideGenerationTimestamp").contains(e.getKey()))
|
||||
.filter(e -> cliOptions.stream().map(CliOption::getOpt).anyMatch(opt -> opt.equals(e.getKey())))
|
||||
.map(e -> Pair.of(e.getKey(), e.getValue().toString()))
|
||||
.collect(Collectors.toList());
|
||||
additionalProperties.put("configOptions", configOptions);
|
||||
|
||||
// Process java8 option before common java ones to change the default dateLibrary to java8.
|
||||
System.out.println("----------------------------------");
|
||||
if (additionalProperties.containsKey(JAVA_8)) {
|
||||
System.out.println("has JAVA8");
|
||||
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
|
||||
additionalProperties.put(JAVA_8, java8);
|
||||
}
|
||||
if (this.java8 && !additionalProperties.containsKey(DATE_LIBRARY)) {
|
||||
setDateLibrary("java8");
|
||||
@@ -232,6 +243,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.setOpenapiDocketConfig(Boolean.valueOf(additionalProperties.get(OPENAPI_DOCKET_CONFIG).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(API_FIRST)) {
|
||||
this.setApiFirst(Boolean.valueOf(additionalProperties.get(API_FIRST).toString()));
|
||||
}
|
||||
|
||||
typeMapping.put("file", "Resource");
|
||||
importMapping.put("Resource", "org.springframework.core.io.Resource");
|
||||
|
||||
@@ -255,16 +270,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
|
||||
if (!this.interfaceOnly) {
|
||||
if (library.equals(SPRING_BOOT)) {
|
||||
if (!this.reactive) {
|
||||
supportingFiles.add(new SupportingFile("homeController.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("openapi2SpringBoot.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "OpenAPI2SpringBoot.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("application.mustache",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
|
||||
}
|
||||
if (library.equals(SPRING_MVC_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("webApplication.mustache",
|
||||
@@ -275,8 +284,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIUiConfiguration.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("application.properties",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "openapi.properties"));
|
||||
}
|
||||
if (library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("apiKeyRequestInterceptor.mustache",
|
||||
@@ -290,20 +297,19 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
} else {
|
||||
apiTemplateFiles.put("apiController.mustache", "Controller.java");
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("apiResponseMessage.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
|
||||
supportingFiles.add(new SupportingFile("notFoundException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
|
||||
if (!this.reactive) {
|
||||
supportingFiles.add(new SupportingFile("apiOriginFilter.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
|
||||
supportingFiles.add(new SupportingFile("application.mustache",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
|
||||
supportingFiles.add(new SupportingFile("homeController.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
|
||||
if (!this.reactive && !this.apiFirst) {
|
||||
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("openapi.mustache",
|
||||
("src/main/resources").replace("/", java.io.File.separator), "openapi.yaml"));
|
||||
}
|
||||
}
|
||||
} else if (this.openapiDocketConfig && !library.equals(SPRING_CLOUD_LIBRARY) && !this.reactive) {
|
||||
} else if (this.openapiDocketConfig && !library.equals(SPRING_CLOUD_LIBRARY) && !this.reactive && !this.apiFirst) {
|
||||
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
|
||||
}
|
||||
@@ -313,6 +319,11 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtil.java"));
|
||||
}
|
||||
|
||||
if (this.apiFirst) {
|
||||
apiTemplateFiles.clear();
|
||||
modelTemplateFiles.clear();
|
||||
}
|
||||
|
||||
if ("threetenbp".equals(dateLibrary)) {
|
||||
supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "CustomInstantDeserializer.java"));
|
||||
@@ -344,6 +355,11 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "Callable");
|
||||
}
|
||||
|
||||
if(!this.apiFirst && !this.reactive) {
|
||||
additionalProperties.put("useSpringfox", true);
|
||||
}
|
||||
|
||||
|
||||
// Some well-known Spring or Spring-Cloud response wrappers
|
||||
switch (this.responseWrapper) {
|
||||
case "Future":
|
||||
@@ -565,6 +581,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateYAMLSpecFile(objs);
|
||||
if(library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
List<CodegenSecurity> authMethods = (List<CodegenSecurity>) objs.get("authMethods");
|
||||
if (authMethods != null) {
|
||||
@@ -659,6 +676,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.openapiDocketConfig = openapiDocketConfig;
|
||||
}
|
||||
|
||||
public void setApiFirst(boolean apiFirst) {
|
||||
this.apiFirst = apiFirst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.openapitools.codegen.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class OpenAPISerializer extends JsonSerializer<OpenAPI> {
|
||||
|
||||
@Override
|
||||
public void serialize(OpenAPI value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
if (value != null) {
|
||||
gen.writeStartObject();
|
||||
gen.writeStringField("openapi", value.getOpenapi());
|
||||
if(value.getInfo() != null) {
|
||||
gen.writeObjectField("info", value.getInfo());
|
||||
}
|
||||
if(value.getExternalDocs() != null) {
|
||||
gen.writeObjectField("externalDocs", value.getExternalDocs());
|
||||
}
|
||||
if(value.getServers() != null) {
|
||||
gen.writeObjectField("servers", value.getServers());
|
||||
}
|
||||
if(value.getSecurity() != null) {
|
||||
gen.writeObjectField("security", value.getSecurity());
|
||||
}
|
||||
if(value.getTags() != null) {
|
||||
gen.writeObjectField("tags", value.getTags());
|
||||
}
|
||||
if(value.getPaths() != null) {
|
||||
gen.writeObjectField("paths", value.getPaths());
|
||||
}
|
||||
if(value.getComponents() != null) {
|
||||
gen.writeObjectField("components", value.getComponents());
|
||||
}
|
||||
if(value.getExtensions() != null) {
|
||||
for (Entry<String, Object> e : value.getExtensions().entrySet()) {
|
||||
gen.writeObjectField(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.openapitools.codegen.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SerializerUtils {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SerializerUtils.class);
|
||||
|
||||
public static String toYamlString(OpenAPI openAPI) {
|
||||
if(openAPI == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleModule module = new SimpleModule("OpenAPIModule");
|
||||
module.addSerializer(OpenAPI.class, new OpenAPISerializer());
|
||||
try {
|
||||
return Yaml.mapper()
|
||||
.registerModule(module)
|
||||
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
|
||||
.writeValueAsString(openAPI)
|
||||
.replace("\r\n", "\n");
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.warn("Can not create yaml content", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class ModelUtils {
|
||||
visitOpenAPI(openAPI, (s, t) -> {
|
||||
if(s.get$ref() != null) {
|
||||
String ref = getSimpleRef(s.get$ref());
|
||||
if ("application/x-www-form-urlencoded".equalsIgnoreCase(t) ||
|
||||
if ("application/x-www-form-urlencoded".equalsIgnoreCase(t) ||
|
||||
"multipart/form-data".equalsIgnoreCase(t)) {
|
||||
schemasUsedInFormParam.add(ref);
|
||||
} else {
|
||||
@@ -153,12 +153,13 @@ public class ModelUtils {
|
||||
* {@link #getUnusedSchemas(OpenAPI)},
|
||||
* {@link #getSchemasUsedOnlyInFormParam(OpenAPI)}, ...) to traverse all paths of an
|
||||
* OpenAPI instance and call the visitor functional interface when a schema is found.
|
||||
*
|
||||
*
|
||||
* @param openAPI specification
|
||||
* @param visitor functional interface (can be defined as a lambda) called each time a schema is found.
|
||||
*/
|
||||
private static void visitOpenAPI(OpenAPI openAPI, OpenAPISchemaVisitor visitor) {
|
||||
Map<String, PathItem> paths = openAPI.getPaths();
|
||||
List<String> visitedSchemas = new ArrayList<>();
|
||||
|
||||
if (paths != null) {
|
||||
for (PathItem path : paths.values()) {
|
||||
@@ -170,7 +171,7 @@ public class ModelUtils {
|
||||
for (Parameter p : operation.getParameters()) {
|
||||
Parameter parameter = getReferencedParameter(openAPI, p);
|
||||
if (parameter.getSchema() != null) {
|
||||
visitor.visit(parameter.getSchema(), null);
|
||||
visitSchema(openAPI, parameter.getSchema(), null, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +181,7 @@ public class ModelUtils {
|
||||
if (requestBody != null && requestBody.getContent() != null) {
|
||||
for (Entry<String, MediaType> e : requestBody.getContent().entrySet()) {
|
||||
if (e.getValue().getSchema() != null) {
|
||||
visitor.visit(e.getValue().getSchema(), e.getKey());
|
||||
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +193,7 @@ public class ModelUtils {
|
||||
if (apiResponse != null && apiResponse.getContent() != null) {
|
||||
for (Entry<String, MediaType> e : apiResponse.getContent().entrySet()) {
|
||||
if (e.getValue().getSchema() != null) {
|
||||
visitor.visit(e.getValue().getSchema(), e.getKey());
|
||||
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,6 +205,59 @@ public class ModelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void visitSchema(OpenAPI openAPI, Schema schema, String mimeType, List<String> visitedSchemas, OpenAPISchemaVisitor visitor) {
|
||||
visitor.visit(schema, mimeType);
|
||||
if(schema.get$ref() != null) {
|
||||
String ref = getSimpleRef(schema.get$ref());
|
||||
if(!visitedSchemas.contains(ref)) {
|
||||
visitedSchemas.add(ref);
|
||||
Schema referencedSchema = getSchemas(openAPI).get(ref);
|
||||
if(referencedSchema != null) {
|
||||
visitSchema(openAPI, referencedSchema, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(schema instanceof ComposedSchema) {
|
||||
List<Schema> oneOf = ((ComposedSchema) schema).getOneOf();
|
||||
if(oneOf != null) {
|
||||
for (Schema s : oneOf) {
|
||||
visitSchema(openAPI, s, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
List<Schema> allOf = ((ComposedSchema) schema).getAllOf();
|
||||
if(allOf != null) {
|
||||
for (Schema s : allOf) {
|
||||
visitSchema(openAPI, s, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
List<Schema> anyOf = ((ComposedSchema) schema).getAnyOf();
|
||||
if(anyOf != null) {
|
||||
for (Schema s : anyOf) {
|
||||
visitSchema(openAPI, s, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
} else if(schema instanceof ArraySchema) {
|
||||
Schema itemsSchema = ((ArraySchema) schema).getItems();
|
||||
if(itemsSchema != null) {
|
||||
visitSchema(openAPI, itemsSchema, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
} else if(isMapSchema(schema)) {
|
||||
Object additionalProperties = schema.getAdditionalProperties();
|
||||
if(additionalProperties instanceof Schema) {
|
||||
visitSchema(openAPI, (Schema) additionalProperties, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
if(schema.getNot() != null) {
|
||||
visitSchema(openAPI, schema.getNot(), mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
Map<String, Schema> properties = schema.getProperties();
|
||||
if(properties != null) {
|
||||
for (Schema property : properties.values()) {
|
||||
visitSchema(openAPI, property, mimeType, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private static interface OpenAPISchemaVisitor {
|
||||
|
||||
@@ -438,7 +492,7 @@ public class ModelUtils {
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
|
||||
|
||||
public static Schema getSchema(OpenAPI openAPI, String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class URLPathUtils {
|
||||
LOGGER.warn("Server information seems not defined in the spec. Default to {}.", LOCAL_HOST);
|
||||
return getDefaultUrl();
|
||||
}
|
||||
// TOOD need a way to obtain all server URLs
|
||||
// TODO need a way to obtain all server URLs
|
||||
final Server server = servers.get(0);
|
||||
String url = sanitizeUrl(server.getUrl());
|
||||
|
||||
@@ -150,4 +150,4 @@ public class URLPathUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ run the following command:
|
||||
gprbuild -p -P{{projectName}}
|
||||
```
|
||||
|
||||
After the build is successfull, you will get the server binary
|
||||
After the build is successful, you will get the server binary
|
||||
in bin/{{packageName}}-server and you can start it as follows:
|
||||
```
|
||||
./bin/{{packageName}}-server
|
||||
|
||||
@@ -7,7 +7,7 @@ expanded class
|
||||
feature -- Access
|
||||
|
||||
from_json (a_val:STRING; a_type: TYPE [detachable ANY] ): detachable ANY
|
||||
-- Deserialize a a json representation `a_val' to an object
|
||||
-- Deserialize a json representation `a_val' to an object
|
||||
-- of type `a_type'
|
||||
local
|
||||
conv_from: JSON_BASIC_REFLECTOR_DESERIALIZER
|
||||
|
||||
@@ -76,7 +76,11 @@ public class JSON {
|
||||
})
|
||||
{{/parent}}
|
||||
;
|
||||
return fireBuilder.createGsonBuilder();
|
||||
GsonBuilder builder = fireBuilder.createGsonBuilder();
|
||||
{{#disableHtmlEscaping}}
|
||||
builder.disableHtmlEscaping();
|
||||
{{/disableHtmlEscaping}}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
|
||||
@@ -915,7 +915,7 @@ public class ApiClient {
|
||||
* @param <T> Type
|
||||
* @param response Response
|
||||
* @param returnType Return type
|
||||
* @throws ApiException If the response has a unsuccessful status code or
|
||||
* @throws ApiException If the response has an unsuccessful status code or
|
||||
* fail to deserialize the response body
|
||||
* @return Type
|
||||
*/
|
||||
|
||||
@@ -82,7 +82,7 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public com.squareup.okhttp.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
|
||||
// create path and map variables
|
||||
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
@@ -527,6 +528,18 @@ public class ApiClient {
|
||||
|
||||
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
|
||||
if (queryParams != null) {
|
||||
//encode the query parameters in case they contain unsafe characters
|
||||
for (List<String> values : queryParams.values()) {
|
||||
if (values != null) {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
try {
|
||||
values.set(i, URLEncoder.encode(values.get(i), "utf8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.queryParams(queryParams);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class {{classname}} {
|
||||
{{/externalDocs}}
|
||||
*/
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException {
|
||||
Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
|
||||
@@ -13,6 +13,9 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
{{/jdk8-no-delegate}}
|
||||
import org.springframework.http.ResponseEntity;
|
||||
{{#useBeanValidation}}
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
{{/useBeanValidation}}
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@@ -50,6 +53,9 @@ import java.util.Optional;
|
||||
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
|
||||
{{/async}}
|
||||
{{>generatedAnnotation}}
|
||||
{{#useBeanValidation}}
|
||||
@Validated
|
||||
{{/useBeanValidation}}
|
||||
@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API")
|
||||
{{#operations}}
|
||||
public interface {{classname}} {
|
||||
|
||||
@@ -5,12 +5,12 @@ import com.fasterxml.jackson.core.JsonTokenId;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
|
||||
import org.threeten.bp.DateTimeException;
|
||||
import org.threeten.bp.DateTimeUtils;
|
||||
import org.threeten.bp.Instant;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import org.threeten.bp.ZoneId;
|
||||
@@ -205,7 +205,7 @@ public class CustomInstantDeserializer<T extends Temporal>
|
||||
|
||||
private ZoneId getZone(DeserializationContext context) {
|
||||
// Instants are always in UTC, so don't waste compute cycles
|
||||
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
|
||||
return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone());
|
||||
}
|
||||
|
||||
private static class FromIntegerArguments {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package {{configPackage}};
|
||||
|
||||
{{^useSpringfox}}
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.Resource;
|
||||
{{/useSpringfox}}
|
||||
import org.springframework.stereotype.Controller;
|
||||
{{^useSpringfox}}
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
{{/useSpringfox}}
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
{{^useSpringfox}}
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
{{/useSpringfox}}
|
||||
{{#reactive}}
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
{{/reactive}}
|
||||
|
||||
{{^useSpringfox}}
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
{{/useSpringfox}}
|
||||
{{#reactive}}
|
||||
import java.net.URI;
|
||||
{{/reactive}}
|
||||
{{^useSpringfox}}
|
||||
import java.nio.charset.Charset;
|
||||
{{/useSpringfox}}
|
||||
{{#reactive}}
|
||||
|
||||
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
|
||||
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
|
||||
{{/reactive}}
|
||||
|
||||
/**
|
||||
* Home redirection to OpenAPI api documentation
|
||||
*/
|
||||
@Controller
|
||||
public class HomeController {
|
||||
|
||||
{{^useSpringfox}}
|
||||
private static YAMLMapper yamlMapper = new YAMLMapper();
|
||||
|
||||
@Value("classpath:/openapi.yaml")
|
||||
private Resource openapi;
|
||||
|
||||
@Bean
|
||||
public String openapiContent() throws IOException {
|
||||
try(InputStream is = openapi.getInputStream()) {
|
||||
return StreamUtils.copyToString(is, Charset.defaultCharset());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi")
|
||||
@ResponseBody
|
||||
public String openapiYaml() throws IOException {
|
||||
return openapiContent();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/openapi.json", produces = "application/json")
|
||||
@ResponseBody
|
||||
public Object openapiJson() throws IOException {
|
||||
return yamlMapper.readValue(openapiContent(), Object.class);
|
||||
}
|
||||
|
||||
{{/useSpringfox}}
|
||||
{{#reactive}}
|
||||
@Bean
|
||||
RouterFunction<ServerResponse> index() {
|
||||
return route(
|
||||
GET("/"),
|
||||
req -> ServerResponse.temporaryRedirect(URI.create("{{#useSpringfox}}swagger-ui.html{{/useSpringfox}}{{^useSpringfox}}swagger-ui/index.html?url=../openapi.json{{/useSpringfox}}")).build()
|
||||
);
|
||||
}
|
||||
{{/reactive}}
|
||||
{{^reactive}}
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return "redirect:{{#useSpringfox}}swagger-ui.html{{/useSpringfox}}{{^useSpringfox}}swagger-ui/index.html?url=../openapi.json{{/useSpringfox}}";
|
||||
}
|
||||
{{/reactive}}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,13 +8,15 @@ This server was generated by the [OpenAPI Generator](https://openapi-generator.t
|
||||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
|
||||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
|
||||
|
||||
{{#useSpringfox}}
|
||||
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
|
||||
|
||||
Start your server as an simple java application
|
||||
{{/useSpringfox}}
|
||||
Start your server as a simple java application
|
||||
|
||||
{{^reactive}}
|
||||
You can view the api documentation in swagger-ui by pointing to
|
||||
http://localhost:8080/
|
||||
http://localhost:{{serverPort}}/
|
||||
|
||||
{{/reactive}}
|
||||
Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}}
|
||||
@@ -44,4 +46,4 @@ public interface PetClient extends PetApi {
|
||||
|
||||
}
|
||||
```
|
||||
{{/interfaceOnly}}
|
||||
{{/interfaceOnly}}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{{#useSpringfox}}
|
||||
springfox.documentation.swagger.v2.path=/api-docs
|
||||
{{/useSpringfox}}
|
||||
server.port={{serverPort}}
|
||||
spring.jackson.date-format={{basePackage}}.RFC3339DateFormat
|
||||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
||||
@@ -4,10 +4,28 @@ import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.ExitCodeGenerator;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
{{^reactive}}
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
{{^useSpringfox}}
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
{{/useSpringfox}}
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
{{^java8}}
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
{{/java8}}
|
||||
{{/reactive}}
|
||||
{{#reactive}}
|
||||
import org.springframework.web.reactive.config.CorsRegistry;
|
||||
{{^useSpringfox}}
|
||||
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
|
||||
{{/useSpringfox}}
|
||||
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
||||
{{/reactive}}
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
|
||||
@ComponentScan(basePackages = {"{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
|
||||
public class OpenAPI2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
@@ -30,4 +48,25 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Web{{^reactive}}Mvc{{/reactive}}{{#reactive}}Flux{{/reactive}}Configurer webConfigurer() {
|
||||
return new Web{{^reactive}}Mvc{{/reactive}}{{#reactive}}Flux{{/reactive}}Configurer{{^java8}}Adapter{{/java8}}() {
|
||||
/*@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("*")
|
||||
.allowedHeaders("Content-Type");
|
||||
}*/
|
||||
{{^useSpringfox}}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/");
|
||||
}
|
||||
{{/useSpringfox}}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
{{^reactive}}
|
||||
{{#useSpringfox}}
|
||||
<springfox-version>2.8.0</springfox-version>
|
||||
{{/reactive}}
|
||||
{{/useSpringfox}}
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -33,6 +33,38 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
{{#apiFirst}}
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>{{{generatorVersion}}}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>src/main/resources/openapi.yaml</inputSpec>
|
||||
<generatorName>spring</generatorName>
|
||||
<apiPackage>{{{apiPackage}}}</apiPackage>
|
||||
<modelPackage>{{{modelPackage}}}</modelPackage>
|
||||
<generateSupportingFiles>false</generateSupportingFiles>
|
||||
{{#modelNamePrefix}}
|
||||
<modelNamePrefix>{{{.}}}</modelNamePrefix>
|
||||
{{/modelNamePrefix}}
|
||||
{{#modelNameSuffix}}
|
||||
<modelNameSuffix>{{{.}}}</modelNameSuffix>
|
||||
{{/modelNameSuffix}}
|
||||
<configOptions>
|
||||
{{#configOptions}}
|
||||
<{{left}}>{{right}}</{{left}}>
|
||||
{{/configOptions}}
|
||||
</configOptions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
{{/apiFirst}}
|
||||
</plugins>
|
||||
{{/interfaceOnly}}
|
||||
</build>
|
||||
@@ -41,7 +73,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web{{#reactive}}flux{{/reactive}}</artifactId>
|
||||
</dependency>
|
||||
{{^reactive}}
|
||||
{{#useSpringfox}}
|
||||
<!--SpringFox dependencies -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
@@ -53,43 +85,47 @@
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${springfox-version}</version>
|
||||
</dependency>
|
||||
{{/reactive}}
|
||||
{{#reactive}}
|
||||
{{/useSpringfox}}
|
||||
{{^useSpringfox}}
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>swagger-ui</artifactId>
|
||||
<version>3.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.14</version>
|
||||
</dependency>
|
||||
{{/reactive}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
</dependency>
|
||||
{{/useSpringfox}}
|
||||
{{#withXml}}
|
||||
|
||||
<!-- XML processing: Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
{{/withXml}}
|
||||
{{#java8}}
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
{{#joda}}
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-joda</artifactId>
|
||||
</dependency>
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.joschi.jackson</groupId>
|
||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||
<version>2.6.4</version>
|
||||
<version>2.8.4</version>
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
{{#useBeanValidation}}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package {{configPackage}};
|
||||
|
||||
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.threeten.bp.Instant;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import org.threeten.bp.ZonedDateTime;
|
||||
|
||||
@Configuration
|
||||
public class JacksonConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ThreeTenModule.class)
|
||||
ThreeTenModule threeTenModule() {
|
||||
ThreeTenModule module = new ThreeTenModule();
|
||||
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
return module;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user