forked from loafle/openapi-generator-original
7141: filter out problem+json mime type from JSON mime types fast tra… (#7976)
* 7141: filter out problem+json mime type from JSON mime types fast tracked into the Accept header (resttemplate) * 7141: ran ensure-up-to-date * 7141: minimize changes with master (keep using isJsonMime for MediaType)
This commit is contained in:
@@ -476,6 +476,15 @@ public class ApiClient {
|
||||
return mediaType != null && (MediaType.APPLICATION_JSON.isCompatibleWith(mediaType) || mediaType.getSubtype().matches("^.*\\+json[;]?\\s*$"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given {@code String} is a Problem JSON MIME (RFC-7807).
|
||||
* @param mediaType the input MediaType
|
||||
* @return boolean true if the MediaType represents Problem JSON, false otherwise
|
||||
*/
|
||||
public boolean isProblemJsonMime(String mediaType) {
|
||||
return "application/problem+json".equalsIgnoreCase(mediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the Accept header's value from the given accepts array:
|
||||
* if JSON exists in the given array, use it;
|
||||
@@ -490,7 +499,7 @@ public class ApiClient {
|
||||
}
|
||||
for (String accept : accepts) {
|
||||
MediaType mediaType = MediaType.parseMediaType(accept);
|
||||
if (isJsonMime(mediaType)) {
|
||||
if (isJsonMime(mediaType) && !isProblemJsonMime(accept)) {
|
||||
return Collections.singletonList(mediaType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user