forked from loafle/openapi-generator-original
[Java][client] Fix feign classcastexception when getting headers (#16745)
* Avoid ClassCastException when getting headers (the header values are Collection<String> and not List<String>) Delete unused classes * Remove feign10x * Add unit test Refactor to avoid creating the headers map when ApiResponse is not used
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ApiResponse<T>{
|
||||
|
||||
final private int statusCode;
|
||||
final private Map<String, List<String>> headers;
|
||||
final private Map<String, Collection<String>> headers;
|
||||
final private T data;
|
||||
|
||||
/**
|
||||
* @param statusCode The status code of HTTP response
|
||||
* @param headers The headers of HTTP response
|
||||
*/
|
||||
public ApiResponse(int statusCode, Map<String, List<String>> headers) {
|
||||
public ApiResponse(int statusCode, Map<String, Collection<String>> headers) {
|
||||
this(statusCode, headers, null);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ApiResponse<T>{
|
||||
* @param headers The headers of HTTP response
|
||||
* @param data The object deserialized from response bod
|
||||
*/
|
||||
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) {
|
||||
public ApiResponse(int statusCode, Map<String, Collection<String>> headers, T data) {
|
||||
this.statusCode = statusCode;
|
||||
this.headers = headers;
|
||||
this.data = data;
|
||||
@@ -32,7 +32,7 @@ public class ApiResponse<T>{
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getHeaders() {
|
||||
public Map<String, Collection<String>> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user