jdoc 0.1.6 → 0.1.7

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: df300f30d95d8a3f3ed9ea1e2a3c0848818c328a
4
- data.tar.gz: 00954109d3497003c916b9c5e6a8bc1015838b73
3
+ metadata.gz: 6327b02b6a01126e085de598704c28f6187903ba
4
+ data.tar.gz: 909c4b63a36d9631d70b2ec7bb98b387f5d11870
5
5
  SHA512:
6
- metadata.gz: c1b786485026d48129e096a64f5398adf78e611db540e31fbaf53294e64ea28915be3739f399bf63200dccffd6e05eef3b15cb46b75044c71310834da91b7f3f
7
- data.tar.gz: 0c563787a3846f4505ecf5b81d46a9a5eed786a35bea5b7c4980807ebee68bf93a59fa02cd47fd1675d430289bbaff8acf79f031f070cbc05274af74769643e5
6
+ metadata.gz: 3d8b8189400dbc6bea3986cc7f507ce588ca8eeb3cb6d34272275905332c10688f9f6f2a7e5a5e084fdfddfa333b1be1128378eebc5fdbaaa211dc67b247a775
7
+ data.tar.gz: 8fdf1d2c6790eccb6f500b8de15483640510a024904b6a8b7c4248ed7b0b3fa6619a4eb3aebbc711f219c237f082a16cef2668a63c99e485de57f873f41043d1
@@ -1,3 +1,7 @@
1
+ ## 0.1.7
2
+ * Support query string example in GET request
3
+ * Improve the description property visibility
4
+
1
5
  ## 0.1.6
2
6
  * Disable `<em>` feature of Redcarpet
3
7
 
@@ -13,22 +13,26 @@
13
13
  An app is a program to be deployed.
14
14
 
15
15
  ### Properties
16
- * id - unique identifier of app
16
+ * id
17
+ * unique identifier of app
17
18
  * Example: `"01234567-89ab-cdef-0123-456789abcdef"`
18
19
  * Type: string
19
20
  * Format: uuid
20
21
  * ReadOnly: true
21
- * name - unique name of app
22
+ * name
23
+ * unique name of app
22
24
  * Example: `"example"`
23
25
  * Type: string
24
26
  * Patern: `(?-mix:^[a-z][a-z0-9-]{3,50}$)`
25
- * private - true if this resource is private use
27
+ * private
28
+ * true if this resource is private use
26
29
  * Example: `false`
27
30
  * Type: boolean
28
- * deleted_at - When this resource was deleted at
31
+ * deleted_at
32
+ * When this resource was deleted at
29
33
  * Example: `nil`
30
34
  * Type: null
31
- * users -
35
+ * users
32
36
  * Type: array
33
37
 
34
38
  ### POST /apps
@@ -172,10 +176,10 @@ Content-Type: application/json
172
176
 
173
177
 
174
178
  ### Properties
175
- * name -
179
+ * name
176
180
  * Example: `"Sushi"`
177
181
  * Type: string
178
- * user -
182
+ * user
179
183
  * Type: object
180
184
 
181
185
  ### GET /recipes
@@ -204,7 +208,7 @@ Content-Type: application/json
204
208
 
205
209
 
206
210
  ### Properties
207
- * name -
211
+ * name
208
212
  * Example: `"alice"`
209
213
  * Type: string
210
214
 
@@ -1,3 +1,4 @@
1
+ require "active_support/core_ext/object/to_query"
1
2
  require "active_support/core_ext/string/inflections"
2
3
  require "cgi"
3
4
  require "erubis"
@@ -62,9 +62,30 @@ module Jdoc
62
62
  end
63
63
  end
64
64
 
65
+ # Adds query string if a link has a schema property and method is GET
66
+ # @return [String, nil] A query string prefixed with `?` only to GET request
67
+ # @example
68
+ # link.query_string #=> "?type=Recipe"
69
+ def query_string
70
+ if method == "GET" && !request_parameters.empty?
71
+ "?#{request_parameters.to_query}"
72
+ end
73
+ end
74
+
65
75
  # @return [String, nil] Example request body in JSON format
66
76
  def request_body
67
- JSON.pretty_generate(RequestGenerator.call(request_schema.properties)) + "\n"
77
+ JSON.pretty_generate(request_parameters) + "\n"
78
+ end
79
+
80
+ # @return [Hash] Example request parameters for this endpoint
81
+ def request_parameters
82
+ @request_parameters ||= begin
83
+ if has_schema_in_link?
84
+ RequestGenerator.call(request_schema.properties)
85
+ else
86
+ {}
87
+ end
88
+ end
68
89
  end
69
90
 
70
91
  # @return [true, false] True if this endpoint must have request body
@@ -101,6 +122,11 @@ module Jdoc
101
122
 
102
123
  private
103
124
 
125
+ # @return [true, false] True if a given link has a schema property
126
+ def has_schema_in_link?
127
+ !!@raw_link.schema
128
+ end
129
+
104
130
  # @return [true, false] True if response is intended to be list data
105
131
  def has_list_data?
106
132
  @raw_link.rel == "instances"
@@ -1,3 +1,3 @@
1
1
  module Jdoc
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -12,7 +12,10 @@
12
12
 
13
13
  ### Properties
14
14
  <% resource.properties.each do |property| %>
15
- * <%= property.name %> - <%= property.description %>
15
+ * <%= property.name %>
16
+ <% if property.description %>
17
+ * <%= property.description %>
18
+ <% end %>
16
19
  <% property.options.each do |key, value| %>
17
20
  * <%= key %>: <%= value %>
18
21
  <% end %>
@@ -23,7 +26,7 @@
23
26
  <%= link.description %>
24
27
 
25
28
  ```
26
- <%= link.method %> <%= link.path %> HTTP/1.1
29
+ <%= link.method %> <%= link.path %><%= link.query_string %> HTTP/1.1
27
30
  <%= "Content-Type: application/json\n" if link.has_request_body? -%>
28
31
  Host: <%= schema.host_with_port %>
29
32
  <%= "\n" + link.request_body if link.has_request_body? -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport