mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Allow generation of Jersey2 clients with JSR310 classes
If the -DdateLibrary=java8 option is set on the command line then jersey2 client code will be generated using JSR310 classes rather than Joda time. Because JSR310 requires java8 the java target version is also changed in the build files.
This commit is contained in:
parent
34fed26e79
commit
9a9d5ebd9f
@ -2,7 +2,12 @@ package {{invokerPackage}};
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
{{#java8}}
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.*;
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
import com.fasterxml.jackson.datatype.joda.*;
|
import com.fasterxml.jackson.datatype.joda.*;
|
||||||
|
{{/java8}}
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
||||||
@ -19,7 +24,12 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
|||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
|
{{#java8}}
|
||||||
|
mapper.registerModule(new JavaTimeModule());
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
mapper.registerModule(new JodaModule());
|
mapper.registerModule(new JodaModule());
|
||||||
|
{{/java8}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +32,14 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
{{#java8}}
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
|
{{/java8}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the aar correctly
|
// Rename the aar correctly
|
||||||
@ -78,8 +84,14 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
|
{{#java8}}
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
|
{{/java8}}
|
||||||
|
|
||||||
install {
|
install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
@ -97,7 +109,9 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.8"
|
swagger_annotations_version = "1.5.8"
|
||||||
jackson_version = "2.7.0"
|
jackson_version = "2.7.0"
|
||||||
jersey_version = "2.22.2"
|
jersey_version = "2.22.2"
|
||||||
|
{{^java8}}
|
||||||
jodatime_version = "2.9.3"
|
jodatime_version = "2.9.3"
|
||||||
|
{{/java8}}
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +123,14 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||||
|
{{#java8}}
|
||||||
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
|
||||||
compile "joda-time:joda-time:$jodatime_version"
|
compile "joda-time:joda-time:$jodatime_version"
|
||||||
|
{{/java8}}
|
||||||
|
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,13 @@ lazy val root = (project in file(".")).
|
|||||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.0",
|
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.0",
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.0",
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.0",
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.0",
|
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.0",
|
||||||
|
{{#java8}}
|
||||||
|
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.0",
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.1.5",
|
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.1.5",
|
||||||
"joda-time" % "joda-time" % "2.9.3",
|
"joda-time" % "joda-time" % "2.9.3",
|
||||||
|
{{/java8}}
|
||||||
"com.brsanthu" % "migbase64" % "2.2",
|
"com.brsanthu" % "migbase64" % "2.2",
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||||
|
@ -100,8 +100,14 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
{{#java8}}
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
|
{{/java8}}
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- For testing build.gradle -->
|
<!-- For testing build.gradle -->
|
||||||
@ -167,6 +173,14 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{#java8}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/java8}}
|
||||||
|
{{^java8}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
@ -177,6 +191,7 @@
|
|||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>${jodatime-version}</version>
|
<version>${jodatime-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{/java8}}
|
||||||
|
|
||||||
<!-- Base64 encoding that works in both JVM and Android -->
|
<!-- Base64 encoding that works in both JVM and Android -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -197,7 +212,9 @@
|
|||||||
<swagger-core-version>1.5.8</swagger-core-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<jersey-version>2.22.2</jersey-version>
|
<jersey-version>2.22.2</jersey-version>
|
||||||
<jackson-version>2.7.0</jackson-version>
|
<jackson-version>2.7.0</jackson-version>
|
||||||
|
{{^java8}}
|
||||||
<jodatime-version>2.9.3</jodatime-version>
|
<jodatime-version>2.9.3</jodatime-version>
|
||||||
|
{{/java8}}
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user