Skip to content

Commit

Permalink
Merge pull request #52 from WoutervanderLoopNL/fix-adding-response-type
Browse files Browse the repository at this point in the history
Added 207 response type. Fixes: #51
  • Loading branch information
casperbakker committed Sep 18, 2024
2 parents e8ae57a + bd0f0ce commit 60ace51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function getCommissionRates(array $products): Model\BulkCommissionRatesMu
'consumes' => 'application/vnd.retailer.v10+json',
];
$responseTypes = [
'207' => Model\BulkCommissionRatesMultiStatusResponse::class,
];

return $this->request('POST', $url, $options, $responseTypes);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenApi/ClientGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected function generateMethod(string $path, string $httpMethod, array &$code
$this->addBodyParam($arguments, $code);
$this->addFormData($arguments, $code);

$responseContent = $methodDefinition['responses']['200']['content'] ?? $methodDefinition['responses']['202']['content'] ?? $methodDefinition['responses']['400']['content'] ?? null;
$responseContent = $methodDefinition['responses']['200']['content'] ?? $methodDefinition['responses']['202']['content'] ?? $methodDefinition['responses']['207']['content'] ?? $methodDefinition['responses']['400']['content'] ?? null;
$code[] = sprintf(' \'produces\' => \'%s\',', array_key_first($responseContent));

if ($methodDefinition['requestBody']['content'] ?? false) {
Expand Down Expand Up @@ -507,7 +507,7 @@ protected function addResponseTypes(array $responses, array &$code): void
$code[] = ' $responseTypes = [';
foreach ($responses as $httpStatus => $response) {
$type = null;
if (in_array($httpStatus, ['200', '202'])) {
if (in_array($httpStatus, ['200', '202', '207'])) {
$response = current($response['content'] ?? []);

if (! isset($response['schema'])) {
Expand Down

0 comments on commit 60ace51

Please sign in to comment.