openapi_first 2.7.0 → 2.7.1

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: 177998c88421283a6868e3aa9c5bbbe1eea702bc8b65abb22c28795cb2b7b6a2
4
- data.tar.gz: 603118b530e39957ea95086d98a95362e9eb9b9490a63adc7c2bc8e0f7ba7846
3
+ metadata.gz: 9e1567faff66c28fcf6edcc19cdfddcad6b2c7344cbd7967ddad8d48216b3702
4
+ data.tar.gz: 378e83d9e1f9083291f31bf07d463fbf4a478039d7b5e5c8f8efc258db84ba50
5
5
  SHA512:
6
- metadata.gz: 58aac32a5c8d7433414f4bf0f2cbf8142376c76d9ad918bf06531f40da0206e870a12e36718ca7763dd273ea18b664799f22acff84df143e36591a19284895fd
7
- data.tar.gz: cba873da9fa8b1bf957a47fe34dcd30c50af51185dc83ba78c3f78ad2d5630399555c7d81f89f6e7cb96d9c56771c55aa956900249c2a6700d88869233339f6d
6
+ metadata.gz: b5f6dc96e129456b1cf46cfa9b457becc8ba62791d3a47703e2265890fbb31f4c99cc704895b15bdff9ebba90e6e7e777a39694f35cfdc4a9599d601ab5f82c2
7
+ data.tar.gz: 5a54293f86d6ecbc384f4b500a53dce34c805c8313a3c267cda95c53ceed95d9382f2dc42d2e4e26896cc042d9275b54c89aa72f18ab72b29623ea2fad01d9c8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.7.1
6
+
7
+ - Speedup loading very large OADs by deferring creation of JSONSchemer::Schema instances.
8
+
5
9
  ## 2.7.0
6
10
 
7
11
  - Allow to override path for schema matching with `config.path = ->(request) { '/prefix' + request.path } ` (https://github.com/ahx/openapi_first/issues/349)
data/README.md CHANGED
@@ -332,8 +332,6 @@ Here is a [feature comparison between openapi_first and committee](https://gist.
332
332
 
333
333
  ### How can I adapt request paths that don't match my schema?
334
334
 
335
- If your API is deployed at a different path than what's defined in your OpenAPI schema, you can use `env[OpenapiFirst::PATH]` to override the path used for schema matching.
336
-
337
335
  Let's say you have `openapi.yaml` like this:
338
336
 
339
337
  ```yaml
@@ -127,9 +127,31 @@ module OpenapiFirst
127
127
  # You have to pass configuration or ref_resolver
128
128
  def schema(options)
129
129
  base_uri = URI::File.build({ path: "#{dir}/" })
130
- root = JSONSchemer::Schema.new(context, base_uri:, **options)
131
- # binding.irb if value['maxItems'] == 4
132
- JSONSchemer::Schema.new(value, nil, root, base_uri:, **options)
130
+ Schema.new(value:, context:, base_uri:, options:)
131
+ end
132
+ end
133
+
134
+ # @visibility private
135
+ # Defers initialization JSONSchemer::Schema, because that takes time.
136
+ class Schema
137
+ extend Forwardable
138
+
139
+ def initialize(value:, context:, base_uri:, options:)
140
+ @value = value
141
+ @context = context
142
+ @base_uri = base_uri
143
+ @options = options
144
+ end
145
+
146
+ attr_reader :value, :context, :base_uri, :options
147
+
148
+ def_delegators :schema, :validate, :valid?
149
+
150
+ def schema
151
+ @schema ||= begin
152
+ root_schema = JSONSchemer::Schema.new(context, base_uri:, **options)
153
+ JSONSchemer::Schema.new(value, nil, root_schema, base_uri:, **options)
154
+ end
133
155
  end
134
156
  end
135
157
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiFirst
4
- VERSION = '2.7.0'
4
+ VERSION = '2.7.1'
5
5
  end
data/lib/openapi_first.rb CHANGED
@@ -16,9 +16,6 @@ module OpenapiFirst
16
16
  # Key in rack to find instance of Request
17
17
  REQUEST = 'openapi.request'
18
18
 
19
- # Key in rack to store the alternate path used for schema matching
20
- PATH = 'openapi.path'
21
-
22
19
  FAILURE = :openapi_first_validation_failure
23
20
 
24
21
  # @return [Configuration]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_first
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Haller
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-04 00:00:00.000000000 Z
10
+ date: 2025-05-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: hana