grape-swagger-entity 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +6 -0
- data/lib/grape-swagger/entity/attribute_parser.rb +20 -2
- data/lib/grape-swagger/entity/parser.rb +2 -0
- data/lib/grape-swagger/entity/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 41afe8433047f9b998351967b5e2ecf4809413c1f622125c70b860c5bbf11a43
|
4
|
+
data.tar.gz: 60e644e6a03258aa4284c348cd486b49027f21558c52805f49a8b08316d5d6bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b16ce2ac2fe5e37c7d67cb5113a0870bcd43dc7addc92b54d983cd8e7f6bb599ea7ab3b13f251eac92d2039ecc120a641eab6b18a256294550f26812247b3e12
|
7
|
+
data.tar.gz: f28eb0a4058f2e007e72acdc38746fa0c8cd72bd46927a1f9519a351c45c9a81124aede349a2780faed8619a0bc1cb95b9be720a2fe782b571fb827380c473dc
|
data/.rubocop.yml
CHANGED
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
|
-
|
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
|
-
|
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
|
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.
|
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-
|
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.
|
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
|