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: snicoll
FTR, this was initially submitted against Spring Boot.
Comment From: rstoyanchev
I'm not sure if it should be tied to @RequestMapping
. It seems more cross-cutting than just HTTP web endpoints.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: imic07
The reason I raise this question is that we've been using the Spring framework and want some of the features it provides to be richer and more powerful. The scenarios used so far (we are using a microservice architecture) : 1. Complete interface documentation for wySIWYG.While Swagger fits the bill nicely, it's too heavy, and we don't want to embed too much else in our code, especially if the native Spring framework will do the job.The Mappings interface currently returns the interface that the project is using, but if it returns some information that can be customized by the user, such as a description, then we can automatically generate API docs using the Mappings interface. 2. Our permission model is rbac. permission determination is implemented in the gateway by determining whether the request URI has an interface (@requestMapping.value) permission.If additional information can be obtained when binding interfaces to menus (such as @requestMapping.describe ='describe for this method' or @requestMapping.auth ='role1, role2') then our permission model can be more powerful and flexible.
Comment From: rstoyanchev
I don't think @RequestMapping
is the place to add any number of extra attributes like "description", "auth", or others. We have separate annotations from Spring Security for expressing authorization and that's a better model because it is more generally usable and applicable.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.