fitting 2.15.0 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +3 -3
  3. data/.rubocop.yml +31 -3
  4. data/CHANGELOG.md +21 -0
  5. data/README.md +96 -281
  6. data/fitting.gemspec +10 -10
  7. data/images/example.png +0 -0
  8. data/images/example2.png +0 -0
  9. data/images/logo.png +0 -0
  10. data/lib/fitting/configuration/legacy.rb +6 -5
  11. data/lib/fitting/configuration/yaml.rb +2 -2
  12. data/lib/fitting/cover/json_schema.rb +3 -2
  13. data/lib/fitting/cover/json_schema_enum.rb +1 -1
  14. data/lib/fitting/cover/json_schema_one_of.rb +1 -1
  15. data/lib/fitting/cover/response.rb +1 -5
  16. data/lib/fitting/documentation.rb +0 -2
  17. data/lib/fitting/matchers/response_matcher.rb +2 -1
  18. data/lib/fitting/records/documented/request.rb +1 -0
  19. data/lib/fitting/records/realized_unit.rb +13 -15
  20. data/lib/fitting/records/spherical/request.rb +1 -1
  21. data/lib/fitting/records/spherical/requests.rb +2 -1
  22. data/lib/fitting/records/spherical/response.rb +2 -2
  23. data/lib/fitting/records/test_unit/request.rb +4 -0
  24. data/lib/fitting/records/tested/request.rb +1 -1
  25. data/lib/fitting/records/unit/combination.rb +5 -6
  26. data/lib/fitting/records/unit/json_schema.rb +38 -33
  27. data/lib/fitting/records/unit/request.rb +1 -0
  28. data/lib/fitting/records/unit/response.rb +1 -0
  29. data/lib/fitting/report/action.rb +6 -9
  30. data/lib/fitting/report/actions.rb +8 -10
  31. data/lib/fitting/report/combination.rb +1 -15
  32. data/lib/fitting/report/combinations.rb +5 -6
  33. data/lib/fitting/report/console.rb +5 -4
  34. data/lib/fitting/report/prefix.rb +46 -20
  35. data/lib/fitting/report/prefixes.rb +17 -5
  36. data/lib/fitting/report/response.rb +19 -20
  37. data/lib/fitting/report/responses.rb +9 -8
  38. data/lib/fitting/report/test.rb +9 -11
  39. data/lib/fitting/report/tests.rb +10 -13
  40. data/lib/fitting/request.rb +0 -1
  41. data/lib/fitting/response.rb +4 -3
  42. data/lib/fitting/statistics/cover_error.rb +2 -0
  43. data/lib/fitting/statistics/cover_error_enum.rb +2 -0
  44. data/lib/fitting/statistics/cover_error_one_of.rb +2 -0
  45. data/lib/fitting/statistics/list.rb +5 -4
  46. data/lib/fitting/statistics/not_covered_responses.rb +1 -1
  47. data/lib/fitting/statistics/percent.rb +2 -1
  48. data/lib/fitting/statistics/template.rb +10 -8
  49. data/lib/fitting/storage/white_list.rb +7 -0
  50. data/lib/fitting/templates/realized_template.rb +2 -0
  51. data/lib/fitting/tests.rb +1 -1
  52. data/lib/fitting/version.rb +1 -1
  53. data/lib/fitting.rb +5 -2
  54. data/lib/tasks/fitting.rake +62 -54
  55. data/lib/templates/bomboniere/package-lock.json +91 -70
  56. data/lib/templates/bomboniere/package.json +2 -1
  57. data/lib/templates/bomboniere/src/components/HelloWorld.vue +3 -0
  58. metadata +34 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d604ca859d26a71406a404ad3fd2ea7d232fa670ee1f930ada129df6fe55f15a
4
- data.tar.gz: 919ece6a20bdf078459ef5b42351687ddbabb01296364ba52cf4f5e669e36d7d
3
+ metadata.gz: 86988a5ed3f114df581b0d6c6550867e2f9864f05808b6ec66a063f2ad573c93
4
+ data.tar.gz: 0b1c58784f5838caea3942d022f9dfaa4196912a7f30119e0b3e1b71080f9e43
5
5
  SHA512:
6
- metadata.gz: '0810933b01cb101b7cee10d06e522a29e746139181ccd7c948f6af3b6aa0dcf082856db941c371b1e1945839b5a7ddff537fc2656025bf905485d06ed61685bd'
7
- data.tar.gz: c08f43a84f31a7d029c0c72f4667e95c9e9769a92a3bb243a4a6de7af8da2e493bd63716794ee24f04eb7bd31dff43a71bb2ebf67ec9078685fb08dffd885195
6
+ metadata.gz: d8f5d03f52a1332fc7483f17c8bbfde3c3a751a1c8f539f65637137e8b6ef95d251574105b5cecd9f4292f47f3a951ad45d9a9c914cfbee450b2d1eee8f1e25e
7
+ data.tar.gz: d40fe0ae76fa5a381e19c1444d84ae90262571cbf2ab9d3198d299b71333f042ccd1a637f150c28403b2a4ccb96b7abf230d9638ffb4ef645700244c4d8194db
@@ -23,10 +23,10 @@ jobs:
23
23
  - name: Set up Ruby
24
24
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
25
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
- # uses: ruby/setup-ruby@v1
27
- uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
26
+ uses: ruby/setup-ruby@v1
27
+ # uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
28
  with:
29
- ruby-version: 2.6
29
+ ruby-version: 2.7
30
30
  - name: Install dependencies
31
31
  run: bundle install
32
32
  - name: Run tests
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.6
3
3
 
4
- Metrics/LineLength:
5
- Max: 120
4
+ Layout/LineLength:
5
+ Max: 130
6
6
 
7
7
  Style/Documentation:
8
8
  Enabled: false
@@ -18,3 +18,31 @@ Style/CaseEquality:
18
18
 
19
19
  Style/NilComparison:
20
20
  Enabled: false
21
+
22
+ Naming/MemoizedInstanceVariableName:
23
+ Enabled: false
24
+
25
+ Lint/UnreachableCode:
26
+ Enabled: false
27
+
28
+ Metrics/MethodLength:
29
+ Max: 50
30
+
31
+ # FIXME
32
+ Metrics/AbcSize:
33
+ Max: 50
34
+
35
+ Metrics/PerceivedComplexity:
36
+ Max: 20
37
+
38
+ Metrics/CyclomaticComplexity:
39
+ Max: 20
40
+
41
+ Metrics/ParameterLists:
42
+ Max: 7
43
+
44
+ Metrics/ClassLength:
45
+ Max: 150
46
+
47
+ Lint/UselessAssignment:
48
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change log
2
2
 
3
+ ### 2.18.0 - 2021-09-29
4
+
5
+ * patch
6
+ * remove multi_json [#119](https://github.com/funbox/fitting/issues/119)
7
+
8
+ ### 2.17.0 - 2021-09-20
9
+
10
+ * features
11
+ * display tests_without_responses details on the main page [#115](https://github.com/funbox/fitting/issues/115)
12
+
13
+ ### 2.16.1 - 2021-02-10
14
+ * patch
15
+ * make prefix optional [#98](https://github.com/funbox/fitting/issues/98)
16
+
17
+ ### 2.16.0 - 2021-02-10
18
+
19
+ * features
20
+ * support swagger and openapi [#96](https://github.com/funbox/fitting/issues/96)
21
+ * patch
22
+ * let's bump to tomograph '3.0.1' [#95](https://github.com/funbox/fitting/issues/95)
23
+
3
24
  ### 2.15.0 - 2020-10-12
4
25
 
5
26
  * features
data/README.md CHANGED
@@ -1,41 +1,38 @@
1
1
  # Fitting
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/fitting.svg)](https://badge.fury.io/rb/fitting)
3
+ <img align="right" width="192" height="192"
4
+ alt="Optimizt avatar: OK sign with Mona Lisa picture between the fingers"
5
+ src="./images/logo.png">
4
6
 
5
- This gem will help you implement your API in strict accordance to the documentation in [API Blueprint](https://apiblueprint.org/) format.
6
- To do this, when you run your RSpec tests on controllers, it automatically searches for the corresponding JSON-schemas in the documentation and then validates responses with them.
7
+ There are such ways of describing the API documentation as API Blueprint, Swagger and OpenAPI. And using the tests already writed for your code, you can reuse them to find out the documentation coverage.
8
+ This makes it easy to find out how much the documentation matches the implementation.
7
9
 
8
- ## Installation
10
+ * Cool if you already have a project with tests and documentation, you can check how good everything is and fix microbags.
9
11
 
10
- First you need to install [drafter](https://github.com/apiaryio/drafter).
12
+ * If are you going developing API and write documentation for it, this tool will help you document-driven development easily create high-quality write API documentation and API.
11
13
 
12
- Then add this line to your application's Gemfile:
14
+ * Also, if you have an undocumented API, this is an easy way to describe it.
13
15
 
16
+ ![exmaple](images/example.png)
17
+
18
+ ## Installation
19
+ Add this line to your application's Gemfile:
14
20
  ```ruby
15
21
  gem 'fitting'
16
22
  ```
17
23
 
18
24
  After that execute:
19
-
20
25
  ```bash
21
26
  $ bundle
22
27
  ```
23
28
 
24
29
  Or install the gem by yourself:
25
-
26
30
  ```bash
27
31
  $ gem install fitting
28
32
  ```
29
33
 
30
34
  ## Usage
31
-
32
- Add this to your `.fitting.yml`:
33
-
34
- ```yaml
35
- apib_path: /path/to/doc.apib
36
- ```
37
-
38
- And this to your `spec_helper.rb`:
35
+ And next to your `spec_helper.rb`:
39
36
 
40
37
  ```ruby
41
38
  require 'fitting'
@@ -43,304 +40,122 @@ require 'fitting'
43
40
  Fitting.save_test_data
44
41
  ```
45
42
 
46
- The result files will be created in `./fitting_tests/` folder.
47
-
48
- Output example:
49
-
50
- ```json
51
- [
52
- {
53
- "method": "GET",
54
- "path": "/api/v1/book",
55
- "body": {},
56
- "response": {
57
- "status": 200,
58
- "body": {
59
- "title": "The Martian Chronicles"
60
- }
61
- },
62
- "title": "/spec/controllers/api/v1/books_controller_spec.rb:11",
63
- "group": "/spec/controllers/api/v1/books_controller_spec.rb"
64
- },
65
- {
66
- "method": "POST",
67
- "path": "/api/v1/book",
68
- "body": {},
69
- "response": {
70
- "status": 200,
71
- "body": {
72
- "title": "The Old Man and the Sea"
73
- }
74
- },
75
- "title": "/spec/controllers/api/v1/books_controller_spec.rb:22",
76
- "group": "/spec/controllers/api/v1/books_controller_spec.rb"
77
- }
78
- ]
79
- ```
80
-
81
- ## Documentation coverage
82
-
83
- To match routes and validate JSON-schemas run:
84
-
85
- ```bash
86
- rake fitting:documentation_responses[report_size]
87
- ```
88
-
89
- There are four types (or `report_size`) of reports available:
90
-
91
- - `xs` — the smallest report;
92
- - `s` — includes coverage for `required` fields;
93
- - `m` — includes coverage for `required` and `enum` fields;
94
- - `l` — includes coverage for `required`, `enum` and `oneOf` fields.
95
-
96
- E.g. for `xs` size:
97
-
98
- ```bash
99
- rake fitting:documentation_responses[xs]
100
- ```
101
-
102
- **Note**: In zsh you should add quotes around the task:
103
-
104
- ```bash
105
- rake 'fitting:documentation_responses[xs]'
106
- ```
107
-
108
- Also you can use `documentation_responses_error` to get more detailed errors description.
109
- Check the examples below.
110
-
111
- ### Examples
112
-
113
- `xs` size:
114
-
115
- ```text
116
- Fully conforming requests:
117
- DELETE /api/v1/book ✔ 200 ✔ 201 ✔ 404
118
- DELETE /api/v1/book/{id} ✔ 200 ✔ 201 ✔ 404
119
- GET /api/v1/book/{id}/seller ✔ 200 ✔ 201 ✔ 404
120
-
121
- Partially conforming requests:
122
- GET /api/v1/book ✖ 200 ✔ 404
123
- POST /api/v1/book ✖ 200 ✔ 201 ✔ 404
124
- GET /api/v1/book/{id} ✖ 200 ✔ 404 ✔ 200
125
- PATCH /api/v1/book/{id} ✖ 200 ✔ 201 ✔ 404
126
-
127
- Non-conforming requests:
128
- GET /api/v1/seller ✖ 200 ✖ 201 ✖ 404
129
- GET /api/v1/buyer ✖ 200 ✖ 404
130
-
131
- API requests with fully implemented responses: 3 (33.33% of 9).
132
- API requests with partially implemented responses: 4 (44.44% of 9).
133
- API requests with no implemented responses: 2 (22.22% of 9).
134
-
135
- API responses conforming to the blueprint: 16 (64.00% of 25).
136
- API responses with validation errors or untested: 9 (36.00% of 25).
137
- ```
138
-
139
- `s` size:
140
-
141
- ```text
142
- Fully conforming requests:
143
- DELETE /api/v1/book 100% 200 100% 201 100% 404
144
- DELETE /api/v1/book/{id} 100% 200 100% 201 100% 404
145
- GET /api/v1/book/{id}/seller 100% 200 100% 201 100% 404
146
-
147
- Partially conforming requests:
148
- GET /api/v1/book 0% 200 66% 404
149
- POST /api/v1/book 0% 200 90% 201 100% 404
150
- GET /api/v1/book/{id} 0% 200 88% 404 10% 200
151
- PATCH /api/v1/book/{id} 0% 200 100% 201 10% 404
152
-
153
- Non-conforming requests:
154
- GET /api/v1/seller 0% 200 0% 201 0 404
155
- GET /api/v1/buyer 0% 200 0% 404
156
-
157
- API requests with fully implemented responses: 3 (33.33% of 9).
158
- API requests with partially implemented responses: 4 (44.44% of 9).
159
- API requests with no implemented responses: 2 (22.22% of 9).
160
-
161
- API responses conforming to the blueprint: 16 (64.00% of 25).
162
- API responses with validation errors or untested: 9 (36.00% of 25).
163
- ```
43
+ Add this to your `.fitting.yml`:
164
44
 
165
- `documentation_responses_error[s]` example:
45
+ ### OpenAPI 2.0
46
+ Also Swagger
166
47
 
48
+ ```yaml
49
+ prefixes:
50
+ - name: /api/v1
51
+ openapi2_json_path: doc.json
167
52
  ```
168
- request method: GET
169
- request path: /api/v1/book
170
- response status: 200
171
- source json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
172
- combination: ["required", "pages"]
173
- new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
174
- ```
175
-
176
- ### Experimental report
177
53
 
178
- This report will be available and properly documented in the next major update, but you already can try it by running:
54
+ ### OpenAPI 3.0
55
+ Also OpenAPI
179
56
 
180
- ```bash
181
- bundle e rake fitting:report
57
+ ```yaml
58
+ prefixes:
59
+ - name: /api/v1
60
+ openapi3_yaml_path: doc.yaml
182
61
  ```
183
62
 
184
- Using this you can document API prefixes.
185
- The task will create JSON (`fitting/report.json`) and HTML (`fitting/index.html`) reports.
186
-
187
- ## Tests coverage
63
+ ### API Blueprint
64
+ First you need to install [drafter](https://github.com/apiaryio/drafter).
65
+ Works after conversion from API Blueprint to API Elements (in YAML file) with Drafter.
188
66
 
189
- Only `xs` size is available for tests coverage:
67
+ That is, I mean that you first need to do this
190
68
 
191
69
  ```bash
192
- rake fitting:tests_responses[xs]
70
+ drafter doc.apib -o doc.yaml
193
71
  ```
194
72
 
195
- ## Config
196
-
197
- You can specify the settings either in a YAML file `.fitting.yml` or in a config.
198
- If your project uses several prefixes, for each one you should create a separate YAML file in the folder `fitting` (`fitting/*.yml`).
199
-
200
- All the available config options are described below.
201
-
202
- ### `apib_path`
203
-
204
- Path to API Blueprint v3 documentation.
205
- There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
206
-
207
- ### `drafter_yaml_path`
208
-
209
- Path to API Blueprint v3 documentation, pre-parsed with `drafter` and saved to a YAML file.
210
-
211
- ### `drafter_4_apib_path`
212
-
213
- Path to API Blueprint v4 documentation.
214
- There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
215
-
216
- ### `drafter_4_yaml_path`
217
-
218
- Path to API Blueprint v4 documentation, pre-parsed with `drafter` and saved to a YAML file.
219
-
220
- ### `crafter_apib_path`
221
-
222
- Path to API Blueprint v4 documentation.
223
-
224
- ### `crafter_yaml_path`
225
-
226
- Path to API Blueprint v4 documentation, pre-parsed with `crafter` and saved to a YAML file.
227
-
228
- ### `tomogram_json_path`
229
-
230
- Path to Tomogram documentation, pre-parsed with [tomograph](https://github.com/funbox/tomograph) and saved to a JSON file.
231
-
232
- ### `strict`
233
-
234
- Default: `false`
235
-
236
- When `true` all properties are considered to have `"required": true` and all objects are considered to have `"additionalProperties": false`.
237
-
238
- ### `prefix`
239
-
240
- Prefix for API requests. E.g. `'/api'`. Validation will not be performed if the request path does not start with a prefix.
241
-
242
- ### `white_list`
243
-
244
- Default: all paths
245
-
246
- This is an array of paths that are mandatory for implementation.
247
- The list does not affect the work of the matcher.
248
- It's used for the CLI report only.
73
+ and then
249
74
 
250
75
  ```yaml
251
- white_list:
252
- /users:
253
- - DELETE
254
- - POST
255
- /users/{id}:
256
- - GET
257
- - PATCH
258
- /users/{id}/employees:
259
- - GET
260
- /sessions: []
76
+ prefixes:
77
+ - name: /api/v1
78
+ drafter_yaml_path: doc.yaml
261
79
  ```
262
80
 
263
- Empty array (`[]`) means all methods.
81
+ ### Tomograph
264
82
 
265
- ### `resource_white_list`
266
-
267
- Default: all resources
268
-
269
- This is an array of resources that are mandatory for implementation.
270
- The list does not affect the work of the matcher.
271
- It's used for the CLI report only.
83
+ To use additional features of the pre-converted [tomograph](https://github.com/funbox/tomograph)
272
84
 
273
85
  ```yaml
274
- resource_white_list:
275
- /users:
276
- - DELETE /users/{id}
277
- - POST /users
278
- - GET /users/{id}
279
- - PATCH /users/{id}
280
- /users/{id}/employees:
281
- - GET /users/{id}/employees
282
- /sessions: []
86
+ prefixes:
87
+ - name: /api/v1
88
+ tomogram_json_path: doc.json
283
89
  ```
284
90
 
285
- Empty array (`[]`) means all methods.
286
-
287
- ### `json_schema_cover`
288
-
289
- Default: false
290
-
291
- JSON-schema covering becomes mandatory.
292
- However, if you don't use `Fitting.statistics` you can call `responses.statistics.cover_save`.
293
-
294
- ### `include_resources`
295
-
296
- Default: all resources (but only when `include_resources` and `include_actions` are not defined)
297
-
298
- This is an array of resources that are mandatory for implementation.
299
- The list does not affect the work of the matcher.
300
- It's used for the CLI report only.
301
-
302
- ```yaml
303
- include_resources:
304
- - /sessions
91
+ ## Run
92
+ Run tests first to get run artifacts
93
+ ```bash
94
+ bundle e rspec
305
95
  ```
306
96
 
307
- ### `include_actions`
308
-
309
- Default: all paths (but only when `include_resources` and `include_actions` are not defined)
310
-
311
- This is an array of paths that are mandatory for implementation.
312
- The list does not affect the work of the matcher.
313
- It's used for the CLI report only.
314
-
315
- ```yaml
316
- include_actions:
317
- - DELETE /users/{id}
318
- - POST /users
319
- - GET /users/{id}
320
- - PATCH /users/{id}
321
- - GET /users/{id}/employees
97
+ and then
98
+ ```bash
99
+ bundle e rake fitting:report
322
100
  ```
323
101
 
324
- ### `ignore_list`
102
+ Console ouptut
325
103
 
326
- You can use ignore list to omit checks with matchers.
104
+ ```text
105
+ /api/v1
106
+ POST /api/v1/accounts/{account_id}/inboxes 0% 200 0% 404 0% 403
107
+ PATCH /api/v1/accounts/{account_id}/inboxes/{id} 0% 200 0% 404 0% 403
108
+ POST /api/v1/accounts/{account_id}/inboxes/{id}/set_agent_bot 0% 204 100% 404 0% 403
109
+ GET /api/v1/agent_bots 0% 200 0% 404 0% 403
110
+ GET /api/v1/accounts/{account_id}/conversations 0% 200 0% 400 0% description
111
+ POST /api/v1/accounts/{account_id}/conversations 0% 200 0% 403
112
+ GET /api/v1/accounts/{account_id}/conversations/{id} 59% 200 0% 404 0% 403
113
+ POST /api/v1/accounts/{account_id}/conversations/{id}/toggle_status 80% 200 0% 404 0% 403
114
+ GET /api/v1/accounts/{account_id}/conversations/{id}/messages 47% 200 0% 404 0% 403
115
+ POST /api/v1/accounts/{account_id}/conversations/{id}/messages 0% 200 0% 404 0% 403
116
+ GET /api/v1/accounts/{account_id}/conversations/{id}/labels 100% 200 0% 404 0% 403
117
+ POST /api/v1/accounts/{account_id}/conversations/{id}/labels 100% 200 0% 404 0% 403
118
+ POST /api/v1/accounts/{account_id}/conversations/{id}/assignments 77% 200 0% 404 0% 403
119
+ GET /api/v1/accounts/{account_id}/contacts 0% 200 0% 400
120
+ POST /api/v1/accounts/{account_id}/contacts 14% 200 0% 400
121
+ GET /api/v1/accounts/{account_id}/contacts/{id} 14% 200 0% 404 0% 403
122
+ PUT /api/v1/accounts/{account_id}/contacts/{id} 0% 204 0% 404 0% 403
123
+ GET /api/v1/accounts/{account_id}/contacts/{id}/conversations 0% 200 0% 404 0% 403
124
+ GET /api/v1/accounts/{account_id}/contacts/search 0% 200 0% 401
125
+ POST /api/v1/accounts/{account_id}/contacts/{id}/contact_inboxes 0% 200 0% 401 100% 422
126
+ GET /api/v1/profile 88% 200 100% 401
127
+
128
+ tests_without_prefixes: 42
129
+ tests_without_actions: 144
130
+ tests_without_responses: 43
131
+ ```
132
+
133
+ And task will create HTML (`fitting/index.html`) reports.
134
+
135
+ ![exmaple](images/example.png)
136
+
137
+ More information on action coverage
138
+
139
+ ![exmaple2](images/example2.png)
140
+
141
+ ## prefix name
142
+
143
+ Setting the prefix name is optional. For example, you can do this:
327
144
 
328
145
  ```yaml
329
- ignore_list:
330
- - %r{/api/v1/users/[1-9].}
331
- - %r{/api/v1/comments}
146
+ prefixes:
147
+ - openapi2_json_path: doc.json
332
148
  ```
333
149
 
334
- It works only for `match_schema` and **not** for `strictly_match_schema`.
335
-
336
- ### `prefixes`
337
-
338
- Example:
150
+ ## prefix skip
339
151
 
152
+ It is not necessary to immediately describe each prefix in detail, you can only specify its name and skip it until you are ready to documented it
340
153
  ```yaml
341
154
  prefixes:
342
- - name: /api/v1
343
- - name: /api/v2
155
+ - name: /api/v1
156
+ openapi2_json_path: doc.json
157
+ - name: /api/v3
158
+ skip: true
344
159
  ```
345
160
 
346
161
  ## Contributing
data/fitting.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'fitting/version'
4
4
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['d.efimov']
9
9
  spec.email = ['d.efimov@fun-box.ru']
10
10
 
11
- spec.summary = 'Validation in the rspec of API Blueprint'
12
- spec.description = 'Validation responses in the rspec with the help of API Blueprint'
11
+ spec.summary = 'Coverage API Blueprint, Swagger and OpenAPI with RSpec'
12
+ spec.description = 'Coverage API Blueprint, Swagger and OpenAPI with RSpec for easily make high-quality API and documenatiton'
13
13
  spec.homepage = 'https://github.com/funbox/fitting'
14
14
  spec.license = 'MIT'
15
15
 
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.required_ruby_version = '>= 2.6.0'
21
22
  spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
22
- spec.add_runtime_dependency 'multi_json', '~> 1.11'
23
- spec.add_runtime_dependency 'tomograph', '~> 3.0', '>= 3.0.0'
23
+ spec.add_runtime_dependency 'tomograph', '~> 3.1', '>= 3.1.0'
24
24
  spec.add_development_dependency 'bundler', '~> 2.0'
25
- spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.1'
26
- spec.add_development_dependency 'rake', '>= 12.3.3'
27
- spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
28
- spec.add_development_dependency 'rubocop', '~> 0.49.1', '>= 0.49.1'
29
- spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
25
+ spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
26
+ spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
27
+ spec.add_development_dependency 'rspec', '~> 3.10'
28
+ spec.add_development_dependency 'rubocop', '~> 1.22.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.21'
30
30
  end
Binary file
Binary file
data/images/logo.png ADDED
Binary file
@@ -36,11 +36,12 @@ module Fitting
36
36
  drafter_4_apib_path: @drafter_4_apib_path,
37
37
  drafter_4_yaml_path: @drafter_4_yaml_path
38
38
  )
39
- else Tomograph::Tomogram.new(
40
- prefix: @prefix,
41
- apib_path: @apib_path,
42
- drafter_yaml_path: @drafter_yaml_path
43
- )
39
+ else
40
+ Tomograph::Tomogram.new(
41
+ prefix: @prefix,
42
+ apib_path: @apib_path,
43
+ drafter_yaml_path: @drafter_yaml_path
44
+ )
44
45
  end
45
46
  end
46
47
 
@@ -43,13 +43,13 @@ module Fitting
43
43
  Tomograph::Tomogram.new(
44
44
  prefix: @prefix,
45
45
  crafter_apib_path: @crafter_apib_path,
46
- crafter_yaml_path: @crafter_yaml_path,
46
+ crafter_yaml_path: @crafter_yaml_path
47
47
  )
48
48
  elsif @drafter_4_apib_path || @drafter_4_yaml_path
49
49
  Tomograph::Tomogram.new(
50
50
  prefix: @prefix,
51
51
  drafter_4_apib_path: @drafter_4_apib_path,
52
- drafter_4_yaml_path: @drafter_4_yaml_path,
52
+ drafter_4_yaml_path: @drafter_4_yaml_path
53
53
  )
54
54
  else
55
55
  Tomograph::Tomogram.new(
@@ -15,17 +15,18 @@ module Fitting
15
15
 
16
16
  def inception(json_schema, combinations)
17
17
  json_schema.each do |key, value|
18
- if key == 'properties' and json_schema['required'] != value.keys
18
+ if (key == 'properties') && (json_schema['required'] != value.keys)
19
19
  schema = json_schema.dup
20
20
  one_of = schema.delete('required') || []
21
21
  schema['properties'].each_key do |property|
22
22
  next if one_of.include?(property)
23
+
23
24
  combinations.push([schema.merge('required' => one_of + [property]), "required.#{property}"])
24
25
  end
25
26
  elsif value.is_a?(Hash)
26
27
  com = inception(value, [])
27
28
  com.each do |combination|
28
- combination[0] = { key => value.merge(combination[0])}
29
+ combination[0] = { key => value.merge(combination[0]) }
29
30
  combination[1] = "#{key}.#{combination[1]}"
30
31
  end
31
32
  combinations += com
@@ -24,7 +24,7 @@ module Fitting
24
24
  elsif value.is_a?(Hash)
25
25
  com = inception(value, [])
26
26
  com.each do |combination|
27
- combination[0] = { key => value.merge(combination[0])}
27
+ combination[0] = { key => value.merge(combination[0]) }
28
28
  combination[1] = "#{key}.#{combination[1]}"
29
29
  end
30
30
  combinations += com
@@ -24,7 +24,7 @@ module Fitting
24
24
  elsif value.is_a?(Hash)
25
25
  com = inception(value, [])
26
26
  com.each do |combination|
27
- combination[0] = { key => value.merge(combination[0])}
27
+ combination[0] = { key => value.merge(combination[0]) }
28
28
  combination[1] = "#{key}.#{combination[1]}"
29
29
  end
30
30
  combinations += com
@@ -13,11 +13,7 @@ module Fitting
13
13
  end
14
14
  end
15
15
 
16
- attr_reader :json_schemas
17
-
18
- attr_reader :combinations
19
-
20
- attr_reader :flags
16
+ attr_reader :json_schemas, :combinations, :flags
21
17
 
22
18
  def update(response)
23
19
  index = 0