swagger_model 0.4.0 → 0.4.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
2
  SHA1:
3
- metadata.gz: 7f7c65359fa58890e69ebd599e538474dfaae1ac
4
- data.tar.gz: 0635b5d20453ea7cb40225142af9a7bd6e611f5d
3
+ metadata.gz: 39600c03ec1cbf1c82ed82ef2056ce4c21a1d09f
4
+ data.tar.gz: eb62ca3794c6b02ed163ad3d5a186360516c6127
5
5
  SHA512:
6
- metadata.gz: 0ee8642f285940a7503b119817dee9bd41f167129f9606228a17467830ab4adcd76f33995b4ea4a241abc93dc79b3a403a32c07390f98a0f4aff0f367eab824b
7
- data.tar.gz: a94348c709d7195b3f1a253fc4135fb829faa11dec6674bc9c9a40ee178804f31ad73aede8e20d5ab3fd170b958452a7a757d6d05b11b44617a34e53dc044c76
6
+ metadata.gz: b440fadc6081cfaa922896accdb1486acbee06d00014bbda75f539b590c3ce1a43acb2a8293284e836d7eaa2f3d3cc394fb3bcf42eab9079cead9425c0591cdd
7
+ data.tar.gz: 6c10cfbc2436ebf3ac80d32cc7436ee27376f8f38a57a4731f0eaf07b5aef0f710a270622d55c184a6b38d6b7fa8f1579a655f9b1474aaf80dc2392f89d89efd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swagger_model (0.4.0)
4
+ swagger_model (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- @relation = Relation.new(array.first)
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
- name = swagger_hash.keys.first
34
- properties[r['key']] = {
35
- '$ref' => "#/definitions/#{name}"
36
- }
37
- model[name] = swagger_hash[name]
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
@@ -1,3 +1,3 @@
1
1
  module SwaggerModel
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - marumemomo