Skip to main content

POST Endpoint for an Action Without Input

src/ApiResource/Admin/BookDto.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\OpenApi\Model\RequestBody;
use App\ApiInput\BookInputDto;
use App\ApiState\Admin\Book\BookCheckProcessor;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
operations: [
// ...
new Post(
uriTemplate: '/books/{id}/check',
processor: BookCheckProcessor::class,
input: false,
openapi: new Operation(
summary: 'Check the book\'s condition',
description: 'Tells us that the book condition has been checked.',
)
),
// ...
]
)]
class BookDto
{
// ...
}