Skip to content

Commit

Permalink
Adjust client response handler to be backwards compatible with older …
Browse files Browse the repository at this point in the history
…versions of Vert.x (<3.5) (OpenAPITools#854)
  • Loading branch information
ccozzolino authored and wing328 committed Aug 21, 2018
1 parent 71cce3a commit e645a3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.vertx.core.file.FileSystem;
import io.vertx.core.file.OpenOptions;
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpRequest;
Expand Down Expand Up @@ -553,7 +554,11 @@ public class ApiClient {
handleFileDownload(httpResponse, handler);
return;
} else {
resultContent = Json.decodeValue(httpResponse.body(), returnType);
try {
resultContent = Json.mapper.readValue(httpResponse.bodyAsString(), returnType);
} catch (Exception e) {
throw new DecodeException("Failed to decode:" + e.getMessage(), e);
}
}
result = Future.succeededFuture(resultContent);
}
Expand Down Expand Up @@ -597,4 +602,4 @@ public class ApiClient {
auth.applyToParams(queryParams, headerParams);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.vertx.core.file.OpenOptions;
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpRequest;
Expand Down Expand Up @@ -554,7 +555,11 @@ protected <T> Handler<AsyncResult<HttpResponse<Buffer>>> buildResponseHandler(Ty
handleFileDownload(httpResponse, handler);
return;
} else {
resultContent = Json.decodeValue(httpResponse.body(), returnType);
try {
resultContent = Json.mapper.readValue(httpResponse.bodyAsString(), returnType);
} catch (Exception e) {
throw new DecodeException("Failed to decode:" + e.getMessage(), e);
}
}
result = Future.succeededFuture(resultContent);
}
Expand Down Expand Up @@ -598,4 +603,4 @@ protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, M
auth.applyToParams(queryParams, headerParams);
}
}
}
}

0 comments on commit e645a3f

Please sign in to comment.