Closed jamisonbryant closed 1 year ago
By reading the stack trace closer I think I have uncovered the problem.
When the OpenApiPathGenerator
scans the controller docblock for my PagesController it picks up the several @throws
annotations that are put there by default:
/**
* Displays a view
*
* @param string ...$path Path segments.
*
* @return \Cake\Http\Response|null
* @throws \Cake\Http\Exception\ForbiddenException When a directory traversal attempt.
* @throws \Cake\View\Exception\MissingTemplateException When the view file could not
* be found and in debug mode.
* @throws \Cake\Http\Exception\NotFoundException When the view file could not
* be found and not in debug mode.
* @throws \Cake\View\Exception\MissingTemplateException In debug mode.
*/
#[Route('/pages/*', 'pages:display', resource: false)]
public function display(string ...$path): ?Response
{ ... }
I'm guessing the path scanner tries to instantiate these exceptions as objects, which it cannot do for the MissingTemplateException
because it doesn't have the required parameter, thus the crash.
Indeed, if I comment out the @throws
lines (there are two) for the MTE the crash disappears.
Looks like this needs to be cleaned up: https://github.com/cnizzardini/cakephp-swagger-bake/blob/master/src/Lib/Operation/ExceptionResponse.php#L73
I will run a manual test before doing a release on this, but probably not today.
Describe the bug
ExceptionResponse.php
creates an instance of the thrown exception object (see line 73) so it can do stuff with it. Occasionally, these exception objects require an argument, such asMissingTemplateException
. When this required argument is not present, the application crashes.To Reproduce Steps to reproduce the behavior: I'm really not sure but I will post the stack trace.
Expected behavior I should probably not be getting the MTE in the first place, but since I am and it requires an argument, I'd expect Swagger Bake to know how to give it what it needs so the framework doesn't crash.
Attachments Was going to
bin/cake swagger bake
and post an updated swagger.json but actually the CLI crashes with the same error...which is super odd I think given that there's no template for the CLI...Version and Platform (please complete the following information):
Additional context I'm trying to get PHP8 attributes to work for setting up flexible routes and making sure they also show up in Swagger.