Skip to content

Commit

Permalink
Merge pull request #5 from KnpLabs:fix/json-content-example
Browse files Browse the repository at this point in the history
fix: shift examples to avoid malformated examples
  • Loading branch information
clementvtrd authored Dec 8, 2022
2 parents 24cf884 + 2b3f85e commit 3952d15
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/OpenApi/Attributes/JsonContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public function __construct(string $schemaClass)
* @var JsonSchemaInterface
*/
$schema = new $schemaClass();
$examples = iterator_to_array($schema->getExamples());

parent::__construct(
schema: json_encode($schema->jsonSerialize()),
example: iterator_to_array($schema->getExamples()),
example: array_shift($examples),
title: $schema->getTitle(),
description: $schema->getDescription(),
);
Expand Down

0 comments on commit 3952d15

Please sign in to comment.