openapi_first 4.1.0 → 4.2.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: ac70785f7221fecd32d0a1408c8c12ee14ea75f5d45be6c9c1efce38e735d02e
4
- data.tar.gz: 0cea3e400f9eed814fc9924c551893d78444920d99f7573d59426a7fa7a61068
3
+ metadata.gz: 70cf5324252fd4c36421cb732127b220e45c3eefbafba7ed63ee513aea2d5b84
4
+ data.tar.gz: 43358cb067c765b59920160f589eb929216a9721b806a4a37b24ab039f536599
5
5
  SHA512:
6
- metadata.gz: 9c8883be1aad4a502ac4596ecb91765b855e2d515ec3e6ad11519a350ed43f29ae591645b71f7f7da709775cd1322c9dd4803f1474032bf5e8004abfd4b0eb51
7
- data.tar.gz: 21e78cbcc5607436c1a32e108f786b0ddfc7ad434d2d103cee6f506eb90bef74d6dfcc4977ce748b612aeeab0c9e50c3a372c77da66a291275ead799bf677226
6
+ metadata.gz: d1b97b74dcdf98616c0f51c3e6a2c53cedb3685518f9697491eadca4110d39f12f68c54769535e6d171bf401d8d47085279124d70534fb5959c47cdf3b4d4eda
7
+ data.tar.gz: a27158cbd2760fa99de1f26193ce5450f5d2ef409c4a780da94ab102c24439dd1d149d6824a99cc8287617cd999cccc9de4989a33edaaaad2debfd7045a3892e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.2.0
6
+
7
+ - Added `config.regexp_resolver` configuration option, `'ruby'` (default) or `'ecma'` (also as Symbol). The value is passed to json_schemer's `regexp_resolver` configuration. In OpenAPI, the pattern keyword specifies a regular expression that must conform to the ECMA-262 standard. So using `'ecma'` is recommended.
8
+
5
9
  ## 4.1.0
6
10
 
7
11
  - Query and cookie parameter values with invalid encoding (like `?search=%C3`) produce a 400 response now. Before such a value passed validation or raised an `ArgumentError`. This applies to documented and undocumented query parameter, but only to documented cookie parameters.
@@ -27,9 +27,9 @@ module OpenapiFirst
27
27
  end
28
28
 
29
29
  def initialize(contents, filepath:, config:)
30
+ @config = config
30
31
  meta_schema = detect_meta_schema(contents, filepath)
31
32
  @schemer_configuration = build_schemer_config(filepath:, meta_schema:)
32
- @config = config
33
33
  @file_loader = FileLoader.new
34
34
  ref_resolver = RefResolver.new(file_loader:)
35
35
  @contents = ref_resolver.for(contents, filepath:)
@@ -47,6 +47,7 @@ module OpenapiFirst
47
47
  end
48
48
  result.meta_schema = meta_schema
49
49
  result.insert_property_defaults = true
50
+ result.regexp_resolver = config.regexp_resolver if config.regexp_resolver
50
51
  result
51
52
  end
52
53
 
@@ -8,6 +8,7 @@ module OpenapiFirst
8
8
  @parent = parent
9
9
  @request_validation_error_response = parent.request_validation_error_response
10
10
  @path = parent.path
11
+ @regexp_resolver = parent.regexp_resolver
11
12
  end
12
13
 
13
14
  private attr_reader :parent
@@ -16,13 +16,14 @@ module OpenapiFirst
16
16
  @request_validation_error_response = OpenapiFirst.find_error_response(:default)
17
17
  @hooks = HOOKS.to_h { [_1, Set.new] }
18
18
  @path = nil
19
+ @regexp_resolver = nil
19
20
  end
20
21
 
21
22
  def register(path_or_definition, as: :default)
22
23
  OpenapiFirst.register(path_or_definition, as:)
23
24
  end
24
25
 
25
- attr_reader :hooks, :request_validation_error_response
26
+ attr_reader :hooks, :request_validation_error_response, :regexp_resolver
26
27
  attr_accessor :path
27
28
 
28
29
  # Return a child configuration that still receives updates of global hooks.
@@ -49,6 +50,10 @@ module OpenapiFirst
49
50
  Plugins.load(name).configure(self, **)
50
51
  end
51
52
 
53
+ def regexp_resolver=(resolver)
54
+ @regexp_resolver = resolver.is_a?(Symbol) ? resolver.to_s : resolver
55
+ end
56
+
52
57
  def request_validation_error_response=(mod)
53
58
  @request_validation_error_response = if mod.is_a?(Symbol)
54
59
  OpenapiFirst.find_error_response(mod)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiFirst
4
- VERSION = '4.1.0'
4
+ VERSION = '4.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_first
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Haller