What is the right way to specify operations? #5420
-
Hi, in the docs it tells me to do something like this: #[ApiResource(
operations: [
new Get(),
new GetCollection()
]
)] But when I look into the demo API it looks like this: #[GetCollection]
#[Post]
#[Get]
#[Put]
#[Patch]
#[Delete]
#[Put(
uriTemplate: '/books/{id}/generate-cover.{_format}',
normalizationContext: ['groups' => ['book:read', 'book:cover']],
output: false,
messenger: true,
)] So what is the right way? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can use both, but the core team prefers the first one (personally I prefer the second one 🙂). |
Beta Was this translation helpful? Give feedback.
-
Ahh ok, Thanks |
Beta Was this translation helpful? Give feedback.
-
We recommend the first one, as the one with attributes under each another was introduced for backward compatibility reasons, especially that at first attributes did not support instantiating classes inside the attribute and calling |
Beta Was this translation helpful? Give feedback.
You can use both, but the core team prefers the first one (personally I prefer the second one 🙂).