Skip to content

Commit

Permalink
pretty print response bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
TildeWill committed Apr 2, 2012
1 parent 637d938 commit f4a600b
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tmp
.rvmrc
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
rspec_api_documentation (0.4.3)
activesupport (>= 3.0.0)
coderay (>= 1.0.5)
i18n (>= 0.1.0)
json (>= 1.4.0)
mustache (>= 0.99.0)
Expand All @@ -13,7 +14,8 @@ PATH
GEM
remote: http://rubygems.org/
specs:
activesupport (3.1.3)
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.7)
aruba (0.4.11)
Expand All @@ -31,6 +33,7 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.1)
ffi (~> 1.0.6)
coderay (1.0.5)
crack (0.3.1)
cucumber (1.1.8)
builder (>= 2.1.2)
Expand Down Expand Up @@ -72,7 +75,7 @@ GEM
tilt (>= 1.2.2, < 2.0)
term-ansicolor (1.0.7)
tilt (1.3.3)
webmock (1.8.4)
webmock (1.8.5)
addressable (>= 2.2.7)
crack (>= 0.1.7)
xpath (0.1.4)
Expand Down
4 changes: 3 additions & 1 deletion example/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
rspec_api_documentation (0.4.3)
activesupport (>= 3.0.0)
coderay (>= 1.0.5)
i18n (>= 0.1.0)
json (>= 1.4.0)
mustache (>= 0.99.0)
Expand Down Expand Up @@ -44,6 +45,7 @@ GEM
addressable (2.2.7)
arel (2.2.1)
builder (3.0.0)
coderay (1.0.5)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
Expand Down Expand Up @@ -138,7 +140,7 @@ GEM
uglifier (1.1.0)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
webmock (1.8.4)
webmock (1.8.5)
addressable (>= 2.2.7)
crack (>= 0.1.7)

Expand Down
22 changes: 18 additions & 4 deletions example/docs/orders/creating_an_order.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot;
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.021959
X-Runtime: 0.021253
Content-Length: 58</pre>
<h4>Status</h4>
<pre class="response status">201 Created</pre>
<h4>Body</h4>
<pre class="response body highlight">{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Order 1&quot;,&quot;paid&quot;:true}</pre>
<div class="response body"><div class="CodeRay">
<div class="code"><pre>{
<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>,
<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>,
<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>
}</pre></div>
</div>
</div>
<h3>Request</h3>
<h4>Headers</h4>
<pre class="request headers">Accept: application/json
Expand All @@ -101,12 +108,19 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot;
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.007483
X-Runtime: 0.009142
Content-Length: 58</pre>
<h4>Status</h4>
<pre class="response status">200 OK</pre>
<h4>Body</h4>
<pre class="response body highlight">{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Order 1&quot;,&quot;paid&quot;:true}</pre>
<div class="response body"><div class="CodeRay">
<div class="code"><pre>{
<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>,
<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>,
<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>
}</pre></div>
</div>
</div>
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/creating_an_order.json
Original file line number Diff line number Diff line change
@@ -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}]}
{"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}]}
8 changes: 6 additions & 2 deletions example/docs/orders/deleting_an_order.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;99914b932bd37a50b983c5e7c90ae93b&quot;
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.010821
X-Runtime: 0.007525
Content-Length: 2</pre>
<h4>Status</h4>
<pre class="response status">200 OK</pre>
<h4>Body</h4>
<pre class="response body highlight">{}</pre>
<div class="response body"><div class="CodeRay">
<div class="code"><pre>{
}</pre></div>
</div>
</div>
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/deleting_an_order.json
Original file line number Diff line number Diff line change
@@ -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}]}
{"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}]}
18 changes: 16 additions & 2 deletions example/docs/orders/getting_a_list_of_orders.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,26 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;6cd5831e98b0090b64672b5604d9eb2a&quot;
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.160810
X-Runtime: 0.130831
Content-Length: 121</pre>
<h4>Status</h4>
<pre class="response status">200 OK</pre>
<h4>Body</h4>
<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>
<div class="response body"><div class="CodeRay">
<div class="code"><pre>[
{
<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>,
<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>,
<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>
},
{
<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>,
<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>,
<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>
}
]</pre></div>
</div>
</div>
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/getting_a_list_of_orders.json
Original file line number Diff line number Diff line change
@@ -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}]}
{"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}]}
11 changes: 9 additions & 2 deletions example/docs/orders/getting_a_specific_order.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;d9eaba14696a65b9dfc66bf203d25a13&quot;
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.004526
X-Runtime: 0.004599
Content-Length: 59</pre>
<h4>Status</h4>
<pre class="response status">200 OK</pre>
<h4>Body</h4>
<pre class="response body highlight">{&quot;email&quot;:&quot;[email protected]&quot;,&quot;name&quot;:&quot;Old Name&quot;,&quot;paid&quot;:true}</pre>
<div class="response body"><div class="CodeRay">
<div class="code"><pre>{
<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>,
<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>,
<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>
}</pre></div>
</div>
</div>
</div>
</div>
</body>
Expand Down
Loading

0 comments on commit f4a600b

Please sign in to comment.