Luca
Luca

Reputation: 351

Document custom annotation in spring rest docs

I have to integrate spring rest docs in a legacy project were they use a bunch of custom annotation (such as for example the user roles). Is there a way in spring rest docs to document this annotation?

Upvotes: 0

Views: 267

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116051

Spring REST Docs works at the level of HTTP requests and responses. By design, it doesn't know anything about annotations or how those requests are handled and the responses created. This ensures that what you're documenting is at the same level as a client interacting with your service over HTTP.

If you want to include information about @PreAuthorize or an annotation that is similar to it, you will have to write something yourself to do that. If you want to fit into the REST Docs way of doing things, you could implement a custom Snippet that's configured with a class or method from which it extracts the annotation using reflection and generates some documentation from it.

Upvotes: 1

Related Questions