grape-swagger-representable 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -7
- data/README.md +1 -1
- data/grape-swagger-representable.gemspec +1 -1
- data/lib/grape-swagger/representable/parser.rb +12 -11
- data/lib/grape-swagger/representable/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7283878859bdf4efc4eaf2a05f148a00d96359f
|
4
|
+
data.tar.gz: ce3cc382572534160da8b25c31576f2a71ed25e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c0676215a1460294fd72349fc0f169c37723b402998a44f61c7cc7fe1312fe2ff850e0138cd5547627ecccd0b342d2ee15455ad057b6f17cf23bb41df9d7b1
|
7
|
+
data.tar.gz: c07328b18c497f3ecef7d4aeef82e08444cb4568d63c99e31453f395f303560a69bd640424889a29899890c48662af0abbb2e9c7cc3fc46108ca73d3b9cfac02
|
data/.travis.yml
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
-
|
1
|
+
before_install:
|
2
|
+
- gem update --system
|
3
|
+
- gem install bundler
|
2
4
|
|
3
|
-
|
5
|
+
rvm:
|
6
|
+
- 2.4.0
|
7
|
+
- 2.3.3
|
8
|
+
- 2.2.6
|
4
9
|
|
5
10
|
matrix:
|
11
|
+
fast_finish: true
|
12
|
+
|
6
13
|
include:
|
7
|
-
- rvm: 2.3.0
|
8
|
-
- rvm: 2.2
|
9
|
-
- rvm: 2.1
|
10
14
|
- rvm: ruby-head
|
11
15
|
- rvm: jruby-head
|
12
|
-
- rvm: jruby-19mode
|
13
16
|
- rvm: rbx-2
|
17
|
+
|
14
18
|
allow_failures:
|
15
19
|
- rvm: ruby-head
|
16
20
|
- rvm: jruby-head
|
17
|
-
|
21
|
+
- rvm: rbx-2
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# GrapeSwagger::Representable [![Build Status](https://travis-ci.org/
|
1
|
+
# GrapeSwagger::Representable [![Build Status](https://travis-ci.org/ruby-grape/grape-swagger-representable.svg)](https://travis-ci.org/ruby-grape/grape-swagger-representable)
|
2
2
|
|
3
3
|
A simple grape-swagger adapter to allow parse representers as response model
|
4
4
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_runtime_dependency 'grape-swagger', '>= 0.20.
|
21
|
+
s.add_runtime_dependency 'grape-swagger', '>= 0.20.4'
|
22
22
|
s.add_runtime_dependency 'representable'
|
23
23
|
|
24
24
|
s.add_development_dependency 'bundler', '~> 1.12'
|
@@ -20,17 +20,17 @@ module GrapeSwagger
|
|
20
20
|
documentation = property[:documentation] ? property[:documentation].dup : {}
|
21
21
|
|
22
22
|
if property[:decorator] && property[:nested]
|
23
|
-
representer_mapping(property[:decorator], documentation, is_a_collection, false, property[:nested])
|
23
|
+
representer_mapping(property[:decorator], documentation, property, is_a_collection, false, property[:nested])
|
24
24
|
elsif property[:decorator]
|
25
|
-
representer_mapping(property[:decorator], documentation, is_a_collection, true)
|
25
|
+
representer_mapping(property[:decorator], documentation, property, is_a_collection, true)
|
26
26
|
elsif property[:nested]
|
27
|
-
representer_mapping(property[:nested], documentation, is_a_collection)
|
27
|
+
representer_mapping(property[:nested], documentation, property, is_a_collection)
|
28
28
|
else
|
29
29
|
memo = {
|
30
|
-
description: documentation[:desc] || ''
|
30
|
+
description: documentation[:desc] || property[:desc] || ''
|
31
31
|
}
|
32
32
|
|
33
|
-
data_type = GrapeSwagger::DocMethods::DataType.call(documentation[:type])
|
33
|
+
data_type = GrapeSwagger::DocMethods::DataType.call(documentation[:type] || property[:type])
|
34
34
|
if GrapeSwagger::DocMethods::DataType.primitive?(data_type)
|
35
35
|
data = GrapeSwagger::DocMethods::DataType.mapping(data_type)
|
36
36
|
memo[:type] = data.first
|
@@ -39,7 +39,8 @@ module GrapeSwagger
|
|
39
39
|
memo[:type] = data_type
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
values = documentation[:values] || property[:values] || nil
|
43
|
+
memo[:enum] = values if values.is_a?(Array)
|
43
44
|
|
44
45
|
if is_a_collection || documentation[:is_array]
|
45
46
|
memo = {
|
@@ -52,7 +53,7 @@ module GrapeSwagger
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
def representer_mapping(representer, documentation, is_a_collection = false, is_a_decorator = false, nested = nil)
|
56
|
+
def representer_mapping(representer, documentation, property, is_a_collection = false, is_a_decorator = false, nested = nil)
|
56
57
|
if nested.nil? && is_a_decorator
|
57
58
|
name = endpoint.send(:expose_params_from_model, representer)
|
58
59
|
|
@@ -62,12 +63,12 @@ module GrapeSwagger
|
|
62
63
|
items: {
|
63
64
|
'$ref' => "#/definitions/#{name}"
|
64
65
|
},
|
65
|
-
description: documentation[:desc] || ''
|
66
|
+
description: documentation[:desc] || property[:desc] || ''
|
66
67
|
}
|
67
68
|
else
|
68
69
|
{
|
69
70
|
'$ref' => "#/definitions/#{name}",
|
70
|
-
description: documentation[:desc] || ''
|
71
|
+
description: documentation[:desc] || property[:desc] || ''
|
71
72
|
}
|
72
73
|
end
|
73
74
|
else
|
@@ -81,13 +82,13 @@ module GrapeSwagger
|
|
81
82
|
type: :object,
|
82
83
|
properties: attributes
|
83
84
|
},
|
84
|
-
description: documentation[:desc] || ''
|
85
|
+
description: documentation[:desc] || property[:desc] || ''
|
85
86
|
}
|
86
87
|
else
|
87
88
|
{
|
88
89
|
type: :object,
|
89
90
|
properties: attributes,
|
90
|
-
description: documentation[:desc] || ''
|
91
|
+
description: documentation[:desc] || property[:desc] || ''
|
91
92
|
}
|
92
93
|
end
|
93
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger-representable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Zaitsev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape-swagger
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.20.
|
19
|
+
version: 0.20.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.20.
|
26
|
+
version: 0.20.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: representable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|