在 Swagger 2.0 中为数组定义枚举 [英] Defining enum for array in Swagger 2.0

查看:34
本文介绍了在 Swagger 2.0 中为数组定义枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

type": "array",
"items": {
    "type": "string",
    "enum": ["MALE","FEMALE","WORKER"]
}

type": "array",
"items": {
    "type": "string",
},
"enum": ["MALE","FEMALE","WORKER"]

?

规范中没有关于此的任何内容.目标当然是让 swagger-ui 显示枚举值.

Nothing in the spec about this. The goal is of course to get swagger-ui to show the enum values.

推荐答案

第一种情况是正确的,现在 swagger-ui 生成枚举值的多项选择.

The first case is correct and these days swagger-ui generates a multiple-choise select of the enum values.

这篇关于在 Swagger 2.0 中为数组定义枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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