1- /*
2- * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved.
3- */
4-
51package com .sap .cloud .sdk .services .openapi .apache .apiclient ;
62
73import static com .sap .cloud .sdk .services .openapi .apache .apiclient .DefaultApiResponseHandler .isJsonMime ;
2824import javax .annotation .Nonnull ;
2925import javax .annotation .Nullable ;
3026
31- import com .fasterxml .jackson .core .JsonProcessingException ;
32- import lombok .extern .slf4j .Slf4j ;
33- import lombok .val ;
3427import org .apache .hc .client5 .http .classic .HttpClient ;
3528import org .apache .hc .client5 .http .entity .UrlEncodedFormEntity ;
3629import org .apache .hc .client5 .http .entity .mime .MultipartEntityBuilder ;
4538import org .apache .hc .core5 .http .io .entity .FileEntity ;
4639import org .apache .hc .core5 .http .io .entity .StringEntity ;
4740import org .apache .hc .core5 .http .io .support .ClassicRequestBuilder ;
41+ import org .apache .hc .core5 .http .message .BasicNameValuePair ;
4842
4943import com .fasterxml .jackson .annotation .JsonAutoDetect .Visibility ;
5044import com .fasterxml .jackson .annotation .PropertyAccessor ;
45+ import com .fasterxml .jackson .core .JsonProcessingException ;
5146import com .fasterxml .jackson .core .type .TypeReference ;
5247import com .fasterxml .jackson .databind .DeserializationFeature ;
5348import com .fasterxml .jackson .databind .MapperFeature ;
6661import lombok .Getter ;
6762import lombok .ToString ;
6863import lombok .With ;
69- import org .apache .hc .core5 .http .message .BasicNameValuePair ;
64+ import lombok .extern .slf4j .Slf4j ;
65+ import lombok .val ;
7066
7167/**
7268 * API client for executing HTTP requests using Apache HttpClient 5.
@@ -373,7 +369,7 @@ public static String escapeString( @Nonnull final String str )
373369 * Parse content type object from header value
374370 */
375371 @ Nonnull
376- private static ContentType getContentType ( @ Nonnull final String headerValue )
372+ private ContentType getContentType ( @ Nonnull final String headerValue )
377373 throws OpenApiRequestException
378374 {
379375 try {
@@ -398,7 +394,7 @@ private static ContentType getContentType( @Nonnull final String headerValue )
398394 * @return The full URL
399395 */
400396 @ Nonnull
401- private static String buildUrl (
397+ private String buildUrl (
402398 @ Nonnull final String basePath ,
403399 @ Nonnull final String path ,
404400 @ Nullable final List <Pair > queryParams ,
@@ -594,6 +590,21 @@ private ClassicRequestBuilder buildClassicRequest(
594590 return builder ;
595591 }
596592
593+ /**
594+ * Serialize the given Java object into string according the given Content-Type (only JSON is supported for now).
595+ *
596+ * @param body
597+ * Object
598+ * @param contentType
599+ * Content type
600+ * @param formParams
601+ * Form parameters
602+ * @param headerParams
603+ * Header parameters, used to check content encoding for JSON serialization
604+ * @return Object
605+ * @throws OpenApiRequestException
606+ * API exception
607+ */
597608 @ Nonnull
598609 private HttpEntity serialize (
599610 @ Nullable final Object body ,
0 commit comments