Skip to content

Commit 3e742ff

Browse files
d0nieksoyuka
authored andcommitted
Allow unset PathItem method
After disabling itemOperation `GET` ``` itemOperations: [ 'get' => [ 'controller' => ApiPlatform\Core\Action\NotFoundAction::class, 'read' => false, 'output' => false, ], ] ``` there is not nice way to remove that path from OpenApi docs. Now to do that you have to write: ``` $pathItem = $openApi->getPaths()->getPath('/resource/{id}'); $openApi->getPaths()->addPath( '/resource/{id}', new Model\PathItem( $pathItem->getRef(), $pathItem->getSummary(), $pathItem->getDescription(), null, $pathItem->getPut(), $pathItem->getPost(), $pathItem->getDelete(), $pathItem->getOptions(), $pathItem->getHead(), $pathItem->getPatch(), $pathItem->getTrace(), $pathItem->getServers(), $pathItem->getParameters(), ) ); ``` After change it will be: ``` $pathItem = $openApi->getPaths()->getPath('/resource/{id}'); $openApi->getPaths()->addPath( '/resource/{id}', $pathItem->withGet(null) ); ```
1 parent 7c6f96f commit 3e742ff

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/OpenApi/Model/PathItem.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,31 @@ public function withDescription(string $description): self
138138
return $clone;
139139
}
140140

141-
public function withGet(Operation $get): self
141+
public function withGet(?Operation $get): self
142142
{
143143
$clone = clone $this;
144144
$clone->get = $get;
145145

146146
return $clone;
147147
}
148148

149-
public function withPut(Operation $put): self
149+
public function withPut(?Operation $put): self
150150
{
151151
$clone = clone $this;
152152
$clone->put = $put;
153153

154154
return $clone;
155155
}
156156

157-
public function withPost(Operation $post): self
157+
public function withPost(?Operation $post): self
158158
{
159159
$clone = clone $this;
160160
$clone->post = $post;
161161

162162
return $clone;
163163
}
164164

165-
public function withDelete(Operation $delete): self
165+
public function withDelete(?Operation $delete): self
166166
{
167167
$clone = clone $this;
168168
$clone->delete = $delete;
@@ -186,7 +186,7 @@ public function withHead(Operation $head): self
186186
return $clone;
187187
}
188188

189-
public function withPatch(Operation $patch): self
189+
public function withPatch(?Operation $patch): self
190190
{
191191
$clone = clone $this;
192192
$clone->patch = $patch;

0 commit comments

Comments
 (0)