[英]Symfony2: Why is the view annotation in NelmioApiDocBundle not working?
I want to split up my documentation for the api I am building. 我想拆分我正在构建的api的文档。 I am using NelmioApiDocBundle and they have a perfect way with the view annotation.
我正在使用NelmioApiDocBundle,它们具有使用视图注释的完美方法。 Nelmio view The problem is my method stays in default view and not in the suggested oauth view:
Nelmio视图 问题是我的方法保留在默认视图中,而不在建议的oauth视图中:
So /doc/api/oauth/ or /api/doc/oauth ends in 404 因此/ 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文档
Looks good man. 看起来不错 At least i can say if you set up everything right - the /api/doc/oauth should never give you 404.
至少我可以说,如果您对所有设置都正确-/ api / doc / oauth应该永远不会给您404。
Try to change both your 尝试改变你的
resource: "@ProfileBundle/Rest/Xwsse/RestController.php"
to this like
resource: "@ProfileBundle/Resources/config/routing.yml"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.