[英]Swagger OpenAPI use object with schema instead of array
我正在使用DarkOnLine
L5 Swagger
使用 OpenApi 原理圖生成 Swagger 文檔。
使用模式我可以做
@OA\Property(property="certification", type="array", @OA\Items(ref="#/components/schemas/Certification"))
它工作得很好,顯示為
"certification": [
{
"certification_id": 0,
"name": "string"
}
],
. 但是它創建了一個帶有方括號的數組塊,里面有多個對象。
如何使用相同的工作但丟失數組。 就像是
@OA\Property(property="certification", type="object", @OA\Items(ref="#/components/schemas/Certification")),
以便刪除方括號並僅顯示對象。
"certification": {
"certification_id": 0,
"name": "string"
}
你可以做:
@OA\Property(
property="certification",
ref="#/components/schemas/Certification"
)
@OA\\Items
注釋僅在您要指定數組內的屬性時使用(請參閱數據類型:數組)。
在您的情況下,您只想描述一個對象,因此您只需在屬性中引用對象的架構並刪除@OA\\Items
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.