Skip to content

Commit

Permalink
Use Content for Model on Response Too
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguitarguy committed Jun 18, 2024
1 parent 3c1d0f2 commit 2993aeb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/rector/src/OpenApiTagValueNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ public function getValues(): array

// request body wants `content` as the ref, so handle that first
$isModel = 'Nelmio\\ApiDocBundle\\Annotation\\Model' === $itemClass;
$isRequestBody = $attributeClass === 'OpenApi\\Attributes\\RequestBody';
if ($isRequestBody && 'content' === $name && $isModel) {
$needsContent = $attributeClass === 'OpenApi\\Attributes\\RequestBody'
|| $attributeClass === 'OpenApi\\Attributes\\Response';
if ($needsContent && 'content' === $name && $isModel) {
$newValues[$name] = new ArrayItemNode(
new OpenApiTagValueNode($item->value),
$name,
$item->kindValueQuoted,
$item->kindKeyQuoted
);
break;
} elseif (!$isRequestBody && 'ref' === $name && $isModel) {
} elseif (!$needsContent && 'ref' === $name && $isModel) {
$newValues[$name] = new ArrayItemNode(
new OpenApiTagValueNode($item->value),
$name,
Expand Down

0 comments on commit 2993aeb

Please # to comment.