Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swagger 如何将ref示例与另一个ref示例一起使用?_Swagger_Openapi_Swaggerhub - Fatal编程技术网

Swagger 如何将ref示例与另一个ref示例一起使用?

Swagger 如何将ref示例与另一个ref示例一起使用?,swagger,openapi,swaggerhub,Swagger,Openapi,Swaggerhub,我试图理解如何将ref嵌套在ref中 我有两个对象,ResponseObject和LastUpdatedAt: ResponseObject: type: object properties: code: type: integer format: int32s minimum: 100 maximum: 600 message: type: string data: type: object

我试图理解如何将ref嵌套在ref中

我有两个对象,ResponseObject和LastUpdatedAt:

ResponseObject:
  type: object
  properties:
    code:
      type: integer
      format: int32s
      minimum: 100
      maximum: 600
    message:
      type: string
    data:
      type: object
  required:
    - code
    - message

我想要实现的是使我的示例如下所示:

我一直在尝试,但没有成功,这是我所能做到的:

LastUpdatedAtResponse:
  schema:
    $ref: "#/components/schemas/ResponseObject"
  example:
    - code: 200
      message: 'Success'
      data:
        schema:
          $ref: "#/components/schemas/LocalDataLastUpdatedAt"
        example:
          - lastUpdated: 1574933675150
但结果是这样的:

我的最终目标是让我的所有对象都使用ResponseObject,但我似乎无法让它工作。
知道我遗漏了什么吗?

示例
关键字不支持
$ref
。您需要内联指定整个示例值:

上次更新的响应:
...
例子:
-代码:200
信息:“成功”
数据:
最后更新电话:1574933675150

请注意,
$ref
在多个
示例中受支持,但它只能用于引用整个示例,不可能仅引用示例的一部分

LastUpdatedAtResponse:
  schema:
    $ref: "#/components/schemas/ResponseObject"
  example:
    - code: 200
      message: 'Success'
      data:
        schema:
          $ref: "#/components/schemas/LocalDataLastUpdatedAt"
        example:
          - lastUpdated: 1574933675150