This version is still in development and is not considered stable yet. For the latest stable version, please use spring-cloud-contract 4.1.4!

How Can I Generate Spring REST Docs Snippets from the Contracts?

When you want to include the requests and responses of your API by using Spring REST Docs, you only need to make some minor changes to your setup if you are using MockMvc and RestAssuredMockMvc. To do so, include the following dependencies (if you have not already done so):

Next, you need to make some changes to your base class. The following examples use WebAppContext and the standalone option with RestAssured:

You need not specify the output directory for the generated snippets (since version 1.2.0.RELEASE of Spring REST Docs).