square / square-java-sdk

Java client library for the Square API
https://developer.squareup.com
Other
59 stars 29 forks source link

Response classes not serializable with Jackson, consider adding `@JsonIgnore` to `getHttpContext` methods #58

Closed finci-square closed 2 years ago

finci-square commented 3 years ago

All of the java response models, e.g. SearchOrdersResponse contain an HttpContext

HttpContext contains HttpRequest and HttpResponse which both contains Headers instances which are not serializable.

This is very strange because for all other intents and purposes, the response models are themselves exact representations of the vanilla JSON that they are deserialized from.

We should consider using the @JsonIgnore annotation in every *Response class on the HttpContext getter such that the *Response classes are serializable back to their source JSON.

finci-square commented 3 years ago

HttpResponse and HttpRequest have TreeMap as a property of https://github.com/square/square-java-sdk/blob/72737e98a6463184c2031629c6f6389c7ab924e4/src/main/java/com/squareup/square/http/Headers.java

Why would the implementation use TreeMap? Is it important that the header order is preserved?