[BUG] Invalid accept header PHP
Created by: dansleboby
OpenAPI Generator version: 4.2.2
Description
You should not overwrite the headers It a valid header and also define in RFC: https://tools.ietf.org/html/rfc2616#section-14.1
Here is the JSON: https://github.com/dansleboby/ubity-sdk-php/blob/master/swagger.json#L307
Suggest a fix/enhancement
The elseif for application/json overwrite the wanted headers in my YAML
I use
'application/json;version=1'
FIX: Remove elseif and content
/**
* Return the header 'Accept' based on an array of Accept provided
*
* @param string[] $accept Array of header
*
* @return string Accept (e.g. application/json)
*/
private function selectAcceptHeader($accept)
{
if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) {
return null;
} elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) {
return implode(',', $jsonAccept);
} else {
return implode(',', $accept);
}
}
/**
* Return the content type based on an array of content-type provided
*
* @param string[] $contentType Array fo content-type
*
* @return string Content-Type (e.g. application/json)
*/
private function selectContentTypeHeader($contentType)
{
if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) {
return 'application/json';
} elseif (preg_grep("/application\/json/i", $contentType)) {
return 'application/json';
} else {
return implode(',', $contentType);
}
}