feat: filter response models in swagger spec
This commit is contained in:
parent
3ff66179c5
commit
d8fd30cffa
|
@ -81,7 +81,9 @@ class Swagger2 extends Format
|
|||
$output['securityDefinitions']['Mode']['x-appwrite'] = ['demo' => ''];
|
||||
}
|
||||
|
||||
foreach ($this->routes as $route) { /* @var $route \Utopia\Route */
|
||||
$usedModels = [];
|
||||
|
||||
foreach ($this->routes as $route) { /** @var \Utopia\Route $route */
|
||||
$url = \str_replace('/v1', '', $route->getURL());
|
||||
$scope = $route->getLabel('scope', '');
|
||||
$hide = $route->getLabel('sdk.hide', false);
|
||||
|
@ -148,6 +150,7 @@ class Swagger2 extends Format
|
|||
],
|
||||
];
|
||||
} else {
|
||||
$usedModels[] = $model->getType();
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
|
||||
'description' => $model->getName(),
|
||||
'schema' => [
|
||||
|
@ -232,7 +235,7 @@ class Swagger2 extends Format
|
|||
$node['format'] = 'format';
|
||||
$node['x-example'] = 'password';
|
||||
break;
|
||||
case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */
|
||||
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
|
||||
$node['type'] = 'integer';
|
||||
$node['format'] = 'int32';
|
||||
$node['x-example'] = $validator->getMin();
|
||||
|
@ -249,7 +252,7 @@ class Swagger2 extends Format
|
|||
$node['format'] = 'url';
|
||||
$node['x-example'] = 'https://example.com';
|
||||
break;
|
||||
case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */
|
||||
case 'Utopia\Validator\WhiteList': /** @var \Utopia\Validator\WhiteList $validator */
|
||||
$node['type'] = 'string';
|
||||
$node['x-example'] = $validator->getList()[0];
|
||||
break;
|
||||
|
@ -310,6 +313,10 @@ class Swagger2 extends Format
|
|||
}
|
||||
|
||||
foreach ($this->models as $model) {
|
||||
if (!in_array($model->getType(), $usedModels)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$required = $model->getRequired();
|
||||
$rules = $model->getRules();
|
||||
|
||||
|
|
Loading…
Reference in a new issue