Resolver error "Could not resolve reference: undefined" in Swagger PHP

239 views Asked by At

enter image description here

I’m inputting Swagger PHP notation into our API. When I use schemas I’ve created I'm getting a resolver error "Could not resolve reference: undefined”.

When I call my schema I have the JsonContent set in the first response in @OA\JsonContent like this

/**
      *  Update
      *
      * @OA\Put(
      *     path="competitions/{uuid}/teams/{team_id}",
      *     summary="Updating resource in storage.",
      *     description="Updating resource in storage with new information.",
      *     operationId="updateTeam",
      *     tags={"compTeamController"},
      *     security={{"bearer": {}}},
      *     @OA\Response(
      *         response=200,
      *         description="Success",
      *     @OA\JsonContent(
      *         @OA\Property(
      *            property="data",
      *            ref="app/Http/Resource/CompetitionTeamResource"
      *                 ),
      *             )
      *     ),
      *     @OA\Response(
      *      response=403,
      *      description="Access denied to team.",
      *      @OA\JsonContent(
      *              @OA\Property(property="message", type="Access denied to team.")
      *              )
      *      ) 
      * )
      *     
      */

And my schema is set up as

/**
     * @OA\Schema(
     *     schema="CompetitionTeamController",
     *     title="Competition Team Controller Model",
     *     description="Competition team controller model",
     *     @OA\Property(
     *          property="id",
     *          title="id",
     *          type="string"
     *     ),
     *      @OA\Property(
     *          property="subid",
     *          title="subid",
     *          type="string"
     *      )
     * )
     */

Is there something I can do to fix this error?

1

There are 1 answers

0
DerManoMann On

Not sure if this actually works of the top of my head, but ref="app/Http/Resource/CompetitionTeamResource" should be a class name and it looks more like a filename.

Maybe ref="\App\\Http\\Resource\\CompetitionTeamResource" works?