swagger-php: Multiple @OA\Response() with the same response="200"
That issue occurs only on server side.
local.ERROR: ErrorException: Multiple @OA\Response() with the same response="200": \App\Http\Controllers\Student\EventsController->update() in /var/www/html/app/Http/Controllers/Student/EventsController.php on line 136 \App\Http\Controllers\Student\EventsController->store() in /var/www/html/app/Http/Controllers/Student/EventsController.php on line 51 in /var/www/html/vendor/zircote/swagger-php/src/Logger.php:39
I tried api-docs generated on local in https://editor.swagger.io and that works very well. How that can be resolved?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
I don’t know if this pertains to the op’s problem, but I had the same sort of error in production vs local dev, and in case someone else ends up here like I did, here was my mistake. I inadvertently had some of the
@OA\Get/Put/Post
items as@OA\GET/PUT/POST
. Presumably this worked on my case-insensitive MacBook, but not on the Linux production server.I think that the problem might be that you try to declare the
@OA\Response
outside of a@OA\Get/Post/etc
context, and then it tries to add both at the same place but can’t because of the collision of having the same response code.Please provide a full example of your PHPDOC, because I think that is where your problem lies.
See https://github.com/zircote/swagger-php/blob/master/Examples/petstore-3.0/controllers/Pet.php#L66 as an example on how to declare a path and response in PHPDOC.