openapi_first 0.12.5 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/benchmarks/Gemfile.lock +6 -6
- data/lib/openapi_first/find_handler.rb +2 -4
- data/lib/openapi_first/request_validation.rb +15 -2
- data/lib/openapi_first/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: 5ffea2d2aacb32af3f0253ff3bf149b63c65d2cc18a91b688d631021b120612f
|
4
|
+
data.tar.gz: 36c3a76640b9a2210da41a165b5254d719c226dd67b32bc7867dbdc809338b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1acb6eb311fb503b30c182e16c37fbdfe4e8ed8219a6900bdc8602d9e4ab83762bb755bbf6a78a5ea7783d39441d3aa15bf49f7a5e631326955e4eb38b03e6ea
|
7
|
+
data.tar.gz: a899dcf6876cc3b8f81d5d4be7bbdc5f9cdd0e04aa67bcd7e74fad7d29a5497e882864e87d7895db88678c5d48a7b6132effc624d36b214c2ccb391a79bbbf06
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -79,7 +79,12 @@ This middleware adds `env[OpenapiFirst::INBOX]` which holds the (filtered) path
|
|
79
79
|
### Parameter validation
|
80
80
|
|
81
81
|
The middleware filteres all top-level query parameters and paths parameters and tries to convert numeric values. Meaning, if you have an `:something_id` path with `type: integer`, it will try convert the value to an integer.
|
82
|
-
|
82
|
+
|
83
|
+
It just works with a parameter with `name: filter[age]`.
|
84
|
+
|
85
|
+
OpenapiFirst also supports `type: array` for query parameters and will convert `items` just as described above. [`style`](http://spec.openapis.org/oas/v3.0.3#style-values) and `explode` attributes are not supported for query parameters. It will always act as if `style: form` and `explode: false` were used for query parameters.
|
86
|
+
|
87
|
+
Conversion is currently done only for path and query parameters, but not for the request body. OpenapiFirst currently does not convert date, date-time or time formats.
|
83
88
|
|
84
89
|
If you want to forbid _nested_ query parameters you will need to use [`additionalProperties: false`](https://json-schema.org/understanding-json-schema/reference/object.html#properties) in your query parameter JSON schema.
|
85
90
|
|
data/benchmarks/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
openapi_first (0.
|
4
|
+
openapi_first (0.13.0)
|
5
5
|
deep_merge (>= 1.2.1)
|
6
6
|
hanami-router (~> 2.0.alpha3)
|
7
7
|
hanami-utils (~> 2.0.alpha1)
|
@@ -25,11 +25,11 @@ GEM
|
|
25
25
|
benchmark-memory (0.1.2)
|
26
26
|
memory_profiler (~> 0.9)
|
27
27
|
builder (3.2.4)
|
28
|
-
committee (4.
|
28
|
+
committee (4.2.0)
|
29
29
|
json_schema (~> 0.14, >= 0.14.3)
|
30
30
|
openapi_parser (>= 0.11.1)
|
31
31
|
rack (>= 1.5)
|
32
|
-
concurrent-ruby (1.1.
|
32
|
+
concurrent-ruby (1.1.7)
|
33
33
|
deep_merge (1.2.1)
|
34
34
|
dry-configurable (0.11.6)
|
35
35
|
concurrent-ruby (~> 1.0)
|
@@ -42,7 +42,7 @@ GEM
|
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
43
|
dry-equalizer (0.3.0)
|
44
44
|
dry-inflector (0.2.0)
|
45
|
-
dry-logic (1.0.
|
45
|
+
dry-logic (1.0.7)
|
46
46
|
concurrent-ruby (~> 1.0)
|
47
47
|
dry-core (~> 0.2)
|
48
48
|
dry-equalizer (~> 0.2)
|
@@ -72,7 +72,7 @@ GEM
|
|
72
72
|
transproc (~> 1.0)
|
73
73
|
hansi (0.2.0)
|
74
74
|
hash-deep-merge (0.1.1)
|
75
|
-
i18n (1.8.
|
75
|
+
i18n (1.8.5)
|
76
76
|
concurrent-ruby (~> 1.0)
|
77
77
|
json_schema (0.20.9)
|
78
78
|
json_schemer (0.2.13)
|
@@ -101,7 +101,7 @@ GEM
|
|
101
101
|
hash-deep-merge
|
102
102
|
mustermann-contrib (~> 1.1.1)
|
103
103
|
nokogiri
|
104
|
-
openapi_parser (0.
|
104
|
+
openapi_parser (0.12.1)
|
105
105
|
public_suffix (4.0.5)
|
106
106
|
rack (2.2.3)
|
107
107
|
rack-accept (0.4.5)
|
@@ -9,10 +9,8 @@ module OpenapiFirst
|
|
9
9
|
@handlers = spec.operations.each_with_object({}) do |operation, hash|
|
10
10
|
operation_id = operation.operation_id
|
11
11
|
handler = find_handler(operation_id)
|
12
|
-
if handler.nil?
|
13
|
-
|
14
|
-
next
|
15
|
-
end
|
12
|
+
next if handler.nil?
|
13
|
+
|
16
14
|
hash[operation_id] = handler
|
17
15
|
end
|
18
16
|
end
|
@@ -150,14 +150,27 @@ module OpenapiFirst
|
|
150
150
|
def parse_parameter(value, schema)
|
151
151
|
return filtered_params(schema, value) if schema['properties']
|
152
152
|
|
153
|
+
return parse_array_parameter(value, schema) if schema['type'] == 'array'
|
154
|
+
|
155
|
+
parse_simple_value(value, schema)
|
156
|
+
end
|
157
|
+
|
158
|
+
def parse_array_parameter(value, schema)
|
159
|
+
array = value.is_a?(Array) ? value : value.split(',')
|
160
|
+
return array unless schema['items']
|
161
|
+
|
162
|
+
array.map! { |e| parse_simple_value(e, schema['items']) }
|
163
|
+
end
|
164
|
+
|
165
|
+
def parse_simple_value(value, schema)
|
166
|
+
return to_boolean(value) if schema['type'] == 'boolean'
|
167
|
+
|
153
168
|
begin
|
154
169
|
return Integer(value, 10) if schema['type'] == 'integer'
|
155
170
|
return Float(value) if schema['type'] == 'number'
|
156
171
|
rescue ArgumentError
|
157
172
|
value
|
158
173
|
end
|
159
|
-
return to_boolean(value) if schema['type'] == 'boolean'
|
160
|
-
|
161
174
|
value
|
162
175
|
end
|
163
176
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_first
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.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: 2020-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|