swagger @ApiModelProperty example value for Listlt;Stringgt; property(招摇 @ApiModelProperty Listlt;Stringgt; 的示例值财产)
问题描述
我有一个类,其中有一个属性是 List<String>
I have one class in which there is one property which is List<String>
此代码生成的示例值如下:
This code generates the example values as following:
此处显示的示例值无效.我预期的示例值应该是这样的:
The example values here shown are not valid. My expected example values should be like :
我尝试传递如下示例属性,但它没有生成正确的值:
I have tried passing example attribute as following but it is not generating proper value:
有什么方法可以为 List 属性生成正确的示例值吗?
Is there any way I can generate proper example value for List property ?
更新:
我已经尝试过@nullpointer 和@Zeeshan Arif 建议的解决方案
I have tried the solutions suggested by @nullpointer and @Zeeshan Arif
更新 2:
尝试了以下没有产生正确响应的方法
Tried following approach which did not generate proper response
我对 swagger jar 的 maven 依赖项是:
my maven dependency for swagger jar is :
更新此问题的github票
推荐答案
我设法让它工作,生成一个字符串列表.
I managed to get this to work, generating a List of Strings.
在 springfox 2 的 ApiModelProperty 中,编写您的示例如下:
Within the ApiModelProperty with springfox 2, write your example as follows:
这是我的例子:
当我渲染 swagger 页面时,我得到以下输出:
When I render the swagger page, I get the following output:
这篇关于招摇 @ApiModelProperty List<String> 的示例值财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!