Skip to content

Commit

Permalink
[Java][Client] Fix Gradle and SBT builds for REST Assured generator (#…
Browse files Browse the repository at this point in the history
…5990)

* Fix Gradle and SBT builds for Java REST Assured generator

* Add missing jackson-databind-nullable dependency to SBT build

* Update rest-assured sample

* Add sample for Java client with REST Assured and Jackson

* Add new REST Assured sample as Maven sub-module
  • Loading branch information
joschi authored Apr 22, 2020
1 parent 12512cf commit 40be1c3
Show file tree
Hide file tree
Showing 240 changed files with 23,146 additions and 125 deletions.
16 changes: 16 additions & 0 deletions bin/ci/java-rest-assured-jackson.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"!include": "bin/java-petstore-rest-assured-jackson.json",
"generatorName": "java",
"inputSpec": "modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml",
"outputDir": "samples/client/petstore/java/rest-assured-jackson",
"templateDir": "modules/openapi-generator/src/main/resources/Java/libraries/rest-assured",
"additionalProperties": {
"hideGenerationTimestamp": true,
"booleanGetterPrefix": "is",
"java8": "true",
"dateLibrary": "java8",
"serializationLibrary": "jackson",
"useBeanValidation": "true",
"performBeanValidation": "true"
}
}
1 change: 1 addition & 0 deletions bin/java-petstore-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
./bin/java-petstore-okhttp-gson-parcelable.sh
./bin/java-petstore-okhttp-gson.sh
./bin/java-petstore-rest-assured.sh
./bin/java-petstore-rest-assured-jackson.sh
./bin/java-petstore-resteasy.sh
./bin/java-petstore-resttemplate-withxml.sh
./bin/java-petstore-resttemplate.sh
Expand Down
4 changes: 4 additions & 0 deletions bin/java-petstore-rest-assured-jackson.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"library": "rest-assured",
"artifactId": "petstore-rest-assured-jackson"
}
36 changes: 36 additions & 0 deletions bin/java-petstore-rest-assured-jackson.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
target_dir="./samples/client/petstore/java/rest-assured-jackson/"

if [ ! -f "$executable" ]
then
mvn -B clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
args="generate -t modules/openapi-generator/src/main/resources/Java/libraries/rest-assured -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin/java-petstore-rest-assured-jackson.json -o ${target_dir} --additional-properties hideGenerationTimestamp=true --additional-properties useBeanValidation=true --additional-properties performBeanValidation=true --additional-properties booleanGetterPrefix=is --additional-properties java8=true --additional-properties dateLibrary=java8 --additional-properties serializationLibrary=jackson $@"

echo "Removing ${target_dir}"
rm -rf "${target_dir}"

java $JAVA_OPTS -jar $executable $args
1 change: 1 addition & 0 deletions bin/windows/java-petstore-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ call .\bin\windows\java-petstore-webclient.bat
call .\bin\windows\java-petstore-resteasy.bat
call .\bin\windows\java-petstore-google-api-client.bat
call .\bin\windows\java-petstore-rest-assured.bat
call .\bin\windows\java-petstore-rest-assured-jackson.bat
call .\bin\windows\java-petstore-vertx.bat
10 changes: 10 additions & 0 deletions bin/windows/java-petstore-rest-assured-jackson.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -t modules\openapi-generator\src\main\resources\Java\libraries\rest-assured -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin\java-petstore-rest-assured-jackson.json -o samples\client\petstore\java\rest-assured-jackson --additional-properties hideGenerationTimestamp=true,booleanGetterPrefix=is,java8=true,dateLibrary=java8,serializationLibrary=jackson,useBeanValidation=true,performBeanValidation=true,

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ ext {
{{#jackson}}
jackson_version = "2.10.3"
jackson_databind_version = "2.10.3"
jackson_databind_nullable_version = 0.2.1
jackson_databind_nullable_version = "0.2.1"
{{#threetenbp}}
jackson_threetenbp_version = "2.10.0"
{{/threetenbp}}
{{/jackson}}
{{#gson}}
gson_version = "2.8.6"
Expand All @@ -119,13 +122,25 @@ ext {
dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.findbugs:jsr305:3.0.2"
compile "io.rest-assured:scala-support:$rest_assured_version"
compile "io.rest-assured:rest-assured:$rest_assured_version"
{{#jackson}}
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
compile "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
{{#withXml}}
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version"
{{/withXml}}
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
{{#threetenbp}}
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_threetenbp_version"
{{/threetenbp}}
{{/jackson}}
{{#gson}}
compile "io.gsonfire:gson-fire:$gson_fire_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,26 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.21",
"io.rest-assured" % "rest-assured" % "4.3.0",
"io.rest-assured" % "scala-support" % "4.3.0",
"com.google.code.findbugs" % "jsr305" % "3.0.2",
{{#jackson}}
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.3" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.3" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.3",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.3",
"org.openapitools" % "jackson-databind-nullable" % "0.2.1",
{{#withXml}}
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.10.3",
{{/withXml}}
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.10.3",
{{/joda}}
{{#java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.10.3",
{{/java8}}
{{#threetenbp}}
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.10.0",
{{/threetenbp}}
{{/jackson}}
{{#gson}}
"com.google.code.gson" % "gson" % "2.8.6",
Expand All @@ -31,7 +46,7 @@ lazy val root = (project in file(".")).
"javax.validation" % "validation-api" % "2.0.1.Final" % "compile",
{{/useBeanValidation}}
{{#performBeanValidation}}
"org.hibernate" % "hibernate-validator" "6.0.19.Final" % "compile",
"org.hibernate" % "hibernate-validator" % "6.0.19.Final" % "compile",
{{/performBeanValidation}}
"junit" % "junit" % "4.13" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,7 @@
<module>samples/client/petstore/java/resteasy</module>
<module>samples/client/petstore/java/google-api-client</module>
<module>samples/client/petstore/java/rest-assured</module>
<module>samples/client/petstore/java/rest-assured-jackson</module>
<module>samples/client/petstore/groovy</module>
<!-- servers -->
<module>samples/server/petstore/jaxrs-jersey</module>
Expand Down
21 changes: 21 additions & 0 deletions samples/client/petstore/java/rest-assured-jackson/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# exclude jar for gradle wrapper
!gradle/wrapper/*.jar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# build files
**/target
target
.gradle
build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.3.1-SNAPSHOT
22 changes: 22 additions & 0 deletions samples/client/petstore/java/rest-assured-jackson/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
# Ref: https://docs.travis-ci.com/user/languages/java/
#
language: java
jdk:
- openjdk12
- openjdk11
- openjdk10
- openjdk9
- openjdk8
before_install:
# ensure gradlew has proper permission
- chmod a+x ./gradlew
script:
# test using maven
#- mvn test
# test using gradle
- gradle test
# test using sbt
# - sbt test
43 changes: 43 additions & 0 deletions samples/client/petstore/java/rest-assured-jackson/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# petstore-rest-assured-jackson

## Requirements

Building the API client library requires [Maven](https://maven.apache.org/) to be installed.

## Installation & Usage

To install the API client library to your local Maven repository, simply execute:

```shell
mvn install
```

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

```shell
mvn deploy
```

Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.

After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*:

```xml
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>petstore-rest-assured-jackson</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>

```

## Recommendation

It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.

## Author




Loading

0 comments on commit 40be1c3

Please sign in to comment.