7

I'd like to be able to create a page that lists off the mappings that were discovered by controllers annotated with @Controller. I'm doing this for REST services that allows us to easily find the endpoints available to the instance on a page.

So far I've manually been doing this, though if it's possible to create a controller that publishes this in a pleasant format nicely it would be greatly beneficial.

Key information I'm after is

  • Endpoint URI
  • Method (GET|POST|DELETE|...)
  • Params
  • Headers

Having access to this information where I could create a JSP view would be ideal.

Brett Ryan
  • 26,937
  • 30
  • 128
  • 163

2 Answers2

8

With Spring 3.1, there is a new feature referred to as "end point documentation". The only thing I could find was some code in the spring-mvc-31-demo sample app. Refer to the example controller and JSP. Seems pretty straight forward.

nickdos
  • 8,348
  • 5
  • 30
  • 47
1

Check out this custom doclet https://github.com/rightshift/spring-mvc-api-doclet. It will create endpoint documentation for all Spring MVC @Controller annotated classes. Custom templates can be created to produce different HTML output. The new template name just needs to be passed as an optional param. It can also be added to as a reportSet to the reporting section of your maven pom.

Barry Jordan
  • 2,666
  • 2
  • 22
  • 24
  • Sounds interesting, possibly something that could be embedded to generate HTML output. I needed my documentation generated on the fly from within the app itself. There's an admin page that allows an administrator to see all endpoints and their security details to allow applying role requirements at runtime. – Brett Ryan Jun 12 '14 at 23:49
  • Ah ok, slightly different use case then I guess. – Barry Jordan Jun 13 '14 at 07:10
  • Still your docket it a cool idea, good work. If I could suggest though it wold be neat if your docket took a configuration and introspected all @Controller annotated classes instead of needing to use command params – Brett Ryan Jun 13 '14 at 07:41