mirror of
				https://github.com/OpenAPITools/openapi-generator.git
				synced 2025-11-03 18:23:44 +00:00 
			
		
		
		
	Merge pull request #3496 from Kvezon/jersey2-byte-array-deserialize
Support byte[] downloading in Java jersey2 client
This commit is contained in:
		
						commit
						7bd37468bc
					
				@ -498,8 +498,15 @@ public class ApiClient {
 | 
			
		||||
   * Deserialize response body to Java object according to the Content-Type.
 | 
			
		||||
   */
 | 
			
		||||
  public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
 | 
			
		||||
    // Handle file downloading.
 | 
			
		||||
    if (returnType.equals(File.class)) {
 | 
			
		||||
    if (response == null || returnType == null) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ("byte[]".equals(returnType.toString())) {
 | 
			
		||||
      // Handle binary response (byte array).
 | 
			
		||||
      return (T) response.readEntity(byte[].class);
 | 
			
		||||
    } else if (returnType.equals(File.class)) {
 | 
			
		||||
      // Handle file downloading.
 | 
			
		||||
      @SuppressWarnings("unchecked")
 | 
			
		||||
      T file = (T) downloadFileFromResponse(response);
 | 
			
		||||
      return file;
 | 
			
		||||
 | 
			
		||||
@ -497,8 +497,15 @@ public class ApiClient {
 | 
			
		||||
   * Deserialize response body to Java object according to the Content-Type.
 | 
			
		||||
   */
 | 
			
		||||
  public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
 | 
			
		||||
    // Handle file downloading.
 | 
			
		||||
    if (returnType.equals(File.class)) {
 | 
			
		||||
    if (response == null || returnType == null) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ("byte[]".equals(returnType.toString())) {
 | 
			
		||||
      // Handle binary response (byte array).
 | 
			
		||||
      return (T) response.readEntity(byte[].class);
 | 
			
		||||
    } else if (returnType.equals(File.class)) {
 | 
			
		||||
      // Handle file downloading.
 | 
			
		||||
      @SuppressWarnings("unchecked")
 | 
			
		||||
      T file = (T) downloadFileFromResponse(response);
 | 
			
		||||
      return file;
 | 
			
		||||
 | 
			
		||||
@ -497,8 +497,15 @@ public class ApiClient {
 | 
			
		||||
   * Deserialize response body to Java object according to the Content-Type.
 | 
			
		||||
   */
 | 
			
		||||
  public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
 | 
			
		||||
    // Handle file downloading.
 | 
			
		||||
    if (returnType.equals(File.class)) {
 | 
			
		||||
    if (response == null || returnType == null) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ("byte[]".equals(returnType.toString())) {
 | 
			
		||||
      // Handle binary response (byte array).
 | 
			
		||||
      return (T) response.readEntity(byte[].class);
 | 
			
		||||
    } else if (returnType.equals(File.class)) {
 | 
			
		||||
      // Handle file downloading.
 | 
			
		||||
      @SuppressWarnings("unchecked")
 | 
			
		||||
      T file = (T) downloadFileFromResponse(response);
 | 
			
		||||
      return file;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user