Swagger中如何操作带参数的GET方法?

Ale*_*ela 1 laravel swagger laravel-api

我使用 Swagger 来编写 Laravel API 的文档,有时除了 POSTMAN 之外还进行测试,问题是带参数的 GET 方法不起作用Route::get('/searchProduct/{id}','Api\ReportController@getProductsByID');

但如果 GET 方法没有参数,它就可以正常工作。在 Swagger 中,我意识到当我进行查询时,我没有输入参数,{id}但我相信之后{id}?id=4

这是我的路线

My route
Route::get('/searchProduct/{id}','Api\ReportController@getProductsByID');

Result in Swagger
www.x.cl/api/searchProduct/{id}?id=4 //ERROR

How it should work
www.x.cl/api/searchProduct/4 
Run Code Online (Sandbox Code Playgroud)

因为在 POSTMAN 中我只通过号码更改我的 ID,并且搜索对我有用。

这是我的控制器

    /**
     *  @OA\Get(
     *      path="/api/searchProduct/{id}",
     *      summary="Search Product by Status",
     *      description="Lorem ipsun",
     *      security={
     *          {"bearer_token":{}},
     *      },
     *      @OA\Parameter(
     *         name="id",
     *         in="query",
     *         description="Buscar por estado",
     *         required=true,
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="OK",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *          )
     *      ),
     *      @OA\Response(
     *          response="default",
     *          description="Ha ocurrido un error."
     *      ),
     *      @OA\Response(
     *          response="401",
     *          description="No se ha autenticado, ingrese el token."
     *      ),
     *  )
     */
    public function getProductsByID($uuid){
        $validated = Product::status($uuid);
        return ReportResource::collection($validated);
    }
Run Code Online (Sandbox Code Playgroud)

Has*_*san 6

尝试in="query",in="path",这里替换:

     *      @OA\Parameter(
     *         name="id",
     *         in="query",
     *         description="Buscar por estado",
     *         required=true,
     *      ),
Run Code Online (Sandbox Code Playgroud)

?查询指的是“查询字符串”,即URL 中后面的一组以“&”分隔的键/值对。