symfony – Swagger-PHP OpenAPI nested route-ThrowExceptions

Exception or error:

Controller

use OpenApi\Annotations as OA;

class ApiPersonController
{
    /**
     * @OA\Post(
     *     path="/add",
     *     responses={
     *          @OA\Response(
     *              response=202,
     *              description="Request has been accepted and is being processed"
     *          )
     *     }
     * )
     */
    public function add()
    {

    }
}

What must I add to the doc comment of ApiPersonController so that the swagger.json generated by Zircote/Swagger-PHP gives this output?

openapi: 3.0.0
info:
  title: 'My API'
  version: 1.1.0
paths:
  /person/add:
    post:
      operationId: 'ApiPersonController::add'
      responses:
        '202':
          description: 'Request has been accepted and is being processed'

Specifically, how do I get all routes inside ApiPersonController to have /person added to them without specifying /person inside each route

I’m looking for something like the following, but this just adds /person and /add separately to my swagger.json

use OpenApi\Annotations as OA;

/**
 * @OA\PathInfo(path="/person")
 **/
class ApiPersonController
{
    ...
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *