Compare commits

...
Author SHA1 Message Date
Chirag Aggarwal 3c3c1dfefa Simplify Swagger2 nested model fix to keep items with $ref
The SDK generator parser looks for items.$ref to resolve sub_schema.
Keep the items approach but remove the incorrect type: object.
2026-04-02 23:32:52 +05:30
Chirag Aggarwal 902642d9fe Use allOf wrapping for nested model $ref in spec output
Direct $ref with sibling properties is not valid OpenAPI 3 / Swagger 2.
Wrap in allOf so SDK generators correctly resolve the referenced schema.
2026-04-02 23:31:06 +05:30
Chirag Aggarwal 60f1426c36 Fix spec output for nested sub-model properties
When a response model rule uses `nestedModel => true` and is not an
array, emit a direct `$ref` on the property instead of wrapping it
in `items`. The `items` keyword is only valid for `type: array` in
OpenAPI 3 / Swagger 2, so the previous output caused SDK generators
to skip producing typed classes for singular object sub-models.
2026-04-02 23:29:14 +05:30
2 changed files with 13 additions and 1 deletions
@@ -931,7 +931,16 @@ class OpenAPI3 extends Format
}
}
if ($items) {
$output['components']['schemas'][$model->getType()]['properties'][$name]['items'] = $items;
if (!empty($rule['nestedModel']) && !$rule['array']) {
$existing = $output['components']['schemas'][$model->getType()]['properties'][$name];
unset($existing['type']);
$output['components']['schemas'][$model->getType()]['properties'][$name] = \array_merge(
$existing,
['allOf' => [$items]]
);
} else {
$output['components']['schemas'][$model->getType()]['properties'][$name]['items'] = $items;
}
}
if ($rule['type'] === 'enum' && !empty($rule['enum'])) {
if ($rule['array']) {
@@ -924,6 +924,9 @@ class Swagger2 extends Format
}
}
if ($items) {
if (!empty($rule['nestedModel']) && !$rule['array']) {
unset($output['definitions'][$model->getType()]['properties'][$name]['type']);
}
$output['definitions'][$model->getType()]['properties'][$name]['items'] = $items;
}
if ($rule['type'] === 'enum' && !empty($rule['enum'])) {