簡體   English   中英

Swagger PHP:如何聲明屬性以使用模式定義?

[英]Swagger PHP: how to declare property to use schema definition?

我的應用程序的響應如下所示:

{
  "status": "success",
  "data": {
      "status": "ready"
   },
  "request_id": "string"
}

我試圖在Swagger中定義響應

 *           @SWG\Response (
 *              response=200,
 *              description="Success response",
 *              @SWG\Schema (
 *                  @SWG\Property(
 *                      property="status",
 *                      type="string",
 *                      default="success"
 *                  ),
 *                  @SWG\Property(
 *                      property="data",
 *                      @SWG\Schema(
 *                          ref="#/definitions/Service/models/Status"
 *                      )
 *                  ),
 *                  @SWG\Property(
 *                      property="request_id",
 *                      type="string"
 *                  ),
 *              )
 *          ),

但它沒有使用狀態的Schema定義,所以我的響應實際上看起來像:

{
  "status": "success",
  "data": {},
  "request_id": "string"
}

如何定義數據屬性以使用模式定義? 或者它可以以不同的方式完成嗎?

有趣的是,人們有時會在發布問題后找到答案。

答案是:

*           @SWG\Response (
 *              response=200,
 *              description="Success response",
 *              @SWG\Schema (
 *                  @SWG\Property(
 *                      property="status",
 *                      type="string",
 *                      default="success"
 *                  ),
 *                  @SWG\Property(
 *                      property="data",
 *                      ref="#/definitions/Service/models/Status"
 *                  ),
 *                  @SWG\Property(
 *                      property="request_id",
 *                      type="string"
 *                  ),
 *              )
 *          ),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM