jdoc 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/example-api-documentation.md +12 -8
- data/lib/jdoc.rb +1 -0
- data/lib/jdoc/link.rb +27 -1
- data/lib/jdoc/version.rb +1 -1
- data/template.md.erb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6327b02b6a01126e085de598704c28f6187903ba
|
4
|
+
data.tar.gz: 909c4b63a36d9631d70b2ec7bb98b387f5d11870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d8b8189400dbc6bea3986cc7f507ce588ca8eeb3cb6d34272275905332c10688f9f6f2a7e5a5e084fdfddfa333b1be1128378eebc5fdbaaa211dc67b247a775
|
7
|
+
data.tar.gz: 8fdf1d2c6790eccb6f500b8de15483640510a024904b6a8b7c4248ed7b0b3fa6619a4eb3aebbc711f219c237f082a16cef2668a63c99e485de57f873f41043d1
|
data/CHANGELOG.md
CHANGED
@@ -13,22 +13,26 @@
|
|
13
13
|
An app is a program to be deployed.
|
14
14
|
|
15
15
|
### Properties
|
16
|
-
* id
|
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
|
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
|
27
|
+
* private
|
28
|
+
* true if this resource is private use
|
26
29
|
* Example: `false`
|
27
30
|
* Type: boolean
|
28
|
-
* 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
|
|
data/lib/jdoc.rb
CHANGED
data/lib/jdoc/link.rb
CHANGED
@@ -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(
|
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"
|
data/lib/jdoc/version.rb
CHANGED
data/template.md.erb
CHANGED
@@ -12,7 +12,10 @@
|
|
12
12
|
|
13
13
|
### Properties
|
14
14
|
<% resource.properties.each do |property| %>
|
15
|
-
* <%= property.name %>
|
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.
|
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-
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|