grape-swagger-entity 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 05c52de504600d57fb8bb41dff26265beb90d32e
4
- data.tar.gz: 6b829aae12775c2f27521cf08be88f56298158d5
2
+ SHA256:
3
+ metadata.gz: 41afe8433047f9b998351967b5e2ecf4809413c1f622125c70b860c5bbf11a43
4
+ data.tar.gz: 60e644e6a03258aa4284c348cd486b49027f21558c52805f49a8b08316d5d6bb
5
5
  SHA512:
6
- metadata.gz: 9dc4d2973ef5f678eddce41c1c5a393f26267cf177b6f2973fd804d278adaa0c5c065cd4ac7b5a8006d561a896350064f96f10043f144071d51e1b402279dcc9
7
- data.tar.gz: a5b0c18af91a1c16c6f8c2d834950dcc82885e375c29b3b6c3547d7481718c31b59fb157aa233e0a49ad6eb9e292001c6a241e2a1e933e092ea872120dd1f16d
6
+ metadata.gz: b16ce2ac2fe5e37c7d67cb5113a0870bcd43dc7addc92b54d983cd8e7f6bb599ea7ab3b13f251eac92d2039ecc120a641eab6b18a256294550f26812247b3e12
7
+ data.tar.gz: f28eb0a4058f2e007e72acdc38746fa0c8cd72bd46927a1f9519a351c45c9a81124aede349a2780faed8619a0bc1cb95b9be720a2fe782b571fb827380c473dc
data/.rubocop.yml CHANGED
@@ -18,8 +18,8 @@ Metrics/MethodLength:
18
18
  Exclude:
19
19
  - spec/**/*
20
20
 
21
- Style/FileName:
21
+ Naming/FileName:
22
22
  Enabled: false
23
23
 
24
- Style/IndentHash:
24
+ Layout/IndentHash:
25
25
  EnforcedStyle: consistent
data/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  * Your contribution here.
10
10
 
11
+ ### 0.3.1 (November 26, 2018)
12
+
13
+ #### Features
14
+
15
+ * [#37](https://github.com/ruby-grape/grape-swagger-entity/pull/37): Add support for minItems, maxItems and uniqueItems - [@fotos](https://github.com/fotos).
16
+
11
17
  ### 0.3.0 (August 22, 2018)
12
18
 
13
19
  #### Features
@@ -13,7 +13,13 @@ module GrapeSwagger
13
13
 
14
14
  if entity_model
15
15
  name = endpoint.nil? ? entity_model.to_s.demodulize : endpoint.send(:expose_params_from_model, entity_model)
16
- return entity_model_type(name, entity_options)
16
+
17
+ entity_model_type = entity_model_type(name, entity_options)
18
+ return entity_model_type unless documentation
19
+
20
+ add_array_documentation(entity_model_type, documentation) if documentation[:is_array]
21
+
22
+ entity_model_type
17
23
  else
18
24
  param = data_type_from(entity_options)
19
25
  return param unless documentation
@@ -25,7 +31,11 @@ module GrapeSwagger
25
31
  param[:enum] = values if values.is_a?(Array)
26
32
  end
27
33
 
28
- param = { type: :array, items: param } if documentation[:is_array]
34
+ if documentation[:is_array]
35
+ param = { type: :array, items: param }
36
+ add_array_documentation(param, documentation)
37
+ end
38
+
29
39
  param
30
40
  end
31
41
  end
@@ -42,6 +52,7 @@ module GrapeSwagger
42
52
 
43
53
  def could_it_be_a_model?(value)
44
54
  return false if value.nil?
55
+
45
56
  direct_model_type?(value[:type]) || ambiguous_model_type?(value[:type])
46
57
  end
47
58
 
@@ -94,8 +105,15 @@ module GrapeSwagger
94
105
 
95
106
  def add_attribute_example(attribute, example)
96
107
  return unless example
108
+
97
109
  attribute[:example] = example.is_a?(Proc) ? example.call : example
98
110
  end
111
+
112
+ def add_array_documentation(param, documentation)
113
+ param[:minItems] = documentation[:min_items] if documentation.key?(:min_items)
114
+ param[:maxItems] = documentation[:max_items] if documentation.key?(:max_items)
115
+ param[:uniqueItems] = documentation[:unique_items] if documentation.key?(:unique_items)
116
+ end
99
117
  end
100
118
  end
101
119
  end
@@ -46,6 +46,7 @@ module GrapeSwagger
46
46
  end
47
47
 
48
48
  next unless documentation
49
+
49
50
  memo[final_entity_name][:readOnly] = documentation[:read_only].to_s == 'true' if documentation[:read_only]
50
51
  memo[final_entity_name][:description] = documentation[:desc] if documentation[:desc]
51
52
  end
@@ -92,6 +93,7 @@ module GrapeSwagger
92
93
 
93
94
  def with_required(hash, required)
94
95
  return hash if required.empty?
96
+
95
97
  hash[:required] = required
96
98
  hash
97
99
  end
@@ -1,5 +1,5 @@
1
1
  module GrapeSwagger
2
2
  module Entity
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger-entity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Zaitsev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-22 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape-entity
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project:
87
- rubygems_version: 2.5.2
87
+ rubygems_version: 2.7.6
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Grape swagger adapter to support grape-entity object parsing