php API平台更新后Swagger上出错

xmq68pz9  于 2023-03-11  发布在  PHP
关注(0)|答案(1)|浏览(162)

我在一个旧项目上将API平台从1.2更新到2.7。
我的API工作正常,但我有一个错误的Swagger HTML页面:

TypeError:
Lexik\Bundle\JWTAuthenticationBundle\OpenApi\OpenApiFactory::__construct(): Argument #2 ($checkPath) must be of type string, null given, called in /app/var/cache/dev/ContainerCRp5KBI/getLexikJwtAuthentication_ApiPlatform_Openapi_FactoryService.php on line 14

  at vendor/lexik/jwt-authentication-bundle/OpenApi/OpenApiFactory.php:31
  at Lexik\Bundle\JWTAuthenticationBundle\OpenApi\OpenApiFactory->__construct(object(OpenApiFactory), null, null, null)
     (var/cache/dev/ContainerCRp5KBI/getLexikJwtAuthentication_ApiPlatform_Openapi_FactoryService.php:14)
  at require('/app/var/cache/dev/ContainerCRp5KBI/getLexikJwtAuthentication_ApiPlatform_Openapi_FactoryService.php')
     (var/cache/dev/ContainerCRp5KBI/srcApp_KernelDevDebugContainer.php:682)
  at ContainerCRp5KBI\srcApp_KernelDevDebugContainer->load('getLexikJwtAuthentication_ApiPlatform_Openapi_FactoryService.php')
     (var/cache/dev/ContainerCRp5KBI/getApiPlatform_SwaggerUi_ActionService.php:12)
  at require('/app/var/cache/dev/ContainerCRp5KBI/getApiPlatform_SwaggerUi_ActionService.php')
     (var/cache/dev/ContainerCRp5KBI/srcApp_KernelDevDebugContainer.php:682)
  at ContainerCRp5KBI\srcApp_KernelDevDebugContainer->load('getApiPlatform_SwaggerUi_ActionService.php')
     (var/cache/dev/ContainerCRp5KBI/getApiPlatform_Swagger_Action_UiService.php:11)
  at require('/app/var/cache/dev/ContainerCRp5KBI/getApiPlatform_Swagger_Action_UiService.php')
     (var/cache/dev/ContainerCRp5KBI/srcApp_KernelDevDebugContainer.php:682)
  at ContainerCRp5KBI\srcApp_KernelDevDebugContainer->load('getApiPlatform_Swagger_Action_UiService.php')
     (vendor/symfony/dependency-injection/Container.php:255)
  at Symfony\Component\DependencyInjection\Container->make('api_platform.swagger.action.ui', 1)
     (vendor/symfony/dependency-injection/Container.php:231)
  at Symfony\Component\DependencyInjection\Container->get('api_platform.swagger.action.ui')
     (vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php:53)
  at Symfony\Component\HttpKernel\Controller\ContainerControllerResolver->instantiateController('api_platform.swagger.action.ui')
     (vendor/symfony/framework-bundle/Controller/ControllerResolver.php:70)
  at Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver->instantiateController('api_platform.swagger.action.ui')
     (vendor/symfony/http-kernel/Controller/ControllerResolver.php:110)
  at Symfony\Component\HttpKernel\Controller\ControllerResolver->createController('api_platform.swagger.action.ui')
     (vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php:42)
  at Symfony\Component\HttpKernel\Controller\ContainerControllerResolver->createController('api_platform.swagger.action.ui')
     (vendor/symfony/framework-bundle/Controller/ControllerResolver.php:62)
  at Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver->createController('api_platform.swagger.action.ui')
     (vendor/symfony/http-kernel/Controller/ControllerResolver.php:86)
  at Symfony\Component\HttpKernel\Controller\ControllerResolver->getController(object(Request))
     (vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php:38)
  at Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:152)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:81)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:25)

为什么我把入口点命名为JSON格式,一切正常。所以我不明白这个错误是从哪里来的?

fwzugrvs

fwzugrvs1#

尝试将其添加到lexik_jwt_authentication.yaml

# config/packages/lexik_jwt_authentication.yaml
lexik_jwt_authentication:
    # ...
    api_platform:
        check_path: /api/login_check
        username_path: email
        password_path: security.credentials.password

相关问题