【发布时间】:2021-09-23 20:44:24
【问题描述】:
我正在使用 zircote/swagger-php 根据已添加到现有代码中的 OpenApi 注释生成 API 文档。
在大多数情况下,它运行良好,但我注意到一个奇怪的地方。我有一个方法,indexAction(),它应该返回一个项目列表:
/**
* @OA\Get(
* path="\location",
* description="Retrieves a list of locations for the current organisation",
* method="indexAction",
* @OA\Response(
* response="200",
* description="List of locations",
* @OA\JsonContent(
* type="array",
* @OA\Items(ref="#/components/schemas/Location")
* ),
* @OA\XmlContent(
* type="array",
* @OA\Items(ref="#/components/schemas/Location")
* )
* )
* )
*/
public function indexAction()
{
编译文档json文件后,我打开它,这个动作如下:
"paths": {
"\\location": {
"get": {
"summary": "The index action handles index/list requests; it should respond with a\nlist of the requested resources.",
"description": "Retrieves a list of locations for the current organisation",
"operationId": "2b36ea7d6a6e350fd6c7564bc908a25b",
"responses": {
"200": {
"description": "List of locations",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Location"
}
}
},
"application/xml": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Location"
}
}
}
}
}
}
}
},
由于某种原因,“路径”被列为\\location 而不是我所期望的\location - 有人知道为什么会这样吗?我希望这就够了,如果需要更多代码,我可以提供。
【问题讨论】:
标签: php swagger openapi openapi-generator swagger-php