@@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.JavaType;
3333 import org.openapitools.jackson.nullable.JsonNullableModule;
3434{ {/openApiNullable} }
3535
36+ import org.apache.commons.lang3.StringUtils;
3637import org.apache.hc.client5.http.cookie.BasicCookieStore;
3738import org.apache.hc.client5.http.cookie.Cookie;
3839import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
@@ -74,6 +75,7 @@ import java.util.concurrent.ConcurrentHashMap;
7475import java.util.regex.Matcher;
7576import java.util.regex.Pattern;
7677
78+
7779import java.net.URLEncoder;
7880
7981import java.io.File;
@@ -744,18 +746,29 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
744746 * @return The Accept header to use. If the given array is empty,
745747 * null will be returned (not to set the Accept header explicitly).
746748 */
747- public String selectHeaderAccept(String[] accepts) {
749+ public String selectHeaderAccept(String[] accepts, String path) {
750+ if (path != null && path.contains(" /sso/saml/metadata" )) {
751+ for (String accept : accepts) {
752+ if (" text/xml" .equalsIgnoreCase(accept)) {
753+ return accept;
754+ }
755+ }
756+ }
757+
748758 if (accepts.length == 0) {
749759 return null;
750760 }
761+
751762 for (String accept : accepts) {
752763 if (isJsonMime(accept)) {
753764 return accept;
754765 }
755766 }
756- return StringUtil.join(accepts, ",");
767+
768+ return StringUtils.join(accepts, ",");
757769 }
758770
771+
759772 /**
760773 * Select the Content-Type header's value from the given array:
761774 * if JSON exists in the given array, use it;
@@ -934,7 +947,12 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
934947 } else if ("text/plain".equalsIgnoreCase(mimeType)) {
935948 // convert input stream to string
936949 return (T) EntityUtils.toString(entity);
950+ } else if ("text/xml".equalsIgnoreCase(mimeType)) {
951+
952+ return (T) EntityUtils.toString(entity);
953+
937954 } else {
955+
938956 Map< String, List< String>> responseHeaders = transformResponseHeaders(response.getHeaders());
939957 throw new ApiException(
940958 " Deserialization for content type '" + mimeType + " ' not supported for type '" + valueType + " '" ,
@@ -1214,7 +1232,12 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
12141232
12151233 if (Objects.nonNull(t)) {
12161234
1217- Map< String, ?> map = getObjectMapper().convertValue(t, LinkedHashMap.class);
1235+ if (t instanceof String && accept != null && accept.contains(" xml" )) {
1236+ return t;
1237+ }
1238+
1239+
1240+ Map<String , ? > map = getObjectMapper().convertValue(t, LinkedHashMap.class);
12181241
12191242 String href = null;
12201243
0 commit comments