Only first element of Enum list is displayed instead of Entire list in Swagger

孤者浪人 提交于 2020-08-10 23:15:48

问题


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.

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


回答1:


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:

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

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]  # <----------


来源:https://stackoverflow.com/questions/54104552/only-first-element-of-enum-list-is-displayed-instead-of-entire-list-in-swagger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!