Skip to content

Commit f6e2173

Browse files
committed
[php-symfony] Never return 406 when user accepts */*
When a query has header "Accept" set to "*/*" it means it accepts everything. It is hence weird to return a 406. This patch ensures it does not occur: when the query accepts everything then we take any produced type. This fixes #13334. This also partly makes the open PR #15560 obsolete (or at least, it provides a workaround)
1 parent d6c4634 commit f6e2173

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ class Controller extends AbstractController
204204
return 'application/xml';
205205
}
206206

207+
if (in_array('*/*', $accept)) {
208+
return $produced[0];
209+
}
210+
207211
// If we reach this point, we don't have a common ground between server and client
208212
return null;
209213
}

samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ protected function getOutputFormat(string $accept, array $produced): ?string
214214
return 'application/xml';
215215
}
216216

217+
if (in_array('*/*', $accept)) {
218+
return $produced[0];
219+
}
220+
217221
// If we reach this point, we don't have a common ground between server and client
218222
return null;
219223
}

0 commit comments

Comments
 (0)