abh*_*g10 3 swagger swagger-php openapi
我正在使用L5 SwaggerfromDarkOnLine使用 OpenApi 原理图生成 Swagger 文档。
使用模式我可以做
@OA\Property(property="certification", type="array", @OA\Items(ref="#/components/schemas/Certification"))
Run Code Online (Sandbox Code Playgroud)
它工作得很好,显示为
"certification": [
{
"certification_id": 0,
"name": "string"
}
],
Run Code Online (Sandbox Code Playgroud)
. 但是它创建了一个带有方括号的数组块,里面有多个对象。
如何使用相同的工作但丢失数组。就像是
@OA\Property(property="certification", type="object", @OA\Items(ref="#/components/schemas/Certification")),
Run Code Online (Sandbox Code Playgroud)
以便删除方括号并仅显示对象。
"certification": {
"certification_id": 0,
"name": "string"
}
Run Code Online (Sandbox Code Playgroud)
你可以做:
@OA\Property(
property="certification",
ref="#/components/schemas/Certification"
)
Run Code Online (Sandbox Code Playgroud)
该@OA\Items注释只有当你需要指定哪些是内部数组的属性(参见数据类型:数组)。
在您的情况下,您只想描述一个对象,因此您只需在属性中引用对象的架构并删除@OA\Items。
| 归档时间: |
|
| 查看次数: |
3257 次 |
| 最近记录: |