tomograph 2.5.1 → 3.0.1

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
- SHA1:
3
- metadata.gz: 6c4366a0176b71d1c6b51227c8e26f1828c5fb26
4
- data.tar.gz: 5cf804f81867664329fdc601e3adfd98166cfe7b
2
+ SHA256:
3
+ metadata.gz: 6b82305a8afc3940fb54799c20a96c71685f1950addb5b0413572bb3ca6e5c2f
4
+ data.tar.gz: eddef2bcfd9ba3f22d3cf4511e0e7ce6a32c28992e0c022602c499210b72c2a1
5
5
  SHA512:
6
- metadata.gz: 7bdcd5d49e4c51da0ea79c5b007eeb59dd02f19f72ef027471d807b9ef542c0bfc5bb7f8346b4176e8161f0a1bf93936d553356d6a4b06e3118ba2bc5a1c13d2
7
- data.tar.gz: a43ea3338ce88798374d835a98ebd5084055f07cbab91dd3f49bbc4f893d0595031d1efb3cf4cd1f3f238dbdb2dc8dd7239760e99695532f7f3e38f197eed7ab
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
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.7
3
3
 
4
4
  Metrics/LineLength:
5
5
  Max: 120
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.7.1
@@ -1 +1,2 @@
1
- ruby 2.2.0
1
+ ruby 2.7.1
2
+ nodejs 11.3.0
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
4
- before_install: gem install bundler -v 1.12
5
-
3
+ - 2.4
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
@@ -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 [![Build Status](https://travis-ci.org/funbox/tomograph.svg?branch=master)](https://travis-ci.org/funbox/tomograph) [![Gem Version](https://badge.fury.io/rb/tomograph.svg)](https://badge.fury.io/rb/tomograph)
1
+ # Tomograph
2
2
 
3
- <a href="https://funbox.ru">
4
- <img src="https://funbox.ru/badges/sponsored_by_funbox_compact.svg" alt="Sponsored by FunBox" width=250 />
5
- </a>
3
+ [![Build Status](https://travis-ci.org/funbox/tomograph.svg?branch=master)](https://travis-ci.org/funbox/tomograph) [![Gem Version](https://badge.fury.io/rb/tomograph.svg)](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
- Second add this line to your application's Gemfile:
11
+ Then add this line to your application's Gemfile:
14
12
 
15
13
  ```ruby
16
14
  gem 'tomograph'
17
15
  ```
18
16
 
19
- And then execute:
17
+ After that execute:
20
18
 
21
- $ bundle
19
+ ```bash
20
+ $ bundle
21
+ ```
22
22
 
23
- Or install it yourself as:
23
+ Or install the gem by yourself:
24
24
 
25
- $ gem install tomograph
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
- ```ruby
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
- The command line tool allows you to convert files from API Blueprint or API Elements to JSON Schema.
40
- ```
41
- tomograph doc.apib doc.json
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
- See
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
- Example input:
60
- ```apib
61
- FORMAT: 1A
62
- HOST: http://test.local
63
-
64
- # project
65
-
66
- # Group project
67
-
68
- Project
69
-
70
- ## Authentication [/sessions]
71
-
72
- ### Sign In [POST]
73
-
74
- + Request (application/json)
75
-
76
- + Attributes
77
- + login (string, required)
78
- + password (string, required)
79
- + captcha (string, optional)
80
-
81
- + Response 401 (application/json)
82
-
83
- + Response 429 (application/json)
84
-
85
- + Response 201 (application/json)
86
-
87
- + Attributes
88
- + confirmation (Confirmation, optional)
89
- + captcha (string, optional)
90
- + captcha_does_not_match (boolean, optional)
91
-
92
-
93
- # Data Structures
94
-
95
- ## Confirmation (object)
96
- + id (string, required)
97
- + type (string, required)
98
- + operation (string, required)
99
- ```
100
-
101
- Example output:
102
- ```json
103
- [
104
- {
105
- "path": "/sessions",
106
- "method": "POST",
107
- "content-type": "application/json",
108
- "request": {
109
- "$schema": "http://json-schema.org/draft-04/schema#",
110
- "type": "object",
111
- "properties": {
112
- "login": {
113
- "type": "string"
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
- "password": {
116
- "type": "string"
134
+ "required": [
135
+ "login",
136
+ "password"
137
+ ]
138
+ }],
139
+ "responses": [
140
+ {
141
+ "status": "401",
142
+ "content-type": "application/json",
143
+ "body": {}
117
144
  },
118
- "captcha": {
119
- "type": "string"
120
- }
121
- },
122
- "required": [
123
- "login",
124
- "password"
125
- ]
126
- },
127
- "responses": [
128
- {
129
- "status": "401",
130
- "content-type": "application/json",
131
- "body": {}
132
- },
133
- {
134
- "status": "429",
135
- "content-type": "application/json",
136
- "body": {}
137
- },
138
- {
139
- "status": "201",
140
- "content-type": "application/json",
141
- "body": {
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
- "operation": {
155
- "type": "string"
156
- }
170
+ "required": [
171
+ "id",
172
+ "type",
173
+ "operation"
174
+ ]
157
175
  },
158
- "required": [
159
- "id",
160
- "type",
161
- "operation"
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
- ### find_request
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
- ### find_request
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 can be useful if you use a prefix.
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
- ## Params
223
+ ### `to_resources`
224
+
225
+ Maps resources with possible requests.
210
226
 
211
- Example:
227
+ Example output:
212
228
 
213
229
  ```ruby
214
- Tomograph::Tomogram.new(prefix: '/api/v2', apib_path: '/path/to/doc.apib')
230
+ {
231
+ '/sessions' => ['POST /sessions']
232
+ }
215
233
  ```
216
234
 
217
- or
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
- ### apib_path
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 v.4
251
+ ### Drafter v4 & Crafter support
238
252
 
239
- If you are using a `drafter v.4`, then you need to use the following parameters`drafter_4_apib_path` and `drafter_4_yaml_path` respectively.
253
+ If you are using a `drafter v4`, you should use `drafter_yaml_path`.
240
254
 
241
- Crafter
255
+ In case when you want to use `сrafter`, then you should pass `crafter_yaml_path` respectively.
242
256
 
243
- In case when you want to use `сrafter`, then you need to specify these parameters `crafter_apib_path`, `crafter_yaml_path`.
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 empty String. Prefix of API requests. Example: `'/api'`.
263
+ Default: `''`
252
264
 
253
- ### to_resources
265
+ Prefix for API requests.
254
266
 
255
- Hash resource with requests.
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
+ [![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)