Skip to content

feat(symfony): ApiOperation attribute on controllers - #8628

Open
soyuka wants to merge 2 commits into
api-platform:mainfrom
soyuka:feat/controller-api-operation
Open

soyuka wants to merge 2 commits into
api-platform:mainfrom
soyuka:feat/controller-api-operation

Conversation

@soyuka

@soyuka soyuka commented Oct 1, 2026

Copy link
Copy Markdown
Member
Q A
Branch? main
Tickets #1423
License MIT
#[Route('/orders/checkout', name: 'order_checkout', methods: ['POST'])]
#[ApiOperation(new Post(input: CheckoutInput::class, output: CheckoutOutput::class))]
public function __invoke(CheckoutInput $data): CheckoutOutput
  • operation flags (read, deserialize, validate, security, serialize, write) toggle the stages
  • controllers tagged controller.service_arguments are scanned at compile time, the resource class is class ?? output ?? input and becomes a resource if it isn't one already
  • the route name comes from the method's #[Route] (or routeName on the operation), uriTemplate is forbidden
  • works with and without use_symfony_listeners, stage defaults extracted from MainController into OperationStageDefaults
  • Laravel: follow-up

Comment thread src/Symfony/Bundle/DependencyInjection/Compiler/ControllerApiOperationPass.php Outdated
Comment thread src/Symfony/EventListener/ControllerApiOperationPipelineListener.php Outdated
@soyuka
soyuka marked this pull request as ready for review October 2, 2026 09:30
soyuka added 2 commits October 2, 2026 11:36
Run the API Platform pipeline (read, deserialize, validate, security,
serialize, respond) on a plain Symfony controller route and document
the operation in OpenAPI and Hydra. The route owns the path, the
operation reuses it through routeName.
- resource class is class ?? output, input alone throws
- dedicated name collection factory for controller resources
- GET/GetCollection default to read: false
- cover get, getcollection, patch and delete in jsonld/json/csv
@soyuka
soyuka force-pushed the feat/controller-api-operation branch from 99c8f57 to e6c7e2e Compare October 2, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant