Symfony2: Why is the view annotation in NelmioApiDocBundle not working?

761 Views Asked by At

I want to split up my documentation for the api I am building. I am using NelmioApiDocBundle and they have a perfect way with the view annotation. Nelmio view The problem is my method stays in default view and not in the suggested oauth view:

So /doc/api/oauth/ or /api/doc/oauth ends in 404

//config.yml
# app/config/config.yml
nelmio_api_doc: ~

// app/config/routing.yml
NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

// routing.yml
    profile_rest_oauth:
        resource: "@ProfileBundle/Rest/Oauth/RestController.php"
        type:     rest
        prefix:   /api/oauth

    profile_rest:
        resource: "@ProfileBundle/Rest/Xwsse/RestController.php"
        type:     rest
        prefix:   /api


//RestController
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Request;

class RestController extends FOSRestController
{
    /**
     * @ApiDoc(
     *   description="Update profile for user",
     *   section="profile",
     *   https=true,
     *   statusCodes={
     *       200="OK, user profile updated",
     *       400="Wrong input, no update"
     *   },
     *   views = { "oauth" }
     * )
     */
    public function putProfileAction(Request $request)
    {
    }
//composer.json
   "nelmio/api-doc-bundle": "2.7.0",
2

There are 2 best solutions below

0
On BEST ANSWER

To answer my own question: the version "2.7.0" in not compatible with the view parameter you need atleast 2.9.0". It's hard to understand it from the symfony documentation because it show version 2.x symfony documentation

0
On

Looks good man. At least i can say if you set up everything right - the /api/doc/oauth should never give you 404.

Try to change both your

resource: "@ProfileBundle/Rest/Xwsse/RestController.php"
to this like
resource: "@ProfileBundle/Resources/config/routing.yml"