Search code examples
phplaravelswagger-php

Laravel Swagger getting [Syntax Error] Expected Value, got '@'


I have written Swagger Annotations for a function in a Controller and I am getting error while generating swagger-ui code. Following is my code for annotation

/*** End of Annotation For deleteNote ***/
     /**
     * @OA\Delete(
     *     path="/api/delete-user-note/{note_id}",
     *     operationId="/api/delete-user-note/{note_id}",
     *     tags={"Patient Routes"},
     *      summary= "Delete Note",
     *      description = "Delete Note",
     *      @OA\Parameters(
     *         description="ID note to delete",
     *         in="path",
     *         name="note_id",
     *         required=true,
     *         @OA\Schema(
     *           type="integer",
     *           format="int64"
     *         )
     *     ),

When I run php artisan l5-swagger:generate I am getting error [Syntax Error] Expected Value, got '@'


Solution

  • There is an error in your Annotation. Please change your code with the following. You need to replace Parameters with Parameter.

    /*** End of Annotation For deleteNote ***/
         /**
         * @OA\Delete(
         *     path="/api/delete-user-note/{note_id}",
         *     operationId="/api/delete-user-note/{note_id}",
         *     tags={"Patient Routes"},
         *      summary= "Delete Note",
         *      description = "Delete Note",
         *      @OA\Parameter( //You need to replace Parameters with Parameter
         *         description="ID note to delete",
         *         in="path",
         *         name="note_id",
         *         required=true,
         *         @OA\Schema(
         *           type="integer",
         *           format="int64"
         *         )
         *     ),