fitting 2.12.0 → 2.12.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 +4 -4
- data/.gitignore +0 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +14 -2
- data/lib/fitting/cover/json_schema_one_of.rb +20 -14
- data/lib/fitting/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1415f580792a267f0db27df63a8ef8334d0cd0cc
|
4
|
+
data.tar.gz: 4e5868e53b370121ab7cfad0e1762d014b4f310d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f93db3c0f9c83d2ec34b84ab4d3e91e8b5d06ba988bc5f4d40eb9c2e63664a30589857909c054e4d19b3099ca223403df2cd8026856a25360dae4ab050cf4dce
|
7
|
+
data.tar.gz: 81ce958a9daed16da84fea079964caf4b7e396bb473a5d89f856f6ff9a453e398b742aedd667a1dbaebb56a71347b3056d3b61f4b188b32615e1050dfb75e3c3
|
data/.gitignore
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.2.0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,9 @@ To do this, when you run your RSpec tests on controllers, it automatically searc
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
|
15
|
+
First you need to install [drafter](https://github.com/apiaryio/drafter).
|
16
|
+
|
17
|
+
Second add this line to your application's Gemfile:
|
16
18
|
|
17
19
|
```ruby
|
18
20
|
gem 'fitting'
|
@@ -82,7 +84,17 @@ Example:
|
|
82
84
|
|
83
85
|
### xs size
|
84
86
|
|
85
|
-
For match routes and valid json-schemas run
|
87
|
+
For match routes and valid json-schemas run
|
88
|
+
|
89
|
+
for bash
|
90
|
+
```
|
91
|
+
rake fitting:documentation_responses[xs]
|
92
|
+
```
|
93
|
+
|
94
|
+
for zsh
|
95
|
+
```
|
96
|
+
rake 'fitting:documentation_responses[xs]'
|
97
|
+
```
|
86
98
|
|
87
99
|
You will get statistics:
|
88
100
|
|
@@ -3,27 +3,33 @@ module Fitting
|
|
3
3
|
class JSONSchemaOneOf
|
4
4
|
def initialize(json_schema)
|
5
5
|
@json_schema = json_schema
|
6
|
+
@combinations = []
|
6
7
|
end
|
7
8
|
|
8
9
|
def combi
|
9
|
-
@combinations
|
10
|
-
|
11
|
-
|
10
|
+
inception(@json_schema, @combinations).each do |combination|
|
11
|
+
combination[0] = @json_schema.merge(combination[0])
|
12
|
+
combination[1] = ['one_of', combination[1]]
|
13
|
+
end
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def inception(json_schema, combinations)
|
17
|
+
json_schema.each do |key, value|
|
18
|
+
if key == 'oneOf'
|
19
|
+
one_of = json_schema.delete('oneOf')
|
20
|
+
one_of.each_index do |index|
|
21
|
+
combinations.push([json_schema.merge('oneOf' => [one_of[index]]), "oneOf.#{index}"])
|
22
|
+
end
|
23
|
+
elsif value.is_a?(Hash)
|
24
|
+
inception(value, combinations)
|
25
|
+
combinations.each do |combination|
|
26
|
+
combination[0] = { key => combination[0]}
|
27
|
+
combination[1] = "#{key}.#{combination[1]}"
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
26
|
-
|
32
|
+
combinations
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
data/lib/fitting/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.12.
|
4
|
+
version: 2.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- d.efimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- ".gitignore"
|
183
183
|
- ".rubocop.yml"
|
184
184
|
- ".ruby-version"
|
185
|
+
- ".tool-versions"
|
185
186
|
- ".travis.yml"
|
186
187
|
- CHANGELOG.md
|
187
188
|
- CODE_OF_CONDUCT.md
|