如何覆盖 openapi 中的示例?

How can I override examples in openapi?

我有响应结构:

responses:
  '200':
    description: OK
    content:
      application/json:
        schema:
          type: object
          properties:
            data:
              allOf:
              - { $ref: ../../components/schemas/Product.yaml }
              example:
                active: false

还有 Product.yaml 一个:

type: object
description: Product
properties:
  id:
    description: ID
    type: integer
    example: 1
  name:
    description: Name
    type: string
    example: 'fresh baguette'
  active:
    description: Is active
    type: boolean
    example: true

所以我想覆盖活动示例,当我这样做时:

data:
  allOf:
  - { $ref: ../../components/schemas/Product.yaml }
  example:
    active: false

在 "Response samples" 下的 redoc ui 我看到唯一活跃的 属性.

我的问题是如何在不覆盖每个产品属性的情况下覆盖仅活动 属性 的示例?

无法覆盖示例中的单个 属性 值。您需要提供整个示例:

responses:
  '200':
    description: OK
    content:
      application/json:
        schema:
          type: object
          properties:
            data:
              $ref: ../../components/schemas/Product.yaml

          example:
            data:
              id: 1
              name: fresh baguette
              active: false