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 +4 -4
- data/acts_as_doc.gemspec +1 -1
- data/lib/acts_as_doc/response_parser.rb +14 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c243f846a2897ead10b45a8db6a13480799563f5f4a204077b937cb96f830305
|
4
|
+
data.tar.gz: 815d8ca1a8ec5fef03970a566552034b5f160026bc3e06307dbfa486d47d1808
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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-
|
56
|
+
if klass && (matches = desc.match(/^\(([a-z,\s_A-Z]+)\)$/))
|
54
57
|
columns = Object.const_get(klass).columns.map do |column|
|
55
|
-
|
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'
|