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 :
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": {}}
* }
* ),
*/
Replace in="header"
with in="query"
and format="date-time"
with format="date"
.