openapi_contracts 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openapi_contracts/doc/path.rb +2 -2
- data/lib/openapi_contracts/doc.rb +4 -4
- data/lib/openapi_contracts/match.rb +1 -1
- data/lib/openapi_contracts/parser/transformers/pointer.rb +14 -2
- data/lib/openapi_contracts/parser/transformers.rb +0 -1
- data/lib/openapi_contracts/validators/schema_validation.rb +3 -0
- metadata +19 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fa5c81703e10335348cefdfdf14ada22c1a66a4017c71e0fd74e2499e95cd75
|
4
|
+
data.tar.gz: ef6ab8b10609f9e048f9ee61cdd017883a4a9c8b7a8f3166ac3891e5e6d51e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb69135e230360714f93b9285efa0fa7cd1cc4b2ab524b5dac1a1bf925ef2cf98a92475b6c7d5528892f2208ba42ee0f71366280808914bb6976ec91db5d3df7
|
7
|
+
data.tar.gz: 71fc02b108dae2bdcf2bcbc40ef7faca01acee5c772a57ec155426ca4aec42b5317e89f828624b2126f658f276261762ccc8eb29b6be2c1cd6f5c9f90663996f
|
@@ -25,10 +25,10 @@ module OpenapiContracts
|
|
25
25
|
|
26
26
|
def path_regexp
|
27
27
|
@path_regexp ||= begin
|
28
|
-
re = /\{(
|
28
|
+
re = /\{([^\}]+)\}/
|
29
29
|
@path.gsub(re) { |placeholder|
|
30
30
|
placeholder.match(re) { |m| "(?<#{m[1]}>[^/]*)" }
|
31
|
-
}.then { |str| Regexp.new(str) }
|
31
|
+
}.then { |str| Regexp.new("^#{str}$") }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -35,20 +35,20 @@ module OpenapiContracts
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Returns an Enumerator over all Operations
|
38
|
-
def operations(&block)
|
38
|
+
def operations(&block) # rubocop:disable Naming/BlockForwarding
|
39
39
|
return enum_for(:operations) unless block_given?
|
40
40
|
|
41
41
|
paths.each do |path|
|
42
|
-
path.operations.each(&block)
|
42
|
+
path.operations.each(&block) # rubocop:disable Naming/BlockForwarding
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
# Returns an Enumerator over all Responses
|
47
|
-
def responses(&block)
|
47
|
+
def responses(&block) # rubocop:disable Naming/BlockForwarding
|
48
48
|
return enum_for(:responses) unless block_given?
|
49
49
|
|
50
50
|
operations.each do |operation|
|
51
|
-
operation.responses.each(&block)
|
51
|
+
operation.responses.each(&block) # rubocop:disable Naming/BlockForwarding
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -1,13 +1,25 @@
|
|
1
1
|
module OpenapiContracts::Parser::Transformers
|
2
2
|
class Pointer < Base
|
3
3
|
def call(object)
|
4
|
+
transform_discriminator(object)
|
5
|
+
transform_refs(object)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def transform_discriminator(object)
|
11
|
+
mappings = object.dig('discriminator', 'mapping')
|
12
|
+
return unless mappings.present?
|
13
|
+
|
14
|
+
mappings.transform_values! { |p| transform_pointer(p) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def transform_refs(object)
|
4
18
|
return unless object['$ref'].present?
|
5
19
|
|
6
20
|
object['$ref'] = transform_pointer(object['$ref'])
|
7
21
|
end
|
8
22
|
|
9
|
-
private
|
10
|
-
|
11
23
|
def transform_pointer(target)
|
12
24
|
if %r{^#/(?<pointer>.*)} =~ target
|
13
25
|
# A JSON Pointer
|
@@ -29,6 +29,9 @@ module OpenapiContracts::Validators
|
|
29
29
|
validation_schemer(schema).validate(data).map do |err|
|
30
30
|
error_to_message(err)
|
31
31
|
end
|
32
|
+
rescue JSONSchemer::UnknownRef => e
|
33
|
+
# This usually happens when discriminators encounter unknown types
|
34
|
+
["Could not resolve pointer #{e.message.inspect}"]
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mkon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -34,16 +34,22 @@ dependencies:
|
|
34
34
|
name: json_schemer
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2
|
39
|
+
version: '2'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.2'
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">="
|
45
48
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2
|
49
|
+
version: '2'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.2'
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: rack
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,28 +98,28 @@ dependencies:
|
|
92
98
|
requirements:
|
93
99
|
- - '='
|
94
100
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
101
|
+
version: 1.57.2
|
96
102
|
type: :development
|
97
103
|
prerelease: false
|
98
104
|
version_requirements: !ruby/object:Gem::Requirement
|
99
105
|
requirements:
|
100
106
|
- - '='
|
101
107
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
108
|
+
version: 1.57.2
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
110
|
name: rubocop-rspec
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
107
113
|
- - '='
|
108
114
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.
|
115
|
+
version: 2.25.0
|
110
116
|
type: :development
|
111
117
|
prerelease: false
|
112
118
|
version_requirements: !ruby/object:Gem::Requirement
|
113
119
|
requirements:
|
114
120
|
- - '='
|
115
121
|
- !ruby/object:Gem::Version
|
116
|
-
version: 2.
|
122
|
+
version: 2.25.0
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
124
|
name: simplecov
|
119
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,17 +186,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
186
|
requirements:
|
181
187
|
- - ">="
|
182
188
|
- !ruby/object:Gem::Version
|
183
|
-
version: '3.
|
189
|
+
version: '3.1'
|
184
190
|
- - "<"
|
185
191
|
- !ruby/object:Gem::Version
|
186
|
-
version: '3.
|
192
|
+
version: '3.4'
|
187
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
194
|
requirements:
|
189
195
|
- - ">="
|
190
196
|
- !ruby/object:Gem::Version
|
191
197
|
version: '0'
|
192
198
|
requirements: []
|
193
|
-
rubygems_version: 3.4.
|
199
|
+
rubygems_version: 3.4.22
|
194
200
|
signing_key:
|
195
201
|
specification_version: 4
|
196
202
|
summary: Openapi schemas as API contracts
|