From 3074597912db53aa0d494232a1b7066b02319b4c Mon Sep 17 00:00:00 2001 From: DerManoMann Date: Fri, 15 Mar 2024 13:39:07 +1300 Subject: [PATCH] Fix resolving general component refs --- src/Annotations/AbstractAnnotation.php | 2 +- src/Annotations/RequestBody.php | 15 +++++- tests/Fixtures/Scratch/RequestBody.php | 70 +++++++++++++++++++++++++ tests/Fixtures/Scratch/RequestBody.yaml | 35 +++++++++++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 tests/Fixtures/Scratch/RequestBody.php create mode 100644 tests/Fixtures/Scratch/RequestBody.yaml diff --git a/src/Annotations/AbstractAnnotation.php b/src/Annotations/AbstractAnnotation.php index f3e7154e0..c23dfdf32 100644 --- a/src/Annotations/AbstractAnnotation.php +++ b/src/Annotations/AbstractAnnotation.php @@ -652,7 +652,7 @@ public function getRoot(): string */ public function isRoot(string $rootClass): bool { - return $this->getRoot() == $rootClass; + return get_class($this) == $rootClass || $this->getRoot() == $rootClass; } /** diff --git a/src/Annotations/RequestBody.php b/src/Annotations/RequestBody.php index 4844d1da2..cf954d5d6 100644 --- a/src/Annotations/RequestBody.php +++ b/src/Annotations/RequestBody.php @@ -29,7 +29,7 @@ class RequestBody extends AbstractAnnotation public $ref = Generator::UNDEFINED; /** - * Request body model name. + * The key into Components->requestBodies array. * * @var string */ @@ -95,4 +95,17 @@ class RequestBody extends AbstractAnnotation MediaType::class => ['content', 'mediaType'], Attachable::class => ['attachables'], ]; + + /** + * @inheritdoc + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = parent::jsonSerialize(); + + unset($data->request); + + return $data; + } } diff --git a/tests/Fixtures/Scratch/RequestBody.php b/tests/Fixtures/Scratch/RequestBody.php new file mode 100644 index 000000000..95515ca1a --- /dev/null +++ b/tests/Fixtures/Scratch/RequestBody.php @@ -0,0 +1,70 @@ +