-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Labels
Description
Description
I use openapi-generator-cli version 6.0.1 to generate php-symfony server.
When I request to my API, I always receive 406 if the request header content-type not in: application/json, application/xml, */*
I checked the code, file OpenApiBundle/Controller/Controller.php
the function getOutputFormat only acepts application/xml and application/json
/**
* Converts an exception to a serializable array.
*
* @param string $accept
* @param array $produced
*
* @return ?string
*/
protected function getOutputFormat(string $accept, array $produced): ?string
{
// Figure out what the client accepts
$accept = preg_split("/[\s,]+/", $accept);
if (in_array('*/*', $accept) || in_array('application/*', $accept)) {
// Prefer JSON if the client has no preference
if (in_array('application/json', $produced)) {
return 'application/json';
}
if (in_array('application/xml', $produced)) {
return 'application/xml';
}
}
if (in_array('application/json', $accept) && in_array('application/json', $produced)) {
return 'application/json';
}
if (in_array('application/xml', $accept) && in_array('application/xml', $produced)) {
return 'application/xml';
}
// If we reach this point, we don't have a common ground between server and client
return null;
}Could you please help to check?
Reactions are currently unavailable