zero-rails_openapi 1.5.5 → 1.5.6

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
  SHA1:
3
- metadata.gz: e530c334773b9ef483102a2cd2c829704ac41ab4
4
- data.tar.gz: 2cabf4dc3335eeea103fbca8863c01ba46b9988a
3
+ metadata.gz: dec6a3ea12a29b24fa6b0ebcedb7ce02ba8e61d9
4
+ data.tar.gz: 05c67721c53cbdd173068f1ae9df0d629d97e3aa
5
5
  SHA512:
6
- metadata.gz: 1bee517abfc870ee6cac040f9a61cc03e724e9e240fdc3aa2b4a7ce217f99ed57724d00d00b00741a1694e75cba9e4368f554cdddddad6c6d407a607a3daba96
7
- data.tar.gz: 73da6d4109dc89c1e079e83dac675099f203c83b00dad28e6da023a1cb1f97344feb0bb283d25e6f0a5ceff25c033cc2d703cac2f3d95240f986d329e420b9a5
6
+ metadata.gz: 660c9cbc7567fa48f70fe3be7638f221a8c0be88ca3c7ea487d7d12535bc155e8a28834ea7577dfb77d1b9161eacc79a05dc702d2d23913b261512a6e6576a3e
7
+ data.tar.gz: 30f0533d1fcdbb05392152f9f742e31501fc196076e946485d679ecd831e280bfaacfc4a33907702c28286e32582f40bb27edadf212bca218b2b613969e793e2
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.5.6] - 2018/3/23 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.5...v1.5.6)
6
+
7
+ ## Changed
8
+
9
+ 1. Update `loofah` and `rails-html-sanitizer` cause XSS vulnerability.
10
+ 2. Refactor and document DSL for Rspec (spec_dsl.rb).
11
+
5
12
  ## [1.5.5] - 2018/2/21 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.4...v1.5.5)
6
13
 
7
14
  ## Added
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zero-rails_openapi (1.5.5)
4
+ zero-rails_openapi (1.5.6)
5
5
  activesupport (>= 3)
6
6
  colorize (= 0.8.1)
7
7
  rails (>= 3)
@@ -52,14 +52,14 @@ GEM
52
52
  concurrent-ruby (1.0.5)
53
53
  crass (1.0.3)
54
54
  diff-lcs (1.3)
55
- docile (1.1.5)
55
+ docile (1.3.0)
56
56
  erubi (1.7.0)
57
57
  globalid (0.4.1)
58
58
  activesupport (>= 4.2.0)
59
59
  i18n (0.9.5)
60
60
  concurrent-ruby (~> 1.0)
61
61
  json (2.1.0)
62
- loofah (2.2.0)
62
+ loofah (2.2.2)
63
63
  crass (~> 1.0.2)
64
64
  nokogiri (>= 1.5.9)
65
65
  mail (2.7.0)
@@ -89,8 +89,8 @@ GEM
89
89
  rails-dom-testing (2.0.3)
90
90
  activesupport (>= 4.2.0)
91
91
  nokogiri (>= 1.6)
92
- rails-html-sanitizer (1.0.3)
93
- loofah (~> 2.0)
92
+ rails-html-sanitizer (1.0.4)
93
+ loofah (~> 2.2, >= 2.2.2)
94
94
  railties (5.1.5)
95
95
  actionpack (= 5.1.5)
96
96
  activesupport (= 5.1.5)
@@ -98,21 +98,21 @@ GEM
98
98
  rake (>= 0.8.7)
99
99
  thor (>= 0.18.1, < 2.0)
100
100
  rake (10.5.0)
101
- rspec (3.6.0)
102
- rspec-core (~> 3.6.0)
103
- rspec-expectations (~> 3.6.0)
104
- rspec-mocks (~> 3.6.0)
105
- rspec-core (3.6.0)
106
- rspec-support (~> 3.6.0)
107
- rspec-expectations (3.6.0)
101
+ rspec (3.7.0)
102
+ rspec-core (~> 3.7.0)
103
+ rspec-expectations (~> 3.7.0)
104
+ rspec-mocks (~> 3.7.0)
105
+ rspec-core (3.7.1)
106
+ rspec-support (~> 3.7.0)
107
+ rspec-expectations (3.7.0)
108
108
  diff-lcs (>= 1.2.0, < 2.0)
109
- rspec-support (~> 3.6.0)
110
- rspec-mocks (3.6.0)
109
+ rspec-support (~> 3.7.0)
110
+ rspec-mocks (3.7.0)
111
111
  diff-lcs (>= 1.2.0, < 2.0)
112
- rspec-support (~> 3.6.0)
113
- rspec-support (3.6.0)
114
- simplecov (0.15.1)
115
- docile (~> 1.1.0)
112
+ rspec-support (~> 3.7.0)
113
+ rspec-support (3.7.1)
114
+ simplecov (0.16.1)
115
+ docile (~> 1.1)
116
116
  json (>= 1.8, < 3)
117
117
  simplecov-html (~> 0.10.0)
118
118
  simplecov-html (0.10.2)
data/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  I'm looking forward to your issue and PR!**
15
15
 
16
16
  If you have any questions, please read the test code first.
17
- such as [api DSL](spec/api_info_obj_spec.rb) and [schema Obj](spec/oas_objs/schema_obj_spec.rb).
17
+ such as [api DSL](spec/api_spec.rb) and [schema Obj](spec/oas_objs/schema_obj_spec.rb).
18
18
 
19
19
  ## Table of Contents
20
20
 
@@ -18,7 +18,7 @@
18
18
  另外,走过路过不妨来个 star?**
19
19
 
20
20
  另外,如果对其行为表现有任何疑惑,请先阅读测试代码,这其中已表明我的大多数考量。
21
- 可一读:[api DSL](spec/api_info_obj_spec.rb) 以及 [schema Obj](spec/oas_objs/schema_obj_spec.rb)。
21
+ 可一读:[api DSL](spec/api_spec.rb) 以及 [schema Obj](spec/oas_objs/schema_obj_spec.rb)。
22
22
 
23
23
 
24
24
  ## Table of Contents
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
@@ -35,8 +35,8 @@ module OpenApi
35
35
  end
36
36
 
37
37
  def processed_block
38
- api = ApiInfo.new.merge! parameters: [ ], requestBody: '', responses: { }
39
- api.instance_exec(&(self.block || ->{ }))
38
+ api = Api.new.merge! parameters: [ ], requestBody: '', responses: { }
39
+ api.instance_exec(&(self.block || -> { }))
40
40
  api.process_objs
41
41
  api.delete_if { |_, v| v.blank? }
42
42
  end
@@ -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, is_and_format, pattern_default_and_other, desc(options)).then_merge!
25
+ reducx(enum_and_length, range, format, pattern_default_and_other, desc(options)).then_merge!
26
26
  end
27
27
 
28
28
  def desc(inside_desc:)
@@ -82,7 +82,7 @@ module OpenApi
82
82
  }.keep_if &value_present
83
83
  end
84
84
 
85
- def is_and_format
85
+ def format
86
86
  result = { is: _is }
87
87
  # `format` that generated in process_type() may be overwrote here.
88
88
  result[:format] = _format || _is if processed[:format].blank? || _format.present?
@@ -91,7 +91,7 @@ module OpenApi
91
91
 
92
92
  def pattern_default_and_other
93
93
  {
94
- pattern: _pattern.is_a?(String)? _pattern : _pattern&.inspect&.delete('/'),
94
+ pattern: _pattern.is_a?(String) ? _pattern : _pattern&.inspect&.delete('/'),
95
95
  default: _default,
96
96
  examples: self[:examples].present? ? ExampleObj.new(self[:examples], self[:exp_by]).process : nil,
97
97
  as: _as, permit: _permit, not_permit: _npermit, req_if: _req_if, opt_if: _opt_if, blankable: _blank
@@ -122,7 +122,7 @@ module OpenApi
122
122
  aliases.each { |alias_name| self[key] = self[alias_name] if self[key].nil? }
123
123
  self[key]
124
124
  end
125
- define_method "#{key}=" do |value| self[key] = value end
125
+ define_method("#{key}=") { |value| self[key] = value }
126
126
  end
127
127
  end
128
128
  end
@@ -36,14 +36,14 @@ module OpenApi
36
36
  end
37
37
 
38
38
  def process_range_enum_and_lth
39
- self[:_enum] = str_range_toa(_enum) if _enum.is_a?(Range)
40
- self[:_length] = str_range_toa(_length) if _length.is_a?(Range)
39
+ self[:_enum] = str_range_to_a(_enum) if _enum.is_a?(Range)
40
+ self[:_length] = str_range_to_a(_length) if _length.is_a?(Range)
41
41
 
42
42
  values = _enum || _value
43
43
  self._enum = Array(values) if truly_present?(values)
44
44
  end
45
45
 
46
- def str_range_toa(val)
46
+ def str_range_to_a(val)
47
47
  val_class = val.first.class
48
48
  action = :"to_#{val_class.to_s.downcase[0]}"
49
49
  (val.first.to_s..val.last.to_s).to_a.map(&action)
@@ -55,7 +55,7 @@ module OpenApi
55
55
  # 'all_desc': :all,
56
56
  # 'one_desc': :one
57
57
  # }
58
- self._enum ||= e = self[:enum!]
58
+ self._enum ||= (e = self[:enum!])
59
59
  return unless e.is_a? Hash
60
60
  @enum_info = e
61
61
  self._enum = e.values
@@ -1,4 +1,4 @@
1
- require 'open_api/dsl/api_info'
1
+ require 'open_api/dsl/api'
2
2
  require 'open_api/dsl/components'
3
3
 
4
4
  module OpenApi
@@ -38,10 +38,10 @@ module OpenApi
38
38
  routes = ctrl_routes_list&.select { |api| api[:action_path].match?(/^#{action_path}$/) }
39
39
  return puts ' ZRO'.red + " Route mapping failed: #{@route_base}##{action}" if routes.blank?
40
40
 
41
- api = ApiInfo.new(action_path, skip: Array(skip), use: Array(use))
42
- .merge! description: '', summary: summary, operationId: action, tags: [@doc_tag],
43
- parameters: [ ], requestBody: '', responses: { }, callbacks: { },
44
- links: { }, security: [ ], servers: [ ]
41
+ api = Api.new(action_path, skip: Array(skip), use: Array(use))
42
+ .merge! description: '', summary: summary, operationId: action, tags: [@doc_tag],
43
+ parameters: [ ], requestBody: '', responses: { }, callbacks: { },
44
+ links: { }, security: [ ], servers: [ ]
45
45
  [action, :all].each { |blk_key| @zro_dry_blocks&.[](blk_key)&.each { |blk| api.instance_eval(&blk) } }
46
46
  api.param_use = api.param_skip = [ ] # `skip` and `use` only affect `api_dry`'s blocks
47
47
  api.instance_exec(&block) if block_given?
@@ -2,7 +2,7 @@ require 'open_api/dsl/common_dsl'
2
2
 
3
3
  module OpenApi
4
4
  module DSL
5
- class ApiInfo < Hash
5
+ class Api < Hash
6
6
  include DSL::CommonDSL
7
7
  include DSL::Helpers
8
8
 
@@ -9,7 +9,7 @@ module OpenApi
9
9
  def schema component_key, type = nil, **schema_info
10
10
  schema = process_schema_info(type, schema_info, model: component_key)
11
11
  return puts ' ZRO'.red + " Syntax Error: component schema `#{component_key}` has no type!" if schema[:illegal?]
12
- self[:schemas][component_key.to_s.to_sym] = (schema[:combined] || SchemaObj.new(type = schema[:info], { })).process
12
+ self[:schemas][component_key.to_s.to_sym] = (schema[:combined] or SchemaObj.new(type = schema[:info], { })).process
13
13
  end
14
14
 
15
15
  arrow_enable :schema
@@ -46,7 +46,7 @@ module OpenApi
46
46
 
47
47
  arrow_enable :_request_body_agent
48
48
 
49
- arrow_enable :resp # alias_method 竟然也会指向旧的方法?
49
+ arrow_enable :resp
50
50
  arrow_enable :response
51
51
 
52
52
  def security_scheme scheme_name, other_info# = { }
@@ -3,7 +3,7 @@ require 'open_api/config'
3
3
 
4
4
  module OpenApi
5
5
  module Generator
6
- extend self
6
+ module_function
7
7
 
8
8
  def self.included(base)
9
9
  base.extend ClassMethods
@@ -1,3 +1,3 @@
1
1
  module OpenApi
2
- VERSION = '1.5.5'
2
+ VERSION = '1.5.6'
3
3
  end
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  spec.add_development_dependency 'simplecov'
30
-
30
+
31
31
  spec.add_runtime_dependency 'colorize', '0.8.1'
32
- spec.add_runtime_dependency 'rails', '>= 3'
33
32
  spec.add_runtime_dependency 'activesupport', '>= 3'
33
+ spec.add_runtime_dependency 'rails', '>= 3'
34
34
 
35
35
  # spec.post_install_message = ""
36
36
  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.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhandao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.8.1
83
83
  - !ruby/object:Gem::Dependency
84
- name: rails
84
+ name: activesupport
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3'
97
97
  - !ruby/object:Gem::Dependency
98
- name: activesupport
98
+ name: rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -152,7 +152,7 @@ files:
152
152
  - lib/open_api/config.rb
153
153
  - lib/open_api/config_dsl.rb
154
154
  - lib/open_api/dsl.rb
155
- - lib/open_api/dsl/api_info.rb
155
+ - lib/open_api/dsl/api.rb
156
156
  - lib/open_api/dsl/common_dsl.rb
157
157
  - lib/open_api/dsl/components.rb
158
158
  - lib/open_api/dsl/helpers.rb