Skip to main content

PATCH and PUT Endpoint for Entity Update

src/ApiResource/Admin/BookDto.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Patch;
use App\ApiInput\BookInputDto;
use App\ApiState\Admin\Book\BookProvider;
use App\ApiState\Admin\Book\BookUpdateProcessor;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
operations: [
// ...
new Patch(
uriTemplate: '/books/{id}',
input: BookInputDto::class,
processor: BookUpdateProcessor::class,
read: false,
),
new Put(
uriTemplate: '/books/{id}',
input: BookInputDto::class,
processor: BookUpdateProcessor::class,
read: false,
),
// ...
]
)]
class BookDto
{
// ...
}