Skip to content

Commit 75e15df

Browse files
authored
Merge pull request #101 from DoclerLabs/support-multiple-responses
support multiple responses
2 parents 1d058ba + d80f7a8 commit 75e15df

File tree

12 files changed

+425
-116
lines changed

12 files changed

+425
-116
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [10.3.0] - 2023.12.08
8+
### Added
9+
- Added support for multiple responses
10+
711
## [10.2.0] - 2023.10.17
812
### Added
913
- Added support for PHP 8

src/Ast/Builder/CodeBuilder.php

+12
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use PhpParser\Node\Name\FullyQualified;
4444
use PhpParser\Node\Name\Relative;
4545
use PhpParser\Node\Stmt;
46+
use PhpParser\Node\Stmt\Case_;
4647
use PhpParser\Node\Stmt\Catch_;
4748
use PhpParser\Node\Stmt\Class_;
4849
use PhpParser\Node\Stmt\ClassConst;
@@ -55,6 +56,7 @@
5556
use PhpParser\Node\Stmt\Namespace_;
5657
use PhpParser\Node\Stmt\Property;
5758
use PhpParser\Node\Stmt\Return_;
59+
use PhpParser\Node\Stmt\Switch_;
5860
use PhpParser\Node\Stmt\Throw_;
5961
use PhpParser\Node\Stmt\TryCatch;
6062
use UnexpectedValueException;
@@ -218,6 +220,16 @@ public function assign(Expr $left, Expr $right): Assign
218220
return new Assign($left, $right);
219221
}
220222

223+
public function switch(Expr $condition, Case_ ...$cases): Switch_
224+
{
225+
return new Switch_($condition, $cases);
226+
}
227+
228+
public function case(Expr $condition, Stmt ...$stmts): Case_
229+
{
230+
return new Case_($condition, $stmts);
231+
}
232+
221233
public function if(Expr $condition, array $stmts, array $elseIfs = [], Else_ $else = null): If_
222234
{
223235
$subNodes = [];

src/Entity/Operation.php

+20-17
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66

77
class Operation
88
{
9-
private string $name;
10-
private string $description;
11-
private Request $request;
12-
private Response $successfulResponse;
13-
private array $errorResponses;
14-
private array $tags;
15-
private array $security;
9+
private string $name;
10+
private string $description;
11+
private Request $request;
12+
private array $successfulResponses;
13+
private array $errorResponses;
14+
private array $tags;
15+
private array $security;
1616

1717
public function __construct(
1818
string $name,
1919
string $description,
2020
Request $request,
21-
Response $successfulResponse,
21+
array $successfulResponses,
2222
array $errorResponses = [],
2323
array $tags = [],
2424
array $security = []
2525
) {
26-
$this->name = $name;
27-
$this->description = $description;
28-
$this->request = $request;
29-
$this->successfulResponse = $successfulResponse;
30-
$this->errorResponses = $errorResponses;
31-
$this->tags = $tags;
32-
$this->security = $security;
26+
$this->name = $name;
27+
$this->description = $description;
28+
$this->request = $request;
29+
$this->successfulResponses = $successfulResponses;
30+
$this->errorResponses = $errorResponses;
31+
$this->tags = $tags;
32+
$this->security = $security;
3333
}
3434

3535
public function getName(): string
@@ -47,9 +47,12 @@ public function getRequest(): Request
4747
return $this->request;
4848
}
4949

50-
public function getSuccessfulResponse(): Response
50+
/**
51+
* @return Response[]
52+
*/
53+
public function getSuccessfulResponses(): array
5154
{
52-
return $this->successfulResponse;
55+
return $this->successfulResponses;
5356
}
5457

5558
public function getErrorResponses(): array

0 commit comments

Comments
 (0)