Hope RequestMapping add a property RequestMapping#describe for describe method or class, then we can use describe like this:
/**
* THIS IS A DESCRIBE FOR CURRENT METHOD
* @return
*/
@GetMapping(value = "/lastTime", describe = "THIS IS A DESCRIBE FOR CURRENT METHOD")
public Response lastTime() {
return new Response<>().success(requirementService.lastTime());
}
in @DeleteMapping @GetMapping @PutMapping @PostMapping @PatchMapping .
When we use actuator: http://user-api-service.sra.svc.cluster.local:30501/user/api/actuator/mappings , hope got describe in contexts['user - api - service - 1'].mappings.dispatcherServlets.dispatcherServlet[0].details.requestMappingConditions.describe (or put it in details.handlerMethod) like this:
{
contexts: {
bootstrap: {
mappings: {
dispatcherServlets: {},
servletFilters: [],
servlets: []
}
},
user - api - service - 1: {
mappings: {
dispatcherServlets: {
dispatcherServlet: [{
handler: "com.ueh.user.api.controller.OrgController#getById(Long)",
predicate: "{GET /org/{id}}",
details: {
handlerMethod: {
className: "com.ueh.user.api.controller.OrgController",
name: "getById",
descriptor: "(Ljava/lang/Long;)Lcom/ueh/common/utils/system/response/Response;"
},
requestMappingConditions: {
consumes: [],
headers: [],
methods: [
"GET"
],
params: [],
patterns: [
"/org/{id}"
],
produces: [],
describe: 'THIS IS A DESCRIBE FOR CURRENT METHOD'
}
}
}
]
},
servletFilters: [
],
servlets: [ ]
},
parentId: "user-api-service-1"
}
}
}
then we can use this api do many thins such as export to swagger/judge dynamic permissions and so on
Of course, if actuator can supply a annotations (@AcutatorMappings)for this purpose, thats very nice:
/**
* THIS IS A DESCRIBE FOR CURRENT METHOD
* @return
*/
@AcutatorMappings("describe" = "THIS IS A DESCRIBE FOR CURRENT METHOD")
@GetMapping(value = "/lastTime")
public Response lastTime() {
return new Response<>().success(requirementService.lastTime());
}
Comment From: wilkinsona
Thanks for the suggestion. A describe
attribute would have to be provided by Spring Framework which maintains the @…Mapping
annotations. Please feel free to raise the suggestion there.
As for an Actuator-specific annotation, I don't think that's something that we should add as there's nothing actuator-specific about describing request mappings.