Hi. I am using S4. When I try to use the @View annotation, receives an error : There are no registered paths for namespace "FOSRest". What am I doing wrong ?
`
/**
*@Rest\Get(
* "/busy-times",
* name="app.api.busytime.get_busy_times"
* )
* @Rest\View()
*/
public function getBusyTimes(): array
{
/** @var User $user */
$user = $this->getUser();
$doctrine = $this->getDoctrine();
$busyTimes = $doctrine->getRepository(BusyTime::class)->findAll();
if (false == $user->isSuperAdmin()) {
$decoratedBusyTimes = [];
/** @var BusyTime $busyTime */
foreach ($busyTimes as $busyTime) {
$decoratedBusyTimes[] = new BusyTimeDecorator($busyTime, $this->translator);
}
$busyTimes = $decoratedBusyTimes;
}
return $busyTimes;
}
`
`
fos_rest:
param_fetcher_listener: true
serializer:
serialize_null: false
view:
view_response_listener: 'force'
body_converter:
enabled: true
validate: true
validation_errors_argument: validationErrors
`
How did you solve this, i'm getting the same error in my unit tests.
I had the same, solved it when I added the following configuration under fos_rest :
format_listener:
rules:
prefer_extension: false
fallback_format: json
I had the same issue on SF 4+ and fixed it by configuring the namespaced path in Twig;
twig:
paths:
"%kernel.project_dir%/templates": FOSRest
If you are encountering the same error: do not open URL from a web brower.
Use postman or any other REST client.
Most helpful comment
I had the same issue on SF 4+ and fixed it by configuring the namespaced path in Twig;