FriendsOfSymfony/FOSRestBundle — Issue #165: Default format is not recognized from the config
Author: mailaneel
Created: 2011-12-20 11:07:42+00:00
State: open

Below is the config i am using, If i call /products by default the format that should be returned is json but i am getting html template not found exception.

``` yaml
sensio_framework_extra:
view: { annotations: false }
router: { annotations: true }
```

``` yaml
fos_rest:
routing_loader:
default_format: json
view:
default_engine: twig
view_response_listener: force
formats:
json: true
xml: true
templating_formats:
html: true
body_listener: true
format_listener:
default_priorities: [json,html,'*/*']
fallback_format: json
prefer_extension: true
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
'WSL\BaseBundle\Exception\EntityNotFoundException': 200
messages:
'WSL\BaseBundle\Exception\EntityNotFoundException': true
service:
view_handler: fos_rest.view_handler.default
```

``` php

* @Route("/products")
* //, defaults={"_format"="json"}
*/
class ProductController extends Controller
{

/**
* @Route("")
* @Method("GET")
* @View()
*/
public function getAction()
{
$productDao = $this->get('wsl.base.product.dao');
$products = $productDao->getProducts();//$productDao::findAll();
return array("products" => $products);
}

}

```