Created
May 14, 2013 14:30
-
-
Save dwelch2344/5576391 to your computer and use it in GitHub Desktop.
Quick little POC for self-documenting the controller layer in a SpringMVC app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ApiDocExample{ | |
| @Inject | |
| private RequestMappingHandlerMapping mapping; | |
| public void foobar(){ | |
| Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods(); | |
| for( RequestMappingInfo info : map.keySet() ){ | |
| HandlerMethod method = map.get(info); | |
| ApiOperation annotation = method.getMethodAnnotation(ApiOperation.class); | |
| if( annotation != null ){ | |
| String className = method.getBeanType().getSimpleName(); | |
| Set<String> patterns = info.getPatternsCondition().getPatterns(); | |
| MethodParameter rt = method.getReturnType(); | |
| String rtc = rt.getParameterType().getSimpleName(); | |
| System.out.println( rtc + " " + className + "(" + patterns + ")"); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment