@@ -51,6 +51,7 @@ import java.util.HashMap;
5151import java.util.LinkedHashMap;
5252import java.util.LinkedHashSet;
5353import java.util.List;
54+ import java.util.Set;
5455import java.util.Arrays;
5556import java.util.ArrayList;
5657import java.util.Date;
@@ -922,8 +923,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
922923
923924 /**
924925 * Select the Accept header's value from the given accepts array:
925- * if JSON exists in the given array, use it;
926- * otherwise use all of them (joining into a string)
926+ * if JSON exists in the given array, makes sure there is only one entry of it.
927927 *
928928 * @param accepts The accepts array to select from
929929 * @return The Accept header to use. If the given array is empty,
@@ -933,12 +933,19 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
933933 if (accepts == null || accepts.length == 0) {
934934 return null;
935935 }
936+ Set<String > acceptHeaders = new LinkedHashSet<> ();
937+ boolean foundJsonMime = false;
936938 for (String accept : accepts) {
937939 if (isJsonMime(accept)) {
938- return accept;
940+ if (foundJsonMime) {
941+ continue;
942+ } else {
943+ foundJsonMime = true ;
944+ }
939945 }
946+ acceptHeaders.add(accept);
940947 }
941- return StringUtil.join(accepts , ",");
948+ return StringUtil.join(acceptHeaders , ",");
942949 }
943950
944951 /**
0 commit comments