rswag-specs 2.6.0 → 2.7.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 989468cbcebd005e6bf95724400366cfa1b80e7d395bb6d1255bc12c283a98b2
|
4
|
+
data.tar.gz: 949a822da86b5d6f3ead28cdd1262a093bcd8399875b1962f101c41634cc4c51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4cb982b39359a8f69dd5ebf18287a2b4941349a202751d10f936b81014fce8ec99a24886e5de63c4fb1d4aba653893cf4ebff9f425f547be99b1ac3910e53ad
|
7
|
+
data.tar.gz: 1064a439e5b8652c40a77eddd6d0837ea908780750187879bb8bdb11af67656ea6882a8a251bb8627001c7857ebad94c378d68432c1101e2e19647b5c7c29ae5
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support'
|
4
|
+
|
3
5
|
module Rswag
|
4
6
|
module Specs
|
5
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
|
+
|
6
10
|
def path(template, metadata = {}, &block)
|
7
11
|
metadata[:path_item] = { template: template }
|
8
12
|
describe(template, metadata, &block)
|
@@ -100,8 +104,8 @@ module Rswag
|
|
100
104
|
end
|
101
105
|
|
102
106
|
def run_test!(&block)
|
103
|
-
# NOTE: rspec 2.x support
|
104
107
|
if RSPEC_VERSION < 3
|
108
|
+
ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0')
|
105
109
|
before do
|
106
110
|
submit_request(example.metadata)
|
107
111
|
end
|
@@ -101,8 +101,28 @@ module Rswag
|
|
101
101
|
request[:verb] = metadata[:operation][:verb]
|
102
102
|
end
|
103
103
|
|
104
|
+
def base_path_from_servers(swagger_doc, use_server = :default)
|
105
|
+
return '' if swagger_doc[:servers].nil? || swagger_doc[:servers].empty?
|
106
|
+
server = swagger_doc[:servers].first
|
107
|
+
variables = {}
|
108
|
+
server.fetch(:variables, {}).each_pair { |k,v| variables[k] = v[use_server] }
|
109
|
+
base_path = server[:url].gsub(/\{(.*?)\}/) { |name| variables[name.to_sym] }
|
110
|
+
URI(base_path).path
|
111
|
+
end
|
112
|
+
|
104
113
|
def add_path(request, metadata, swagger_doc, parameters, example)
|
105
|
-
|
114
|
+
open_api_3_doc = doc_version(swagger_doc).start_with?('3')
|
115
|
+
uses_base_path = swagger_doc[:basePath].present?
|
116
|
+
|
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')
|
119
|
+
end
|
120
|
+
|
121
|
+
if uses_base_path
|
122
|
+
template = (swagger_doc[:basePath] || '') + metadata[:path_item][:template]
|
123
|
+
else # OpenAPI 3
|
124
|
+
template = base_path_from_servers(swagger_doc) + metadata[:path_item][:template]
|
125
|
+
end
|
106
126
|
|
107
127
|
request[:path] = template.tap do |path_template|
|
108
128
|
parameters.select { |p| p[:in] == :path }.each do |p|
|
@@ -150,7 +170,7 @@ module Rswag
|
|
150
170
|
when :spaceDelimited then '%20'
|
151
171
|
when :pipeDelimited then '|'
|
152
172
|
end
|
153
|
-
return "#{CGI.escape(name.to_s)}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
|
173
|
+
return "#{CGI.escape(name.to_s)}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
|
154
174
|
end
|
155
175
|
else
|
156
176
|
return "#{name}=#{value}"
|
@@ -7,10 +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'
|
10
11
|
|
11
|
-
# NOTE: rspec 2.x support
|
12
12
|
if RSPEC_VERSION > 2
|
13
13
|
::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')
|
14
16
|
end
|
15
17
|
|
16
18
|
def initialize(output, config = Rswag::Specs.config)
|
@@ -21,7 +23,6 @@ module Rswag
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def example_group_finished(notification)
|
24
|
-
# NOTE: rspec 2.x support
|
25
26
|
metadata = if RSPEC_VERSION > 2
|
26
27
|
notification.group.metadata
|
27
28
|
else
|
@@ -54,9 +55,9 @@ module Rswag
|
|
54
55
|
doc[:paths]&.each_pair do |_k, v|
|
55
56
|
v.each_pair do |_verb, value|
|
56
57
|
is_hash = value.is_a?(Hash)
|
57
|
-
if is_hash && value
|
58
|
-
schema_param = value
|
59
|
-
mime_list = value
|
58
|
+
if is_hash && value[:parameters]
|
59
|
+
schema_param = value[:parameters]&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
|
60
|
+
mime_list = value[:consumes] || doc[:consumes]
|
60
61
|
if value && schema_param && mime_list
|
61
62
|
value[:requestBody] = { content: {} } unless value.dig(:requestBody, :content)
|
62
63
|
value[:requestBody][:required] = true if schema_param[:required]
|
@@ -197,8 +198,8 @@ module Rswag
|
|
197
198
|
|
198
199
|
def remove_invalid_operation_keys!(value)
|
199
200
|
is_hash = value.is_a?(Hash)
|
200
|
-
value.delete(:consumes) if is_hash && value
|
201
|
-
value.delete(:produces) if is_hash && value
|
201
|
+
value.delete(:consumes) if is_hash && value[:consumes]
|
202
|
+
value.delete(:produces) if is_hash && value[:produces]
|
202
203
|
end
|
203
204
|
end
|
204
205
|
end
|
@@ -11,10 +11,15 @@ namespace :rswag do
|
|
11
11
|
'spec/requests/**/*_spec.rb, spec/api/**/*_spec.rb, spec/integration/**/*_spec.rb'
|
12
12
|
)
|
13
13
|
|
14
|
-
|
14
|
+
additional_rspec_opts = ENV.fetch(
|
15
|
+
'ADDITIONAL_RSPEC_OPTS',
|
16
|
+
''
|
17
|
+
)
|
18
|
+
|
15
19
|
if Rswag::Specs::RSPEC_VERSION > 2 && Rswag::Specs.config.swagger_dry_run
|
16
|
-
t.rspec_opts = ['--format Rswag::Specs::SwaggerFormatter', '--dry-run', '--order defined']
|
20
|
+
t.rspec_opts = ['--format Rswag::Specs::SwaggerFormatter', '--dry-run', '--order defined'] << additional_rspec_opts
|
17
21
|
else
|
22
|
+
ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0')
|
18
23
|
t.rspec_opts = ['--format Rswag::Specs::SwaggerFormatter', '--order defined']
|
19
24
|
end
|
20
25
|
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.
|
4
|
+
version: 2.7.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: 2022-
|
13
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -56,16 +56,50 @@ dependencies:
|
|
56
56
|
name: json-schema
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.2'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '4.0'
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
|
-
- - "
|
69
|
+
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: '2.2'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '4.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec-core
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.14'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.14'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.21.2
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.21.2
|
69
103
|
description: 'Simplify API integration testing with a succinct rspec DSL and generate
|
70
104
|
OpenAPI specification files directly from your rspec tests. More about the OpenAPI
|
71
105
|
initiative here: http://spec.openapis.org/'
|