fix: order spec defaults before examples

This commit is contained in:
Chirag Aggarwal
2026-05-26 10:48:13 +05:30
parent 6266dfb7ab
commit 7f97d91f66
2 changed files with 8 additions and 2 deletions
@@ -782,9 +782,14 @@ class OpenAPI3 extends Format
$body['content'][$consumes[0]]['schema']['properties'][$name] = [
'type' => $node['schema']['type'],
'description' => $node['description'],
'x-example' => $node['schema']['x-example'] ?? null
];
if (\array_key_exists('default', $node['schema'])) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['default'] = $node['schema']['default'];
}
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-example'] = $node['schema']['x-example'] ?? null;
if (isset($node['schema']['format'])) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['format'] = $node['schema']['format'];
}
@@ -757,13 +757,14 @@ class Swagger2 extends Format
$body['schema']['properties'][$name] = [
'type' => $node['type'],
'description' => $node['description'],
'x-example' => $node['x-example'] ?? null,
];
if (\array_key_exists('default', $node)) {
$body['schema']['properties'][$name]['default'] = $node['default'];
}
$body['schema']['properties'][$name]['x-example'] = $node['x-example'] ?? null;
if (isset($node['format'])) {
$body['schema']['properties'][$name]['format'] = $node['format'];
}