Skip to main content

POST Endpoint for Entity Creation

src/ApiResource/Admin/BookDto.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\ApiInput\BookInputDto;
use App\ApiState\Admin\Book\BookCreateProcessor;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
operations: [
// ...
new Post(
uriTemplate: '/books',
input: BookInputDto::class,
processor: BookCreateProcessor::class
),
// ...
]
)]
class BookDto
{
// ...
}