Re-usable patterns
Let's consider a chat REST API example where we want to display a sample input, example code snippet, and sample output. Here how documentation may look like. Use to send a new message http.post("/messages", [message: "Hello all"]) { id.should == "mid1" } This is the source to render the layout above Note: request and response were automatically captured using WebTau testing framework. We need to document other methods as well, and as you can imagine, the repetition will take place. :include-groovy: org/testingisdocumenting/testing/examples/restapi/WebTauRestAPIGroovyTest.groovy { title: "POST messages", entry: "postMessages", bodyOnly: true, excludeRegexp: "http.doc" } ```columns left: :include-json: chat-post-messages/request.json { title: "POST /messages request" } right: :include-json: chat-post-messages/response.json { title: "POST /messages response", highlightValueFile: "chat-post-messages/paths.json" } ```