mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 17:47:05 +00:00
[Java] remove deprecated jackson classes (#7304)
* [java/resttemplate] Generate valid code if no Authentication implementations present Take the logic used to decide which instances to add to the authentications map and re-use to not import classes or offer non-functional util methods * parameterize formParams fixes #5782 * replace use of ISO8601DateFormat and ISO8601Utils with StdDateFormat fixes #5779 * add constructor to intialise calendar * Revert "[java/resttemplate] Generate valid code if no Authentication implementations present" This reverts commit6e450907ba. * Revert "parameterize formParams" This reverts commit7a26ce5dd2. * also override single arg parse method to avoid throwing exception * also override single arg parse method to avoid throwing exception * update samples * update samples * fix jersey1 tests * fix jersey2 test * update resteasy dependencies * fix java jersey2 oas3 tests * use java8 in springboot-beanvalidation Co-authored-by: Jon Freedman <jon.freedman@zoho.com>
This commit is contained in:
@@ -12,21 +12,44 @@
|
||||
|
||||
package org.openapitools.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
|
||||
import com.fasterxml.jackson.databind.util.ISO8601Utils;
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class RFC3339DateFormat extends DateFormat {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
|
||||
|
||||
public class RFC3339DateFormat extends ISO8601DateFormat {
|
||||
private final StdDateFormat fmt = new StdDateFormat()
|
||||
.withTimeZone(TIMEZONE_Z)
|
||||
.withColonInTimeZone(true);
|
||||
|
||||
// Same as ISO8601DateFormat but serializing milliseconds.
|
||||
@Override
|
||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||
String value = ISO8601Utils.format(date, true);
|
||||
toAppendTo.append(value);
|
||||
return toAppendTo;
|
||||
public RFC3339DateFormat() {
|
||||
this.calendar = new GregorianCalendar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date parse(String source) {
|
||||
return parse(source, new ParsePosition(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date parse(String source, ParsePosition pos) {
|
||||
return fmt.parse(source, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||
return fmt.format(date, toAppendTo, fieldPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class ApiClientTest {
|
||||
@Test
|
||||
public void testParseAndFormatDate() {
|
||||
// default date format
|
||||
String dateStr = "2015-11-07T03:49:09.356Z";
|
||||
String dateStr = "2015-11-07T03:49:09.356+00:00";
|
||||
assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T03:49:09.356+00:00")));
|
||||
assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T03:49:09.356Z")));
|
||||
assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T05:49:09.356+02:00")));
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JSONTest {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String s = df.format(date);
|
||||
System.out.println("DATE: " + s);
|
||||
assertEquals("2011-01-18T00:00:00.000Z", s);
|
||||
assertEquals("2011-01-18T00:00:00.000+00:00", s);
|
||||
}
|
||||
{
|
||||
String dateStr = "2011-01-18 00:00:00.0";
|
||||
@@ -58,7 +58,7 @@ public class JSONTest {
|
||||
RFC3339DateFormat df = new RFC3339DateFormat();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String s = df.format(date);
|
||||
assertEquals("2011-01-18T08:00:00.000Z", s);
|
||||
assertEquals("2011-01-18T08:00:00.000+00:00", s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,4 +87,4 @@ public class JSONTest {
|
||||
assertNotNull(o);
|
||||
assertEquals((long)12345, (long)o.get$SpecialPropertyName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user