-
-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
338 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Feature: Sending PATCH requets | ||
As a client software developer | ||
I need to be able to send partial updates | ||
|
||
@createSchema | ||
Scenario: Detect accepted patch formats | ||
Given I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "POST" request to "/patch_dummies" with body: | ||
""" | ||
{"name": "Hello"} | ||
""" | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "GET" request to "/patch_dummies/1" | ||
Then the header "Accept-Patch" should be equal to "application/merge-patch+json, application/vnd.api+json" | ||
|
||
Scenario: Patch an item | ||
When I add "Content-Type" header equal to "application/merge-patch+json" | ||
And I send a "PATCH" request to "/patch_dummies/1" with body: | ||
""" | ||
{"name": "Patched"} | ||
""" | ||
Then the JSON node "name" should contain "Patched" | ||
|
||
Scenario: Remove a property according to RFC 7386 | ||
When I add "Content-Type" header equal to "application/merge-patch+json" | ||
And I send a "PATCH" request to "/patch_dummies/1" with body: | ||
""" | ||
{"name": null} | ||
""" | ||
Then the JSON node "name" should not exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Document; | ||
|
||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
|
||
/** | ||
* @author Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* @ApiResource( | ||
* itemOperations={ | ||
* "get", | ||
* "patch"={"input_formats"={"json"={"application/merge-patch+json"}, "jsonapi"}} | ||
* } | ||
* ) | ||
* @ODM\Document | ||
*/ | ||
class PatchDummy | ||
{ | ||
/** | ||
* @ODM\Id(strategy="INCREMENT", type="integer") | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ODM\Field(type="string") | ||
*/ | ||
public $name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @author Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* @ApiResource( | ||
* itemOperations={ | ||
* "get", | ||
* "patch"={"input_formats"={"json"={"application/merge-patch+json"}, "jsonapi"}} | ||
* } | ||
* ) | ||
* @ORM\Entity | ||
*/ | ||
class PatchDummy | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ORM\Column(nullable=true) | ||
*/ | ||
public $name; | ||
} |
Oops, something went wrong.