add support for jsr310 dates to okhttp-gson client

This commit is contained in:
cbornet
2016-06-20 16:50:08 +02:00
parent 79dc34266f
commit d29a5537bc
11 changed files with 99 additions and 32 deletions

View File

@@ -173,8 +173,8 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}

View File

@@ -234,4 +234,3 @@ class LocalDateTypeAdapter extends TypeAdapter<LocalDate> {
}
}
}

View File

@@ -39,8 +39,8 @@ import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import java.lang.reflect.Type;
import java.util.ArrayList;

View File

@@ -39,8 +39,8 @@ import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import io.swagger.client.model.Pet;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;

View File

@@ -10,8 +10,6 @@ import java.lang.reflect.Field;
import java.util.Map;
import java.text.SimpleDateFormat;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.*;
import static org.junit.Assert.*;
@@ -63,7 +61,7 @@ public class StoreApiTest {
assertEquals(order.getId(), fetched.getId());
assertEquals(order.getPetId(), fetched.getPetId());
assertEquals(order.getQuantity(), fetched.getQuantity());
assertEquals(order.getShipDate().withZone(DateTimeZone.UTC), fetched.getShipDate().withZone(DateTimeZone.UTC));
assertEquals(order.getShipDate().toInstant(), fetched.getShipDate().toInstant());
}
@Test
@@ -88,7 +86,7 @@ public class StoreApiTest {
Order order = new Order();
order.setPetId(new Long(200));
order.setQuantity(new Integer(13));
order.setShipDate(DateTime.now());
order.setShipDate(org.joda.time.DateTime.now());
order.setStatus(Order.StatusEnum.PLACED);
order.setComplete(true);