Swagger 是否有可能在OAS v.3中合并两个响应

Swagger 是否有可能在OAS v.3中合并两个响应,swagger,openapi,Swagger,Openapi,我希望为端点提供另一个响应和对象数组的组合响应,如下面的示例所示: { access: "string", refresh: "string", "hospitals": [ { "title": "a hospital", "base_url": "hospital.com", "secre

我希望为端点提供另一个响应和对象数组的组合响应,如下面的示例所示:

{
  access: "string",
  refresh: "string",
  "hospitals": [
    {
      "title": "a hospital",
      "base_url": "hospital.com",
      "secret_key": "68e656b251e67e8358bef8483ab0d51c6619f3e7a1a9f0e75838d41ff368f728"
    }
  ]
}
下面是我的令牌对响应,它包括
访问
刷新

responses:
    TokenPairResponse:
        description: generated token pair
        content:
            application/json:
                schema:
                    type: object
                    properties:
                      access:
                        type: string
     
                      refresh:
                        type: string
此外,要创建一系列医院:

description: user verified successfully
content:
    application/json:
        schema:
            type: object
            properties:
                hospitals:
                    type: array
                items:
                      $ref: "#/components/schemas/Hospital"
现在,我想知道是否有任何方法可以将
医院数组
TokenPairResponse
组合在一个响应中,如上述示例所示

更新:我在回复中添加了以下内容:

hospitals:
  description: array of hostpitals
  content:
    application/json:
      schema:
        type: object
        properties:
          hospitals:
            type: array
            items:
              $ref: "#/components/schemas/Hospital"

VerifyUser:
  description: repsonse of user successfull verfication
  content:
    application/json:
      schema:
        allOf:
          - $ref: "#/components/responses/hospitals"
          - $ref: "#/components/responses/TokenPairResponse"
我在我的路径中引用了它们,如下所示:

responses:
    200:
        description: user verified successfully
        $ref: "#/components/responses/VerifyUser"

这将不会呈现,我得到:
没有可用的示例

allOf
只能引用模式(即
\/components/schemas/…
),而不能引用响应组件(
\/components/responses/…

将响应模式移动到
组件/模式
部分。然后您可以定义一个
allOf
模式,如下所示:

responses:
    200:
        description: user verified successfully
        $ref: "#/components/responses/VerifyUser"
openapi:3.0.0
...
组件:
模式:
验证用户:
所有:

-$ref:“#/components/schemas/Hospitals”#你是说
allOf
?看到了吗?是的,但我仍然得到“没有可用的示例”。我将添加我当前的进度作为问题的更新。@Helen另外,我正在使用OAS v.3感谢您的回答。实际上,我想结合两个
响应,而不是两个模式,主要是因为我不想让我的模式部分与这些类型的模式混杂在一起,这些模式实际上不是我项目的主要模型。尽管如此,克服此问题的一种方法是将这些模式移动到另一个文件中以防止混乱。您不能组合
响应
参数
请求体
组件等。;您只能组合架构。我面临的一个问题是,我的组件有响应头,我想使用
allOf
与基于主体的组件组合。你知道它是如何工作的吗?我应该把它们保存在
响应中
还是
模式中
-它在
模式中不起作用。