Skip to content

Commit f4a600b

Browse files
committed
pretty print response bodies
1 parent 637d938 commit f4a600b

19 files changed

+93
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
tmp
2+
.rvmrc

Gemfile.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PATH
33
specs:
44
rspec_api_documentation (0.4.3)
55
activesupport (>= 3.0.0)
6+
coderay (>= 1.0.5)
67
i18n (>= 0.1.0)
78
json (>= 1.4.0)
89
mustache (>= 0.99.0)
@@ -13,7 +14,8 @@ PATH
1314
GEM
1415
remote: http://rubygems.org/
1516
specs:
16-
activesupport (3.1.3)
17+
activesupport (3.2.3)
18+
i18n (~> 0.6)
1719
multi_json (~> 1.0)
1820
addressable (2.2.7)
1921
aruba (0.4.11)
@@ -31,6 +33,7 @@ GEM
3133
xpath (~> 0.1.4)
3234
childprocess (0.3.1)
3335
ffi (~> 1.0.6)
36+
coderay (1.0.5)
3437
crack (0.3.1)
3538
cucumber (1.1.8)
3639
builder (>= 2.1.2)
@@ -72,7 +75,7 @@ GEM
7275
tilt (>= 1.2.2, < 2.0)
7376
term-ansicolor (1.0.7)
7477
tilt (1.3.3)
75-
webmock (1.8.4)
78+
webmock (1.8.5)
7679
addressable (>= 2.2.7)
7780
crack (>= 0.1.7)
7881
xpath (0.1.4)

example/Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PATH
33
specs:
44
rspec_api_documentation (0.4.3)
55
activesupport (>= 3.0.0)
6+
coderay (>= 1.0.5)
67
i18n (>= 0.1.0)
78
json (>= 1.4.0)
89
mustache (>= 0.99.0)
@@ -44,6 +45,7 @@ GEM
4445
addressable (2.2.7)
4546
arel (2.2.1)
4647
builder (3.0.0)
48+
coderay (1.0.5)
4749
coffee-rails (3.1.1)
4850
coffee-script (>= 2.2.0)
4951
railties (~> 3.1.0)
@@ -138,7 +140,7 @@ GEM
138140
uglifier (1.1.0)
139141
execjs (>= 0.3.0)
140142
multi_json (>= 1.0.2)
141-
webmock (1.8.4)
143+
webmock (1.8.5)
142144
addressable (>= 2.2.7)
143145
crack (>= 0.1.7)
144146

example/docs/orders/creating_an_order.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,19 @@ <h4>Headers</h4>
8080
X-Ua-Compatible: IE=Edge,chrome=1
8181
E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot;
8282
Cache-Control: max-age=0, private, must-revalidate
83-
X-Runtime: 0.021959
83+
X-Runtime: 0.021253
8484
Content-Length: 58</pre>
8585
<h4>Status</h4>
8686
<pre class="response status">201 Created</pre>
8787
<h4>Body</h4>
88-
<pre class="response body highlight">{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Order 1&quot;,&quot;paid&quot;:true}</pre>
88+
<div class="response body"><div class="CodeRay">
89+
<div class="code"><pre>{
90+
<span style="color:#606"><span style="color:#404">&quot;</span><span>email</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">[email protected]</span><span style="color:#710">&quot;</span></span>,
91+
<span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Order 1</span><span style="color:#710">&quot;</span></span>,
92+
<span style="color:#606"><span style="color:#404">&quot;</span><span>paid</span><span style="color:#404">&quot;</span></span>: <span style="color:#088">true</span>
93+
}</pre></div>
94+
</div>
95+
</div>
8996
<h3>Request</h3>
9097
<h4>Headers</h4>
9198
<pre class="request headers">Accept: application/json
@@ -101,12 +108,19 @@ <h4>Headers</h4>
101108
X-Ua-Compatible: IE=Edge,chrome=1
102109
E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot;
103110
Cache-Control: max-age=0, private, must-revalidate
104-
X-Runtime: 0.007483
111+
X-Runtime: 0.009142
105112
Content-Length: 58</pre>
106113
<h4>Status</h4>
107114
<pre class="response status">200 OK</pre>
108115
<h4>Body</h4>
109-
<pre class="response body highlight">{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Order 1&quot;,&quot;paid&quot;:true}</pre>
116+
<div class="response body"><div class="CodeRay">
117+
<div class="code"><pre>{
118+
<span style="color:#606"><span style="color:#404">&quot;</span><span>email</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">[email protected]</span><span style="color:#710">&quot;</span></span>,
119+
<span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Order 1</span><span style="color:#710">&quot;</span></span>,
120+
<span style="color:#606"><span style="color:#404">&quot;</span><span>paid</span><span style="color:#404">&quot;</span></span>: <span style="color:#088">true</span>
121+
}</pre></div>
122+
</div>
123+
</div>
110124
</div>
111125
</div>
112126
</body>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"resource":"Orders","description":"Creating an order","explanation":null,"parameters":[{"name":"name","description":"Name of order","required":true,"scope":"order"},{"name":"paid","description":"If the order has been paid for","required":true,"scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"method":"POST","route":"/orders","request_body":"order[name]=Order 1\norder[paid]=true\norder[email][email protected]","request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":201,"response_status_text":"Created","response_body":"{\"email\":\"[email protected]\",\"name\":\"Order 1\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders/1\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.021959\nContent-Length: 58","curl":null},{"method":"GET","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{\"email\":\"[email protected]\",\"name\":\"Order 1\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.007483\nContent-Length: 58","curl":null}]}
1+
{"resource":"Orders","description":"Creating an order","explanation":null,"parameters":[{"name":"name","description":"Name of order","required":true,"scope":"order"},{"name":"paid","description":"If the order has been paid for","required":true,"scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"method":"POST","route":"/orders","request_body":"order[name]=Order 1\norder[paid]=true\norder[email][email protected]","request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":201,"response_status_text":"Created","response_body":"<div class=\"CodeRay\">\n <div class=\"code\"><pre>{\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>email</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">[email protected]</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>name</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">Order 1</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>paid</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"color:#088\">true</span>\n}</pre></div>\n</div>\n","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders/1\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.021253\nContent-Length: 58","curl":null},{"method":"GET","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"<div class=\"CodeRay\">\n <div class=\"code\"><pre>{\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>email</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">[email protected]</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>name</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">Order 1</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>paid</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"color:#088\">true</span>\n}</pre></div>\n</div>\n","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.009142\nContent-Length: 58","curl":null}]}

example/docs/orders/deleting_an_order.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ <h4>Headers</h4>
4141
X-Ua-Compatible: IE=Edge,chrome=1
4242
E-Tag: &quot;99914b932bd37a50b983c5e7c90ae93b&quot;
4343
Cache-Control: max-age=0, private, must-revalidate
44-
X-Runtime: 0.010821
44+
X-Runtime: 0.007525
4545
Content-Length: 2</pre>
4646
<h4>Status</h4>
4747
<pre class="response status">200 OK</pre>
4848
<h4>Body</h4>
49-
<pre class="response body highlight">{}</pre>
49+
<div class="response body"><div class="CodeRay">
50+
<div class="code"><pre>{
51+
}</pre></div>
52+
</div>
53+
</div>
5054
</div>
5155
</div>
5256
</body>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"resource":"Orders","description":"Deleting an order","explanation":null,"parameters":[],"requests":[{"method":"DELETE","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"99914b932bd37a50b983c5e7c90ae93b\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.010821\nContent-Length: 2","curl":null}]}
1+
{"resource":"Orders","description":"Deleting an order","explanation":null,"parameters":[],"requests":[{"method":"DELETE","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"<div class=\"CodeRay\">\n <div class=\"code\"><pre>{\n}</pre></div>\n</div>\n","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"99914b932bd37a50b983c5e7c90ae93b\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.007525\nContent-Length: 2","curl":null}]}

example/docs/orders/getting_a_list_of_orders.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,26 @@ <h4>Headers</h4>
6060
X-Ua-Compatible: IE=Edge,chrome=1
6161
E-Tag: &quot;6cd5831e98b0090b64672b5604d9eb2a&quot;
6262
Cache-Control: max-age=0, private, must-revalidate
63-
X-Runtime: 0.160810
63+
X-Runtime: 0.130831
6464
Content-Length: 121</pre>
6565
<h4>Status</h4>
6666
<pre class="response status">200 OK</pre>
6767
<h4>Body</h4>
68-
<pre class="response body highlight">[{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Order 0&quot;,&quot;paid&quot;:true},{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Order 1&quot;,&quot;paid&quot;:true}]</pre>
68+
<div class="response body"><div class="CodeRay">
69+
<div class="code"><pre>[
70+
{
71+
<span style="color:#606"><span style="color:#404">&quot;</span><span>email</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">[email protected]</span><span style="color:#710">&quot;</span></span>,
72+
<span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Order 0</span><span style="color:#710">&quot;</span></span>,
73+
<span style="color:#606"><span style="color:#404">&quot;</span><span>paid</span><span style="color:#404">&quot;</span></span>: <span style="color:#088">true</span>
74+
},
75+
{
76+
<span style="color:#606"><span style="color:#404">&quot;</span><span>email</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">[email protected]</span><span style="color:#710">&quot;</span></span>,
77+
<span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Order 1</span><span style="color:#710">&quot;</span></span>,
78+
<span style="color:#606"><span style="color:#404">&quot;</span><span>paid</span><span style="color:#404">&quot;</span></span>: <span style="color:#088">true</span>
79+
}
80+
]</pre></div>
81+
</div>
82+
</div>
6983
</div>
7084
</div>
7185
</body>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"resource":"Orders","description":"Getting a list of orders","explanation":null,"parameters":[{"name":"page","description":"Current page of orders"}],"requests":[{"method":"GET","route":"/orders?page=1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":"page: 1","response_status":200,"response_status_text":"OK","response_body":"[{\"email\":\"[email protected]\",\"name\":\"Order 0\",\"paid\":true},{\"email\":\"[email protected]\",\"name\":\"Order 1\",\"paid\":true}]","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"6cd5831e98b0090b64672b5604d9eb2a\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.160810\nContent-Length: 121","curl":null}]}
1+
{"resource":"Orders","description":"Getting a list of orders","explanation":null,"parameters":[{"name":"page","description":"Current page of orders"}],"requests":[{"method":"GET","route":"/orders?page=1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":"page: 1","response_status":200,"response_status_text":"OK","response_body":"<div class=\"CodeRay\">\n <div class=\"code\"><pre>[\n {\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>email</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">[email protected]</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>name</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">Order 0</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>paid</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"color:#088\">true</span>\n },\n {\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>email</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">[email protected]</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>name</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">Order 1</span><span style=\"color:#710\">&quot;</span></span>,\n <span style=\"color:#606\"><span style=\"color:#404\">&quot;</span><span>paid</span><span style=\"color:#404\">&quot;</span></span>: <span style=\"color:#088\">true</span>\n }\n]</pre></div>\n</div>\n","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"6cd5831e98b0090b64672b5604d9eb2a\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.130831\nContent-Length: 121","curl":null}]}

example/docs/orders/getting_a_specific_order.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ <h4>Headers</h4>
3939
X-Ua-Compatible: IE=Edge,chrome=1
4040
E-Tag: &quot;d9eaba14696a65b9dfc66bf203d25a13&quot;
4141
Cache-Control: max-age=0, private, must-revalidate
42-
X-Runtime: 0.004526
42+
X-Runtime: 0.004599
4343
Content-Length: 59</pre>
4444
<h4>Status</h4>
4545
<pre class="response status">200 OK</pre>
4646
<h4>Body</h4>
47-
<pre class="response body highlight">{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Old Name&quot;,&quot;paid&quot;:true}</pre>
47+
<div class="response body"><div class="CodeRay">
48+
<div class="code"><pre>{
49+
<span style="color:#606"><span style="color:#404">&quot;</span><span>email</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">[email protected]</span><span style="color:#710">&quot;</span></span>,
50+
<span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Old Name</span><span style="color:#710">&quot;</span></span>,
51+
<span style="color:#606"><span style="color:#404">&quot;</span><span>paid</span><span style="color:#404">&quot;</span></span>: <span style="color:#088">true</span>
52+
}</pre></div>
53+
</div>
54+
</div>
4855
</div>
4956
</div>
5057
</body>

0 commit comments

Comments
 (0)