openapi_contracts 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5891083b3cb25419145aab30a963c61f28973c40b8a4a74ea080b63bc970670b
4
- data.tar.gz: 5febe1b938ba77edef2e6955e3b8cf8a161f40e5b5f828c6cc39f5105ed734d7
3
+ metadata.gz: f5da42f028abf33be62403ea88cea635c1593f9ee8519a5f589285e1dfdda0ad
4
+ data.tar.gz: e0dbff76da2693ca9ded40d219616a62ee9cc0271679b6e46398d79cec3ab6f2
5
5
  SHA512:
6
- metadata.gz: 87441e69b4caa9ac627e82c27e3d0b0e15162da1587c3bdb7ed4f5c2102fdda02f583df01652676d056b60af24fa9c67dedf38e38b1dfed346211f439de640c2
7
- data.tar.gz: a725d1696dc0e7a3ee19bc3c46c1248f0ada9185bb492f44ea5c571944d98dbb6eb0f69625f68169ed931717782438524bbdc337014ea83116ad60a2d565b545
6
+ metadata.gz: 702a9649cf01d4c15525e908d896a4f90cfb12ac927222c4a934950e88dca9d758ef89669e48462706307bae4f87382f0084fa183fa77279ea0ad7b898741355
7
+ data.tar.gz: d2e4d6c7280f8d36e0b2e5beaafeef3c6ea76e85d8fb77b44944d0397aa8da08814af2051e4fd84dd430d182ea418890ff3728a9ff0a6d5ee11514736bb70461
@@ -25,10 +25,10 @@ module OpenapiContracts
25
25
 
26
26
  def path_regexp
27
27
  @path_regexp ||= begin
28
- re = /\{(\S+)\}/
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
 
@@ -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
@@ -1,5 +1,4 @@
1
1
  module OpenapiContracts::Parser::Transformers
2
2
  autoload :Base, 'openapi_contracts/parser/transformers/base'
3
- autoload :Nullable, 'openapi_contracts/parser/transformers/nullable'
4
3
  autoload :Pointer, 'openapi_contracts/parser/transformers/pointer'
5
4
  end
@@ -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.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mkon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-22 00:00:00.000000000 Z
11
+ date: 2023-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 1.56.1
95
+ version: 1.57.2
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 1.56.1
102
+ version: 1.57.2
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rubocop-rspec
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 2.23.2
109
+ version: 2.25.0
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 2.23.2
116
+ version: 2.25.0
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: simplecov
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.4.18
193
+ rubygems_version: 3.4.22
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Openapi schemas as API contracts