zero-rails_openapi 2.0.2 → 2.0.3

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
- SHA1:
3
- metadata.gz: 406f69d0bc9ba791d43c9989267f43d1b8d49f50
4
- data.tar.gz: 81938569b866c04e5c9e61f5dc3feb6b6d523108
2
+ SHA256:
3
+ metadata.gz: 99c7a0aeaedb2ff14dc929912f7aa734122c7ab76bea448c68186ab512ef79e1
4
+ data.tar.gz: a2c95b2bf0856dee961183bb10f8f76f7a9031902199fc5874ac195b04eb4691
5
5
  SHA512:
6
- metadata.gz: f78ea71f4788e0f89745fd36c265a61a1a6e6bbf6d969e604b6b043b82937253a75fba6f37b8bc33ae616d757c26cecbbd952be48c7778c7cc6d9e407cdd3f60
7
- data.tar.gz: c3ff2a18f99422385a340068ef38a6e86a6b89979e2bf986a84a88536adc82750b9112a461e56bcb71a075ae59be83d60b64e1c080e7efdc202cf8fff01b6f46
6
+ metadata.gz: 7f868f8ccc21c52f10391dd9153814fa0cad1378fb1044455d07754639ad9e2951b331013d38accc28006e3ddf20944fa3179c1f34f5b460c3dff0072758de3b
7
+ data.tar.gz: 18b5a70b962887ba16a79e58cd11ae3e16cd8460f4c9e3d2f96812e9effdf482203a7f8bb92697ddd6046b1e7e9f9e9d184eed2624cf601eb905aa909aab4145
@@ -10,8 +10,8 @@ require 'open_api/dsl'
10
10
 
11
11
  module OpenApi
12
12
  module_function
13
- cattr_accessor :routes_index, default: { }
14
- cattr_accessor :docs, default: { }
13
+ cattr_accessor(:routes_index) { { } }
14
+ cattr_accessor(:docs) { { } }
15
15
 
16
16
  def write_docs(if: true, read_on_controller: true)
17
17
  (docs = generate_docs(read_on_controller)) and Tip.loaded
@@ -1,52 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/concern'
4
+
3
5
  module OpenApi
4
6
  module ConfigDSL
5
- def self.included(base)
6
- base.class_eval do
7
- module_function
8
-
9
- def open_api name, base_doc_classes:
10
- @api = name
11
- open_api_docs[name] = { base_doc_classes: base_doc_classes }
12
- end
13
-
14
- def info version:, title:, desc: '', **addition
15
- open_api_docs[@api][:info] = { version: version, title: title, description: desc, **addition }
16
- end
17
-
18
- def server url, desc: ''
19
- (open_api_docs[@api][:servers] ||= [ ]) << { url: url, description: desc }
20
- end
21
-
22
- def security_scheme scheme_name, other_info# = { }
23
- other_info[:description] = other_info.delete(:desc) if other_info.key?(:desc)
24
- (open_api_docs[@api][:securitySchemes] ||= { })[scheme_name] = other_info
25
- end
26
-
27
- def base_auth scheme_name, other_info = { }
28
- security_scheme scheme_name, { type: 'http', scheme: 'basic', **other_info }
29
- end
30
-
31
- def bearer_auth scheme_name, format = 'JWT', other_info = { }
32
- security_scheme scheme_name, { type: 'http', scheme: 'bearer', bearerFormat: format, **other_info }
33
- end
34
-
35
- def api_key scheme_name, field:, in: 'header', **other_info
36
- _in = binding.local_variable_get(:in)
37
- security_scheme scheme_name, { type: 'apiKey', name: field, in: _in, **other_info }
38
- end
39
-
40
- def global_security_require scheme_name, scopes: [ ]
41
- (open_api_docs[@api][:global_security] ||= [ ]) << { scheme_name => scopes }
42
- end
43
-
44
- class << self
45
- alias global_security global_security_require
46
- alias global_auth global_security_require
47
- alias auth_scheme security_scheme
48
- end
7
+ extend ActiveSupport::Concern
8
+
9
+ class_methods do
10
+ def open_api name, base_doc_classes:
11
+ @api = name
12
+ open_api_docs[name] = { base_doc_classes: base_doc_classes }
49
13
  end
14
+
15
+ def info version:, title:, desc: '', **addition
16
+ open_api_docs[@api][:info] = { version: version, title: title, description: desc, **addition }
17
+ end
18
+
19
+ def server url, desc: ''
20
+ (open_api_docs[@api][:servers] ||= [ ]) << { url: url, description: desc }
21
+ end
22
+
23
+ def security_scheme scheme_name, other_info# = { }
24
+ other_info[:description] = other_info.delete(:desc) if other_info.key?(:desc)
25
+ (open_api_docs[@api][:securitySchemes] ||= { })[scheme_name] = other_info
26
+ end
27
+
28
+ def base_auth scheme_name, other_info = { }
29
+ security_scheme scheme_name, { type: 'http', scheme: 'basic', **other_info }
30
+ end
31
+
32
+ def bearer_auth scheme_name, format = 'JWT', other_info = { }
33
+ security_scheme scheme_name, { type: 'http', scheme: 'bearer', bearerFormat: format, **other_info }
34
+ end
35
+
36
+ def api_key scheme_name, field:, in: 'header', **other_info
37
+ _in = binding.local_variable_get(:in)
38
+ security_scheme scheme_name, { type: 'apiKey', name: field, in: _in, **other_info }
39
+ end
40
+
41
+ def global_security_require scheme_name, scopes: [ ]
42
+ (open_api_docs[@api][:global_security] ||= [ ]) << { scheme_name => scopes }
43
+ end
44
+
45
+ alias global_security global_security_require
46
+ alias global_auth global_security_require
47
+ alias auth_scheme security_scheme
50
48
  end
51
49
  end
52
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenApi
4
- VERSION = '2.0.2'
4
+ VERSION = '2.0.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zero-rails_openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhandao
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.6.12
191
+ rubygems_version: 2.7.3
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Concise DSL for generating OpenAPI3 documentation.