verquest 0.10.0 → 0.11.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: ba6bc529dbf828ec473edcf82a1cedefe5d3b1ac4b581a159e5421ab3dc9f751
4
- data.tar.gz: 7a1e7463fcd6987fcaaed5fab9b757acff2e7176f7a5a490e6de5c6197e84b8b
3
+ metadata.gz: 7419f824e6f2966c2301b9f9c2ea9a3df48c6dd7559e7adbbd3ab297476726df
4
+ data.tar.gz: ece88f624641894745c5b6d0a5a3dc818839ceb79deef5548657a8e9bf7553c2
5
5
  SHA512:
6
- metadata.gz: 67030d45303503d3e2ea2a8258c7c74081c66582458e228a965cd0335431a1a713ad6617d5dd6a7242ce84ff0e79c9890a7d27f8b704a4e295e857ae9414cdc7
7
- data.tar.gz: 5f503d96382ca5c77ba193cfd5cabf2e494fa3273b770b1f73a38b07e6e96151983b571cb35def51378278060a1874104c67d9efa91dd6f379a99c55ba2eb8db
6
+ metadata.gz: d541f01f0945d3003d21edf031eb1dca54256d5ed702b7bae7d08ab99a32407873822a787f509d0512edc93cf8cd09e4220cf7cf2b83bdf2d84c407459902524
7
+ data.tar.gz: 43cbf7621f6a84d7f396835bf75358d842b835f92209abc3748bdd83e3287723a0a3895abb452a092e1ded7c9ac9470a6d6987424cfe8201fc13a4f237cceb0c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.11.0] - 2026-11-10
4
+
5
+ ### Added
6
+ - `case_insensitive: true` on `field`, `enum` and `array` (and `filter`) in query and path requests reads a value matching a declared string enum value case-insensitively as that value, in every version, without a lenient correction. The schema is unchanged. It raises `Verquest::DefinitionError` in a body request, with `with_options`, with a value other than `true`, `false` or `nil`, without string enum values (also on `const`, `object` and `collection`), or with values that differ only by case.
7
+
3
8
  ## [0.10.0] - 2026-11-09
4
9
 
5
10
  ### Added
data/README.md CHANGED
@@ -861,6 +861,15 @@ array :status, type: :string, explode: false, item_schema_options: {enum: %w[ope
861
861
  # => {name: "status", ..., examples: {single: {value: ["open"]}, multiple: {value: ["open", "won"]}}, schema: {...}}
862
862
  ```
863
863
 
864
+ `case_insensitive: true` on a `field` or `enum`, or an `array` of enum items, reads a value matching a declared string value case-insensitively as that value, in every version and without a [lenient](#lenient-requests) correction. The schema lists only the declared values, so mention it in `description:` if clients should know:
865
+
866
+ ```ruby
867
+ field :sort_direction, type: :string, enum: %w[ASC DESC], case_insensitive: true, description: "`ASC` or `DESC`, case-insensitive"
868
+ # ?sort_direction=desc => {"sort_direction" => "DESC"}
869
+ ```
870
+
871
+ It raises `Verquest::DefinitionError` in a body request, with `with_options`, with a value other than `true`, `false` or `nil`, on a property without string enum values (such as a `const` or an `object`), or when two values differ only by case. A `reference` to the property keeps the option in a query or path class; a body class referencing it matches exactly.
872
+
864
873
  A property reference to another query class reuses its definition, e.g. a shared `expand` parameter: `reference :expand, from: ExpandQuery, property: :expand`.
865
874
 
866
875
  #### Lenient requests
@@ -876,7 +885,7 @@ end
876
885
  | Rule | Value sent | Correction |
877
886
  |------|------------|------------|
878
887
  | `blank` | `page=` | Removed, where strict validation would reject it (not for required properties, arrays, properties that accept null, or strings without constraints, also as an anyOf or oneOf variant) |
879
- | `enum_case` | `sort_direction=desc` | `"DESC"`, when exactly one enum value matches case-insensitively |
888
+ | `enum_case` | `sort_direction=desc` | `"DESC"`, when exactly one enum value matches case-insensitively (properties with `case_insensitive: true` match without a correction) |
880
889
  | `maximum` | `limit=200` | Capped at the `maximum`, `100` |
881
890
  | `datetime_offset` | `2025-01-12 15:30:00`, `...+0100` | `T` between the date and the time, and `Z` added or a colon added to the offset (`+01:00`) |
882
891
  | `invalid` | `page=0` | Removed when it still fails validation, except a filter or a required property, which is still rejected |
@@ -227,7 +227,10 @@ module Verquest
227
227
  # @param options [Hash] The options to set during the block execution
228
228
  # @yield Block to be executed with the temporary options
229
229
  # @return [void]
230
+ # @raise [Verquest::DefinitionError] If options include case_insensitive
230
231
  def with_options(**options, &block)
232
+ raise DefinitionError, "case_insensitive can't be set with with_options, set it on each property" if options.key?(:case_insensitive)
233
+
231
234
  camelize(options)
232
235
 
233
236
  original_options = default_options
@@ -247,8 +250,9 @@ module Verquest
247
250
  # @param nullable [Boolean] Whether the field can be null
248
251
  # @param schema_options [Hash] Additional schema options for the field
249
252
  # @param parameter_examples [Hash, nil] Named OpenAPI Example Objects for the query parameter (query requests only)
253
+ # @param case_insensitive [Boolean, nil] Whether a query value matches the enum case-insensitively (query and path requests only)
250
254
  # @return [void]
251
- def field(name, type: nil, map: nil, required: nil, nullable: nil, parameter_examples: nil, **schema_options)
255
+ def field(name, type: nil, map: nil, required: nil, nullable: nil, parameter_examples: nil, case_insensitive: nil, **schema_options)
252
256
  camelize(schema_options)
253
257
 
254
258
  type = default_options.fetch(:type, type)
@@ -257,7 +261,7 @@ module Verquest
257
261
  schema_options = default_options.except(:type, :required, :nullable).merge(schema_options)
258
262
 
259
263
  field = Properties::Field.new(name:, type:, map:, required:, nullable:, **schema_options)
260
- add_property(field, parameter_examples)
264
+ add_property(field, parameter_examples, case_insensitive)
261
265
  end
262
266
 
263
267
  # Defines a new enum property for the current version scope
@@ -269,8 +273,9 @@ module Verquest
269
273
  # @param nullable [Boolean] Whether the enum can be null
270
274
  # @param schema_options [Hash] Additional schema options for the enum
271
275
  # @param parameter_examples [Hash, nil] Named OpenAPI Example Objects for the query parameter (query requests only)
276
+ # @param case_insensitive [Boolean, nil] Whether a query value matches the enum case-insensitively (query and path requests only)
272
277
  # @return [void]
273
- def enum(name, values:, map: nil, required: nil, nullable: nil, parameter_examples: nil, **schema_options)
278
+ def enum(name, values:, map: nil, required: nil, nullable: nil, parameter_examples: nil, case_insensitive: nil, **schema_options)
274
279
  camelize(schema_options)
275
280
 
276
281
  required = default_options.fetch(:required, false) if required.nil?
@@ -278,7 +283,7 @@ module Verquest
278
283
  schema_options = default_options.except(:type, :required, :nullable).merge(schema_options)
279
284
 
280
285
  enum_property = Properties::Enum.new(name:, values:, map:, required:, nullable:, **schema_options)
281
- add_property(enum_property, parameter_examples)
286
+ add_property(enum_property, parameter_examples, case_insensitive)
282
287
  end
283
288
 
284
289
  # Defines a new constant property for the current version scope
@@ -290,14 +295,15 @@ module Verquest
290
295
  # @param nullable [Boolean] Whether the constant can be null
291
296
  # @param schema_options [Hash] Additional schema options for the constant
292
297
  # @param parameter_examples [Hash, nil] Named OpenAPI Example Objects for the query parameter (query requests only)
298
+ # @param case_insensitive [Boolean, nil] Not supported (a constant has no enum); `true` raises Verquest::DefinitionError
293
299
  # @return [void]
294
- def const(name, value:, map: nil, required: nil, nullable: nil, parameter_examples: nil, **schema_options)
300
+ def const(name, value:, map: nil, required: nil, nullable: nil, parameter_examples: nil, case_insensitive: nil, **schema_options)
295
301
  camelize(schema_options)
296
302
  required = default_options.fetch(:required, false) if required.nil?
297
303
  nullable = default_options.fetch(:nullable, false) if nullable.nil?
298
304
 
299
305
  const = Properties::Const.new(name:, value:, map:, required:, nullable:, **schema_options)
300
- add_property(const, parameter_examples)
306
+ add_property(const, parameter_examples, case_insensitive)
301
307
  end
302
308
 
303
309
  # Defines a new object for the current version scope
@@ -308,9 +314,10 @@ module Verquest
308
314
  # @param nullable [Boolean] Whether the object can be null
309
315
  # @param schema_options [Hash] Additional schema options for the object
310
316
  # @param parameter_examples [Hash, nil] Named OpenAPI Example Objects for the query parameter (query requests only)
317
+ # @param case_insensitive [Boolean, nil] Not supported (an object has no enum); `true` raises Verquest::DefinitionError
311
318
  # @yield Block executed in the context of the new object definition
312
319
  # @return [void]
313
- def object(name, map: nil, required: nil, nullable: nil, parameter_examples: nil, **schema_options, &block)
320
+ def object(name, map: nil, required: nil, nullable: nil, parameter_examples: nil, case_insensitive: nil, **schema_options, &block)
314
321
  unless block_given?
315
322
  raise ArgumentError, "a block must be given to define the object"
316
323
  end
@@ -321,7 +328,7 @@ module Verquest
321
328
  schema_options = default_options.except(:type, :required, :nullable).merge(schema_options)
322
329
 
323
330
  object = Properties::Object.new(name:, map:, required:, nullable:, **schema_options)
324
- add_property(object, parameter_examples)
331
+ add_property(object, parameter_examples, case_insensitive)
325
332
 
326
333
  if block_given?
327
334
  previous_scope = current_scope
@@ -341,10 +348,11 @@ module Verquest
341
348
  # @param nullable [Boolean] Whether the collection can be null
342
349
  # @param map [String, nil] An optional mapping to another collection
343
350
  # @param schema_options [Hash] Additional schema options for the collection
351
+ # @param case_insensitive [Boolean, nil] Not supported (a collection has no enum); `true` raises Verquest::DefinitionError
344
352
  # @yield Block executed in the context of the new collection definition
345
353
  # @return [void]
346
354
  # @raise [ArgumentError] without item: or a block, or when item does not respond to to_ref
347
- def collection(name, item: nil, required: nil, nullable: nil, map: nil, **schema_options, &block)
355
+ def collection(name, item: nil, required: nil, nullable: nil, map: nil, case_insensitive: nil, **schema_options, &block)
348
356
  if item.nil? && !block_given?
349
357
  raise ArgumentError, "item must be provided or a block must be given to define the collection"
350
358
  elsif !item.nil? && !item.respond_to?(:to_ref)
@@ -357,7 +365,7 @@ module Verquest
357
365
  schema_options = default_options.except(:required, :nullable).merge(schema_options)
358
366
 
359
367
  collection = Properties::Collection.new(name:, item:, required:, nullable:, map:, **schema_options)
360
- current_scope.add(collection)
368
+ add_property(collection, nil, case_insensitive)
361
369
 
362
370
  if block_given?
363
371
  previous_scope = current_scope
@@ -398,8 +406,9 @@ module Verquest
398
406
  # @param item_schema_options [Hash] Additional JSON schema options for the array items (merged with custom type options)
399
407
  # @param schema_options [Hash] Additional schema options for the array property
400
408
  # @param parameter_examples [Hash, nil] Named OpenAPI Example Objects for the query parameter (query requests only)
409
+ # @param case_insensitive [Boolean, nil] Whether a query item matches the items' enum case-insensitively (query and path requests only)
401
410
  # @return [void]
402
- def array(name, type:, required: nil, nullable: nil, map: nil, explode: nil, parameter_examples: nil, item_schema_options: {}, **schema_options)
411
+ def array(name, type:, required: nil, nullable: nil, map: nil, explode: nil, parameter_examples: nil, case_insensitive: nil, item_schema_options: {}, **schema_options)
403
412
  camelize(schema_options)
404
413
 
405
414
  type = default_options.fetch(:type, type)
@@ -408,7 +417,7 @@ module Verquest
408
417
  schema_options = default_options.except(:type, :required, :nullable).merge(schema_options)
409
418
 
410
419
  array = Properties::Array.new(name:, type:, required:, nullable:, map:, explode:, item_schema_options:, **schema_options)
411
- add_property(array, parameter_examples)
420
+ add_property(array, parameter_examples, case_insensitive)
412
421
  end
413
422
 
414
423
  # Defines a property and the block that filters by its processed value
@@ -530,9 +539,18 @@ module Verquest
530
539
  #
531
540
  # @param property [Verquest::Properties::Base] The property to add
532
541
  # @param parameter_examples [Hash, nil] Named OpenAPI Example Objects for the query parameter
542
+ # @param case_insensitive [Boolean, nil] Whether a query value matches the enum case-insensitively
533
543
  # @return [void]
534
- def add_property(property, parameter_examples)
544
+ # @raise [Verquest::DefinitionError] If case_insensitive isn't true, false or nil, or is set in a body request
545
+ def add_property(property, parameter_examples, case_insensitive = nil)
546
+ label = "Property '#{property.name}' in version '#{@defining_version&.name}'"
547
+ unless [true, false, nil].include?(case_insensitive)
548
+ raise DefinitionError, "#{label} has case_insensitive: #{case_insensitive.inspect}, which must be true, false or nil"
549
+ end
550
+ raise DefinitionError, "#{label} is case_insensitive, which only query and path parameters support" if case_insensitive && location == :body
551
+
535
552
  property.parameter_examples = parameter_examples
553
+ property.case_insensitive = case_insensitive
536
554
  current_scope.add(property)
537
555
  end
538
556
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Verquest
4
- GEM_VERSION = "0.10.0"
4
+ GEM_VERSION = "0.11.0"
5
5
  end
@@ -83,13 +83,13 @@ module Verquest
83
83
  mapping[(key_prefix + [name]).join("/")] = mapping_value_key(value_prefix:)
84
84
  end
85
85
 
86
- # Returns this array's explode value and parameter examples
86
+ # Returns this array's explode value, parameter examples and case_insensitive
87
87
  #
88
88
  # @param prefix [Array<String>] Path of the parent property
89
89
  # @param version [String] The version to resolve references with
90
90
  # @return [Hash{Array<String> => Hash}] The options of this array, by path
91
91
  def query_options(prefix:, version:)
92
- {prefix + [name] => {explode:, examples: parameter_examples}.compact}
92
+ {prefix + [name] => {explode:}.compact.merge(super.fetch(prefix + [name], {}))}
93
93
  end
94
94
 
95
95
  private
@@ -23,7 +23,9 @@ module Verquest
23
23
  # @return [String, nil] The mapping path for this property
24
24
  # @!attribute [rw] parameter_examples
25
25
  # @return [Hash, nil] Named OpenAPI Example Objects for this property's query parameter, kept out of the JSON schemas
26
- attr_accessor :name, :required, :map, :parameter_examples
26
+ # @!attribute [rw] case_insensitive
27
+ # @return [Boolean, nil] Whether a query value matches the enum case-insensitively
28
+ attr_accessor :name, :required, :map, :parameter_examples, :case_insensitive
27
29
 
28
30
  # Adds a child property to this property
29
31
  # @abstract
@@ -76,14 +78,16 @@ module Verquest
76
78
 
77
79
  # Returns the query parameter options under this property, by path
78
80
  #
79
- # Options are `explode:` for arrays and `examples:` for properties with
80
- # parameter examples. Paths without options are left out.
81
+ # Options are `explode:` for arrays, `examples:` for properties with
82
+ # parameter examples, and `case_insensitive:` for properties matching
83
+ # their enum case-insensitively. Paths without options are left out.
81
84
  #
82
85
  # @param prefix [Array<String>] Path of the parent property
83
86
  # @param version [String] The version to resolve references with
84
87
  # @return [Hash{Array<String> => Hash}] The options of each property path
85
88
  def query_options(prefix:, version:)
86
- parameter_examples ? {prefix + [name] => {examples: parameter_examples}} : {}
89
+ options = {examples: parameter_examples, case_insensitive: (true if case_insensitive)}.compact
90
+ options.empty? ? {} : {prefix + [name] => options}
87
91
  end
88
92
 
89
93
  # Returns a copy of this property under another name and map:
@@ -38,9 +38,11 @@ module Verquest
38
38
 
39
39
  # @param schema [Hash] The version's validation schema
40
40
  # @param explodes [Hash{Array<String> => Boolean}] The explode value of each array property, by path
41
- def initialize(schema:, explodes:)
41
+ # @param case_insensitive [Set<Array<String>>] Paths of properties matching their enum case-insensitively
42
+ def initialize(schema:, explodes:, case_insensitive: Set.new)
42
43
  @schema = schema
43
44
  @explodes = explodes
45
+ @case_insensitive = case_insensitive
44
46
  end
45
47
 
46
48
  # Converts the params
@@ -53,7 +55,7 @@ module Verquest
53
55
 
54
56
  private
55
57
 
56
- attr_reader :schema, :explodes
58
+ attr_reader :schema, :explodes, :case_insensitive
57
59
 
58
60
  # @return [Hash] A copy of the hash with each known property converted
59
61
  def coerce_properties(hash, object_schema, path)
@@ -141,14 +143,22 @@ module Verquest
141
143
  BOOLEANS.fetch(value, NO_MATCH)
142
144
  end
143
145
 
144
- # A string outside the schema's enum tries the next type, so "" can still map to nil
146
+ # A string outside the schema's enum tries the next type, so "" can still map to nil.
147
+ # On a case-insensitive path, a string matching an enum value case-insensitively is that value.
145
148
  #
146
- # @return [String, Object] The string or NO_MATCH
147
- def coerce_string(value, value_schema, _path)
149
+ # @return [String, Object] The string, the declared value or NO_MATCH
150
+ def coerce_string(value, value_schema, path)
148
151
  return NO_MATCH unless value.is_a?(::String)
149
- return NO_MATCH if value_schema.key?("enum") && !value_schema["enum"].include?(value)
152
+ return value unless value_schema.key?("enum")
153
+ return value if value_schema["enum"].include?(value)
154
+ return NO_MATCH unless case_insensitive?(path)
150
155
 
151
- value
156
+ enum_matches(value, value_schema).first || NO_MATCH
157
+ end
158
+
159
+ # @return [Array<String>] The schema's string enum values matching the value case-insensitively
160
+ def enum_matches(value, value_schema)
161
+ value_schema["enum"].select { |declared| declared.is_a?(::String) && declared.casecmp?(value) }
152
162
  end
153
163
 
154
164
  # Splits a string by the array's explode value and converts each item;
@@ -175,6 +185,13 @@ module Verquest
175
185
  def explode?(path)
176
186
  explodes.fetch(path) { Verquest.configuration.query_array_explode }
177
187
  end
188
+
189
+ # The path of an array item ends with its index, so an item is case-insensitive when its array is
190
+ #
191
+ # @return [Boolean] Whether the value at the path matches its enum case-insensitively
192
+ def case_insensitive?(path)
193
+ case_insensitive.include?(path) || case_insensitive.include?(path[...-1])
194
+ end
178
195
  end
179
196
  end
180
197
  end
@@ -7,11 +7,14 @@ module Verquest
7
7
  # Query parameters are scalars, arrays of scalars, or one level of objects
8
8
  # sent as `deepObject` (`filter[status]=open`). Path parameters are required
9
9
  # scalars. Anything else, and oneOf properties, raise when the version is
10
- # prepared.
10
+ # prepared, as does `case_insensitive` on a property without string enum
11
+ # values, or with values equal case-insensitively.
11
12
  class DefinitionCheck
12
13
  # @param version [Verquest::Version] The query or path version to check
13
- def initialize(version)
14
+ # @param query_options [Hash{Array<String> => Hash}] The version's query options, by path
15
+ def initialize(version, query_options: {})
14
16
  @version = version
17
+ @query_options = query_options
15
18
  end
16
19
 
17
20
  # @return [void]
@@ -26,11 +29,13 @@ module Verquest
26
29
  version.validation_schema.fetch("properties", {}).each do |name, property_schema|
27
30
  (version.location == :path) ? check_path(property_schema, name) : check(property_schema, [name], nested: false)
28
31
  end
32
+
33
+ query_options.each { |path, options| check_case_insensitive(path) if options[:case_insensitive] }
29
34
  end
30
35
 
31
36
  private
32
37
 
33
- attr_reader :version
38
+ attr_reader :version, :query_options
34
39
 
35
40
  # Rejects path parameters that aren't required scalars
36
41
  #
@@ -77,6 +82,36 @@ module Verquest
77
82
  reject(path, "an array of objects or arrays") if item_types.intersect?(%w[object array])
78
83
  end
79
84
 
85
+ # Rejects case_insensitive on a property without string enum values (for an array, its items'),
86
+ # or with two values equal case-insensitively
87
+ #
88
+ # @return [void]
89
+ # @raise [Verquest::DefinitionError] If the property can't match case-insensitively
90
+ def check_case_insensitive(path)
91
+ label = "Property '#{path.join("/")}' in version '#{version.name}' is case_insensitive"
92
+ strings = enum_strings(property_schemas(path))
93
+ raise DefinitionError, "#{label}, which needs string enum values" if strings.empty?
94
+
95
+ first, second = strings.group_by { |value| value.downcase(:fold) }.values.find { |same| same.size > 1 }
96
+ raise DefinitionError, "#{label}, but its enum values #{first.inspect} and #{second.inspect} differ only by case" if first
97
+ end
98
+
99
+ # @return [Array<Hash>] The schemas at the path, through anyOf and oneOf variants, with an array's items in place of the array
100
+ def property_schemas(path)
101
+ schemas = path.reduce([version.validation_schema]) do |current, name|
102
+ current.flat_map { |schema| variants(schema) }.filter_map { |schema| schema.dig("properties", name) }
103
+ end
104
+
105
+ schemas.flat_map { |schema| variants(schema) }.map do |schema|
106
+ (Array(schema["type"]).include?("array") && schema.key?("items")) ? schema["items"] : schema
107
+ end
108
+ end
109
+
110
+ # @return [Array<String>] The distinct string enum values of the schemas and their variants
111
+ def enum_strings(schemas)
112
+ schemas.flat_map { |schema| variants(schema) }.flat_map { |schema| Array(schema["enum"]) }.grep(::String).uniq
113
+ end
114
+
80
115
  # @return [Array<Hash>] The schema and its anyOf and oneOf variants
81
116
  def variants(schema)
82
117
  [schema, *schema.values_at("anyOf", "oneOf").compact.flatten]
@@ -18,8 +18,9 @@ module Verquest
18
18
  # @param explodes [Hash{Array<String> => Boolean}] The explode value of each array property, by path
19
19
  # @param required [Array<String>] Root properties that are never removed (see {Verquest::Version#required_property_names})
20
20
  # @param on_correction [#call, nil] Called with each {Verquest::Correction}
21
- def initialize(schema:, explodes:, required:, on_correction:)
22
- super(schema:, explodes:)
21
+ # @param case_insensitive [Set<Array<String>>] Paths of properties matching their enum case-insensitively
22
+ def initialize(schema:, explodes:, required:, on_correction:, case_insensitive: Set.new)
23
+ super(schema:, explodes:, case_insensitive:)
23
24
  @required = required
24
25
  @on_correction = on_correction
25
26
  end
@@ -96,14 +97,14 @@ module Verquest
96
97
  coerced = super
97
98
  return coerced unless value.is_a?(::String)
98
99
  return enum_case(value, value_schema, path) if coerced.equal?(NO_MATCH) && value_schema.key?("enum")
99
- return with_offset(value, path) if value_schema["format"] == "date-time"
100
+ return with_offset(coerced, path) if value_schema["format"] == "date-time"
100
101
 
101
102
  coerced
102
103
  end
103
104
 
104
105
  # @return [String, Object] The only declared value matching case-insensitively or NO_MATCH
105
106
  def enum_case(value, value_schema, path)
106
- matches = value_schema["enum"].select { |declared| declared.is_a?(::String) && declared.casecmp?(value) }
107
+ matches = enum_matches(value, value_schema)
107
108
  return NO_MATCH unless matches.one?
108
109
 
109
110
  correct(path, :enum_case, value, matches.first)
@@ -17,7 +17,7 @@ module Verquest
17
17
  DOCUMENTATION_KEYS = %w[description deprecated].freeze
18
18
 
19
19
  # @param schema [Hash] The version's validation schema
20
- # @param options [Hash{Array<String> => Hash}] The `explode:` and `examples:` of each property path
20
+ # @param options [Hash{Array<String> => Hash}] The `explode:` and `examples:` of each property path; other options, such as `case_insensitive:`, are ignored
21
21
  # @param location [Symbol] `:query` or `:path`, written as `in:`
22
22
  def initialize(schema:, options:, location: :query)
23
23
  @schema = schema
@@ -275,7 +275,8 @@ module Verquest
275
275
  return params unless parameters?
276
276
  return query_coercer.call(params) unless lenient
277
277
 
278
- Query::LenientCoercer.new(schema: validation_schema, explodes: query_explodes, required: required_property_names, on_correction:).call(params)
278
+ Query::LenientCoercer.new(schema: validation_schema, explodes: query_explodes, required: required_property_names,
279
+ on_correction:, case_insensitive: query_case_insensitive).call(params)
279
280
  end
280
281
 
281
282
  # Returns the root properties the validation schema requires, always (`required`), when another
@@ -364,6 +365,9 @@ module Verquest
364
365
  # @return [Hash{Array<String> => Boolean}, nil] The explode value of each array property of a query or path version, by path
365
366
  attr_reader :query_explodes
366
367
 
368
+ # @return [Set<Array<String>>, nil] Paths of query or path properties matching their enum case-insensitively
369
+ attr_reader :query_case_insensitive
370
+
367
371
  # @return [Hash{Array<String> => Hash}, nil] The parameter options of each property path of a query or path version
368
372
  attr_reader :query_options
369
373
 
@@ -372,13 +376,14 @@ module Verquest
372
376
  # @return [void]
373
377
  # @raise [Verquest::DefinitionError] If the version uses a shape its location can't express
374
378
  def prepare_parameters
375
- Query::DefinitionCheck.new(self).call
376
-
377
379
  @query_options = all_properties.each_value.with_object({}) do |property, options|
378
380
  options.merge!(property.query_options(prefix: [], version: name))
379
381
  end.freeze
382
+ Query::DefinitionCheck.new(self, query_options: @query_options).call
383
+
380
384
  @query_explodes = query_options.filter_map { |path, options| [path, options[:explode]] if options.key?(:explode) }.to_h.freeze
381
- @query_coercer = Query::Coercer.new(schema: validation_schema, explodes: @query_explodes)
385
+ @query_case_insensitive = query_options.filter_map { |path, options| path if options[:case_insensitive] }.to_set.freeze
386
+ @query_coercer = Query::Coercer.new(schema: validation_schema, explodes: @query_explodes, case_insensitive: @query_case_insensitive)
382
387
  end
383
388
 
384
389
  # Returns the compiled validation schema for the current configuration
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verquest
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
  - Petr Hlavicka