我正在学习如何使用swagger记录API。我已经启动here并运行了文档,但是在测试应该更新图书资源的Put
方法时,我注意到该图书从未更新过,但是在Postman上它是成功的。
这就是我的openapi注释和控制器update
方法的样子
/**
* @OA\Put(
* path="/books/{book}",
* tags={"Book"},
* operationId="updateBook",
* description="Updates a book in the store",
* summary="Updates an existing book",
* @OA\Parameter(
* description="ID of book to be updated",
* in="path",
* name="book",
* required=true,
* @OA\Schema(
* type="integer",
* format="int64",
* )
* ),
* @OA\RequestBody(
* description="Book to add to the store",
* required=true,
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(ref="#/components/schemas/NewBook")
* )
* ),
* @OA\Response(
* response=200,
* description="book response",
* @OA\JsonContent(ref="#/components/schemas/Book")
* ),
* @OA\Response(
* response="default",
* description="unexpected error",
* )
* )
*/
/**
* Update the specified book in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $book
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Book $book)
{
$book->update($request->only(['title', 'author', 'description']));
return new BookResource($book);
}
考虑到我几天前才刚刚开始使用swagger,对于在swagger-ui上为何不进行更新的任何帮助,我将不胜感激