openapi_parameters 0.4.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +12 -1
- data/lib/openapi_parameters/error.rb +3 -0
- data/lib/openapi_parameters/parameter.rb +7 -0
- data/lib/openapi_parameters/query.rb +9 -2
- data/lib/openapi_parameters/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778cfe7ccd40119158a3c158b5cf1dcf8000436a4c747a1ecfa349782ffa99d1
|
4
|
+
data.tar.gz: ebdb7a20b68b881e526e11fd30e05458ed8dd5dea34b16f94115e522dfa1801f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61c5e95989223be85f4965355aede74739ac71a3f07ebeba9b6486ef56acf45a64093ffa23b680d1ccad28f7abbbcc4d94a6135acf4575f87f7e67773ccdd97c
|
7
|
+
data.tar.gz: 82fe0b18f8a79e758b5b3a3a496a8de373cc7a47079a3944cd5a6843130c03c1ca6b5173d479a8c2c0a14697e106f2d1aa407d6181e1feac8e5b2cdd074bb4bd
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.
|
3
|
+
## [0.5.0] - 2025-04-01
|
4
|
+
|
5
|
+
- Add option to remove "[]" from unpacked query openapi_parameters
|
6
|
+
```ruby
|
7
|
+
OpenapiParameters::Query.new(
|
8
|
+
[parameter],
|
9
|
+
rack_array_compat: true
|
10
|
+
).unpack('ids[]=2')
|
11
|
+
# => { 'ids' => ['2'] }
|
12
|
+
```
|
13
|
+
|
14
|
+
## [0.4.0] - 2024-12-17
|
4
15
|
|
5
16
|
- Add Parameter#convert(value)
|
6
17
|
- Slight performance optimization
|
@@ -52,6 +52,13 @@ module OpenapiParameters
|
|
52
52
|
type == 'array'
|
53
53
|
end
|
54
54
|
|
55
|
+
EMPTY_BRACKETS = '[]'
|
56
|
+
private_constant :EMPTY_BRACKETS
|
57
|
+
|
58
|
+
def bracket_array?
|
59
|
+
@bracket_array ||= array? && name.end_with?(EMPTY_BRACKETS)
|
60
|
+
end
|
61
|
+
|
55
62
|
def object?
|
56
63
|
type == 'object' || style == 'deepObject' || schema&.key?('properties')
|
57
64
|
end
|
@@ -7,9 +7,10 @@ module OpenapiParameters
|
|
7
7
|
class Query
|
8
8
|
# @param parameters [Array<Hash>] The OpenAPI query parameter definitions.
|
9
9
|
# @param convert [Boolean] Whether to convert the values to the correct type.
|
10
|
-
def initialize(parameters, convert: true)
|
10
|
+
def initialize(parameters, convert: true, rack_array_compat: false)
|
11
11
|
@parameters = parameters.map { Parameter.new(_1) }
|
12
12
|
@convert = convert
|
13
|
+
@remove_array_brackets = rack_array_compat
|
13
14
|
end
|
14
15
|
|
15
16
|
def unpack(query_string) # rubocop:disable Metrics/AbcSize
|
@@ -25,11 +26,17 @@ module OpenapiParameters
|
|
25
26
|
|
26
27
|
value = Unpacker.unpack_value(parameter, parsed_query[parameter.name])
|
27
28
|
end
|
28
|
-
|
29
|
+
key = if remove_array_brackets && parameter.bracket_array?
|
30
|
+
parameter.name.delete_suffix('[]')
|
31
|
+
else
|
32
|
+
parameter.name
|
33
|
+
end
|
34
|
+
result[key] = @convert ? parameter.convert(value) : value
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
38
|
attr_reader :parameters
|
39
|
+
private attr_reader :remove_array_brackets
|
33
40
|
|
34
41
|
private
|
35
42
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Haller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|