haveapi 0.10.0 → 0.11.0
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/.gitignore +3 -21
- data/CHANGELOG +3 -0
- data/README.md +8 -58
- data/doc/Hooks.md +81 -0
- data/haveapi.gemspec +2 -2
- data/lib/haveapi/model_adapters/active_record.rb +2 -2
- data/lib/haveapi/server.rb +1 -1
- data/lib/haveapi/version.rb +1 -1
- metadata +6 -6
- data/.editorconfig +0 -15
- data/doc/json-schema.erb +0 -443
- data/doc/protocol.plantuml +0 -226
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c12b496f9b73690134a0cc5f37fcb455b2c40e9
|
4
|
+
data.tar.gz: 79c6fced059fe33ecee876079ca50bc7dea1b3b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14cb8803a22775f2f18021fc76c45da34693c231250aeffda5c1a45889b63a527ca79ad4989107156afc91c4f5ebc93b32c20ee04ee4f67b27887de30078784b
|
7
|
+
data.tar.gz: c81a82a1c3a735630f389b0f4a6fecdbddc93b4d07fd78b388cb6d5aefa3b4e8beb8043217acf3799c8c124a0f88c6edbbcb0ddb9a505f17ddf5d84663ee2cfb
|
data/.gitignore
CHANGED
@@ -1,21 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
.
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
lib/bundler/man
|
11
|
-
pkg
|
12
|
-
rdoc
|
13
|
-
spec/reports
|
14
|
-
test/tmp
|
15
|
-
test/version_tmp
|
16
|
-
tmp
|
17
|
-
*.bundle
|
18
|
-
*.so
|
19
|
-
*.o
|
20
|
-
*.a
|
21
|
-
mkmf.log
|
1
|
+
doc/protocol.*
|
2
|
+
doc/create-client.md
|
3
|
+
doc/json-schema.html
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,55 +1,11 @@
|
|
1
|
-
HaveAPI
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
of available resources and their actions. The description contains
|
10
|
-
a full list of parameters, their labels, text notes, data types, validators
|
11
|
-
and example usage.
|
12
|
-
|
13
|
-
Clients use the self-description to learn how to communicate with the API,
|
14
|
-
which they otherwise know nothing about.
|
15
|
-
|
16
|
-
## Motivation
|
17
|
-
Whenever you create an API server, you need to implement clients in various programming
|
18
|
-
languages to work with it. Even if you make all APIs similar using e.g. REST or SOAP,
|
19
|
-
you still need clients to know what resources and actions the API has, what are their
|
20
|
-
parameters, and so on.
|
21
|
-
|
22
|
-
When your API speaks the HaveAPI protocol, you can use pre-created clients that will
|
23
|
-
know how to work with it. You can do this by using this framework to handle all
|
24
|
-
HaveAPI-protocol stuff for you, or you can implement the [protocol](doc/protocol.md)
|
25
|
-
on your own.
|
26
|
-
|
27
|
-
At the moment, the following clients are available:
|
28
|
-
|
29
|
-
- Ruby client library and CLI: https://github.com/vpsfreecz/haveapi-client
|
30
|
-
- PHP client: https://github.com/vpsfreecz/haveapi-client-php
|
31
|
-
- JavaScript client: https://github.com/vpsfreecz/haveapi-client-js
|
32
|
-
|
33
|
-
Complex applications can be built on top of these basic clients, e.g.:
|
34
|
-
|
35
|
-
- [haveapi-webui](https://github.com/vpsfreecz/haveapi-webui), a generic web administration
|
36
|
-
for HaveAPI-based APIs
|
37
|
-
- [haveapi-fs](https://github.com/vpsfreecz/haveapi-fs), a FUSE based filesystem that can
|
38
|
-
mount any HaveAPI-based API
|
39
|
-
|
40
|
-
If there isn't a client in the language you need, you can [create it](doc/create-client.md)
|
41
|
-
and then use it for all HaveAPI-based APIs.
|
42
|
-
|
43
|
-
## Protocol features
|
44
|
-
- Creates RESTful APIs usable even with simple HTTP client, should it be needed
|
45
|
-
- A change in the API is immediately reflected in all clients when they re-download the
|
46
|
-
documentation
|
47
|
-
- Generic interface for clients - one client can be used to access all APIs
|
48
|
-
that implement this protocol
|
49
|
-
- Supports API versioning
|
50
|
-
- Standardised authentication methods
|
51
|
-
- Defines action input/output parameters and their validators
|
52
|
-
- Clients can monitor progress of long-running actions
|
1
|
+
# HaveAPI
|
2
|
+
Server-side implementation of the [HaveAPI](https://github.com/vpsfreecz/haveapi)
|
3
|
+
protocol in Ruby in the form of a framework that can be used to create
|
4
|
+
self-descriptive RESTful web APIs. The framework features a DSL aimed at
|
5
|
+
creating API resources, actions and specifying input/output parameters. HaveAPI
|
6
|
+
handles everything from HTTP communication, authentication, parsing of input
|
7
|
+
parameters and formatting output, so that users can focus on their bussiness
|
8
|
+
logic.
|
53
9
|
|
54
10
|
## Server framework features
|
55
11
|
- Handles network communication, authentication, authorization, input/output formats
|
@@ -298,12 +254,6 @@ Blocking mode is for actions whose execution is not immediate but takes an unspe
|
|
298
254
|
amount of time. HaveAPI protocol allows clients to monitor progress of such actions
|
299
255
|
or cancel their execution.
|
300
256
|
|
301
|
-
## Read more
|
302
|
-
- [Protocol definition](doc/protocol.md)
|
303
|
-
- [How to create a client](doc/create-client.md)
|
304
|
-
- [Project templates](https://github.com/vpsfreecz/haveapi-server-project-templates)
|
305
|
-
- [API examples](https://github.com/vpsfreecz/haveapi-server-examples)
|
306
|
-
|
307
257
|
## Contributing
|
308
258
|
|
309
259
|
1. Fork it ( https://github.com/vpsfreecz/haveapi/fork )
|
data/doc/Hooks.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
|
2
|
+
# Hooks
|
3
|
+
|
4
|
+
##HaveAPI::Server
|
5
|
+
|
6
|
+
### post_authenticated
|
7
|
+
<table>
|
8
|
+
<tr>
|
9
|
+
<td style="vertical-align: top;">Description:</td>
|
10
|
+
<td>Called after the user was authenticated</td>
|
11
|
+
</tr>
|
12
|
+
<tr>
|
13
|
+
<td style="vertical-align: top;">Context:</td>
|
14
|
+
<td>current</td>
|
15
|
+
</tr>
|
16
|
+
<tr>
|
17
|
+
<td style="vertical-align: top;">Arguments:</td>
|
18
|
+
<td><dl><dt>current_user</dt><dd>object returned by the authentication backend</dd></dl></td>
|
19
|
+
</tr>
|
20
|
+
<tr>
|
21
|
+
<td style="vertical-align: top;">Initial value:</td>
|
22
|
+
<td>none</td>
|
23
|
+
</tr>
|
24
|
+
<tr>
|
25
|
+
<td style="vertical-align: top;">Return value:</td>
|
26
|
+
<td>none</td>
|
27
|
+
</tr>
|
28
|
+
</table>
|
29
|
+
|
30
|
+
### description_exception
|
31
|
+
<table>
|
32
|
+
<tr>
|
33
|
+
<td style="vertical-align: top;">Description:</td>
|
34
|
+
<td>Called when an exception occurs when building self-description</td>
|
35
|
+
</tr>
|
36
|
+
<tr>
|
37
|
+
<td style="vertical-align: top;">Context:</td>
|
38
|
+
<td>current</td>
|
39
|
+
</tr>
|
40
|
+
<tr>
|
41
|
+
<td style="vertical-align: top;">Arguments:</td>
|
42
|
+
<td><dl><dt>context</dt><dd>HaveAPI::Context</dd><dt>exception</dt><dd>exception instance</dd></dl></td>
|
43
|
+
</tr>
|
44
|
+
<tr>
|
45
|
+
<td style="vertical-align: top;">Initial value:</td>
|
46
|
+
<td>none</td>
|
47
|
+
</tr>
|
48
|
+
<tr>
|
49
|
+
<td style="vertical-align: top;">Return value:</td>
|
50
|
+
<td><dl><dt>http_status</dt><dd>HTTP status code to send to client</dd><dt>message</dt><dd>error message sent to the client</dd></dl></td>
|
51
|
+
</tr>
|
52
|
+
</table>
|
53
|
+
|
54
|
+
|
55
|
+
##HaveAPI::Action
|
56
|
+
|
57
|
+
### exec_exception
|
58
|
+
<table>
|
59
|
+
<tr>
|
60
|
+
<td style="vertical-align: top;">Description:</td>
|
61
|
+
<td>Called when unhandled exceptions occurs during Action.exec</td>
|
62
|
+
</tr>
|
63
|
+
<tr>
|
64
|
+
<td style="vertical-align: top;">Context:</td>
|
65
|
+
<td>current</td>
|
66
|
+
</tr>
|
67
|
+
<tr>
|
68
|
+
<td style="vertical-align: top;">Arguments:</td>
|
69
|
+
<td><dl><dt>action</dt><dd>HaveAPI::Action instance</dd><dt>exception</dt><dd>exception instance</dd></dl></td>
|
70
|
+
</tr>
|
71
|
+
<tr>
|
72
|
+
<td style="vertical-align: top;">Initial value:</td>
|
73
|
+
<td>none</td>
|
74
|
+
</tr>
|
75
|
+
<tr>
|
76
|
+
<td style="vertical-align: top;">Return value:</td>
|
77
|
+
<td><dl><dt>status</dt><dd>true or false, indicating whether error should be reported</dd><dt>message</dt><dd>error message sent to the user</dd></dl></td>
|
78
|
+
</tr>
|
79
|
+
</table>
|
80
|
+
|
81
|
+
|
data/haveapi.gemspec
CHANGED
@@ -5,12 +5,12 @@ require 'haveapi/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'haveapi'
|
7
7
|
s.version = HaveAPI::VERSION
|
8
|
-
s.date = '2017-
|
8
|
+
s.date = '2017-11-27'
|
9
9
|
s.summary =
|
10
10
|
s.description = 'Framework for creating self-describing APIs'
|
11
11
|
s.authors = 'Jakub Skokan'
|
12
12
|
s.email = 'jakub.skokan@vpsfree.cz'
|
13
|
-
s.files = `git ls-files -z`.split("\x0")
|
13
|
+
s.files = `git ls-files -z`.split("\x0") + Dir.glob('doc/*')
|
14
14
|
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.required_ruby_version = '>= 2.0.0'
|
@@ -49,11 +49,11 @@ module HaveAPI::ModelAdapters
|
|
49
49
|
# associations in AR.
|
50
50
|
if inc.is_a?(::Hash)
|
51
51
|
inc.each_key do |k|
|
52
|
-
next(false) unless self.class.model.reflections.has_key?(k)
|
52
|
+
next(false) unless self.class.model.reflections.has_key?(k.to_s)
|
53
53
|
end
|
54
54
|
|
55
55
|
else
|
56
|
-
next(false) unless self.class.model.reflections.has_key?(inc)
|
56
|
+
next(false) unless self.class.model.reflections.has_key?(inc.to_s)
|
57
57
|
end
|
58
58
|
|
59
59
|
true
|
data/lib/haveapi/server.rb
CHANGED
@@ -264,7 +264,7 @@ module HaveAPI
|
|
264
264
|
@sinatra.get "#{@root}doc/json-schema" do
|
265
265
|
content_type 'text/html'
|
266
266
|
erb :doc_layout, layout: :main_layout do
|
267
|
-
@content =
|
267
|
+
@content = File.read(File.join(settings.root, '../../doc/json-schema.html'))
|
268
268
|
@sidebar = erb :'doc_sidebars/json-schema'
|
269
269
|
end
|
270
270
|
end
|
data/lib/haveapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haveapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Skokan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: require_all
|
@@ -170,19 +170,19 @@ executables: []
|
|
170
170
|
extensions: []
|
171
171
|
extra_rdoc_files: []
|
172
172
|
files:
|
173
|
-
- ".editorconfig"
|
174
173
|
- ".gitignore"
|
175
174
|
- CHANGELOG
|
176
175
|
- Gemfile
|
177
176
|
- LICENSE.txt
|
178
177
|
- README.md
|
179
178
|
- Rakefile
|
179
|
+
- doc/Hooks.md
|
180
180
|
- doc/create-client.md
|
181
181
|
- doc/hooks.erb
|
182
182
|
- doc/index.md
|
183
|
-
- doc/json-schema.
|
183
|
+
- doc/json-schema.html
|
184
184
|
- doc/protocol.md
|
185
|
-
- doc/protocol.
|
185
|
+
- doc/protocol.png
|
186
186
|
- haveapi.gemspec
|
187
187
|
- lib/haveapi.rb
|
188
188
|
- lib/haveapi/action.rb
|
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
303
|
version: '0'
|
304
304
|
requirements: []
|
305
305
|
rubyforge_project:
|
306
|
-
rubygems_version: 2.
|
306
|
+
rubygems_version: 2.6.14
|
307
307
|
signing_key:
|
308
308
|
specification_version: 4
|
309
309
|
summary: Framework for creating self-describing APIs
|
data/.editorconfig
DELETED
data/doc/json-schema.erb
DELETED
@@ -1,443 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
DEFINITIONS = {
|
5
|
-
version: {
|
6
|
-
type: :object,
|
7
|
-
properties: {
|
8
|
-
authentication: {
|
9
|
-
type: :object,
|
10
|
-
properties: {
|
11
|
-
basic: { '$ref' => '#/definitions/auth_basic' },
|
12
|
-
token: { '$ref' => '#/definitions/auth_token' },
|
13
|
-
}
|
14
|
-
},
|
15
|
-
resources: {
|
16
|
-
type: :object,
|
17
|
-
'$ref' => '#/definitions/resources'
|
18
|
-
},
|
19
|
-
meta: {
|
20
|
-
type: :object,
|
21
|
-
properties: {
|
22
|
-
namespace: {
|
23
|
-
type: :string,
|
24
|
-
default: '_meta'
|
25
|
-
}
|
26
|
-
}
|
27
|
-
},
|
28
|
-
help: { type: :string }
|
29
|
-
}
|
30
|
-
},
|
31
|
-
|
32
|
-
auth_basic: {
|
33
|
-
type: :object,
|
34
|
-
},
|
35
|
-
|
36
|
-
auth_token: {
|
37
|
-
type: :object,
|
38
|
-
properties: {
|
39
|
-
http_header: {
|
40
|
-
type: :string,
|
41
|
-
default: 'X-HaveAPI-Auth-Token'
|
42
|
-
},
|
43
|
-
query_parameter: {
|
44
|
-
type: :string,
|
45
|
-
default: '_auth_token'
|
46
|
-
},
|
47
|
-
resources: {
|
48
|
-
type: :object,
|
49
|
-
'$ref' => '#/definitions/resources'
|
50
|
-
}
|
51
|
-
}
|
52
|
-
},
|
53
|
-
|
54
|
-
resources: {
|
55
|
-
type: :object,
|
56
|
-
patternProperties: {
|
57
|
-
'^[a-z_]+$' => {
|
58
|
-
type: :object,
|
59
|
-
properties: {
|
60
|
-
description: { type: :string },
|
61
|
-
actions: {
|
62
|
-
'$ref' => '#/definitions/actions'
|
63
|
-
},
|
64
|
-
resources: {
|
65
|
-
'$ref' => '#/definitions/resources'
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
},
|
71
|
-
|
72
|
-
actions: {
|
73
|
-
type: :object,
|
74
|
-
patternProperties: {
|
75
|
-
'^[a-z_]+$' => {
|
76
|
-
type: :object,
|
77
|
-
properties: {
|
78
|
-
auth: { type: :boolean },
|
79
|
-
description: { type: :string },
|
80
|
-
aliases: {
|
81
|
-
type: :array,
|
82
|
-
items: { type: :string }
|
83
|
-
},
|
84
|
-
blocking: { type: :boolean },
|
85
|
-
input: { '$ref' => '#/definitions/input_parameters' },
|
86
|
-
output: { '$ref' => '#/definitions/output_parameters' },
|
87
|
-
meta: { '$ref' => '#/definitions/action_meta' },
|
88
|
-
examples: {
|
89
|
-
type: :object,
|
90
|
-
properties: {
|
91
|
-
title: { type: :string },
|
92
|
-
url_params: { type: :array, items: { type: :integer } },
|
93
|
-
request: { type: :object },
|
94
|
-
response: { type: :object },
|
95
|
-
status: { type: :boolean },
|
96
|
-
message: { type: :string },
|
97
|
-
errors: {
|
98
|
-
type: :object,
|
99
|
-
patternProperties: {
|
100
|
-
'^[a-z_]+$' => {
|
101
|
-
type: :array,
|
102
|
-
items: { type: :string },
|
103
|
-
}
|
104
|
-
}
|
105
|
-
},
|
106
|
-
http_status: { type: :integer },
|
107
|
-
comment: { type: :string },
|
108
|
-
}
|
109
|
-
},
|
110
|
-
url: { type: :string },
|
111
|
-
method: { type: :string },
|
112
|
-
help: { type: :string }
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
},
|
118
|
-
|
119
|
-
input_parameters: {
|
120
|
-
type: :object,
|
121
|
-
properties: {
|
122
|
-
parameters: {
|
123
|
-
type: :object,
|
124
|
-
patternProperties: {
|
125
|
-
'^[a-z_]+$' => {
|
126
|
-
type: :object,
|
127
|
-
oneOf: [
|
128
|
-
{
|
129
|
-
title: 'Data type',
|
130
|
-
type: :object,
|
131
|
-
properties: {
|
132
|
-
required: { type: :boolean },
|
133
|
-
label: { type: :string },
|
134
|
-
description: { type: :string },
|
135
|
-
type: {
|
136
|
-
type: :string,
|
137
|
-
enum: %w(String Text Integer Float Datetime Boolean)
|
138
|
-
},
|
139
|
-
validators: { '$ref' => '#/definitions/input_validators' },
|
140
|
-
default: {},
|
141
|
-
protected: { type: :boolean },
|
142
|
-
}
|
143
|
-
},
|
144
|
-
{
|
145
|
-
title: 'Resource',
|
146
|
-
type: :object,
|
147
|
-
properties: {
|
148
|
-
required: { type: :boolean },
|
149
|
-
label: { type: :string },
|
150
|
-
description: { type: :string },
|
151
|
-
type: {
|
152
|
-
type: :string,
|
153
|
-
enum: %w(Resource)
|
154
|
-
},
|
155
|
-
resource: { type: :array },
|
156
|
-
value_id: { type: :string },
|
157
|
-
value_label: { type: :string },
|
158
|
-
value: {
|
159
|
-
type: :object,
|
160
|
-
properties: {
|
161
|
-
url: { type: :string },
|
162
|
-
method: { type: :string },
|
163
|
-
help: { type: :string },
|
164
|
-
}
|
165
|
-
},
|
166
|
-
choices: {
|
167
|
-
type: :object,
|
168
|
-
properties: {
|
169
|
-
url: { type: :string },
|
170
|
-
method: { type: :string },
|
171
|
-
help: { type: :string },
|
172
|
-
}
|
173
|
-
}
|
174
|
-
}
|
175
|
-
}
|
176
|
-
]
|
177
|
-
}
|
178
|
-
}
|
179
|
-
},
|
180
|
-
layout: {
|
181
|
-
type: :string,
|
182
|
-
enum: %w(hash hash_list object object_list),
|
183
|
-
},
|
184
|
-
namespace: { type: :string }
|
185
|
-
}
|
186
|
-
},
|
187
|
-
|
188
|
-
input_validators: {
|
189
|
-
type: :object,
|
190
|
-
properties: {
|
191
|
-
accept: {
|
192
|
-
type: :object,
|
193
|
-
properties: {
|
194
|
-
value: {},
|
195
|
-
message: { type: :string }
|
196
|
-
}
|
197
|
-
},
|
198
|
-
confirm: {
|
199
|
-
type: :object,
|
200
|
-
properties: {
|
201
|
-
equal: { type: :boolean },
|
202
|
-
parameter: { type: :string },
|
203
|
-
message: { type: :string }
|
204
|
-
}
|
205
|
-
},
|
206
|
-
custom: { type: :string },
|
207
|
-
exclude: {
|
208
|
-
type: :object,
|
209
|
-
properties: {
|
210
|
-
values: { type: :array },
|
211
|
-
message: { type: :string }
|
212
|
-
}
|
213
|
-
},
|
214
|
-
format: {
|
215
|
-
type: :object,
|
216
|
-
properties: {
|
217
|
-
rx: { type: :string },
|
218
|
-
match: { type: :boolean },
|
219
|
-
description: { type: :string },
|
220
|
-
message: { type: :string }
|
221
|
-
}
|
222
|
-
},
|
223
|
-
include: {
|
224
|
-
type: :object,
|
225
|
-
properties: {
|
226
|
-
values: {
|
227
|
-
oneOf: [
|
228
|
-
{
|
229
|
-
title: 'Array of allowed values',
|
230
|
-
type: :array
|
231
|
-
},
|
232
|
-
{
|
233
|
-
title: 'Hash of allowed values',
|
234
|
-
type: :object
|
235
|
-
}
|
236
|
-
|
237
|
-
]
|
238
|
-
},
|
239
|
-
message: { type: :string }
|
240
|
-
}
|
241
|
-
},
|
242
|
-
length: {
|
243
|
-
oneOf: [
|
244
|
-
{
|
245
|
-
title: 'Equality',
|
246
|
-
type: :object,
|
247
|
-
properties: {
|
248
|
-
equals: { type: :integer },
|
249
|
-
message: { type: :string },
|
250
|
-
}
|
251
|
-
},
|
252
|
-
{
|
253
|
-
title: 'Interval',
|
254
|
-
type: :object,
|
255
|
-
properties: {
|
256
|
-
min: { type: :integer },
|
257
|
-
max: { type: :integer },
|
258
|
-
message: { type: :string },
|
259
|
-
}
|
260
|
-
}
|
261
|
-
]
|
262
|
-
},
|
263
|
-
number: {
|
264
|
-
type: :object,
|
265
|
-
properties: {
|
266
|
-
min: { type: :number },
|
267
|
-
max: { type: :number },
|
268
|
-
step: { type: :number },
|
269
|
-
mod: { type: :integer },
|
270
|
-
odd: { type: :boolean },
|
271
|
-
even: { type: :boolean },
|
272
|
-
message: { type: :string },
|
273
|
-
}
|
274
|
-
},
|
275
|
-
present: {
|
276
|
-
type: :object,
|
277
|
-
properties: {
|
278
|
-
empty: { type: :boolean },
|
279
|
-
message: { type: :string },
|
280
|
-
}
|
281
|
-
}
|
282
|
-
}
|
283
|
-
},
|
284
|
-
|
285
|
-
output_parameters: {
|
286
|
-
type: :object,
|
287
|
-
properties: {
|
288
|
-
parameters: {
|
289
|
-
type: :object,
|
290
|
-
patternProperties: {
|
291
|
-
'^[a-z_]+$' => {
|
292
|
-
type: :object,
|
293
|
-
oneOf: [
|
294
|
-
{
|
295
|
-
title: 'Data type',
|
296
|
-
type: :object,
|
297
|
-
properties: {
|
298
|
-
label: { type: :string },
|
299
|
-
description: { type: :string },
|
300
|
-
type: {
|
301
|
-
type: :string,
|
302
|
-
enum: %w(String Text Integer Float Datetime Boolean)
|
303
|
-
},
|
304
|
-
protected: { type: :boolean },
|
305
|
-
}
|
306
|
-
},
|
307
|
-
{
|
308
|
-
title: 'Resource',
|
309
|
-
type: :object,
|
310
|
-
properties: {
|
311
|
-
label: { type: :string },
|
312
|
-
description: { type: :string },
|
313
|
-
type: {
|
314
|
-
type: :string,
|
315
|
-
enum: %w(Resource)
|
316
|
-
},
|
317
|
-
resource: { type: :array },
|
318
|
-
value_id: { type: :string },
|
319
|
-
value_label: { type: :string },
|
320
|
-
value: {
|
321
|
-
type: :object,
|
322
|
-
properties: {
|
323
|
-
url: { type: :string },
|
324
|
-
method: { type: :string },
|
325
|
-
help: { type: :string },
|
326
|
-
}
|
327
|
-
},
|
328
|
-
choices: {
|
329
|
-
type: :object,
|
330
|
-
properties: {
|
331
|
-
url: { type: :string },
|
332
|
-
method: { type: :string },
|
333
|
-
help: { type: :string },
|
334
|
-
}
|
335
|
-
}
|
336
|
-
}
|
337
|
-
}
|
338
|
-
]
|
339
|
-
}
|
340
|
-
}
|
341
|
-
},
|
342
|
-
layout: {
|
343
|
-
type: :string,
|
344
|
-
enum: %w(hash hash_list object object_list),
|
345
|
-
},
|
346
|
-
namespace: { type: :string },
|
347
|
-
}
|
348
|
-
},
|
349
|
-
|
350
|
-
action_meta: {
|
351
|
-
type: :object,
|
352
|
-
properties: {
|
353
|
-
object: {
|
354
|
-
input: { '$ref' => '#/definitions/input_parameters' },
|
355
|
-
output: { '$ref' => '#/definitions/output_parameters' },
|
356
|
-
},
|
357
|
-
global: {
|
358
|
-
input: { '$ref' => '#/definitions/input_parameters' },
|
359
|
-
output: { '$ref' => '#/definitions/output_parameters' },
|
360
|
-
}
|
361
|
-
}
|
362
|
-
}
|
363
|
-
}
|
364
|
-
|
365
|
-
ROOTS = {
|
366
|
-
all: {
|
367
|
-
title: 'Describe all API versions',
|
368
|
-
type: :object,
|
369
|
-
properties: {
|
370
|
-
default_version: {},
|
371
|
-
versions: {
|
372
|
-
type: :object,
|
373
|
-
patternProperties: {
|
374
|
-
'^.+$' => { '$ref' => '#/definitions/version' }
|
375
|
-
},
|
376
|
-
properties: {
|
377
|
-
default: { '$ref' => '#/definitions/version' }
|
378
|
-
},
|
379
|
-
}
|
380
|
-
},
|
381
|
-
required: %i(default_version versions)
|
382
|
-
},
|
383
|
-
|
384
|
-
versions: {
|
385
|
-
title: 'Show available API versions',
|
386
|
-
type: :object,
|
387
|
-
properties: {
|
388
|
-
versions: { type: :array },
|
389
|
-
default: {}
|
390
|
-
},
|
391
|
-
required: %i(versions default)
|
392
|
-
},
|
393
|
-
|
394
|
-
default: {
|
395
|
-
title: 'Describe only the default version of the API',
|
396
|
-
'$ref' => '#/definitions/version'
|
397
|
-
},
|
398
|
-
|
399
|
-
envelope: {
|
400
|
-
title: 'All response are wrapped in this envelope',
|
401
|
-
type: :object,
|
402
|
-
properties: {
|
403
|
-
version: {},
|
404
|
-
status: { type: :boolean },
|
405
|
-
response: { type: :object },
|
406
|
-
message: { type: :string },
|
407
|
-
errors: {
|
408
|
-
type: :object,
|
409
|
-
patternProperties: {
|
410
|
-
'^.+$' => { type: :array }
|
411
|
-
},
|
412
|
-
},
|
413
|
-
},
|
414
|
-
required: ['status'],
|
415
|
-
}
|
416
|
-
}
|
417
|
-
|
418
|
-
urls = {
|
419
|
-
'/' => {
|
420
|
-
root: :all,
|
421
|
-
definitions: true
|
422
|
-
},
|
423
|
-
'/?describe=versions' => {
|
424
|
-
root: :versions
|
425
|
-
},
|
426
|
-
'/?describe=default' => {
|
427
|
-
root: :default,
|
428
|
-
definitions: true
|
429
|
-
},
|
430
|
-
}
|
431
|
-
%>
|
432
|
-
|
433
|
-
<h1 id="envelope">Envelope</h1>
|
434
|
-
<pre><code><%= JSON.pretty_generate(ROOTS[:envelope]) %></code></pre>
|
435
|
-
|
436
|
-
<%
|
437
|
-
urls.each do |url, opts|
|
438
|
-
hash = ROOTS[opts[:root]]
|
439
|
-
hash = hash.merge(DEFINITIONS) if opts[:definitions]
|
440
|
-
%>
|
441
|
-
<h1 id="<%= opts[:root] %>">OPTIONS <%= url %></h1>
|
442
|
-
<pre><code><%= JSON.pretty_generate(hash) %></code></pre>
|
443
|
-
<% end %>
|
data/doc/protocol.plantuml
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
@startuml
|
2
|
-
|
3
|
-
class Version {
|
4
|
-
help : String
|
5
|
-
}
|
6
|
-
|
7
|
-
class Meta {
|
8
|
-
namespace : String
|
9
|
-
}
|
10
|
-
|
11
|
-
abstract class Authentication {
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
class Basic {
|
16
|
-
description : String
|
17
|
-
}
|
18
|
-
|
19
|
-
class Token {
|
20
|
-
description : String
|
21
|
-
http_header : String
|
22
|
-
query_parameter : String
|
23
|
-
}
|
24
|
-
|
25
|
-
class Resource {
|
26
|
-
name : String
|
27
|
-
description : String
|
28
|
-
}
|
29
|
-
|
30
|
-
class Action {
|
31
|
-
name : String
|
32
|
-
auth : Bool
|
33
|
-
description : String
|
34
|
-
aliases : Array<String>
|
35
|
-
blocking : Bool
|
36
|
-
url : String
|
37
|
-
method : String
|
38
|
-
help : String
|
39
|
-
}
|
40
|
-
|
41
|
-
class Example {
|
42
|
-
title : String
|
43
|
-
url_params : Array<Integer>
|
44
|
-
request : hash
|
45
|
-
response : hash
|
46
|
-
status : Bool
|
47
|
-
message : String
|
48
|
-
http_status : Integer
|
49
|
-
comment : String
|
50
|
-
}
|
51
|
-
|
52
|
-
class Parameters {
|
53
|
-
layout : String
|
54
|
-
namespace : String
|
55
|
-
}
|
56
|
-
|
57
|
-
abstract class Parameter {
|
58
|
-
required : Bool
|
59
|
-
label : String
|
60
|
-
description : String
|
61
|
-
type : String
|
62
|
-
}
|
63
|
-
|
64
|
-
class InputParameter {
|
65
|
-
default : any
|
66
|
-
}
|
67
|
-
|
68
|
-
class OutputParameter {
|
69
|
-
|
70
|
-
}
|
71
|
-
|
72
|
-
abstract class ResourceParameter {
|
73
|
-
value_id : String
|
74
|
-
value_label : String
|
75
|
-
}
|
76
|
-
|
77
|
-
class TypedInputParameter {
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
class ResourceInputParameter {
|
82
|
-
}
|
83
|
-
|
84
|
-
class TypedOutputParameter {
|
85
|
-
|
86
|
-
}
|
87
|
-
|
88
|
-
class ResourceOutputParameter {
|
89
|
-
}
|
90
|
-
|
91
|
-
class ResourceLink {
|
92
|
-
url : String
|
93
|
-
method : String
|
94
|
-
help : String
|
95
|
-
}
|
96
|
-
|
97
|
-
|
98
|
-
class ActionMeta {
|
99
|
-
}
|
100
|
-
|
101
|
-
abstract class Validator {
|
102
|
-
message : String
|
103
|
-
}
|
104
|
-
|
105
|
-
class AcceptanceValidator {
|
106
|
-
value : any
|
107
|
-
}
|
108
|
-
|
109
|
-
class ConfirmationValidator {
|
110
|
-
equal : Bool
|
111
|
-
}
|
112
|
-
|
113
|
-
class CustomValidator {
|
114
|
-
description : String
|
115
|
-
}
|
116
|
-
|
117
|
-
class ExclusionValidator {
|
118
|
-
values : list
|
119
|
-
}
|
120
|
-
|
121
|
-
class FormatValidator {
|
122
|
-
rx : RegExp
|
123
|
-
match : Bool
|
124
|
-
description : String
|
125
|
-
}
|
126
|
-
|
127
|
-
abstract class InclusionValidator {
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
class ArrayInclusionValidator {
|
132
|
-
values : list
|
133
|
-
}
|
134
|
-
|
135
|
-
class HashInclusionValidator {
|
136
|
-
values : hash
|
137
|
-
}
|
138
|
-
|
139
|
-
abstract class LengthValidator {
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
class EqualLengthValidator {
|
144
|
-
equals : Integer
|
145
|
-
}
|
146
|
-
|
147
|
-
class RangeLengthValidator {
|
148
|
-
min : Integer
|
149
|
-
max : Integer
|
150
|
-
}
|
151
|
-
|
152
|
-
class NumericalityValidator {
|
153
|
-
min : Number
|
154
|
-
max : Number
|
155
|
-
step : Number
|
156
|
-
mod : Integer
|
157
|
-
odd : Bool
|
158
|
-
even : Bool
|
159
|
-
}
|
160
|
-
|
161
|
-
class PresenceValidator {
|
162
|
-
empty : Bool
|
163
|
-
}
|
164
|
-
|
165
|
-
Version -- Meta
|
166
|
-
Version *-- Authentication
|
167
|
-
|
168
|
-
Authentication <|-- Basic
|
169
|
-
Authentication <|-- Token
|
170
|
-
|
171
|
-
Token *-- Resource
|
172
|
-
|
173
|
-
Version *-- Resource
|
174
|
-
|
175
|
-
Resource *-- Resource
|
176
|
-
Resource *-- Action
|
177
|
-
|
178
|
-
Action *-- Example
|
179
|
-
Action -- Parameters : input
|
180
|
-
Action -- Parameters : output
|
181
|
-
Action -- ActionMeta : object
|
182
|
-
Action -- ActionMeta : global
|
183
|
-
|
184
|
-
ActionMeta -- Parameters : input
|
185
|
-
ActionMeta -- Parameters : output
|
186
|
-
|
187
|
-
Parameters *-- Parameter
|
188
|
-
|
189
|
-
Parameter <|-- InputParameter
|
190
|
-
Parameter <|-- OutputParameter
|
191
|
-
Parameter <|-- ResourceParameter
|
192
|
-
|
193
|
-
ResourceParameter <|-- ResourceInputParameter
|
194
|
-
ResourceParameter <|-- ResourceOutputParameter
|
195
|
-
ResourceParameter -- Resource : associated with
|
196
|
-
|
197
|
-
InputParameter <|-- TypedInputParameter
|
198
|
-
InputParameter <|-- ResourceInputParameter
|
199
|
-
|
200
|
-
TypedInputParameter *-- Validator
|
201
|
-
|
202
|
-
Validator <|-- AcceptanceValidator
|
203
|
-
Validator <|-- ConfirmationValidator
|
204
|
-
ConfirmationValidator -- InputParameter : confirms
|
205
|
-
Validator <|-- CustomValidator
|
206
|
-
Validator <|-- ExclusionValidator
|
207
|
-
Validator <|-- FormatValidator
|
208
|
-
Validator <|-- InclusionValidator
|
209
|
-
InclusionValidator <|-- ArrayInclusionValidator
|
210
|
-
InclusionValidator <|-- HashInclusionValidator
|
211
|
-
Validator <|-- LengthValidator
|
212
|
-
LengthValidator <|-- EqualLengthValidator
|
213
|
-
LengthValidator <|-- RangeLengthValidator
|
214
|
-
Validator <|-- NumericalityValidator
|
215
|
-
Validator <|-- PresenceValidator
|
216
|
-
|
217
|
-
OutputParameter <|-- TypedOutputParameter
|
218
|
-
OutputParameter <|-- ResourceOutputParameter
|
219
|
-
|
220
|
-
ResourceInputParameter -- ResourceLink : value
|
221
|
-
ResourceInputParameter -- ResourceLink : choices
|
222
|
-
|
223
|
-
ResourceOutputParameter -- ResourceLink : value
|
224
|
-
ResourceOutputParameter -- ResourceLink : choices
|
225
|
-
|
226
|
-
@enduml
|