0

i am using swagger documentation to chow api data, i one of my case i want to get data from database by a specific date, get a day by a $day variable i use a method and working fine in Postman in postman : enter image description here

But in swagger i dont know how i can add parameter $day in swagger

my code work fine :

public function getdatabydate() {
    $p = "zero";
    $day = date('Y-m-d ', strtotime($_GET['day']));
    $users = DB::select('select * from S where (`timestamp` like "'.$day.'%")' );
    if (!$users){
        return $p;
    }
    return $users;


    }

In swagger :

/**
     * @OA\Get(
     *
     *   path="/api/getdatabydate",
     *   summary="Get weather",
     *   @OA\Response(
     *     response=200,
     *     description="successful operation",
      *   ),
      * @OA\Parameter(
 *    description="Date day",
 *    in="header",
 *    name="day",
 *    required=true,
 *    @OA\Schema(
 *       type="string",
 * format ="date-time",
 *    )
 * ),
     *     security={
     *         {"bearerAuth": {}}
     *     }
     * ),
     */
2
  • 1
    Replace in="header" with in="query" and format="date-time" with format="date". Does this help? Commented Aug 10, 2020 at 16:22
  • thanks u ! worked :))))))))))) Commented Aug 11, 2020 at 15:55

1 Answer 1

0

Replace in="header" with in="query" and format="date-time" with format="date".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.