fix: missing Whitelist enums
This commit is contained in:
parent
cec9798126
commit
528846c35e
3 changed files with 12 additions and 2 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -293,6 +293,7 @@ class Swagger2 extends Format
|
||||||
$validator = $validator->getValidator();
|
$validator = $validator->getValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch ((!empty($validator)) ? \get_class($validator) : '') {
|
switch ((!empty($validator)) ? \get_class($validator) : '') {
|
||||||
case 'Utopia\Validator\Text':
|
case 'Utopia\Validator\Text':
|
||||||
$node['type'] = $validator->getType();
|
$node['type'] = $validator->getType();
|
||||||
|
@ -413,11 +414,13 @@ class Swagger2 extends Format
|
||||||
/** @var \Utopia\Validator\WhiteList $validator */
|
/** @var \Utopia\Validator\WhiteList $validator */
|
||||||
$node['type'] = $validator->getType();
|
$node['type'] = $validator->getType();
|
||||||
$node['x-example'] = $validator->getList()[0];
|
$node['x-example'] = $validator->getList()[0];
|
||||||
|
|
||||||
if (!($route->getLabel('sdk.namespace', '') == 'users' && $route->getLabel('sdk.method', '') == 'getUsage' && $name == 'provider')) {
|
if (!($route->getLabel('sdk.namespace', '') == 'users' && $route->getLabel('sdk.method', '') == 'getUsage' && $name == 'provider')) {
|
||||||
$node['enum'] = $validator->getList();
|
$node['enum'] = $validator->getList();
|
||||||
$node['x-enum-name'] = $this->getEnumName($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
|
$node['x-enum-name'] = $this->getEnumName($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
|
||||||
$node['x-enum-keys'] = $this->getEnumKeys($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
|
$node['x-enum-keys'] = $this->getEnumKeys($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($validator->getType() === 'integer') {
|
if ($validator->getType() === 'integer') {
|
||||||
$node['format'] = 'int32';
|
$node['format'] = 'int32';
|
||||||
}
|
}
|
||||||
|
@ -456,6 +459,13 @@ class Swagger2 extends Format
|
||||||
'x-example' => $node['x-example'] ?? null,
|
'x-example' => $node['x-example'] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (isset($node['enum'])) {
|
||||||
|
/// If the enum flag is Set, add the enum values to the body
|
||||||
|
$body['schema']['properties'][$name]['enum'] = $node['enum'];
|
||||||
|
$body['schema']['properties'][$name]['x-enum-name'] = $node['x-enum-name'] ?? null;
|
||||||
|
$body['schema']['properties'][$name]['x-enum-keys'] = $node['x-enum-keys'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($node['x-global'] ?? false) {
|
if ($node['x-global'] ?? false) {
|
||||||
$body['schema']['properties'][$name]['x-global'] = true;
|
$body['schema']['properties'][$name]['x-global'] = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue