-
-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(symfony): status at 200 when allowCreate is false (#5465)
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
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,29 @@ | ||
Feature: Spec-compliant PUT support | ||
As a client software developer | ||
I need to be able to create or replace resources using the PUT HTTP method | ||
|
||
@createSchema | ||
@!mongodb | ||
Scenario: Get a correct status code when updating a resource that is not allowed to read nor to create | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "PUT" request to "/custom_puts/1" with body: | ||
""" | ||
{ | ||
"foo": "a", | ||
"bar": "b" | ||
} | ||
""" | ||
Then the response status code should be 200 | ||
And the response status code should not be 201 | ||
And the response should be in JSON | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "/contexts/CustomPut", | ||
"@id": "/custom_puts/1", | ||
"@type": "CustomPut", | ||
"id": 1, | ||
"foo": "a", | ||
"bar": "b" | ||
} | ||
""" |
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,44 @@ | ||
<?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\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Get; | ||
use ApiPlatform\Metadata\Put; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\Id; | ||
|
||
/** | ||
* @author Kévin Dunglas <kevin@dunglas.fr> | ||
*/ | ||
#[ApiResource( | ||
operations: [new Get(), new Put(read: false, allowCreate: false)], | ||
extraProperties: [ | ||
'custom_put' => true, | ||
] | ||
)] | ||
#[Entity] | ||
class CustomPut | ||
{ | ||
#[Id] | ||
#[Column] | ||
public ?int $id = null; | ||
|
||
#[Column] | ||
public string $foo = ''; | ||
|
||
#[Column] | ||
public string $bar = ''; | ||
} |