swagger_model 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/swagger_model/attributes.rb +2 -2
- data/lib/swagger_model/relation_data_array.rb +7 -1
- data/lib/swagger_model/relationships.rb +7 -5
- data/lib/swagger_model/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39600c03ec1cbf1c82ed82ef2056ce4c21a1d09f
|
4
|
+
data.tar.gz: eb62ca3794c6b02ed163ad3d5a186360516c6127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b440fadc6081cfaa922896accdb1486acbee06d00014bbda75f539b590c3ce1a43acb2a8293284e836d7eaa2f3d3cc394fb3bcf42eab9079cead9425c0591cdd
|
7
|
+
data.tar.gz: 6c10cfbc2436ebf3ac80d32cc7436ee27376f8f38a57a4731f0eaf07b5aef0f710a270622d55c184a6b38d6b7fa8f1579a655f9b1474aaf80dc2392f89d89efd
|
data/Gemfile.lock
CHANGED
@@ -10,7 +10,6 @@ module SwaggerModel
|
|
10
10
|
hash.keys.each do |key|
|
11
11
|
value = hash[key]
|
12
12
|
attribute = get_attribute(value, key)
|
13
|
-
attribute['key'] = key
|
14
13
|
@attributes.push(attribute)
|
15
14
|
end
|
16
15
|
end
|
@@ -90,13 +89,14 @@ module SwaggerModel
|
|
90
89
|
item = value.first
|
91
90
|
attribute = {
|
92
91
|
'type' => 'array',
|
93
|
-
'item' => get_attribute(item)
|
92
|
+
'item' => get_attribute(item, key)
|
94
93
|
}
|
95
94
|
else
|
96
95
|
attribute = {
|
97
96
|
'type' => type
|
98
97
|
}
|
99
98
|
end
|
99
|
+
attribute['key'] = key
|
100
100
|
attribute
|
101
101
|
end
|
102
102
|
def get_type(value)
|
@@ -4,10 +4,16 @@ module SwaggerModel
|
|
4
4
|
module SwaggerV2
|
5
5
|
class RelationDataArray
|
6
6
|
def initialize(array)
|
7
|
-
|
7
|
+
if array.size > 0
|
8
|
+
@relation = Relation.new(array.first)
|
9
|
+
end
|
10
|
+
|
8
11
|
end
|
9
12
|
|
10
13
|
def to_swagger_hash(key, parent_name)
|
14
|
+
if @relation.nil?
|
15
|
+
return nil
|
16
|
+
end
|
11
17
|
name = parent_name + ActiveSupport::Inflector.classify(key.gsub('-', '_')) + 'Data'
|
12
18
|
{
|
13
19
|
name => {
|
@@ -30,11 +30,13 @@ module SwaggerModel
|
|
30
30
|
@relationships.each do |r|
|
31
31
|
parent_name = model_name + 'Relationships'
|
32
32
|
swagger_hash = r['data'].to_swagger_hash(r['key'], parent_name)
|
33
|
-
|
34
|
-
|
35
|
-
'
|
36
|
-
|
37
|
-
|
33
|
+
unless swagger_hash.nil?
|
34
|
+
name = swagger_hash.keys.first
|
35
|
+
properties[r['key']] = {
|
36
|
+
'$ref' => "#/definitions/#{name}"
|
37
|
+
}
|
38
|
+
model[name] = swagger_hash[name]
|
39
|
+
end
|
38
40
|
end
|
39
41
|
hash['properties'] = properties
|
40
42
|
hash['required'] = properties.keys
|