Skip to content

Commit e790617

Browse files
committed
feat(examples-prepartor): exclude array bodies from auto complete
1 parent be171f6 commit e790617

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/Definition/Example/OperationExample.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ public function getQueryParameters(): array
226226
->count()
227227
;
228228
if ($this->forceRandom || ($this->autoComplete && \count(
229-
$this->queryParameters
230-
) < $definitionParamsCount)) {
229+
$this->queryParameters
230+
) < $definitionParamsCount)) {
231231
$randomQueryParams = $this->parent
232232
->getQueryParameters()
233233
->getRandomExamples()
@@ -265,8 +265,8 @@ public function getHeaders(): array
265265

266266
if ($this->parent !== null) {
267267
$definitionHeadersCount = $this->parent
268-
->getHeaders()
269-
->count() + 1 // content-type
268+
->getHeaders()
269+
->count() + 1 // content-type
270270
;
271271

272272
if ($this->parent->getSecurities()->count() > 0) {
@@ -324,7 +324,10 @@ public function getBody(): ?BodyExample
324324
if ($this->autoComplete) {
325325
$randomBody = BodyExample::create($requestBody->getRandomContent());
326326
if ($this->body !== null) {
327-
$this->body->setContent(array_merge($randomBody->getContent(), $this->body->getContent()));
327+
$content = $this->body->getContent();
328+
if (!isset($content[0])) {
329+
$this->body->setContent(array_merge($randomBody->getContent(), $content));
330+
}
328331
} else {
329332
$this->body = $randomBody;
330333
}

0 commit comments

Comments
 (0)