-
-
Notifications
You must be signed in to change notification settings - Fork 950
Description
API Platform version(s) affected: 4.2.7
Description
With Symfony 8.0 it is unable to render swagger docs because app.request.get method has been removed
How to reproduce
Update to Symfony 8.0 and try to open swagger docs.
With default config I have got an error:
{"@context":"\/api\/contexts\/Error","@id":"\/api\/errors\/500","@type":"Error","title":"An error occurred","detail":"Neither the property \u0022get\u0022 nor one of the methods \u0022get()\u0022, \u0022getget()\u0022, \u0022isget()\u0022, \u0022hasget()\u0022 or \u0022__call()\u0022 exist and have public access in class \u0022Symfony\\Component\\HttpFoundation\\Request\u0022 in \u0022@ApiPlatform\/SwaggerUi\/index.html.twig\u0022 at line 84.","status":500,"type":"\/errors\/500","description":"Neither the property \u0022get\u0022 nor one of the methods \u0022get()\u0022, \u0022getget()\u0022, \u0022isget()\u0022, \u0022hasget()\u0022 or \u0022__call()\u0022 exist and have public access in class \u0022Symfony\\Component\\HttpFoundation\\Request\u0022 in \u0022@ApiPlatform\/SwaggerUi\/index.html.twig\u0022 at line 84.","trace":[{"file":"\/app\/var\/cache\/dev\/twig\/27\/2729dc4334e20a58b0dc92cea2a29e11.php","line":165,"function":"getAttribute","class":"Twig\\Extension\\CoreExtension","type":"::"},{"file":"\/app\/vendor\/twig\/twig\/src\/Template.php","line":402,"function":"doDisplay","class":"__TwigTemplate_fc6dc15201c6974fc57a60eed766dd67","type":"-\u003E"},{"file":"\/app\/vendor\/twig\/twig\/src\/Template.php","line":358,"function":"yield","class":"Twig\\Template","type":"-\u003E"},{"file":"\/app\/vendor\/twig\/twig\/src\/Template.php","line":373,"function":"display","class":"Twig\\Template","type":"-\u003E"},{"file":"\/app\/vendor\/twig\/twig\/src\/TemplateWrapper.php","line":51,"function":"render","class":"Twig\\Template","type":"-\u003E"},{"file":"\/app\/vendor\/twig\/twig\/src\/Environment.php","line":333,"function":"render","class":"Twig\\TemplateWrapper","type":"-\u003E"},{"file":"\/app\/vendor\/api-platform\/core\/src\/Symfony\/Bundle\/SwaggerUi\/SwaggerUiProcessor.php","line":94,"function":"render","class":"Twig\\Environment","type":"-\u003E"},{"file":"\/app\/vendor\/api-platform\/core\/src\/State\/CallableProcessor.php","line":52,"function":"process","class":"ApiPlatform\\Symfony\\Bundle\\SwaggerUi\\SwaggerUiProcessor","type":"-\u003E"},{"file":"\/app\/vendor\/api-platform\/core\/src\/State\/Processor\/WriteProcessor.php","line":58,"function":"process","class":"ApiPlatform\\State\\CallableProcessor","type":"-\u003E"},{"file":"\/app\/vendor\/api-platform\/core\/src\/Symfony\/Action\/EntrypointAction.php","line":61,"function":"process","class":"ApiPlatform\\State\\Processor\\WriteProcessor","type":"-\u003E"},{"file":"\/app\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":183,"function":"__invoke","class":"ApiPlatform\\Symfony\\Action\\EntrypointAction","type":"-\u003E"},{"file":"\/app\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":76,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/app\/vendor\/symfony\/http-kernel\/Kernel.php","line":180,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/app\/vendor\/symfony\/runtime\/Runner\/Symfony\/HttpKernelRunner.php","line":35,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"-\u003E"},{"file":"\/app\/vendor\/autoload_runtime.php","line":32,"function":"run","class":"Symfony\\Component\\Runtime\\Runner\\Symfony\\HttpKernelRunner","type":"-\u003E"},{"file":"\/app\/public\/index.php","line":5,"function":"require_once"}]}
Possible Solution
It caused by line
{% set active_ui = app.request.get('ui', 'swagger_ui') %}
in the SwaggerUi/index.html.twig.
In order to avoid it, we need to use direct way:
{% set active_ui = app.request.query.get('ui', 'swagger_ui') %}