php - 无法从 Swagger API 文档中获取数据
问题描述
我昨晚刚开始使用 swagger/openapi,我正在尝试为演示书店应用程序记录 API,但我无法从 swagger-ui 上的 api 获取数据。
这是 api doc bookstore api doc的链接
我已经像这样向 BookController 添加了注释
/**
* @OA\Schema(
* schema="Book",
* @OA\Property(property="title", type="string"),
* @OA\Property(property="author", type="string"),
* @OA\Property(property="description", type="string")
* )
*/
/**
* @OA\Schema(
* schema="NewBook",
* required={"title", "author", "description"}
* )
*/
class BookController extends Controller
{
/**
* @OA\Get(
* path="/books",
* description="Returns a books list from the app",
* operationId="getBooksList",
* summary="Gets a complete list of all books available on the app with their ratings",
* @OA\Response(
* response=200,
* description="book response",
* @OA\JsonContent(
* type="array",
* @OA\Items(ref="#/components/schemas/Book")
* )
* ),
* @OA\Response(
* response="default",
* description="unexpected error",
* )
* )
*/
/**
* Display a listing of the books.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return BookResource::collection(Book::with('ratings')->get());
}
}
我哪里出错了,我该如何解决?
解决方案
推荐阅读
- microsoft-graph-api - Office 365 的 Exchange Web 服务 (EWS) API 即将发生的变化
- sql - 我有一个由于传入值而未运行的 SQL 查询
- html - 单击视频元素时如何放大它?
- selenium - 我如何绕过 Selenium 的 Google 登录步骤?
- javascript - 如何通过body onload()函数将数组从javascript函数获取到html表单作为输入字段值?
- javascript - JavaScript 数组到 Django 表单输入下拉列表
- java - 无法远程连接到 jmx 端口
- php - 从 grapEdge 创建一个数组并打印
- excel - 将 VBA 代码限制为工作表中特定范围的单元格
- python - 从 Flask 中的 JSON 数据提供动态 matplotlib 图像