2017-05-24 71 views
0

我想爲我正在構建的api分割我的文檔。我正在使用NelmioApiDocBundle,並且它們具有視圖註釋的完美方式。 Nelmio view問題是我的方法停留在默認視圖,而不是在建議OAuth的看法:Symfony2:爲什麼NelmioApiDocBundle中的視圖註釋不起作用?

所以/ 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", 
+0

你記得在你的控制器'ApiDoc'使用的語句? – DevDonkey

+0

@DevDonkey感謝您的迴應,但是我使用了捆綁包。我更新了我的帖子 –

回答

0

結束要回答我自己的問題:與您需要atleast 2.9.0的視圖參數不兼容的版本「2.7.0」。很難從symfony文檔中理解它,因爲它顯示版本2.x symfony documentation

0

看起來不錯至少我可以說,如果你設置了一切正確 -/api/doc/oauth應該nev呃給你404

試圖改變你都

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