swagger-core: ApiModelProperty doesn't support example for arrays / Lists
By default array or List of integers is generated in UI with example:
"eventTypes": [0],
I’ve tried to add “example” property, but that:
@ApiModelProperty(required = true, example = "[2, 3]")
private int[] lorem;
generates example values as string:
"eventTypes": "[2, 3]",
Other options like "2, 3" don’t work neither. In result to have valid json in example it has to have only one value, zero.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 53
- Comments: 48 (4 by maintainers)
it’s work
This takes a major refactoring of the models, which is on the way.
A working solution:
When I render the swagger page, I get the following output:
Credit @dane_griffiths https://stackoverflow.com/a/50132642/2245264
Will be supported in 3.0.0 support, please see the feature/3.0.0-rc2 branch for details.
@fehguy You closed the issue, but it is not solved! See https://github.com/swagger-api/swagger-core/issues/3863 and see also a lot of comments here.
Is there any progress on this issue?
It doesn’t work for me. Result is “[AddLine1,AddLine2,AddLine3,AddLine4]” , it’s a string,not a list.
Waste a lot of time on this, can’t get it done, and give up finally.
I would suggest migrating to springdoc to get a smooth and intuitive experience
It looks like a lot of people are looking for this feature. This is great. If anyone wants to try and submit a PR to add the functionality, that would be appreciated.
@biniama, can you please send your swagger version, because i tried the above solution, and it doesn’t work for me.