fitting 2.12.0 → 2.12.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
2
  SHA1:
3
- metadata.gz: 8234af5ba817adef5ce3ff1bf03d4e84c7747169
4
- data.tar.gz: c8a247c8467765022ef0f5f2c7b58b669464cdaf
3
+ metadata.gz: 1415f580792a267f0db27df63a8ef8334d0cd0cc
4
+ data.tar.gz: 4e5868e53b370121ab7cfad0e1762d014b4f310d
5
5
  SHA512:
6
- metadata.gz: 00863f51cc9692a16ce6cb24aaf83309c4490daac1430081e45081e3c5d24dfe6dba0e17b1df659f3ee84a0b1e49ecaa8c76a1ef5bfc301a70752db6beeafe18
7
- data.tar.gz: fda881919cf0c1bef0ed9228a8d450e866e234da599822f843bed76a146b02ebc143d85d87bda60c294603066a98c4179f9e7dc27162f7b91489eb9d9b90563f
6
+ metadata.gz: f93db3c0f9c83d2ec34b84ab4d3e91e8b5d06ba988bc5f4d40eb9c2e63664a30589857909c054e4d19b3099ca223403df2cd8026856a25360dae4ab050cf4dce
7
+ data.tar.gz: 81ce958a9daed16da84fea079964caf4b7e396bb473a5d89f856f6ff9a453e398b742aedd667a1dbaebb56a71347b3056d3b61f4b188b32615e1050dfb75e3c3
data/.gitignore CHANGED
@@ -9,4 +9,3 @@
9
9
  /tmp/
10
10
  .idea/
11
11
  .byebug_history
12
- .tool-versions
@@ -0,0 +1 @@
1
+ ruby 2.2.0
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ### 2.12.1 - 2020-02-07
4
+
5
+ * fixes
6
+ * oneOf
7
+
3
8
  ### 2.12.0 - 2019-09-10
4
9
 
5
10
  * features
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
- Add this line to your application's Gemfile:
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 `rake fitting:documentation_responses[xs]`
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
- return @combinations unless @json_schema['oneOf'] || @json_schema['allOf']
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
- if @json_schema['oneOf']
14
- one_of = @json_schema.delete("oneOf")
15
- one_of.each_index do |index|
16
- @combinations.push([@json_schema.merge(one_of[index]), ['one_of', "properties.#{index}"]])
17
- end
18
- elsif @json_schema['allOf']
19
- all_of = @json_schema.delete("allOf")
20
- one_of = all_of[0].delete("oneOf")
21
- one_of.each_index do |index|
22
- @combinations.push([@json_schema.merge(one_of[index]), ['one_of', "properties.#{index}"]])
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
- @combinations
32
+ combinations
27
33
  end
28
34
  end
29
35
  end
@@ -1,3 +1,3 @@
1
1
  module Fitting
2
- VERSION = '2.12.0'.freeze
2
+ VERSION = '2.12.1'.freeze
3
3
  end
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.0
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: 2019-09-09 00:00:00.000000000 Z
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