autodoc 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b959243c809886f4e1933c89600e19549fb7bdd
4
- data.tar.gz: 8c6413d2c36bf8e717601e4472d160ef09df28b3
3
+ metadata.gz: 6d6bfb36e5c0208cc5d6b9eec52aab2c27494c4d
4
+ data.tar.gz: 69af7a3f323a6dff4053c133e304606ae379d207
5
5
  SHA512:
6
- metadata.gz: 7e37eda35bed6135a209aa11eb6858173509908bbf4a5c7f3e9ca3a5d79f84d6570739189fc1061c004af3b394d48a8a7288c6ef5c7ea2095b2457152b4bb628
7
- data.tar.gz: 03dbc7218c2cc2bc93d30d67c6abc0d10d45b4c36d4c6ae303516971f782d7bc42b92720509e75f4925e7086dd38f4f8d6f2c25e55be24e7a0043f42583a07c4
6
+ metadata.gz: 27ad733e1e05f272b165cbb99617abb74efa465b430bbf819ea6955b0c13c8655774938c576b957e87e098b177052f51dcd8468bd0a064ecce04699c591160f2
7
+ data.tar.gz: 4c78e9ead939463818b20d20e48885bbb5dd73f4d47f4bf600e7928e4e9841c4f254a3009bce2edc83b039696ead3ea8db658af0d2feba62da277f41d152aa7e
@@ -27,12 +27,17 @@ module Autodoc
27
27
  example.full_description[%r<(GET|POST|PUT|DELETE) ([^ ]+)>, 2]
28
28
  end
29
29
 
30
- # request.body can be "" (e.g. in PUT and DELETE request)
31
- def request_body
30
+ def response_body
32
31
  "\n" + JSON.parse(response.body).ai(plain: true, indent: -2, index: false)
33
32
  rescue JSON::ParserError
34
33
  end
35
34
 
35
+ def request_body_section
36
+ if has_request_body?
37
+ "\n```\n#{request_body}\n```\n"
38
+ end
39
+ end
40
+
36
41
  def parameters_section
37
42
  if has_validators?
38
43
  "\n### parameters\n#{parameters}\n"
@@ -43,6 +48,14 @@ module Autodoc
43
48
  validators.map {|validator| Parameter.new(validator) }.join("\n")
44
49
  end
45
50
 
51
+ def request_body
52
+ request.body.string
53
+ end
54
+
55
+ def has_request_body?
56
+ request_body.present?
57
+ end
58
+
46
59
  def has_validators?
47
60
  !!(defined?(WeakParameters) && validators)
48
61
  end
@@ -99,15 +112,16 @@ end
99
112
 
100
113
  __END__
101
114
  ## <%= request.method %> <%= path %>
102
- <%= example.description.camelize %>
103
-
115
+ <%= example.full_description %>.
116
+ <%= parameters_section %>
117
+ ### request
104
118
  ```
105
119
  <%= request.method %> <%= request.path %>
106
120
  ```
107
- <%= parameters_section %>
121
+ <%= request_body_section %>
108
122
  ### response
109
123
  ```ruby
110
124
  Status: <%= response.status %><%= headers %>
111
- response: <%= request_body %>
125
+ response: <%= response_body %>
112
126
  ```
113
127
 
@@ -1,3 +1,3 @@
1
1
  module Autodoc
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,13 +1,18 @@
1
1
  ## POST /recipes
2
- Creates a new recipe
2
+ Recipes POST /recipes with valid condition creates a new recipe.
3
3
 
4
+ ### parameters
5
+ * `name` string (required, except: `["alice", "bob"]`)
6
+ * `type` integer (only: `"1".."3"`)
7
+
8
+ ### request
4
9
  ```
5
10
  POST /recipes
6
11
  ```
7
12
 
8
- ### parameters
9
- * `name` string (required, except: `["alice", "bob"]`)
10
- * `type` integer (only: `"1".."3"`)
13
+ ```
14
+ name=name&type=1
15
+ ```
11
16
 
12
17
  ### response
13
18
  ```ruby
@@ -15,10 +20,10 @@ Status: 201
15
20
  location: http://www.example.com/recipes/1
16
21
  response:
17
22
  {
18
- "created_at" => "2013-06-18T06:33:40Z",
23
+ "created_at" => "2013-07-08T06:11:46Z",
19
24
  "id" => 1,
20
25
  "name" => "name",
21
- "updated_at" => "2013-06-18T06:33:40Z"
26
+ "updated_at" => "2013-07-08T06:11:46Z"
22
27
  }
23
28
  ```
24
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-18 00:00:00.000000000 Z
11
+ date: 2013-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  requirements: []
172
172
  rubyforge_project:
173
- rubygems_version: 2.0.2
173
+ rubygems_version: 2.0.3
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Auto-generate API documents from your request-specs.