From c821a15f99d97ce7c4d8ab36acc5811eba84c89b Mon Sep 17 00:00:00 2001 From: Bruno Drzanic Date: Thu, 4 Jan 2024 16:40:31 +0100 Subject: [PATCH 1/3] feat: add ability to deprecate the result --- src/Support/Generator/Operation.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Support/Generator/Operation.php b/src/Support/Generator/Operation.php index f3e8ae24..65dc14ea 100644 --- a/src/Support/Generator/Operation.php +++ b/src/Support/Generator/Operation.php @@ -16,6 +16,8 @@ class Operation public string $summary = ''; + public bool $deprecated = false; + /** @var array */ public array $security = []; @@ -111,6 +113,13 @@ public function description(string $description) return $this; } + public function deprecated(bool $deprecated) + { + $this->deprecated = $deprecated; + + return $this; + } + public function setTags(array $tags) { $this->tags = array_map(fn ($t) => (string) $t, $tags); @@ -141,6 +150,10 @@ public function toArray() $result['summary'] = $this->summary; } + if ($this->deprecated) { + $result['deprecated'] = $this->deprecated; + } + if (count($this->tags)) { $result['tags'] = $this->tags; } From 3c7c4d730dfd6805fc6d8d56a5bbcba9c7c8bbfb Mon Sep 17 00:00:00 2001 From: Bruno Drzanic Date: Mon, 8 Jan 2024 14:43:45 +0100 Subject: [PATCH 2/3] test: added operation deprecated property test --- tests/Generator/Operation/OperationTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/Generator/Operation/OperationTest.php diff --git a/tests/Generator/Operation/OperationTest.php b/tests/Generator/Operation/OperationTest.php new file mode 100644 index 00000000..8c97017a --- /dev/null +++ b/tests/Generator/Operation/OperationTest.php @@ -0,0 +1,12 @@ +deprecated(true); + + $array = $operation->toArray(); + + expect($operation->deprecated)->toBeTrue() + ->and($array)->toHaveKey('deprecated') + ->and($array['deprecated'])->toBeTrue(); +}); From 0f6a798d33863fa695c3a824c98c9de0c3766134 Mon Sep 17 00:00:00 2001 From: Bruno Drzanic Date: Mon, 8 Jan 2024 22:49:29 +0100 Subject: [PATCH 3/3] test: extend operation test --- tests/Generator/Operation/OperationTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Generator/Operation/OperationTest.php b/tests/Generator/Operation/OperationTest.php index 8c97017a..0eb8f2c7 100644 --- a/tests/Generator/Operation/OperationTest.php +++ b/tests/Generator/Operation/OperationTest.php @@ -10,3 +10,12 @@ ->and($array)->toHaveKey('deprecated') ->and($array['deprecated'])->toBeTrue(); }); + +it('default deprecated key is false', function () { + $operation = new \Dedoc\Scramble\Support\Generator\Operation('get'); + + $array = $operation->toArray(); + + expect($operation->deprecated)->toBeFalse() + ->and($array)->not()->toHaveKey('deprecated'); +});