@ApiModelProperty not displaying attribute when using @ModelAttributeode
See original GitHub issueHi,
I have a POJO (FilterRequest) that is used to configure various filter parameters for submission to a REST endpoint. I have added @ModelAttribute in the controller endpoint so that it is picked up by springfox.
@ApiOperation(value = "Filtering endpoint", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<<FilterResponse>> search(@ModelAttribute @Valid FilterRequest filterRequest) {
...
}
//The FilterRequest is defined as follows:
public class FilterRequest {
private static final String FILTER1_NAME = "filter1"
...
private static final String FILTER_N_NAME = "filterN"
private final Map<String, String> filterMap = new HashMap<>();
public void setFilter1(String filter){
if (filter != null) {
filterMap.put(FILTER1_NAME, filter);
}
}
@ApiModelProperty(value = "Filters by filter1", required = true)
public String getFilter1(){filterMap.get(FILTER1_NAME);}
...
public void setFilterN(String filter){...}
@ApiModelProperty(value = "Filters by filterN", required = true)
public String getFilterN(){...}
}
In principle this should be enough seeing as @ApiModelProperty should work on getters. However this is not the case, and nothing appears in the swagger output. If I declare the filters as individual state attributes they appear. I want to be able to save all these fields in a map, seeing as I need to process these down the line.
How can I get the @ApiModelProperty to wotk in my case>?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Swagger ApiModelProperty not working - Stack Overflow
Same problem with springfox-swagger2 package in 2.9.2 version, position property doesn't work for ordering property in swagger UI. – robynico. Mar 10, 2021...
Read more >docs/release-notes.md · serv/springfox - Gitee.com
@jfiala; (#1449) @ApiModelProperty not displaying attribute when using @ModelAttributeode duplicate @rantunesboreas. Bugs. (#2039) Endpoints with the same ...
Read more >Springfox 2.9.0 发布,开源的API doc 框架 - 码农网
(#2253) Producing "x-example" with @apiparam for @pathvariable feature ... (#1449) @apimodelproperty not displaying attribute when using @modelattributeode ...
Read more >ApiModelProperty (swagger-annotations 1.5.0 API)
Adds and manipulates data of a model property. ... Allows for filtering a property from the API documentation. ... Currently not in use....
Read more >value for @ApiModelProperty not showing up for lists
I'm working with swagger annotations 1.5.3. Code example for provenance: import com.wordnik.swagger.annotations.ApiModelProperty;.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sure, I’ll give it a try once I get back from holiday.
HI Dilip,
Thanks for replying. I have tried applying the @ApiModelProperty to the setter methods but with no success. The filters still don’t appear in the documentation.
Do you have any other suggestions?