仅显示枚举列表的第一个元素,而不显示Swagger中的整个列表 [英] Only first element of Enum list is displayed instead of Entire list in Swagger

查看:397
本文介绍了仅显示枚举列表的第一个元素,而不显示Swagger中的整个列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Below is the generated YAML from python execution

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

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

I have provided my enum values in the form of list.

我在下图所示的大张旗鼓(3.0.0)中只能看到NC

I see only NC in the swagger(3.0.0) shown below

推荐答案

您的规范正确。 示例值根据您在OpenAPI文件中指定的信息显示一个示例请求。完整的枚举列在 Schema 选项卡上:

Your spec is correct. "Example Value" displays an example request based on the info you specified in the OpenAPI file. The full enum is listed on the Schema tab:

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

If you want to display "element_type": ["NC", "CELL"] in the JSON example, add the corresponding example to the element_type property definition:

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

这篇关于仅显示枚举列表的第一个元素,而不显示Swagger中的整个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆