英文:
Error on Swagger after API Platform update
问题
我将为您翻译以下部分:
"我将API平台从1.2升级到了2.7版本,但在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格式,一切都正常运行,所以我不明白这个错误是从哪里引起的?"
英文:
I updated API Platform from 1.2 to 2.7 on an old project.
My API work fine, but I've an error on the Swagger HTML page :
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)
Why I call the entrypoint as a JSON format, everything work fine. So I don't understand where this error comes from ?
答案1
得分: 1
尝试将此内容添加到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
英文:
Try adding this to 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论