rswag-specs 2.14.0 → 2.16.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 +4 -4
- data/lib/rswag/specs/configuration.rb +8 -0
- data/lib/rswag/specs/request_factory.rb +2 -2
- data/lib/rswag/specs/response_validator.rb +14 -4
- data/lib/rswag/specs.rb +12 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8022f62493aff9272dc9e28dd243b7b4323dd34ebd7e6e2cd0c686ad5c04c252
|
4
|
+
data.tar.gz: 4926c9541ef625bd6acc1e1360b9c151a89b55dec7d3b8bb2cffb5f787d7546f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bd7e73cbface6b2aba3192e0ea7c4894834cfb18b1ad4a78a5661979d8674281d75d0f994de90319acdbe41136a5860675d9745c5de9ec9be0738775fa4c502
|
7
|
+
data.tar.gz: d641e842144cf173c6af4ab1ed17eeb72c95ad926f9c731afa426679ca8138b0467a151a8ecfcaa61bb18f2fb7f364043db99e58e2b96383c71cfd525daf76b8
|
@@ -61,6 +61,14 @@ module Rswag
|
|
61
61
|
def openapi_strict_schema_validation
|
62
62
|
@rspec_config.openapi_strict_schema_validation || false
|
63
63
|
end
|
64
|
+
|
65
|
+
def openapi_all_properties_required
|
66
|
+
@rspec_config.openapi_all_properties_required || false
|
67
|
+
end
|
68
|
+
|
69
|
+
def openapi_no_additional_properties
|
70
|
+
@rspec_config.openapi_no_additional_properties || false
|
71
|
+
end
|
64
72
|
end
|
65
73
|
|
66
74
|
class ConfigurationError < StandardError; end
|
@@ -174,7 +174,7 @@ module Rswag
|
|
174
174
|
return "#{escaped_name}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
|
175
175
|
end
|
176
176
|
else
|
177
|
-
return "#{
|
177
|
+
return "#{escaped_name}=#{CGI.escape(value.to_s)}"
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -244,7 +244,7 @@ module Rswag
|
|
244
244
|
|
245
245
|
request[:payload] = if ['application/x-www-form-urlencoded', 'multipart/form-data'].include?(content_type)
|
246
246
|
build_form_payload(parameters, example)
|
247
|
-
elsif content_type
|
247
|
+
elsif content_type =~ /\Aapplication\/([0-9A-Za-z._-]+\+json\z|json\z)/
|
248
248
|
build_json_payload(parameters, example)
|
249
249
|
else
|
250
250
|
build_raw_payload(parameters, example)
|
@@ -73,14 +73,24 @@ module Rswag
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def validation_options_from(metadata)
|
76
|
+
is_strict = @config.openapi_strict_schema_validation
|
77
|
+
|
76
78
|
if metadata.key?(:swagger_strict_schema_validation)
|
77
|
-
Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: This option will be
|
79
|
+
Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: This option will be removed in v3.0 please use openapi_all_properties_required and openapi_no_additional_properties set to true')
|
78
80
|
is_strict = !!metadata[:swagger_strict_schema_validation]
|
79
|
-
|
80
|
-
|
81
|
+
elsif metadata.key?(:openapi_strict_schema_validation)
|
82
|
+
Rswag::Specs.deprecator.warn('Rswag::Specs: WARNING: This option will be removed in v3.0 please use openapi_all_properties_required and openapi_no_additional_properties set to true')
|
83
|
+
is_strict = !!metadata[:openapi_strict_schema_validation]
|
81
84
|
end
|
82
85
|
|
83
|
-
|
86
|
+
all_properties_required = metadata.fetch(:openapi_all_properties_required, @config.openapi_all_properties_required)
|
87
|
+
no_additional_properties = metadata.fetch(:openapi_no_additional_properties, @config.openapi_no_additional_properties)
|
88
|
+
|
89
|
+
{
|
90
|
+
strict: is_strict,
|
91
|
+
allPropertiesRequired: all_properties_required,
|
92
|
+
noAdditionalProperties: no_additional_properties
|
93
|
+
}
|
84
94
|
end
|
85
95
|
|
86
96
|
def definitions_or_component_schemas(swagger_doc, version)
|
data/lib/rswag/specs.rb
CHANGED
@@ -12,8 +12,7 @@ module Rswag
|
|
12
12
|
swagger_root: :openapi_root,
|
13
13
|
swagger_docs: :openapi_specs,
|
14
14
|
swagger_dry_run: :rswag_dry_run,
|
15
|
-
swagger_format: :openapi_format
|
16
|
-
swagger_strict_schema_validation: :openapi_strict_schema_validation
|
15
|
+
swagger_format: :openapi_format
|
17
16
|
}.freeze
|
18
17
|
private_constant :RENAMED_METHODS
|
19
18
|
|
@@ -24,6 +23,8 @@ module Rswag
|
|
24
23
|
c.add_setting :rswag_dry_run
|
25
24
|
c.add_setting :openapi_format, default: :json
|
26
25
|
c.add_setting :openapi_strict_schema_validation
|
26
|
+
c.add_setting :openapi_all_properties_required
|
27
|
+
c.add_setting :openapi_no_additional_properties
|
27
28
|
c.extend ExampleGroupHelpers, type: :request
|
28
29
|
c.include ExampleHelpers, type: :request
|
29
30
|
end
|
@@ -46,6 +47,10 @@ module Rswag
|
|
46
47
|
public_send("#{new_name}=", *args, &block)
|
47
48
|
end
|
48
49
|
end
|
50
|
+
|
51
|
+
define_method('swagger_strict_schema_validation=') do |*args, &block|
|
52
|
+
public_send('openapi_strict_schema_validation=', *args, &block)
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
56
|
Specs.deprecator.deprecate_methods(
|
@@ -53,6 +58,11 @@ module Rswag
|
|
53
58
|
RENAMED_METHODS.to_h { |old_name, new_name| ["#{old_name}=".to_sym, "#{new_name}=".to_sym] }
|
54
59
|
)
|
55
60
|
|
61
|
+
Specs.deprecator.deprecate_methods(
|
62
|
+
RSpec::Core::Configuration,
|
63
|
+
:openapi_strict_schema_validation= => 'use openapi_all_properties_required and openapi_no_additional_properties set to true'
|
64
|
+
)
|
65
|
+
|
56
66
|
if RUBY_VERSION.start_with? '2.6'
|
57
67
|
Specs.deprecator.warn('Rswag::Specs: WARNING: Support for Ruby 2.6 will be dropped in v3.0')
|
58
68
|
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.16.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: 2024-
|
13
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '5.2'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '8.
|
24
|
+
version: '8.1'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: '5.2'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '8.
|
34
|
+
version: '8.1'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: json-schema
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
version: '2.2'
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
44
|
+
version: '6.0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
version: '2.2'
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '6.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: railties
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '5.2'
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '8.
|
64
|
+
version: '8.1'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '5.2'
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '8.
|
74
|
+
version: '8.1'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rspec-core
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|