mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Merge pull request #10815 from appwrite/fix-response-models-multi-methods
fix: generation of all response models in case of multi method endpoints
This commit is contained in:
commit
a1dff370a4
2 changed files with 39 additions and 7 deletions
|
|
@ -255,10 +255,21 @@ class OpenAPI3 extends Format
|
|||
}
|
||||
|
||||
foreach ($methodObj->getResponses() as $response) {
|
||||
if (\is_array($response->getModel())) {
|
||||
/** @var Response|array $response */
|
||||
$responseModel = $response->getModel();
|
||||
|
||||
if (\is_array($responseModel)) {
|
||||
foreach ($responseModel as $modelName) {
|
||||
foreach ($this->models as $value) {
|
||||
if ($value->getType() === $modelName) {
|
||||
$usedModels[] = $modelName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$additionalMethod['responses'][] = [
|
||||
'code' => $response->getCode(),
|
||||
'model' => \array_map(fn ($m) => '#/components/schemas/' . $m, $response->getModel())
|
||||
'model' => \array_map(fn ($m) => '#/components/schemas/' . $m, $responseModel)
|
||||
];
|
||||
} else {
|
||||
$responseData = [
|
||||
|
|
@ -267,7 +278,13 @@ class OpenAPI3 extends Format
|
|||
|
||||
// lets not assume stuff here!
|
||||
if ($response->getCode() !== 204) {
|
||||
$responseData['model'] = '#/components/schemas/' . $response->getModel();
|
||||
$responseData['model'] = '#/components/schemas/' . $responseModel;
|
||||
foreach ($this->models as $value) {
|
||||
if ($value->getType() === $responseModel) {
|
||||
$usedModels[] = $responseModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$additionalMethod['responses'][] = $responseData;
|
||||
|
|
|
|||
|
|
@ -264,11 +264,20 @@ class Swagger2 extends Format
|
|||
}
|
||||
|
||||
foreach ($methodObj->getResponses() as $response) {
|
||||
/** @var Response $response */
|
||||
if (\is_array($response->getModel())) {
|
||||
/** @var Response|array $response */
|
||||
$responseModel = $response->getModel();
|
||||
if (\is_array($responseModel)) {
|
||||
foreach ($responseModel as $modelName) {
|
||||
foreach ($this->models as $value) {
|
||||
if ($value->getType() === $modelName) {
|
||||
$usedModels[] = $modelName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$additionalMethod['responses'][] = [
|
||||
'code' => $response->getCode(),
|
||||
'model' => \array_map(fn ($m) => '#/definitions/' . $m, $response->getModel())
|
||||
'model' => \array_map(fn ($m) => '#/definitions/' . $m, $responseModel)
|
||||
];
|
||||
} else {
|
||||
$responseData = [
|
||||
|
|
@ -277,7 +286,13 @@ class Swagger2 extends Format
|
|||
|
||||
// lets not assume stuff here!
|
||||
if ($response->getCode() !== 204) {
|
||||
$responseData['model'] = '#/definitions/' . $response->getModel();
|
||||
$responseData['model'] = '#/definitions/' . $responseModel;
|
||||
foreach ($this->models as $value) {
|
||||
if ($value->getType() === $responseModel) {
|
||||
$usedModels[] = $responseModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$additionalMethod['responses'][] = $responseData;
|
||||
|
|
|
|||
Loading…
Reference in a new issue