square / square-java-sdk

Java client library for the Square API

Home Page:https://developer.squareup.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

finci-square opened this issue · comments

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.

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?