Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned.
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned; if it only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -753,10 +753,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, JSON will be used.
* @return MediaType The Content-Type header to use. If the given array is empty, or only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -655,10 +655,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned.
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned; if it only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -654,10 +654,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned.
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned; if it only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -603,10 +603,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, JSON will be used.
* @return MediaType The Content-Type header to use. If the given array is empty, or only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -567,10 +567,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned.
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned; if it only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -602,10 +602,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned.
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned; if it only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -601,10 +601,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned.
* @return MediaType The Content-Type header to use. If the given array is empty, null will be returned; if it only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -601,10 +601,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, JSON will be used.
* @return MediaType The Content-Type header to use. If the given array is empty, or only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -510,10 +510,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ public List<MediaType> selectHeaderAccept(String[] accepts) {
/**
* Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it;
* otherwise use the first one of the array.
* otherwise use the first non-wildcard one of the array.
*
* @param contentTypes The Content-Type array to select from
* @return MediaType The Content-Type header to use. If the given array is empty, JSON will be used.
* @return MediaType The Content-Type header to use. If the given array is empty, or only contains wildcard media types, JSON will be used.
*/
public MediaType selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) {
Expand All @@ -510,10 +510,20 @@ public MediaType selectHeaderContentType(String[] contentTypes) {
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (isJsonMime(mediaType)) {
// A wildcard media type (e.g. "*/*" or "application/*") is treated as
// JSON-compatible but cannot be used as a request Content-Type header,
// so fall back to concrete JSON in that case.
return mediaType.isWildcardType() || mediaType.isWildcardSubtype() ? MediaType.APPLICATION_JSON : mediaType;
}
}
// No JSON type found; use the first concrete (non-wildcard) media type instead.
for (String contentType : contentTypes) {
MediaType mediaType = MediaType.parseMediaType(contentType);
if (!mediaType.isWildcardType() && !mediaType.isWildcardSubtype()) {
return mediaType;
}
}
return MediaType.parseMediaType(contentTypes[0]);
return MediaType.APPLICATION_JSON;
}

/**
Expand Down
Loading
Loading