chore: add x-enum-name param
This commit is contained in:
parent
7a91e9f552
commit
3616756f50
9 changed files with 30 additions and 6 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -97,4 +97,26 @@ abstract class Format
|
|||
{
|
||||
return $this->params[$key] ?? $default;
|
||||
}
|
||||
|
||||
protected function getEnumName(string $service, string $method): ?string
|
||||
{
|
||||
switch ($service) {
|
||||
case 'account':
|
||||
switch ($method) {
|
||||
case 'createOAuth2Session':
|
||||
return 'Provider';
|
||||
}
|
||||
break;
|
||||
case 'avatars':
|
||||
switch ($method) {
|
||||
case 'getBrowser':
|
||||
return 'Browser';
|
||||
case 'getCreditCard':
|
||||
return 'CreditCard';
|
||||
case 'getFlag':
|
||||
return 'Flag';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,6 +412,7 @@ class OpenAPI3 extends Format
|
|||
$node['schema']['type'] = $validator->getType();
|
||||
$node['schema']['x-example'] = $validator->getList()[0];
|
||||
$node['schema']['enum'] = $validator->getList();
|
||||
$node['schema']['x-enum-name'] = $this->getEnumName($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''));
|
||||
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['format'] = 'int32';
|
||||
|
|
|
@ -414,6 +414,7 @@ class Swagger2 extends Format
|
|||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = $validator->getList()[0];
|
||||
$node['enum'] = $validator->getList();
|
||||
$node['x-enum-name'] = $this->getEnumName($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''));
|
||||
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['format'] = 'int32';
|
||||
|
|
Loading…
Reference in a new issue