openapi_first 0.12.5 → 0.13.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: e8692df035f2c27738cc74a8265ad45f6235397c0ce35059fdeef29ef54402ba
4
- data.tar.gz: 156a0c22674e9eed4b2a7ffdfff1cde726b721bf63e8cede6c0d006442c72890
3
+ metadata.gz: 5ffea2d2aacb32af3f0253ff3bf149b63c65d2cc18a91b688d631021b120612f
4
+ data.tar.gz: 36c3a76640b9a2210da41a165b5254d719c226dd67b32bc7867dbdc809338b50
5
5
  SHA512:
6
- metadata.gz: 7f4bedb9b730bb1c27a29d04fe7b915f2e61b0ac6305d6faccb52fd7baa962356704ce0ec85c192f36b9bb5ba9323d29cefa014d287c564fc48dcdaa8bd953a1
7
- data.tar.gz: 9341ba6927183ad541b0b5d3dbc4096112a74204ce14abd1b2c72bfa339c757853f93041f80df85aa51d83377380d9ba034ce260885a5ddbbc64cb769e177d16
6
+ metadata.gz: 1acb6eb311fb503b30c182e16c37fbdfe4e8ed8219a6900bdc8602d9e4ab83762bb755bbf6a78a5ea7783d39441d3aa15bf49f7a5e631326955e4eb38b03e6ea
7
+ data.tar.gz: a899dcf6876cc3b8f81d5d4be7bbdc5f9cdd0e04aa67bcd7e74fad7d29a5497e882864e87d7895db88678c5d48a7b6132effc624d36b214c2ccb391a79bbbf06
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+ - Add support for arrays in query parameters (style: form, explode: false)
5
+ - Remove warning when handler is not implemented
6
+
3
7
  ## 0.12.5
4
8
  - Add `not_found: :continue` option to Router to make it do nothing if request is unknown
5
9
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_first (0.12.5)
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)
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
- Note that is currently does not convert date, date-time or time formats and that conversion is currently done only for path and query parameters, but not for the request body. It just works with a parameter with `name: filter[age]`.
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
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- openapi_first (0.12.5)
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.1.0)
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.6)
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.6)
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.4)
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.11.2)
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
- warn "#{self.class.name} cannot not find handler for '#{operation.operation_id}' (#{operation.method} #{operation.path}). This operation will be ignored." # rubocop:disable Layout/LineLength
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiFirst
4
- VERSION = '0.12.5'
4
+ VERSION = '0.13.0'
5
5
  end
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.12.5
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-10 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge