rswag-specs 2.12.0 → 2.14.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: 8365b4004ddfecc85ca45dd075921a254a22445f83dfbca7d400c80b92090062
4
- data.tar.gz: c9909fc3b98dd83eae3f5d1d83cf065cb293583fc6b9b1edcad696cd5bf5398f
3
+ metadata.gz: 632bdf59bdc4251188267dec82987bd14466f625e34e54501383a298081c9cdc
4
+ data.tar.gz: 19f715a56062c2aaa9bd6db80392e154a6f7ebcac70077d2e59c38fe614baf77
5
5
  SHA512:
6
- metadata.gz: d605e82f0cf92dc730a7c33ff205758328be6874381e72dfa7c5ff2adcc4ad330e67a1ca36781a838a09556059ad2a574b32c9fdb3ef7eeada7b9215465a1ff3
7
- data.tar.gz: 1f9368eb7f6a268f59114ecf6a2fa8493cc855e8e9aeb708f6fe762e623a5a606b01080e44cd85734fe72add620d08c85949be71e31ae2f6c4207a4c047b9e63
6
+ metadata.gz: 02fcf0b9b5f42f837c434badc4275a72fd6789fbe973dbb703dcfaf0237699cb008b8c7ce51e4ba150429717e714a9b741d4788257a6ba09d8b06ef617521f0b
7
+ data.tar.gz: 79c42771f6131b91ab849c770a6c2ef9461d54737059b4b24c03ca85a20e1c82fd26cf9ea4eb92d03f914ed3126b4e4c0571cea81e69ad89453d63d1441088a2
@@ -6,15 +6,15 @@ RSpec.configure do |config|
6
6
  # Specify a root folder where Swagger JSON files are generated
7
7
  # NOTE: If you're using the rswag-api to serve API descriptions, you'll need
8
8
  # to ensure that it's configured to serve Swagger from the same folder
9
- config.swagger_root = Rails.root.join('swagger').to_s
9
+ config.openapi_root = Rails.root.join('swagger').to_s
10
10
 
11
11
  # Define one or more Swagger documents and provide global metadata for each one
12
12
  # When you run the 'rswag:specs:swaggerize' rake task, the complete Swagger will
13
- # be generated at the provided relative path under swagger_root
13
+ # be generated at the provided relative path under openapi_root
14
14
  # By default, the operations defined in spec files are added to the first
15
- # document below. You can override this behavior by adding a swagger_doc tag to the
16
- # the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
17
- config.swagger_docs = {
15
+ # document below. You can override this behavior by adding a openapi_spec tag to the
16
+ # the root example_group in your specs, e.g. describe '...', openapi_spec: 'v2/swagger.json'
17
+ config.openapi_specs = {
18
18
  'v1/swagger.yaml' => {
19
19
  openapi: '3.0.1',
20
20
  info: {
@@ -36,8 +36,8 @@ RSpec.configure do |config|
36
36
  }
37
37
 
38
38
  # Specify the format of the output Swagger file when running 'rswag:specs:swaggerize'.
39
- # The swagger_docs configuration option has the filename including format in
39
+ # The openapi_specs configuration option has the filename including format in
40
40
  # the key, this may want to be changed to avoid putting yaml in json files.
41
41
  # Defaults to json. Accepts ':json' and ':yaml'.
42
- config.swagger_format = :yaml
42
+ config.openapi_format = :yaml
43
43
  end
@@ -7,63 +7,59 @@ module Rswag
7
7
  @rspec_config = rspec_config
8
8
  end
9
9
 
10
- def swagger_root
11
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: The method will be renamed to "openapi_root" in v3.0')
12
- @swagger_root ||= begin
13
- if @rspec_config.swagger_root.nil?
14
- raise ConfigurationError, 'No swagger_root provided. See swagger_helper.rb'
10
+ def openapi_root
11
+ @openapi_root ||=
12
+ @rspec_config.openapi_root || raise(ConfigurationError, 'No openapi_root provided. See swagger_helper.rb')
13
+ end
14
+
15
+ def openapi_specs
16
+ @openapi_specs ||= begin
17
+ if @rspec_config.openapi_specs.nil? || @rspec_config.openapi_specs.empty?
18
+ raise ConfigurationError, 'No openapi_specs defined. See swagger_helper.rb'
15
19
  end
16
20
 
17
- @rspec_config.swagger_root
21
+ @rspec_config.openapi_specs
18
22
  end
19
23
  end
20
24
 
21
- def swagger_docs
22
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: The method will be renamed to "openapi_specs" in v3.0')
23
- @swagger_docs ||= begin
24
- if @rspec_config.swagger_docs.nil? || @rspec_config.swagger_docs.empty?
25
- raise ConfigurationError, 'No swagger_docs defined. See swagger_helper.rb'
25
+ def rswag_dry_run
26
+ @rswag_dry_run ||= begin
27
+ if ENV.key?('SWAGGER_DRY_RUN') || ENV.key?('RSWAG_DRY_RUN')
28
+ @rspec_config.rswag_dry_run = ENV['SWAGGER_DRY_RUN'] == '1' || ENV['RSWAG_DRY_RUN'] == '1'
26
29
  end
27
30
 
28
- @rspec_config.swagger_docs
31
+ @rspec_config.rswag_dry_run.nil? || @rspec_config.rswag_dry_run
29
32
  end
30
33
  end
31
34
 
32
- def swagger_dry_run
33
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: The method will be renamed to "rswag_dry_run" in v3.0')
34
- return @swagger_dry_run if defined? @swagger_dry_run
35
- if ENV.key?('SWAGGER_DRY_RUN')
36
- @rspec_config.swagger_dry_run = ENV['SWAGGER_DRY_RUN'] == '1'
37
- end
38
- @swagger_dry_run = @rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run
39
- end
35
+ def openapi_format
36
+ @openapi_format ||= begin
37
+ if @rspec_config.openapi_format.nil? || @rspec_config.openapi_format.empty?
38
+ @rspec_config.openapi_format = :json
39
+ end
40
40
 
41
- def swagger_format
42
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: The method will be renamed to "openapi_format" in v3.0')
43
- @swagger_format ||= begin
44
- @rspec_config.swagger_format = :json if @rspec_config.swagger_format.nil? || @rspec_config.swagger_format.empty?
45
- raise ConfigurationError, "Unknown swagger_format '#{@rspec_config.swagger_format}'" unless [:json, :yaml].include?(@rspec_config.swagger_format)
41
+ unless [:json, :yaml].include?(@rspec_config.openapi_format)
42
+ raise ConfigurationError, "Unknown openapi_format '#{@rspec_config.openapi_format}'"
43
+ end
46
44
 
47
- @rspec_config.swagger_format
45
+ @rspec_config.openapi_format
48
46
  end
49
47
  end
50
48
 
51
- def get_swagger_doc(name)
52
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: The method will be renamed to "get_openapi_spec" in v3.0')
53
- return swagger_docs.values.first if name.nil?
54
- raise ConfigurationError, "Unknown swagger_doc '#{name}'" unless swagger_docs[name]
49
+ def get_openapi_spec(name)
50
+ return openapi_specs.values.first if name.nil?
51
+ raise ConfigurationError, "Unknown openapi_spec '#{name}'" unless openapi_specs[name]
55
52
 
56
- swagger_docs[name]
53
+ openapi_specs[name]
57
54
  end
58
55
 
59
- def get_swagger_doc_version(name)
60
- doc = get_swagger_doc(name)
56
+ def get_openapi_spec_version(name)
57
+ doc = get_openapi_spec(name)
61
58
  doc[:openapi] || doc[:swagger]
62
59
  end
63
60
 
64
- def swagger_strict_schema_validation
65
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: The method will be renamed to "openapi_strict_schema_validation" in v3.0')
66
- @swagger_strict_schema_validation ||= (@rspec_config.swagger_strict_schema_validation || false)
61
+ def openapi_strict_schema_validation
62
+ @rspec_config.openapi_strict_schema_validation || false
67
63
  end
68
64
  end
69
65
 
@@ -5,8 +5,6 @@ require 'active_support'
5
5
  module Rswag
6
6
  module Specs
7
7
  module ExampleGroupHelpers
8
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for Ruby 2.6 will be dropped in v3.0') if RUBY_VERSION.start_with? '2.6'
9
-
10
8
  def path(template, metadata = {}, &block)
11
9
  metadata[:path_item] = { template: template }
12
10
  describe(template, metadata, &block)
@@ -129,7 +127,6 @@ module Rswag
129
127
  description ||= "returns a #{metadata[:response][:code]} response"
130
128
 
131
129
  if RSPEC_VERSION < 3
132
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0')
133
130
  before do
134
131
  submit_request(example.metadata)
135
132
  end
@@ -8,7 +8,13 @@ module Rswag
8
8
  end
9
9
 
10
10
  generators do
11
- require 'generators/rspec/swagger_generator.rb'
11
+ require 'generators/rspec/swagger_generator'
12
+ end
13
+
14
+ initializer 'rswag-specs.deprecator' do |app|
15
+ if app.respond_to?(:deprecators)
16
+ app.deprecators[:rswag_specs] = Rswag::Specs.deprecator
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -12,7 +12,7 @@ module Rswag
12
12
  end
13
13
 
14
14
  def build_request(metadata, example)
15
- swagger_doc = @config.get_swagger_doc(metadata[:swagger_doc])
15
+ swagger_doc = @config.get_openapi_spec(metadata[:openapi_spec] || metadata[:swagger_doc])
16
16
  parameters = expand_parameters(metadata, swagger_doc, example)
17
17
 
18
18
  {}.tap do |request|
@@ -53,7 +53,7 @@ module Rswag
53
53
  (swagger_doc[:securityDefinitions] || {}).slice(*scheme_names).values
54
54
  else # Openapi3
55
55
  if swagger_doc.key?(:securityDefinitions)
56
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: securityDefinitions is replaced in OpenAPI3! Rename to components/securitySchemes (in swagger_helper.rb)')
56
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: securityDefinitions is replaced in OpenAPI3! Rename to components/securitySchemes (in swagger_helper.rb)')
57
57
  swagger_doc[:components] ||= { securitySchemes: swagger_doc[:securityDefinitions] }
58
58
  swagger_doc.delete(:securityDefinitions)
59
59
  end
@@ -75,7 +75,7 @@ module Rswag
75
75
  ref.sub('#/parameters/', '').to_sym
76
76
  else # Openapi3
77
77
  if ref.start_with?('#/parameters/')
78
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: #/parameters/ refs are replaced in OpenAPI3! Rename to #/components/parameters/')
78
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: #/parameters/ refs are replaced in OpenAPI3! Rename to #/components/parameters/')
79
79
  ref.sub('#/parameters/', '').to_sym
80
80
  else
81
81
  ref.sub('#/components/parameters/', '').to_sym
@@ -88,7 +88,7 @@ module Rswag
88
88
  swagger_doc[:parameters]
89
89
  else # Openapi3
90
90
  if swagger_doc.key?(:parameters)
91
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: parameters is replaced in OpenAPI3! Rename to components/parameters (in swagger_helper.rb)')
91
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: parameters is replaced in OpenAPI3! Rename to components/parameters (in swagger_helper.rb)')
92
92
  swagger_doc[:parameters]
93
93
  else
94
94
  components = swagger_doc[:components] || {}
@@ -115,7 +115,7 @@ module Rswag
115
115
  uses_base_path = swagger_doc[:basePath].present?
116
116
 
117
117
  if open_api_3_doc && uses_base_path
118
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: basePath is replaced in OpenAPI3! Update your swagger_helper.rb')
118
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: basePath is replaced in OpenAPI3! Update your swagger_helper.rb')
119
119
  end
120
120
 
121
121
  if uses_base_path
@@ -242,11 +242,13 @@ module Rswag
242
242
  content_type = request[:headers]['CONTENT_TYPE']
243
243
  return if content_type.nil?
244
244
 
245
- if ['application/x-www-form-urlencoded', 'multipart/form-data'].include?(content_type)
246
- request[:payload] = build_form_payload(parameters, example)
247
- else
248
- request[:payload] = build_json_payload(parameters, example)
249
- end
245
+ request[:payload] = if ['application/x-www-form-urlencoded', 'multipart/form-data'].include?(content_type)
246
+ build_form_payload(parameters, example)
247
+ elsif content_type == 'application/json'
248
+ build_json_payload(parameters, example)
249
+ else
250
+ build_raw_payload(parameters, example)
251
+ end
250
252
  end
251
253
 
252
254
  def build_form_payload(parameters, example)
@@ -260,14 +262,17 @@ module Rswag
260
262
  Hash[tuples]
261
263
  end
262
264
 
263
- def build_json_payload(parameters, example)
265
+ def build_raw_payload(parameters, example)
264
266
  body_param = parameters.select { |p| p[:in] == :body }.first
265
-
266
267
  return nil unless body_param
267
268
 
268
269
  raise(MissingParameterError, body_param[:name]) unless example.respond_to?(body_param[:name])
269
270
 
270
- example.send(body_param[:name]).to_json
271
+ example.send(body_param[:name])
272
+ end
273
+
274
+ def build_json_payload(parameters, example)
275
+ build_raw_payload(parameters, example)&.to_json
271
276
  end
272
277
 
273
278
  def doc_version(doc)
@@ -13,7 +13,7 @@ module Rswag
13
13
  end
14
14
 
15
15
  def validate!(metadata, response)
16
- swagger_doc = @config.get_swagger_doc(metadata[:swagger_doc])
16
+ swagger_doc = @config.get_openapi_spec(metadata[:openapi_spec] || metadata[:swagger_doc])
17
17
 
18
18
  validate_code!(metadata, response)
19
19
  validate_headers!(metadata, response.headers)
@@ -55,7 +55,7 @@ module Rswag
55
55
  response_schema = metadata[:response][:schema]
56
56
  return if response_schema.nil?
57
57
 
58
- version = @config.get_swagger_doc_version(metadata[:swagger_doc])
58
+ version = @config.get_openapi_spec_version(metadata[:openapi_spec] || metadata[:swagger_doc])
59
59
  schemas = definitions_or_component_schemas(swagger_doc, version)
60
60
 
61
61
  validation_schema = response_schema
@@ -73,10 +73,12 @@ module Rswag
73
73
  end
74
74
 
75
75
  def validation_options_from(metadata)
76
- is_strict = !!metadata.fetch(
77
- :swagger_strict_schema_validation,
78
- @config.swagger_strict_schema_validation
79
- )
76
+ if metadata.key?(:swagger_strict_schema_validation)
77
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: This option will be renamed to "openapi_strict_schema_validation" in v3.0')
78
+ is_strict = !!metadata[:swagger_strict_schema_validation]
79
+ else
80
+ is_strict = !!metadata.fetch(:openapi_strict_schema_validation, @config.openapi_strict_schema_validation)
81
+ end
80
82
 
81
83
  { strict: is_strict }
82
84
  end
@@ -86,7 +88,7 @@ module Rswag
86
88
  swagger_doc.slice(:definitions)
87
89
  else # Openapi3
88
90
  if swagger_doc.key?(:definitions)
89
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: definitions is replaced in OpenAPI3! Rename to components/schemas (in swagger_helper.rb)')
91
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: definitions is replaced in OpenAPI3! Rename to components/schemas (in swagger_helper.rb)')
90
92
  swagger_doc.slice(:definitions)
91
93
  else
92
94
  components = swagger_doc[:components] || {}
@@ -7,16 +7,12 @@ require 'swagger_helper'
7
7
  module Rswag
8
8
  module Specs
9
9
  class SwaggerFormatter < ::RSpec::Core::Formatters::BaseTextFormatter
10
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for Ruby 2.6 will be dropped in v3.0') if RUBY_VERSION.start_with? '2.6'
11
-
12
10
  if RSPEC_VERSION > 2
13
11
  ::RSpec::Core::Formatters.register self, :example_group_finished, :stop
14
- else
15
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0')
16
12
  end
17
13
 
18
14
  def initialize(output, config = Rswag::Specs.config)
19
- @output = output
15
+ super(output)
20
16
  @config = config
21
17
 
22
18
  @output.puts 'Generating Swagger docs ...'
@@ -34,7 +30,7 @@ module Rswag
34
30
  return if metadata[:document] == false
35
31
  return unless metadata.key?(:response)
36
32
 
37
- swagger_doc = @config.get_swagger_doc(metadata[:swagger_doc])
33
+ swagger_doc = @config.get_openapi_spec(metadata[:openapi_spec] || metadata[:swagger_doc])
38
34
 
39
35
  unless doc_version(swagger_doc).start_with?('2')
40
36
  # This is called multiple times per file!
@@ -50,7 +46,7 @@ module Rswag
50
46
  end
51
47
 
52
48
  def stop(_notification = nil)
53
- @config.swagger_docs.each do |url_path, doc|
49
+ @config.openapi_specs.each do |url_path, doc|
54
50
  unless doc_version(doc).start_with?('2')
55
51
  doc[:paths]&.each_pair do |_k, v|
56
52
  v.each_pair do |_verb, value|
@@ -78,6 +74,11 @@ module Rswag
78
74
  end
79
75
  end
80
76
 
77
+ enum_param = value.dig(:parameters).find{|p| p[:enum]}
78
+ if enum_param && enum_param.is_a?(Hash)
79
+ enum_param[:description] = generate_enum_description(enum_param)
80
+ end
81
+
81
82
  value[:parameters].reject! { |p| p[:in] == :body || p[:in] == :formData }
82
83
  end
83
84
  remove_invalid_operation_keys!(value)
@@ -85,7 +86,7 @@ module Rswag
85
86
  end
86
87
  end
87
88
 
88
- file_path = File.join(@config.swagger_root, url_path)
89
+ file_path = File.join(@config.openapi_root, url_path)
89
90
  dirname = File.dirname(file_path)
90
91
  FileUtils.mkdir_p dirname unless File.exist?(dirname)
91
92
 
@@ -100,10 +101,10 @@ module Rswag
100
101
  private
101
102
 
102
103
  def pretty_generate(doc)
103
- if @config.swagger_format == :yaml
104
+ if @config.openapi_format == :yaml
104
105
  clean_doc = yaml_prepare(doc)
105
106
  YAML.dump(clean_doc)
106
- else # config errors are thrown in 'def swagger_format', no throw needed here
107
+ else # config errors are thrown in 'def openapi_format', no throw needed here
107
108
  JSON.pretty_generate(doc)
108
109
  end
109
110
  end
@@ -170,7 +171,7 @@ module Rswag
170
171
  def upgrade_servers!(swagger_doc)
171
172
  return unless swagger_doc[:servers].nil? && swagger_doc.key?(:schemes)
172
173
 
173
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: schemes, host, and basePath are replaced in OpenAPI3! Rename to array of servers[{url}] (in swagger_helper.rb)')
174
+ Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: schemes, host, and basePath are replaced in OpenAPI3! Rename to array of servers[{url}] (in swagger_helper.rb)')
174
175
 
175
176
  swagger_doc[:servers] = { urls: [] }
176
177
  swagger_doc[:schemes].each do |scheme|
@@ -190,14 +191,14 @@ module Rswag
190
191
  schemes.each do |name, v|
191
192
  next unless v.key?(:flow)
192
193
 
193
- ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions flow is replaced in OpenAPI3! Rename to components/securitySchemes/#{name}/flows[] (in swagger_helper.rb)")
194
+ Rswag::Specs.deprecator.warn("Rswag::Specs: WARNING: securityDefinitions flow is replaced in OpenAPI3! Rename to components/securitySchemes/#{name}/flows[] (in swagger_helper.rb)")
194
195
  flow = swagger_doc[:components][:securitySchemes][name].delete(:flow).to_s
195
196
  if flow == 'accessCode'
196
- ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions accessCode is replaced in OpenAPI3! Rename to clientCredentials (in swagger_helper.rb)")
197
+ Rswag::Specs.deprecator.warn("Rswag::Specs: WARNING: securityDefinitions accessCode is replaced in OpenAPI3! Rename to clientCredentials (in swagger_helper.rb)")
197
198
  flow = 'authorizationCode'
198
199
  end
199
200
  if flow == 'application'
200
- ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions application is replaced in OpenAPI3! Rename to authorizationCode (in swagger_helper.rb)")
201
+ Rswag::Specs.deprecator.warn("Rswag::Specs: WARNING: securityDefinitions application is replaced in OpenAPI3! Rename to authorizationCode (in swagger_helper.rb)")
201
202
  flow = 'clientCredentials'
202
203
  end
203
204
  flow_elements = swagger_doc[:components][:securitySchemes][name].except(:type).each_with_object({}) do |(k, _v), a|
@@ -215,6 +216,14 @@ module Rswag
215
216
  value.delete(:request_examples) if value[:request_examples]
216
217
  value[:parameters].each { |p| p.delete(:getter) } if value[:parameters]
217
218
  end
219
+
220
+ def generate_enum_description(param)
221
+ enum_description = "#{param[:description]}:\n "
222
+ param[:enum].each do |k,v|
223
+ enum_description += "* `#{k}` #{v}\n "
224
+ end
225
+ enum_description
226
+ end
218
227
  end
219
228
  end
220
229
  end
data/lib/rswag/specs.rb CHANGED
@@ -8,13 +8,22 @@ require 'rswag/specs/railtie' if defined?(Rails::Railtie)
8
8
 
9
9
  module Rswag
10
10
  module Specs
11
+ RENAMED_METHODS = {
12
+ swagger_root: :openapi_root,
13
+ swagger_docs: :openapi_specs,
14
+ swagger_dry_run: :rswag_dry_run,
15
+ swagger_format: :openapi_format,
16
+ swagger_strict_schema_validation: :openapi_strict_schema_validation
17
+ }.freeze
18
+ private_constant :RENAMED_METHODS
19
+
11
20
  # Extend RSpec with a swagger-based DSL
12
21
  ::RSpec.configure do |c|
13
- c.add_setting :swagger_root
14
- c.add_setting :swagger_docs
15
- c.add_setting :swagger_dry_run
16
- c.add_setting :swagger_format
17
- c.add_setting :swagger_strict_schema_validation
22
+ c.add_setting :openapi_root
23
+ c.add_setting :openapi_specs
24
+ c.add_setting :rswag_dry_run
25
+ c.add_setting :openapi_format, default: :json
26
+ c.add_setting :openapi_strict_schema_validation
18
27
  c.extend ExampleGroupHelpers, type: :request
19
28
  c.include ExampleHelpers, type: :request
20
29
  end
@@ -23,8 +32,31 @@ module Rswag
23
32
  @config ||= Configuration.new(RSpec.configuration)
24
33
  end
25
34
 
35
+ def self.deprecator
36
+ @deprecator ||= ActiveSupport::Deprecation.new('3.0', 'rswag-specs')
37
+ end
38
+
26
39
  # Support Rails 3+ and RSpec 2+ (sigh!)
27
40
  RAILS_VERSION = Rails::VERSION::MAJOR
28
41
  RSPEC_VERSION = RSpec::Core::Version::STRING.split('.').first.to_i
42
+
43
+ RSpec::Core::Configuration.class_eval do
44
+ RENAMED_METHODS.each do |old_name, new_name|
45
+ define_method("#{old_name}=") do |*args, &block|
46
+ public_send("#{new_name}=", *args, &block)
47
+ end
48
+ end
49
+ end
50
+
51
+ Specs.deprecator.deprecate_methods(
52
+ RSpec::Core::Configuration,
53
+ RENAMED_METHODS.to_h { |old_name, new_name| ["#{old_name}=".to_sym, "#{new_name}=".to_sym] }
54
+ )
55
+
56
+ if RUBY_VERSION.start_with? '2.6'
57
+ Specs.deprecator.warn('Rswag::Specs: WARNING: Support for Ruby 2.6 will be dropped in v3.0')
58
+ end
59
+
60
+ Specs.deprecator.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0') if RSPEC_VERSION < 3
29
61
  end
30
62
  end
@@ -18,10 +18,9 @@ namespace :rswag do
18
18
 
19
19
  t.rspec_opts = [additional_rspec_opts]
20
20
 
21
- if Rswag::Specs::RSPEC_VERSION > 2 && Rswag::Specs.config.swagger_dry_run
21
+ if Rswag::Specs.config.rswag_dry_run
22
22
  t.rspec_opts += ['--format Rswag::Specs::SwaggerFormatter', '--dry-run', '--order defined']
23
23
  else
24
- ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0')
25
24
  t.rspec_opts += ['--format Rswag::Specs::SwaggerFormatter', '--order defined']
26
25
  end
27
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rswag-specs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.0
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richie Morris
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-11-25 00:00:00.000000000 Z
13
+ date: 2024-08-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -18,20 +18,20 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '3.1'
21
+ version: '5.2'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '7.2'
24
+ version: '8.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: '3.1'
31
+ version: '5.2'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '7.2'
34
+ version: '8.0'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: json-schema
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -58,20 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.1'
61
+ version: '5.2'
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
- version: '7.2'
64
+ version: '8.0'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '3.1'
71
+ version: '5.2'
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
- version: '7.2'
74
+ version: '8.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec-core
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.3.3
151
+ rubygems_version: 3.5.11
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: An OpenAPI-based (formerly called Swagger) DSL for rspec-rails & accompanying