zero-rails_openapi 1.5.9 → 1.6.0

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
  SHA256:
3
- metadata.gz: '08be41261a50ecc6ed82129ba00cfdbd39bfe642db60bb8822891c40592ef26c'
4
- data.tar.gz: 21f231545cb2be40dae468179d1d6a30365a2b8209319a853055122a004ab5f5
3
+ metadata.gz: f02e4f2dff6974c8ea59e4e410e695f27d7395a417612003525ed6fa250c008a
4
+ data.tar.gz: 23e2eb595a89c71e3f417b295d107de43d9cf5e3af917329715d69fe42846a0f
5
5
  SHA512:
6
- metadata.gz: 17041c2c4b9a9eb34475d2d7139f27a5c5871c0f9d713c3c8a4b4cff6be5ad2b348f7b6902cf55b348e5e2742d77a42f75cd12301475753b7519f65ced912c96
7
- data.tar.gz: cf3c94e723cf771173f20ea2b9e1db18bcc0b29b10de9c8ca76ccefe4b1f2f845de444e1effbd0a5eac29db7313030daa85ed05a5082df77c420dd4cf8fc791f
6
+ metadata.gz: de28674280308d143a856a82cdc7fee995b1a506ac4b0342ff9721d3656637f87444c4ff69f4967e8a839e36598797e1559f41a02145c24bce8c823916bc1318
7
+ data.tar.gz: ccea172bdb47b90b97f423ac0d6a744e996de455c6fc1a82cf3ba22a12126978e0ff13278d8737ddc4f699065980fb755c2776bf6f98e695598ac74cba357619
data/CHANGELOG.md CHANGED
@@ -2,15 +2,33 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.6.0] - 2018/6/26 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.9...v1.6.0)
6
+
7
+ ## Changed
8
+
9
+ 1. issue [#21](https://github.com/zhandao/zero-rails_openapi/issues/21) support additionalProperties. Thanks @barnaclebarnes
10
+ 2. issue [#23](https://github.com/zhandao/zero-rails_openapi/issues/23) Uniqueness of operationId. Thanks @barnaclebarnes
11
+
12
+ ## Fixed
13
+
14
+ 1. issue [#22](https://github.com/zhandao/zero-rails_openapi/issues/22) missing `/` in reference. Thanks @barnaclebarnes
15
+
16
+ ## [1.5.8 & 1.5.9] - 2018/6/19 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.7...v1.5.9)
17
+
18
+ ## Changed
19
+
20
+ 1. issue [#17](https://github.com/zhandao/zero-rails_openapi/issues/17) singular example in schema. Thanks @williamdias
21
+ 1. issue [#18](https://github.com/zhandao/zero-rails_openapi/issues/18) define multiple components blocks in one class. Thanks @Amnesthesia
22
+
5
23
  ## [1.5.7] - 2018/4/6 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.6...v1.5.7)
6
24
 
7
25
  ## Changed
8
26
 
9
- 1. issue [#16](https://github.com/zhandao/zero-rails_openapi/issues/16) DSL in `base_doc_class` can not be generated.
27
+ 1. issue [#16](https://github.com/zhandao/zero-rails_openapi/issues/16) DSL in `base_doc_class` can not be generated. Thanks @jonathantribouharet
10
28
 
11
29
  ## Fixed
12
30
 
13
- 1. issue [#15](https://github.com/zhandao/zero-rails_openapi/issues/15) colorize was not required.
31
+ 1. issue [#15](https://github.com/zhandao/zero-rails_openapi/issues/15) colorize was not required. Thanks @jonathantribouharet
14
32
  2. securitySchemes defined by config DSL was not be generated.
15
33
 
16
34
  ## [1.5.6] - 2018/3/23 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.5...v1.5.6)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zero-rails_openapi (1.5.9)
4
+ zero-rails_openapi (1.6.0)
5
5
  activesupport (>= 3)
6
6
  colorize
7
7
  rails (>= 3)
@@ -9,7 +9,7 @@ module OpenApi
9
9
  attr_accessor :processed
10
10
  def initialize(ref_to, component_key)
11
11
  self.processed = {
12
- '$ref': "#components/#{ref_to.to_s.pluralize}/#{component_key}"
12
+ '$ref': "#/components/#{ref_to.to_s.pluralize}/#{component_key}"
13
13
  }
14
14
  end
15
15
 
@@ -22,7 +22,7 @@ module OpenApi
22
22
 
23
23
  def process(options = { inside_desc: false })
24
24
  processed.merge!(processed_type)
25
- reducx(enum_and_length, range, format, pattern_default_and_other, desc(options)).then_merge!
25
+ reducx(additional_properties, enum_and_length, range, format, pattern_default_and_other, desc(options)).then_merge!
26
26
  end
27
27
 
28
28
  def desc(inside_desc:)
@@ -47,11 +47,21 @@ module OpenApi
47
47
  { type: 'string', format: Config.file_format }
48
48
  elsif t == 'datetime'
49
49
  { type: 'string', format: 'date-time' }
50
+ elsif t.match?(/\{=>.*\}/)
51
+ self[:values_type] = t[3..-2]
52
+ { type: 'object' }
50
53
  else # other string
51
54
  { type: t }
52
55
  end
53
56
  end
54
57
 
58
+ def additional_properties
59
+ return { } if processed[:type] != 'object' || _addProp.nil?
60
+ {
61
+ additionalProperties: SchemaObj.new(_addProp, { }).process(inside_desc: true)
62
+ }
63
+ end
64
+
55
65
  def enum_and_length
56
66
  process_enum_info
57
67
  process_range_enum_and_lth
@@ -112,6 +122,7 @@ module OpenApi
112
122
  __desc: %i[ desc! description! d! ],
113
123
  _exp: %i[ example ],
114
124
  _exps: %i[ examples ],
125
+ _addProp: %i[ additional_properties add_prop values_type ],
115
126
  _is: %i[ is_a is ], # NOT OAS Spec, see documentation/parameter.md
116
127
  _as: %i[ as to for map mapping ], # NOT OAS Spec, it's for zero-params_processor
117
128
  _permit: %i[ permit pmt ], # ditto
data/lib/open_api/dsl.rb CHANGED
@@ -34,7 +34,7 @@ module OpenApi
34
34
  (@doc_info[:components] ||= { }).deep_merge!(current_doc)
35
35
  end
36
36
 
37
- def api action, summary = '', http: http_method = nil, skip: [ ], use: [ ], &block
37
+ def api action, summary = '', id: nil, http: http_method = nil, skip: [ ], use: [ ], &block
38
38
  doc_tag if @doc_info.nil?
39
39
  # select the routing info (corresponding to the current method) from routing list.
40
40
  action_path = "#{@route_base ||= controller_path}##{action}"
@@ -42,8 +42,8 @@ module OpenApi
42
42
  return puts ' ZRO'.red + " Route mapping failed: #{action_path}" if routes.blank?
43
43
 
44
44
  api = Api.new(action_path, skip: Array(skip), use: Array(use))
45
- .merge! description: '', summary: summary, operationId: action, tags: [@doc_tag],
46
- parameters: [ ], requestBody: '', responses: { }, callbacks: { },
45
+ .merge! description: '', summary: summary, operationId: id || "#{@doc_info[:tag][:name]}_#{action}",
46
+ tags: [@doc_tag], parameters: [ ], requestBody: '', responses: { }, callbacks: { },
47
47
  links: { }, security: [ ], servers: [ ]
48
48
  [action, :all].each { |blk_key| @zro_dry_blocks&.[](blk_key)&.each { |blk| api.instance_eval(&blk) } }
49
49
  api.param_use = api.param_skip = [ ] # `skip` and `use` only affect `api_dry`'s blocks
@@ -1,3 +1,3 @@
1
1
  module OpenApi
2
- VERSION = '1.5.9'
2
+ VERSION = '1.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zero-rails_openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.9
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhandao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-19 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler