我尝试使用 nelmioapidocbundle :
namespace App\Controller;
use App\Entity\User;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use App\Service\UserService;
use Nelmio\ApiDocBundle\Annotation as Doc;
use Symfony\Component\Routing\Annotation\Route;
当我使用这样的配置描述时,t 有效
paths:
/api/login_check:
post:
tags:
- Login
description: Login into the api.
produces:
- application/json
parameters:
- name: username
description: User to login
in: body
required: true
schema:
type: object
properties:
_username:
type: string
_password:
type: string
responses:
'200':
description: Login successful
schema:
type: object
properties:
token:
type: string
但是当我使用注释时(安装了,我可以毫无问题地使用@Route,我得到这个错误:
[Semantical Error] The annotation "@Nelmio\ApiDocBundle\Annotation\ApiDoc" in method App\Controller\AuthController::register() was never imported. Did you maybe forget to add a "use" statement for this annotation? in /Sites/symfony/guest/config/routes/../../src/Controller/ (which is being imported from "Sites/symfony/guest/config/routes/annotations.yaml"). Make sure annotations are installed and enabled.
任何想法 ?