acts_as_doc 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84a468753835af1c1f73d8edf468234bd164283c67b18a0f1a4281bea905fc86
4
- data.tar.gz: 498222082962d5a7376994cdde490ea64d03440a1a1487b568a9fc9cad6c0d38
3
+ metadata.gz: c243f846a2897ead10b45a8db6a13480799563f5f4a204077b937cb96f830305
4
+ data.tar.gz: 815d8ca1a8ec5fef03970a566552034b5f160026bc3e06307dbfa486d47d1808
5
5
  SHA512:
6
- metadata.gz: 7965992ef4dc0b7464b1742a261a668d1793343bee96d876d3b9771328d54dc97740db4df2fafe9f2b8848c2eed7e45d931503e6c19a896a846cbfc5cb2e4e16
7
- data.tar.gz: 951e8fc0ac3c327979e8bf2d53c32dcaef6fda75aafb3b7e4e2815695ff72261feda7234ec64f40ee99234156194f5a1973cb8cd141dcdc4879c69cec0d06821
6
+ metadata.gz: 70327eca03665679438dd48e9e2f9f17b506b0a4448b50997a6e3e3d06b130c575987390504a302306cc13887a85a4a4077f39eba41bd79ad83d79b6281b2b4a
7
+ data.tar.gz: 8d5d2f27ffffdbe9b6519852fa3fa0995f62e64dcd114ff713e365f5ff8d57cb82f5b92a406170e9e545bb1272ec4277bada09e9be5898cd5373eb39d7cc4225
data/acts_as_doc.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # rubocop:disable all
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "acts_as_doc"
4
- s.version = "1.1.0"
4
+ s.version = "1.1.2"
5
5
  s.summary = "Generate swagger response doc"
6
6
  s.description = "Add swagger comment to any ruby file for generating swagger response doc struct"
7
7
  s.authors = ["alex.zang"]
@@ -24,7 +24,10 @@ module ActsAsDoc
24
24
  geography: 'string',
25
25
  json: 'object',
26
26
  jsonb: 'object',
27
- array: 'array'
27
+ array: 'array',
28
+ datetime: 'string',
29
+ date: 'string',
30
+ boolean: 'boolean'
28
31
  }.freeze
29
32
 
30
33
  # 处理注释
@@ -50,12 +53,18 @@ module ActsAsDoc
50
53
  hash[name] = {} unless hash.key?(name)
51
54
 
52
55
  if arr.empty?
53
- if klass && (matches = desc.match(/^\(([a-zA-Z]+)\)$/))
56
+ if klass && (matches = desc.match(/^\(([a-z,\s_A-Z]+)\)$/))
54
57
  columns = Object.const_get(klass).columns.map do |column|
55
- [ column.name.to_s, [TYPE_MAPPER[column.type], column.comment] ]
58
+ column_type = if column.respond_to?(:array?) && column.array?
59
+ 'array'
60
+ else
61
+ TYPE_MAPPER[column.type]
62
+ end
63
+ [ column.name.to_s, [column_type, column.comment] ]
56
64
  end.to_h
57
65
 
58
66
  matches[1].split(',').each do |attr_name|
67
+ attr_name.strip!
59
68
  c_type, c_desc = columns[attr_name]
60
69
  self.props_recursion!(hash, "$#{name}.#{attr_name}", c_type, c_desc)
61
70
  end
@@ -86,10 +95,10 @@ module ActsAsDoc
86
95
  if tag == '@prop'
87
96
  desc = arr[3..] ? arr[3..].join(' ') : ''
88
97
 
89
- matches = type.match(/\[(?<type>[a-zA-Z<>]+)\]/)
98
+ matches = type.match(/\[(?<type>[a-zA-Z<>:]+)\]/)
90
99
  type = matches ? matches[:type] : 'string'
91
100
 
92
- klass_matches = type.match(/(?<type>[a-zA-Z]+)<(?<klass>[a-zA-Z]+)>/)
101
+ klass_matches = type.match(/(?<type>[a-zA-Z]+)<(?<klass>[a-zA-Z:]+)>/)
93
102
  klass = nil
94
103
  if klass_matches
95
104
  type = SUPPORT_TYPES.include?(klass_matches[:type]) ? klass_matches[:type] : 'string'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - alex.zang