仅显示枚举列表的第一个元素,而不显示Swagger中的整个列表

时间:2019-01-09 06:46:57

标签: python enums yaml swagger

以下是从python执行中生成的YAML

requestBody:
    content:
      application/json:
        schema:
          properties:
            element_ids:
              items:
                type: string
              type: array
            element_type:
              items:
                enum:
                - NC
                - CELL
                type: string
              type: array
            expires_in:
              format: int32
              type: integer
            group_id:
              type: string
          required:
          - element_ids
          - element_type
          - expires_in
          - group_id

我以列表的形式提供了枚举值。

在下面显示的swagger(3.0.0)中我只能看到NC

enter image description here

1 个答案:

答案 0 :(得分:1)

您的规格正确。 “示例值”根据您在OpenAPI文件中指定的信息显示一个示例请求。完整的枚举列在模式标签上:

Enum values listed on the "Schema" tab in Swagger UI.

如果要在JSON示例中显示"element_type": ["NC", "CELL"],请将相应的example添加到element_type属性定义中:

element_type:
  items:
    enum:
    - NC
    - CELL
    type: string
  type: array
  example: [NC, CELL]  # <----------