如何将Swagger UI的参数设置为下拉菜单而不是文本输入 [英] How to get Swagger UI's Parameter to be Dropdown menu instead of Text Input
本文介绍了如何将Swagger UI的参数设置为下拉菜单而不是文本输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用swagger显示我的RESTApi,API的一个参数将字符串作为输入并将其转换为枚举值.有什么方法可以在Swagger UI上显示下拉菜单,而不是具有文本输入字段,以便用户只能在枚举值内选择字符串值.
I am using swagger to display my RESTApi, one parameter of an API takes string as input and convert it to enum value. Is there any way to display a drop-down menu on the Swagger UI instead of having a text input field so that users can only select the string values within the enum value.
推荐答案
The key is to use allowableValues
in the @ApiParam
annotation.
显示结果的演示:
http://petstore.swagger.io/#!/pet/findPetsByStatus
签出 pet/findByStatus
,它不是下拉菜单,但输入受到限制多选框.
Check out pet/findByStatus
, it's not a dropdown but input is limited in
the multi-select box.
这篇关于如何将Swagger UI的参数设置为下拉菜单而不是文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文