sunshine
sunshine

Reputation: 166

How to document http error codes using spring-restdocs

Is there a way to document http error codes using spring-restdocs? I did not find anything about the same on http://docs.spring.io/spring-restdocs/docs/current/reference/html5/

Any help with an example will be greatly appreciated.

Regards, Surya

Upvotes: 4

Views: 1536

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116311

Spring REST Docs doesn't provide anything to help you document HTTP error codes. The theory is that it isn't really necessary to document error codes, and certainly not on every single resource in the API.

The HTTP spec provides definitions for its error codes and your API should adhere to the definitions. This allows users of the API to use their existing knowledge of HTTP, rather than having to learn something new that's specific to your API. If you aren't sure that your users will already have this knowledge, you could include some information about HTTP error codes in an overview section of the documentation. This is the approach taken in one of Spring REST Docs' sample projects. Both the Asciidoctor source and resulting HTML documentation are available online .

Upvotes: 7

Related Questions