ApiOperation support dynamically Generic
See original GitHub issue#consult#
When developing management system, basically all are CRUD operations , e.g.
GET /foos
GET /foos/{id}
POST /foos
PUT /foos
DELETE /foos/{id}
so for reducing development work, I put common logic in BaseController and concrete Controller extend BaseController e.g.
public abstract class BaseController<V, F extends BaseForm> {
@GetMapping("/{id}")
protected ApiResult detail(@PathVariable String id) {
V v = getService().getById(id);
return ApiResult.success(v);
}
}
but in this case I have to override detail to add @ApiOperation respectively
@Override
@ApiOperation(value = "Detail info", response = BarVO.class)
public ApiResult detail(@PathVariable String id) {
return super.detail(id);
}
Because ApiOperation annotation cannot support generic
@ApiOperation(value = "Detail info", response = V.class)
even below manner also not support
@ApiOperation(value = "Detail info", response = getClazz())
public abstract Class<V> getClazz();
So any idea could help ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How to let generic T type in java annotation? - Stack Overflow
Annotation values must be constants so the response values can not be generic because the actual is not known at compile time and...
Read more >Springfox Reference Documentation - GitHub Pages
Allows globally configuration of default path-/request-/headerparameters which are common for every rest operation of the api, but aren`t needed ...
Read more >Operations - OpenAPI - A progressive Node.js framework
With the ability to provide Raw Definitions, we can define Generic schema for Swagger UI. ... It can grow thanks to the support...
Read more >Customizing your auto-generated Swagger Definitions in 1.5.x
The extension annotation allows you to add extension properties to a Swagger definition. It is currently supported within the @ApiOperation, @ ...
Read more >Chapter 54. Extending JAX-RS Endpoints with OpenAPI Support
Copied! import io.swagger.annotations.*. where * = Api , ApiOperation , ApiParam , ApiResponse , ...
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 FreeTop 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
Top GitHub Comments
It might be easier if ApiResult would be generic and
ApiResult<V>
could make it very easy to inform the types without having you do so many things to get that to work, what do you think?This issue has been automatically closed because it has not had recent activity. Please re-open a new issue if this is still an issue.