tomograph 2.5.1 → 3.0.1
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 +5 -5
- data/.github/workflows/ruby.yml +33 -0
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/.tool-versions +2 -1
- data/.travis.yml +4 -3
- data/CHANGELOG.md +33 -0
- data/README.md +172 -164
- data/exe/tomograph +9 -48
- data/lib/tomograph/api_blueprint/crafter/yaml.rb +6 -10
- data/lib/tomograph/api_blueprint/crafter/yaml/action.rb +3 -3
- data/lib/tomograph/api_blueprint/drafter_4/yaml.rb +5 -9
- data/lib/tomograph/api_blueprint/drafter_4/yaml/action.rb +3 -3
- data/lib/tomograph/api_blueprint/json_schema.rb +2 -2
- data/lib/tomograph/tomogram.rb +6 -9
- data/lib/tomograph/tomogram/action.rb +4 -4
- data/lib/tomograph/version.rb +1 -1
- data/tomograph.gemspec +7 -8
- metadata +29 -65
- data/lib/tomograph/api_blueprint/drafter_3/yaml.rb +0 -128
- data/lib/tomograph/api_blueprint/drafter_3/yaml/action.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6b82305a8afc3940fb54799c20a96c71685f1950addb5b0413572bb3ca6e5c2f
|
4
|
+
data.tar.gz: eddef2bcfd9ba3f22d3cf4511e0e7ce6a32c28992e0c022602c499210b72c2a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4843bb38871e842c26f63c6af9ac1d87fd5f153a56255c1b3d070eb35686c08b84c8279bf900d9dd4a0cf38fb9daff3b905bb58285e169c118ad7d36c7855b8c
|
7
|
+
data.tar.gz: 3df3afd4cc5064d767dad8640f156bd39972a728927621ac740f332609b21a3533be36d71099208f527e7d290970ab0e59814bc5d00239135687e2015a9e8b9d
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
+
# uses: ruby/setup-ruby@v1
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.6
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/.tool-versions
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 2.7.1
|
2
|
+
nodejs 11.3.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
### 3.0.1 - 2020-10-14
|
4
|
+
|
5
|
+
* removed
|
6
|
+
* delete apib_path [#31](https://github.com/funbox/tomograph/issues/31)
|
7
|
+
* delete drafter_4_apib_path [#32](https://github.com/funbox/tomograph/issues/32)
|
8
|
+
* replace drafter_yaml_path with drafter_4_yaml_path [#33](https://github.com/funbox/tomograph/issues/33)
|
9
|
+
* delete crafter_apib_path [#34](https://github.com/funbox/tomograph/issues/34)
|
10
|
+
* delete multi_json [#35](https://github.com/funbox/tomograph/issues/35)
|
11
|
+
|
12
|
+
### 3.0.0 - 2020-08-27
|
13
|
+
|
14
|
+
* features
|
15
|
+
* support multi request for one resource path [#27](https://github.com/funbox/tomograph/issues/27)
|
16
|
+
* removed
|
17
|
+
* delete support drafter 3 [#29](https://github.com/funbox/tomograph/issues/29)
|
18
|
+
|
19
|
+
### 2.5.4 - 2020-04-06
|
20
|
+
|
21
|
+
* fixed warnings on ruby 2.7
|
22
|
+
* updated dependences
|
23
|
+
|
24
|
+
# Change log
|
25
|
+
|
26
|
+
### 2.5.3 - 2020-03-10
|
27
|
+
|
28
|
+
* bug fixes
|
29
|
+
* fix parser status to string
|
30
|
+
|
31
|
+
### 2.5.2 - 2020-01-10
|
32
|
+
|
33
|
+
* bug fixes
|
34
|
+
* fix parser for new crafter version
|
35
|
+
|
3
36
|
### 2.5.1 - 2019-12-09
|
4
37
|
|
5
38
|
* bug fixes
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# Tomograph
|
1
|
+
# Tomograph
|
2
2
|
|
3
|
-
|
4
|
-
<img src="https://funbox.ru/badges/sponsored_by_funbox_compact.svg" alt="Sponsored by FunBox" width=250 />
|
5
|
-
</a>
|
3
|
+
[](https://travis-ci.org/funbox/tomograph) [](https://badge.fury.io/rb/tomograph)
|
6
4
|
|
7
5
|
Convert API Blueprint to JSON Schema and search.
|
8
6
|
|
@@ -10,187 +8,203 @@ Convert API Blueprint to JSON Schema and search.
|
|
10
8
|
|
11
9
|
First you need to install [drafter](https://github.com/apiaryio/drafter).
|
12
10
|
|
13
|
-
|
11
|
+
Then add this line to your application's Gemfile:
|
14
12
|
|
15
13
|
```ruby
|
16
14
|
gem 'tomograph'
|
17
15
|
```
|
18
16
|
|
19
|
-
|
17
|
+
After that execute:
|
20
18
|
|
21
|
-
|
19
|
+
```bash
|
20
|
+
$ bundle
|
21
|
+
```
|
22
22
|
|
23
|
-
Or install
|
23
|
+
Or install the gem by yourself:
|
24
24
|
|
25
|
-
|
25
|
+
```bash
|
26
|
+
$ gem install tomograph
|
27
|
+
```
|
26
28
|
|
27
29
|
## Usage
|
28
30
|
|
29
31
|
```ruby
|
30
32
|
require 'tomograph'
|
31
|
-
```
|
32
33
|
|
33
|
-
|
34
|
-
tomogram = Tomograph::Tomogram.new(apib_path: '/path/to/doc.apib')
|
34
|
+
tomogram = Tomograph::Tomogram.new(drafter_yaml_path: '/path/to/doc.yaml')
|
35
35
|
```
|
36
36
|
|
37
37
|
### Command line tool
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Now there is support for documents pre-parsed by [drafter](https://github.com/apiaryio/drafter) versions 3 and 4, or crafter. To select the handler version, use the -d key and specify the required version. For example:
|
39
|
+
CLI allows you to convert files from API Elements to JSON Schema.
|
40
|
+
|
41
|
+
```bash
|
42
|
+
tomograph doc.yaml doc.json
|
44
43
|
```
|
44
|
+
|
45
|
+
There is also support for documents pre-parsed by [drafter](https://github.com/apiaryio/drafter) versions 3 and 4, or `crafter`.
|
46
|
+
To specify the handler version use the `-d` flag:
|
47
|
+
|
48
|
+
```bash
|
45
49
|
tomograph -d 4 doc_by_drafter4.yaml doc.json
|
46
50
|
```
|
47
|
-
|
48
|
-
|
51
|
+
|
52
|
+
Run CLI with `-h` to get detailed help:
|
53
|
+
|
54
|
+
```bash
|
49
55
|
tomograph -h
|
50
56
|
```
|
51
|
-
for more details on usage.
|
52
57
|
|
53
58
|
## Convert
|
54
59
|
|
60
|
+
Use `to_json` for converting APIB to JSON:
|
61
|
+
|
55
62
|
```ruby
|
56
63
|
tomogram.to_json
|
57
64
|
```
|
58
65
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
+
|
82
|
-
|
83
|
-
+ Response
|
84
|
-
|
85
|
-
+ Response
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
"
|
111
|
-
"
|
112
|
-
|
113
|
-
|
66
|
+
<details>
|
67
|
+
<summary>Example input</summary>
|
68
|
+
|
69
|
+
```apib
|
70
|
+
FORMAT: 1A
|
71
|
+
HOST: http://test.local
|
72
|
+
|
73
|
+
# project
|
74
|
+
|
75
|
+
# Group project
|
76
|
+
|
77
|
+
Project
|
78
|
+
|
79
|
+
## Authentication [/sessions]
|
80
|
+
|
81
|
+
### Sign In [POST]
|
82
|
+
|
83
|
+
+ Request (application/json)
|
84
|
+
|
85
|
+
+ Attributes
|
86
|
+
+ login (string, required)
|
87
|
+
+ password (string, required)
|
88
|
+
+ captcha (string, optional)
|
89
|
+
|
90
|
+
+ Response 401 (application/json)
|
91
|
+
|
92
|
+
+ Response 429 (application/json)
|
93
|
+
|
94
|
+
+ Response 201 (application/json)
|
95
|
+
|
96
|
+
+ Attributes
|
97
|
+
+ confirmation (Confirmation, optional)
|
98
|
+
+ captcha (string, optional)
|
99
|
+
+ captcha_does_not_match (boolean, optional)
|
100
|
+
|
101
|
+
|
102
|
+
# Data Structures
|
103
|
+
|
104
|
+
## Confirmation (object)
|
105
|
+
+ id (string, required)
|
106
|
+
+ type (string, required)
|
107
|
+
+ operation (string, required)
|
108
|
+
```
|
109
|
+
</details>
|
110
|
+
|
111
|
+
<details>
|
112
|
+
<summary>Example output</summary>
|
113
|
+
|
114
|
+
```json
|
115
|
+
[
|
116
|
+
{
|
117
|
+
"path": "/sessions",
|
118
|
+
"method": "POST",
|
119
|
+
"content-type": "application/json",
|
120
|
+
"requests": [{
|
121
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
122
|
+
"type": "object",
|
123
|
+
"properties": {
|
124
|
+
"login": {
|
125
|
+
"type": "string"
|
126
|
+
},
|
127
|
+
"password": {
|
128
|
+
"type": "string"
|
129
|
+
},
|
130
|
+
"captcha": {
|
131
|
+
"type": "string"
|
132
|
+
}
|
114
133
|
},
|
115
|
-
"
|
116
|
-
"
|
134
|
+
"required": [
|
135
|
+
"login",
|
136
|
+
"password"
|
137
|
+
]
|
138
|
+
}],
|
139
|
+
"responses": [
|
140
|
+
{
|
141
|
+
"status": "401",
|
142
|
+
"content-type": "application/json",
|
143
|
+
"body": {}
|
117
144
|
},
|
118
|
-
|
119
|
-
"
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
143
|
-
"type": "object",
|
144
|
-
"properties": {
|
145
|
-
"confirmation": {
|
146
|
-
"type": "object",
|
147
|
-
"properties": {
|
148
|
-
"id": {
|
149
|
-
"type": "string"
|
150
|
-
},
|
151
|
-
"type": {
|
152
|
-
"type": "string"
|
145
|
+
{
|
146
|
+
"status": "429",
|
147
|
+
"content-type": "application/json",
|
148
|
+
"body": {}
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"status": "201",
|
152
|
+
"content-type": "application/json",
|
153
|
+
"body": {
|
154
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
155
|
+
"type": "object",
|
156
|
+
"properties": {
|
157
|
+
"confirmation": {
|
158
|
+
"type": "object",
|
159
|
+
"properties": {
|
160
|
+
"id": {
|
161
|
+
"type": "string"
|
162
|
+
},
|
163
|
+
"type": {
|
164
|
+
"type": "string"
|
165
|
+
},
|
166
|
+
"operation": {
|
167
|
+
"type": "string"
|
168
|
+
}
|
153
169
|
},
|
154
|
-
"
|
155
|
-
"
|
156
|
-
|
170
|
+
"required": [
|
171
|
+
"id",
|
172
|
+
"type",
|
173
|
+
"operation"
|
174
|
+
]
|
157
175
|
},
|
158
|
-
"
|
159
|
-
"
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
"captcha": {
|
165
|
-
"type": "string"
|
166
|
-
},
|
167
|
-
"captcha_does_not_match": {
|
168
|
-
"type": "boolean"
|
176
|
+
"captcha": {
|
177
|
+
"type": "string"
|
178
|
+
},
|
179
|
+
"captcha_does_not_match": {
|
180
|
+
"type": "boolean"
|
181
|
+
}
|
169
182
|
}
|
170
183
|
}
|
171
184
|
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
185
|
+
]
|
186
|
+
}
|
187
|
+
]
|
188
|
+
```
|
189
|
+
</details>
|
177
190
|
|
178
191
|
## Search
|
179
192
|
|
180
|
-
|
193
|
+
Use these methods to search through parsed API Blueprint spec to get request => responses hash maps.
|
194
|
+
|
195
|
+
### `find_request`
|
181
196
|
|
182
197
|
```ruby
|
183
198
|
request = tomogram.find_request(method: 'GET', path: '/status/1?qwe=rty')
|
184
199
|
```
|
185
200
|
|
186
|
-
###
|
201
|
+
### `find_request_with_content_type`
|
187
202
|
|
188
203
|
```ruby
|
189
204
|
request = tomogram.find_request_with_content_type(method: 'GET', path: '/status/1?qwe=rty', content_type: 'application/json')
|
190
205
|
```
|
191
206
|
|
192
|
-
### find_responses
|
193
|
-
|
207
|
+
### `find_responses`
|
194
208
|
|
195
209
|
```ruby
|
196
210
|
responses = request.find_responses(status: '200')
|
@@ -198,68 +212,62 @@ responses = request.find_responses(status: '200')
|
|
198
212
|
|
199
213
|
## Other methods
|
200
214
|
|
201
|
-
### prefix_match
|
215
|
+
### `prefix_match?`
|
202
216
|
|
203
|
-
This
|
217
|
+
This may be useful if you specify a prefix.
|
204
218
|
|
205
219
|
```ruby
|
206
220
|
tomogram.prefix_match?('http://local/api/v2/users')
|
207
221
|
```
|
208
222
|
|
209
|
-
|
223
|
+
### `to_resources`
|
224
|
+
|
225
|
+
Maps resources with possible requests.
|
210
226
|
|
211
|
-
Example:
|
227
|
+
Example output:
|
212
228
|
|
213
229
|
```ruby
|
214
|
-
|
230
|
+
{
|
231
|
+
'/sessions' => ['POST /sessions']
|
232
|
+
}
|
215
233
|
```
|
216
234
|
|
217
|
-
|
235
|
+
## Constructor params
|
236
|
+
|
237
|
+
You can specify API prefix and path to the spec using one of the possible formats:
|
218
238
|
|
219
239
|
```ruby
|
220
240
|
Tomograph::Tomogram.new(prefix: '/api/v2', drafter_yaml_path: '/path/to/doc.yaml')
|
221
241
|
```
|
222
242
|
|
223
|
-
or
|
224
|
-
|
225
243
|
```ruby
|
226
244
|
Tomograph::Tomogram.new(prefix: '/api/v2', tomogram_json_path: '/path/to/doc.json')
|
227
245
|
```
|
228
246
|
|
229
|
-
###
|
230
|
-
|
231
|
-
Path to API Blueprint documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
232
|
-
|
233
|
-
### drafter_yaml_path
|
247
|
+
### `drafter_yaml_path`
|
234
248
|
|
235
249
|
Path to API Blueprint documentation pre-parsed with `drafter` and saved to a YAML file.
|
236
250
|
|
237
|
-
Drafter
|
251
|
+
### Drafter v4 & Crafter support
|
238
252
|
|
239
|
-
If you are using a `drafter
|
253
|
+
If you are using a `drafter v4`, you should use `drafter_yaml_path`.
|
240
254
|
|
241
|
-
|
255
|
+
In case when you want to use `сrafter`, then you should pass `crafter_yaml_path` respectively.
|
242
256
|
|
243
|
-
|
244
|
-
|
245
|
-
### tomogram_json_path
|
257
|
+
### `tomogram_json_path`
|
246
258
|
|
247
259
|
Path to API Blueprint documentation converted with `tomograph` to a JSON file.
|
248
260
|
|
249
|
-
### prefix
|
261
|
+
### `prefix`
|
250
262
|
|
251
|
-
Default
|
263
|
+
Default: `''`
|
252
264
|
|
253
|
-
|
265
|
+
Prefix for API requests.
|
254
266
|
|
255
|
-
|
256
|
-
The result for the example above:
|
257
|
-
```ruby
|
258
|
-
{
|
259
|
-
'/sessions' => ['POST /sessions']
|
260
|
-
}
|
261
|
-
```
|
267
|
+
Example: `'/api'`.
|
262
268
|
|
263
269
|
## License
|
264
270
|
|
265
271
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
272
|
+
|
273
|
+
[](https://funbox.ru)
|