From 0b16fc16a21361aa873ec851f81e58c845e24cf2 Mon Sep 17 00:00:00 2001 From: Antoine Lelaisant Date: Fri, 21 Oct 2022 08:42:48 +0200 Subject: [PATCH] fix: make ObjectSchema implements JsonSchemaInterface --- src/ObjectSchema.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ObjectSchema.php b/src/ObjectSchema.php index 852c11e..d419391 100644 --- a/src/ObjectSchema.php +++ b/src/ObjectSchema.php @@ -68,4 +68,24 @@ public function getSchema(): array 'required' => $this->required, ]; } + + /** + * {@inheritdoc} + */ + public function jsonSerialize(): array + { + $schema = $this->getSchema(); + + /** + * @var array&array{title: string, description: string, examples: array} + */ + return array_merge( + $schema, + [ + 'title' => $this->getTitle(), + 'description' => $this->getDescription(), + 'examples' => [...$this->getExamples()], + ], + ); + } }