用于 PHP 数组的 Swagger

问题描述 投票:0回答:2

我正在尝试创建一个响应示例,该示例应返回如下所示的数组:

[
  [
    "Shop Name",
    "53.7094190",
    "-1.9084720"
    ,1
  ]
]

为此,我使用此代码:

*   @OA\Response(
*     response= "default",
*     description="Success: Array of shops",
*     @OA\MediaType(
*       mediaType="text/plain",
*         @OA\Schema(
*           type = "array",
*           @OA\Items( type="array",
*              @OA\Items(type="string", default="'Bridge Balti','53.7094190','-1.9084720',1"),
*           ),
*         )
*     )
*   )

我在 swagger hub 中得到了这个:

[
  [
    "string"
  ]
]
php swagger openapi swagger-php
2个回答
1
投票

如果你只想在 swagger ui 中显示一个示例,那么你需要使用“example”参数。

@OA\Items(type="string",example="'Bridge Balti','53.7094190','-1.9084720',1")


0
投票

接受的答案对我不起作用。它不是数组,而是显示为字符串。 跟随改变对我有用。 (双引号有魔力)

example="[""Bridge Balti"",""53.7094190"",""-1.9084720"",1]"
© www.soinside.com 2019 - 2024. All rights reserved.