Symfony2:为什么 NelmioApiDocBundle 中的视图注释不起作用?

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

我想为我正在构建的 api 拆分我的文档。我正在使用 NelmioApiDocBundle,他们有一个完美的视图注释方式。 Nelmio view 问题 是我的方法停留在默认视图中,而不是在建议的 oauth 视图中:

所以/doc/api/oauth/或/api/doc/oauth以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.7.0”与您至少需要 2.9.0 的视图参数不兼容。很难从 symfony 文档中理解它,因为它显示版本 2.x symfony documentation

看起来不错的人。至少我可以说,如果你设置正确 - /api/doc/oauth 永远不会给你 404.

尝试改变你的

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