1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13:00

fix: specs generation for nullable params

This commit is contained in:
Torsten Dittmann 2023-03-13 15:54:49 +05:30
parent 2178bfc126
commit 2f1dda891b
2 changed files with 16 additions and 4 deletions

View file

@ -285,9 +285,11 @@ class OpenAPI3 extends Format
}
}
if ($validator instanceof Nullable) {
$isNullable = $validator instanceof Nullable;
if ($isNullable) {
/** @var Nullable $validator */
$validator = $validator->getValidator();
$node['schema']['x-nullable'] = true;
}
switch ((!empty($validator)) ? \get_class($validator) : '') {
@ -455,6 +457,10 @@ class OpenAPI3 extends Format
if ($node['x-global'] ?? false) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-global'] = true;
}
if ($isNullable) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-nullable'] = true;
}
}
$url = \str_replace(':' . $name, '{' . $name . '}', $url);

View file

@ -286,9 +286,11 @@ class Swagger2 extends Format
}
}
if ($validator instanceof Nullable) {
$isNullable = $validator instanceof Nullable;
if ($isNullable) {
/** @var Nullable $validator */
$validator = $validator->getValidator();
$node['schema']['x-nullable'] = true;
}
switch ((!empty($validator)) ? \get_class($validator) : '') {
@ -454,6 +456,10 @@ class Swagger2 extends Format
$body['schema']['properties'][$name]['x-global'] = true;
}
if ($isNullable) {
$body['schema']['properties'][$name]['x-nullable'] = true;
}
if (\array_key_exists('items', $node)) {
$body['schema']['properties'][$name]['items'] = $node['items'];
}