Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 1.45 KB

contract-dsl-rest-docs.adoc

File metadata and controls

48 lines (39 loc) · 1.45 KB

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):

maven
link:{standalone_restdocs_path}/http-server/pom.xml[role=include]
gradle
link:{standalone_restdocs_path}/http-server/build.gradle[role=include]

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

WebAppContext
link:{standalone_restdocs_path}/http-server/src/test/java/com/example/fraud/FraudBaseWithWebAppSetup.java[role=include]
Standalone
link:{standalone_restdocs_path}/http-server/src/test/java/com/example/fraud/FraudBaseWithStandaloneSetup.java[role=include]
Tip
You need not specify the output directory for the generated snippets (since version 1.2.0.RELEASE of Spring REST Docs).