Skip to content

Commit

Permalink
Merge c25f961 into 7c6f96f
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Mar 2, 2021
2 parents 7c6f96f + c25f961 commit cca3460
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/OpenApi/Model/PathItem.php
Expand Up @@ -138,31 +138,31 @@ public function withDescription(string $description): self
return $clone;
}

public function withGet(Operation $get): self
public function withGet(?Operation $get): self
{
$clone = clone $this;
$clone->get = $get;

return $clone;
}

public function withPut(Operation $put): self
public function withPut(?Operation $put): self
{
$clone = clone $this;
$clone->put = $put;

return $clone;
}

public function withPost(Operation $post): self
public function withPost(?Operation $post): self
{
$clone = clone $this;
$clone->post = $post;

return $clone;
}

public function withDelete(Operation $delete): self
public function withDelete(?Operation $delete): self
{
$clone = clone $this;
$clone->delete = $delete;
Expand All @@ -186,7 +186,7 @@ public function withHead(Operation $head): self
return $clone;
}

public function withPatch(Operation $patch): self
public function withPatch(?Operation $patch): self
{
$clone = clone $this;
$clone->patch = $patch;
Expand Down
17 changes: 17 additions & 0 deletions tests/OpenApi/Factory/OpenApiFactoryTest.php
Expand Up @@ -30,6 +30,7 @@
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactory;
use ApiPlatform\Core\OpenApi\Model;
use ApiPlatform\Core\OpenApi\Model\PathItem;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\Core\OpenApi\Options;
use ApiPlatform\Core\OpenApi\Serializer\OpenApiNormalizer;
Expand Down Expand Up @@ -745,4 +746,20 @@ public function testSubresourceDocumentation()
$normalizer = new OpenApiNormalizer($normalizers[0]);
$normalizer->normalize($openApi);
}

public function testResetPathItem()
{
$pathItem = new PathItem();
$pathItem->withGet(null);
$pathItem->withDelete(null);
$pathItem->withPost(null);
$pathItem->withPut(null);
$pathItem->withPatch(null);

$this->assertNull($pathItem->getGet());
$this->assertNull($pathItem->getDelete());
$this->assertNull($pathItem->getPost());
$this->assertNull($pathItem->getPut());
$this->assertNull($pathItem->getPatch());
}
}

0 comments on commit cca3460

Please sign in to comment.