openapi_first 0.13.3 → 0.14.3

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: 94cbe97158c8482c40dd1521e1f83cef287ad2e7e32f82746f24adcf45f60c4e
4
- data.tar.gz: 1aff02e97e51b67334c34bc6ee967559def9218c4e81dc6295204bb5447f6715
3
+ metadata.gz: 1b6acd9051ff71dbc3980ec2547e6597992b4970f2aef176c4e118227f6ede01
4
+ data.tar.gz: d8f7a2142aaf4c2d07f951c75500bf1790fc7e9bee0006242a075de6f35ed405
5
5
  SHA512:
6
- metadata.gz: 4ca9c77f8b70024083b831a02d824c2fd0321ff3598234f085133b161ba46a2177e9279e80e22f2ca56da466b087c0c7ac3a62c6dec9a7f906bf03fd44f2eb47
7
- data.tar.gz: bcffa9f70194081780a0348f17e695b05f879eb029e4932baa224c3ca1d03e7fb531931f111bfdbcf452f772c0729e725cd3101779aa363408f859e63fd989f8
6
+ metadata.gz: 5ca8769be4df5874bd1c4c36c80df6a9301c06687385cd6105f6c0acbcbcb39ff903b55a16df36aad3933e7f490ea8817975bf601c37b10d8b8489946e01cc1c
7
+ data.tar.gz: '08588cfd43470ed9181b2420731e86ef2fdc99cb90dafd55af6228cd67d0e94c4eea9d7a9b3695a0034bd88c0d0a3ce071081579aeac66cf96ae995a8869d53f'
data/.rubocop.yml CHANGED
@@ -1,13 +1,14 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
3
  NewCops: enable
4
+ SuggestExtensions: false
4
5
  Style/Documentation:
5
6
  Enabled: false
6
7
  Style/ExponentialNotation:
7
8
  Enabled: true
8
9
  Metrics/BlockLength:
9
10
  Exclude:
10
- - 'spec/**/*.rb'
11
- - '*.gemspec'
11
+ - "spec/**/*.rb"
12
+ - "*.gemspec"
12
13
  Metrics/MethodLength:
13
14
  Max: 20
data/CHANGELOG.md CHANGED
@@ -1,33 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.3
4
+
5
+ - Use json_refs to resolve OpenAPI file. This removes oas_parser and ActiveSupport from list of dependencies
6
+
7
+ ## 0.14.2
8
+
9
+ - Empty query parameters are parsed and request validation returns 400 if an empty string is not allowed. Note that this does not look at `allowEmptyValue` in any way, because allowEmptyValue is deprecated.
10
+
11
+ ## 0.14.1
12
+
13
+ - Bugfix: Don't mix path- and operation-level parameters for request validation
14
+
15
+ ## 0.14.0
16
+
17
+ - Handle custom x-handler field in the API description to find a handler method not based on operationId
18
+ - Add `resolver` option to provide a custom resolver to find a handler method
19
+
3
20
  ## 0.13.3
21
+
4
22
  - Better error message if string does not match format
23
+ - readOnly and writeOnly just works when used inside allOf
5
24
 
6
25
  ## 0.13.2
26
+
7
27
  - Return indicator (`source: { parameter: 'list/1' }`) in error response body when array item in query parameter is invalid
8
28
 
9
29
  ## 0.13.0
30
+
10
31
  - Add support for arrays in query parameters (style: form, explode: false)
11
32
  - Remove warning when handler is not implemented
12
33
 
13
34
  ## 0.12.5
35
+
14
36
  - Add `not_found: :continue` option to Router to make it do nothing if request is unknown
15
37
 
16
38
  ## 0.12.4
39
+
17
40
  - content-type is found while ignoring additional content-type parameters (`application/json` is found when request/response content-type is `application/json; charset=UTF8`)
18
41
  - Support wildcard mime-types when finding the content-type
19
42
 
20
43
  ## 0.12.3
44
+
21
45
  - Add `response_validation:`, `router_raise_error` options to standalone mode.
22
46
 
23
47
  ## 0.12.2
48
+
24
49
  - Allow response to have no media type object specified
25
50
 
26
51
  ## 0.12.1
52
+
27
53
  - Fix response when handler returns 404 or 405
28
54
  - Don't validate the response content if status is 204 (no content)
29
55
 
30
56
  ## 0.12.0
57
+
31
58
  - Change `ResponseValidator` to raise an exception if it found a problem
32
59
  - Params have symbolized keys now
33
60
  - Remove `not_found` option from Router. Return 405 if HTTP verb is not allowed (via Hanami::Router)
@@ -39,6 +66,7 @@
39
66
  - Add `Operation#name` that returns a human readable name for an operation
40
67
 
41
68
  ## 0.11.0
69
+
42
70
  - Raise error if you forgot to add the Router middleware
43
71
  - Make OpenapiFirst.app raise an error in test env when request path is not specified
44
72
  - Rename OperationResolver to Responder
@@ -47,48 +75,60 @@
47
75
  - Move namespace option from Router to OperationResolver
48
76
 
49
77
  ## 0.10.2
78
+
50
79
  - Return 400 if request body has invalid JSON ([issue](https://github.com/ahx/openapi_first/issues/73)) thanks Thomas Frütel
51
80
 
52
81
  ## 0.10.1
82
+
53
83
  - Fix duplicated key in `required` when generating JSON schema for `some[thing]` parameters
54
84
 
55
85
  ## 0.10.0
86
+
56
87
  - Add support for query parameters named `"some[thing]"` ([issue](https://github.com/ahx/openapi_first/issues/40))
57
88
 
58
89
  ## 0.9.0
90
+
59
91
  - Make request validation usable standalone
60
92
 
61
93
  ## 0.8.0
94
+
62
95
  - Add merged parameter and request body available to env at `env[OpenapiFirst::INBOX]` in request validation
63
96
  - Path and query parameters with `type: boolean` now get converted to `true`/`false`
64
97
  - Rename `OpenapiFirst::PARAMS` to `OpenapiFirst::PARAMETERS`
65
98
 
66
99
  ## 0.7.1
100
+
67
101
  - Add missing `require` to work with new version of `oas_parser`
68
102
 
69
103
  ## 0.7.0
104
+
70
105
  - Make use of hanami-router, because it's fast
71
106
  - Remove option `allow_unknown_query_paramerters`
72
107
  - Move the namespace option to Router
73
- - Convert numeric path and query parameters to `Integer` or `Float`
108
+ - Convert numeric path and query parameters to `Integer` or `Float`
74
109
  - Pass the Rack env if your action class' initializers accepts an argument
75
110
  - Respec rack's `env['SCRIPT_NAME']` in router
76
111
  - Add MIT license
77
112
 
78
113
  ## 0.6.10
114
+
79
115
  - Bugfix: params.env['unknown'] now returns `nil` as expected. Thanks @tristandruyen.
80
116
 
81
117
  ## 0.6.9
118
+
82
119
  - Removed radix tree, because of a bug (https://github.com/namusyaka/r2ree-ruby/issues/2)
83
120
 
84
121
  ## 0.6.8
122
+
85
123
  - Performance: About 25% performance increase (i/s) with help of c++ based radix-tree and some optimizations
86
124
  - Update dependencies
87
125
 
88
126
  ## 0.6.7
127
+
89
128
  - Fix: version number of oas_parser
90
129
 
91
130
  ## 0.6.6
131
+
92
132
  - Remove warnings for Ruby 2.7
93
133
 
94
134
  ## 0.6.5
data/Gemfile.lock CHANGED
@@ -1,120 +1,93 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_first (0.13.3)
4
+ openapi_first (0.14.2)
5
5
  deep_merge (>= 1.2.1)
6
- hanami-router (~> 2.0.alpha3)
6
+ hanami-router (~> 2.0.alpha4)
7
7
  hanami-utils (~> 2.0.alpha1)
8
+ json_refs (>= 0.1.7)
8
9
  json_schemer (~> 0.2.16)
9
10
  multi_json (~> 1.14)
10
- oas_parser (~> 0.25.1)
11
11
  rack (~> 2.2)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.0.3.4)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- zeitwerk (~> 2.2, >= 2.2.2)
22
- addressable (2.7.0)
23
- public_suffix (>= 2.0.2, < 5.0)
24
- ast (2.4.1)
25
- builder (3.2.4)
16
+ ast (2.4.2)
26
17
  coderay (1.1.3)
27
- concurrent-ruby (1.1.7)
18
+ concurrent-ruby (1.1.9)
28
19
  deep_merge (1.2.1)
29
20
  diff-lcs (1.4.4)
30
- ecma-re-validator (0.2.1)
31
- regexp_parser (~> 1.2)
32
- hana (1.3.6)
33
- hanami-router (2.0.0.alpha3)
21
+ dry-transformer (0.1.1)
22
+ ecma-re-validator (0.3.0)
23
+ regexp_parser (~> 2.0)
24
+ hana (1.3.7)
25
+ hanami-router (2.0.0.alpha5)
34
26
  mustermann (~> 1.0)
35
27
  mustermann-contrib (~> 1.0)
36
28
  rack (~> 2.0)
37
- hanami-utils (2.0.0.alpha1)
29
+ hanami-utils (2.0.0.alpha3)
38
30
  concurrent-ruby (~> 1.0)
39
- transproc (~> 1.0)
31
+ dry-transformer (~> 0.1)
40
32
  hansi (0.2.0)
41
- hash-deep-merge (0.1.1)
42
- i18n (1.8.5)
43
- concurrent-ruby (~> 1.0)
44
- json_schemer (0.2.16)
45
- ecma-re-validator (~> 0.2)
33
+ json_refs (0.1.7)
34
+ hana
35
+ json_schemer (0.2.18)
36
+ ecma-re-validator (~> 0.3)
46
37
  hana (~> 1.3)
47
- regexp_parser (~> 1.5)
38
+ regexp_parser (~> 2.0)
48
39
  uri_template (~> 0.7)
49
40
  method_source (1.0.0)
50
- mini_portile2 (2.4.0)
51
- minitest (5.14.2)
52
41
  multi_json (1.15.0)
53
42
  mustermann (1.1.1)
54
43
  ruby2_keywords (~> 0.0.1)
55
44
  mustermann-contrib (1.1.1)
56
45
  hansi (~> 0.2.0)
57
46
  mustermann (= 1.1.1)
58
- nokogiri (1.10.10)
59
- mini_portile2 (~> 2.4.0)
60
- oas_parser (0.25.1)
61
- activesupport (>= 4.0.0)
62
- addressable (~> 2.3)
63
- builder (~> 3.2.3)
64
- deep_merge (~> 1.2.1)
65
- hash-deep-merge
66
- mustermann-contrib (~> 1.1.1)
67
- nokogiri
68
- parallel (1.19.2)
69
- parser (2.7.2.0)
47
+ parallel (1.21.0)
48
+ parser (3.0.2.0)
70
49
  ast (~> 2.4.1)
71
- pry (0.13.1)
50
+ pry (0.14.1)
72
51
  coderay (~> 1.1)
73
52
  method_source (~> 1.0)
74
- public_suffix (4.0.6)
75
53
  rack (2.2.3)
76
54
  rack-test (1.1.0)
77
55
  rack (>= 1.0, < 3)
78
56
  rainbow (3.0.0)
79
- rake (13.0.1)
80
- regexp_parser (1.8.2)
81
- rexml (3.2.4)
82
- rspec (3.9.0)
83
- rspec-core (~> 3.9.0)
84
- rspec-expectations (~> 3.9.0)
85
- rspec-mocks (~> 3.9.0)
86
- rspec-core (3.9.3)
87
- rspec-support (~> 3.9.3)
88
- rspec-expectations (3.9.2)
57
+ rake (13.0.6)
58
+ regexp_parser (2.1.1)
59
+ rexml (3.2.5)
60
+ rspec (3.10.0)
61
+ rspec-core (~> 3.10.0)
62
+ rspec-expectations (~> 3.10.0)
63
+ rspec-mocks (~> 3.10.0)
64
+ rspec-core (3.10.1)
65
+ rspec-support (~> 3.10.0)
66
+ rspec-expectations (3.10.1)
89
67
  diff-lcs (>= 1.2.0, < 2.0)
90
- rspec-support (~> 3.9.0)
91
- rspec-mocks (3.9.1)
68
+ rspec-support (~> 3.10.0)
69
+ rspec-mocks (3.10.2)
92
70
  diff-lcs (>= 1.2.0, < 2.0)
93
- rspec-support (~> 3.9.0)
94
- rspec-support (3.9.3)
95
- rubocop (0.93.1)
71
+ rspec-support (~> 3.10.0)
72
+ rspec-support (3.10.3)
73
+ rubocop (1.23.0)
96
74
  parallel (~> 1.10)
97
- parser (>= 2.7.1.5)
75
+ parser (>= 3.0.0.0)
98
76
  rainbow (>= 2.2.2, < 4.0)
99
- regexp_parser (>= 1.8)
77
+ regexp_parser (>= 1.8, < 3.0)
100
78
  rexml
101
- rubocop-ast (>= 0.6.0)
79
+ rubocop-ast (>= 1.12.0, < 2.0)
102
80
  ruby-progressbar (~> 1.7)
103
- unicode-display_width (>= 1.4.0, < 2.0)
104
- rubocop-ast (0.8.0)
105
- parser (>= 2.7.1.5)
106
- ruby-progressbar (1.10.1)
107
- ruby2_keywords (0.0.2)
108
- thread_safe (0.3.6)
109
- transproc (1.1.1)
110
- tzinfo (1.2.8)
111
- thread_safe (~> 0.1)
112
- unicode-display_width (1.7.0)
81
+ unicode-display_width (>= 1.4.0, < 3.0)
82
+ rubocop-ast (1.13.0)
83
+ parser (>= 3.0.1.1)
84
+ ruby-progressbar (1.11.0)
85
+ ruby2_keywords (0.0.5)
86
+ unicode-display_width (2.1.0)
113
87
  uri_template (0.7.0)
114
- zeitwerk (2.4.1)
115
88
 
116
89
  PLATFORMS
117
- ruby
90
+ x86_64-darwin-20
118
91
 
119
92
  DEPENDENCIES
120
93
  bundler (~> 2)
@@ -126,4 +99,4 @@ DEPENDENCIES
126
99
  rubocop
127
100
 
128
101
  BUNDLED WITH
129
- 2.1.4
102
+ 2.2.28
data/README.md CHANGED
@@ -29,9 +29,9 @@ You always have to add this middleware first in order to make the other middlewa
29
29
  use OpenapiFirst::Router, spec: OpenapiFirst.load('./openapi/openapi.yaml')
30
30
  ```
31
31
 
32
- This middleware adds `env[OpenapiFirst::OPERATION]` which holds an Operation object that responds to `operation_id` and `path`.
32
+ This middleware adds `env[OpenapiFirst::OPERATION]` which holds an Operation object that responds to `#operation_id`, `#path` (and `#[]` to access raw fields).
33
33
 
34
- Options and their defaults:
34
+ ### Options and defaults
35
35
 
36
36
  | Name | Possible values | Description | Default
37
37
  |:---|---|---|---|
@@ -48,7 +48,7 @@ use OpenapiFirst::RequestValidation
48
48
  ```
49
49
 
50
50
 
51
- Options and their defaults:
51
+ ### Options and defaults
52
52
 
53
53
  | Name | Possible values | Description | Default
54
54
  |:---|---|---|---|
@@ -109,16 +109,19 @@ Response validation fails if response body includes a property with `writeOnly:
109
109
 
110
110
  This Rack endpoint maps the HTTP request to a method call based on the [operationId](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#operation-object) in your API description and calls it. Responder also adds a content-type to the response.
111
111
 
112
- Currently there are no customization options for this part. Please [share your ideas](#contributing) on how to best meet your needs and preferred style.
113
-
114
112
  ```ruby
115
113
  run OpenapiFirst::Responder, spec: OpenapiFirst.load('./openapi/openapi.yaml')
116
114
  ```
117
115
 
116
+ ### Options
118
117
  | Name | Description
119
118
  |:---|---|
120
- |`spec:`| The spec loaded via `OpenapiFirst.load` |
121
- | `namespace:` | A class or module where to find the handler method. |
119
+ | `namespace:` | Optional. A class or module where to find the handler method. |
120
+ | `resolver:` | Optional. An object that responds to `#call(operation)` and returns a [handler](#handlers). By default this is an instance of [DefaultOperationResolver](#OpenapiFirst::DefaultOperationResolver) |
121
+
122
+
123
+ ### OpenapiFirst::DefaultOperationResolver
124
+ This is the default way to look up a handler method for an operation. Handlers are always looked up in a namespace module that needs to be specified.
122
125
 
123
126
  It works like this:
124
127
 
@@ -176,7 +179,7 @@ The above will use the mentioned Rack middlewares to:
176
179
  - Map the request to a method call `Pets.find_pet` based on the `operationId` in the API description
177
180
  - Set the response content type according to your spec (here with the default status code `200`)
178
181
 
179
- ### Options and their defaults:
182
+ ### Options and defaults
180
183
 
181
184
  | Name | Possible values | Description | Default
182
185
  |:---|---|---|---|
@@ -185,6 +188,7 @@ The above will use the mentioned Rack middlewares to:
185
188
  | `response_validation:` | `true`, `false` | If set to true it raises an exception if the response is invalid. This is useful during testing. | `false`
186
189
  | `router_raise_error:` | `true`, `false` | If set to true it raises an exception (subclass of `OpenapiFirst::Error` when a request path/method is not specified. This is useful during testing. | `false`
187
190
  | `request_validation_raise_error:` | `true`, `false` | If set to true it raises an exception (subclass of `OpenapiFirst::Error` when a request is not valid. | `false`
191
+ | `resolver:` | | Option to customize finding the [handler](#handlers) method for an operation. See [OpenapiFirst::Responder](#OpenapiFirst::Responder) for details.
188
192
 
189
193
 
190
194
  Handler functions (`find_pet`) are called with two arguments:
@@ -285,6 +289,10 @@ Run `bundle exec rspec` to run the tests.
285
289
 
286
290
  See `bundle exec rake -T` for rubygems related tasks.
287
291
 
292
+ ## Benchmarks
293
+
294
+ [Results](https://gist.github.com/ahx/e6ffced58bd2e8d5baffb2f4d2c1f823)
295
+
288
296
  ### Run benchmarks
289
297
 
290
298
  ```sh
@@ -1,90 +1,85 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- openapi_first (0.13.3)
4
+ openapi_first (0.14.2)
5
5
  deep_merge (>= 1.2.1)
6
- hanami-router (~> 2.0.alpha3)
6
+ hanami-router (~> 2.0.alpha4)
7
7
  hanami-utils (~> 2.0.alpha1)
8
+ json_refs (>= 0.1.7)
8
9
  json_schemer (~> 0.2.16)
9
10
  multi_json (~> 1.14)
10
- oas_parser (~> 0.25.1)
11
11
  rack (~> 2.2)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.0.3.4)
16
+ activesupport (6.1.4.1)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- zeitwerk (~> 2.2, >= 2.2.2)
22
- addressable (2.7.0)
23
- public_suffix (>= 2.0.2, < 5.0)
24
- benchmark-ips (2.8.3)
25
- benchmark-memory (0.1.2)
26
- memory_profiler (~> 0.9)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
22
+ benchmark-ips (2.9.2)
23
+ benchmark-memory (0.2.0)
24
+ memory_profiler (~> 1)
27
25
  builder (3.2.4)
28
- committee (4.2.0)
26
+ committee (4.4.0)
29
27
  json_schema (~> 0.14, >= 0.14.3)
30
- openapi_parser (>= 0.11.1)
28
+ openapi_parser (>= 0.11.1, < 1.0)
31
29
  rack (>= 1.5)
32
- concurrent-ruby (1.1.7)
30
+ concurrent-ruby (1.1.9)
33
31
  deep_merge (1.2.1)
34
- dry-configurable (0.11.6)
32
+ dry-configurable (0.13.0)
35
33
  concurrent-ruby (~> 1.0)
36
- dry-core (~> 0.4, >= 0.4.7)
37
- dry-equalizer (~> 0.2)
38
- dry-container (0.7.2)
34
+ dry-core (~> 0.6)
35
+ dry-container (0.9.0)
39
36
  concurrent-ruby (~> 1.0)
40
- dry-configurable (~> 0.1, >= 0.1.3)
41
- dry-core (0.4.9)
37
+ dry-configurable (~> 0.13, >= 0.13.0)
38
+ dry-core (0.7.1)
42
39
  concurrent-ruby (~> 1.0)
43
- dry-equalizer (0.3.0)
44
- dry-inflector (0.2.0)
45
- dry-logic (1.0.8)
40
+ dry-inflector (0.2.1)
41
+ dry-logic (1.2.0)
46
42
  concurrent-ruby (~> 1.0)
47
- dry-core (~> 0.2)
48
- dry-equalizer (~> 0.2)
49
- dry-types (1.4.0)
43
+ dry-core (~> 0.5, >= 0.5)
44
+ dry-transformer (0.1.1)
45
+ dry-types (1.5.1)
50
46
  concurrent-ruby (~> 1.0)
51
47
  dry-container (~> 0.3)
52
- dry-core (~> 0.4, >= 0.4.4)
53
- dry-equalizer (~> 0.3)
48
+ dry-core (~> 0.5, >= 0.5)
54
49
  dry-inflector (~> 0.1, >= 0.1.2)
55
50
  dry-logic (~> 1.0, >= 1.0.2)
56
- ecma-re-validator (0.2.1)
57
- regexp_parser (~> 1.2)
58
- grape (1.5.0)
51
+ ecma-re-validator (0.3.0)
52
+ regexp_parser (~> 2.0)
53
+ grape (1.6.0)
59
54
  activesupport
60
55
  builder
61
56
  dry-types (>= 1.1)
62
57
  mustermann-grape (~> 1.0.0)
63
58
  rack (>= 1.3.0)
64
59
  rack-accept
65
- hana (1.3.6)
66
- hanami-api (0.1.1)
60
+ hana (1.3.7)
61
+ hanami-api (0.2.0)
67
62
  hanami-router (~> 2.0.alpha)
68
- hanami-router (2.0.0.alpha3)
63
+ hanami-router (2.0.0.alpha5)
69
64
  mustermann (~> 1.0)
70
65
  mustermann-contrib (~> 1.0)
71
66
  rack (~> 2.0)
72
- hanami-utils (2.0.0.alpha1)
67
+ hanami-utils (2.0.0.alpha3)
73
68
  concurrent-ruby (~> 1.0)
74
- transproc (~> 1.0)
69
+ dry-transformer (~> 0.1)
75
70
  hansi (0.2.0)
76
- hash-deep-merge (0.1.1)
77
- i18n (1.8.5)
71
+ i18n (1.8.11)
78
72
  concurrent-ruby (~> 1.0)
79
- json_schema (0.20.9)
80
- json_schemer (0.2.16)
81
- ecma-re-validator (~> 0.2)
73
+ json_refs (0.1.7)
74
+ hana
75
+ json_schema (0.21.0)
76
+ json_schemer (0.2.18)
77
+ ecma-re-validator (~> 0.3)
82
78
  hana (~> 1.3)
83
- regexp_parser (~> 1.5)
79
+ regexp_parser (~> 2.0)
84
80
  uri_template (~> 0.7)
85
- memory_profiler (0.9.14)
86
- mini_portile2 (2.4.0)
87
- minitest (5.14.2)
81
+ memory_profiler (1.0.0)
82
+ minitest (5.14.4)
88
83
  multi_json (1.15.0)
89
84
  mustermann (1.1.1)
90
85
  ruby2_keywords (~> 0.0.1)
@@ -93,44 +88,31 @@ GEM
93
88
  mustermann (= 1.1.1)
94
89
  mustermann-grape (1.0.1)
95
90
  mustermann (>= 1.0.0)
96
- nokogiri (1.10.10)
97
- mini_portile2 (~> 2.4.0)
98
- oas_parser (0.25.2)
99
- activesupport (>= 4.0.0)
100
- addressable (~> 2.3)
101
- builder (~> 3.2.3)
102
- deep_merge (~> 1.2.1)
103
- hash-deep-merge
104
- mustermann-contrib (~> 1.1.1)
105
- nokogiri
106
- openapi_parser (0.12.1)
107
- public_suffix (4.0.6)
91
+ openapi_parser (0.15.0)
108
92
  rack (2.2.3)
109
93
  rack-accept (0.4.5)
110
94
  rack (>= 0.4)
111
95
  rack-protection (2.1.0)
112
96
  rack
113
- regexp_parser (1.8.2)
114
- ruby2_keywords (0.0.2)
97
+ regexp_parser (2.1.1)
98
+ ruby2_keywords (0.0.5)
115
99
  seg (1.2.0)
116
100
  sinatra (2.1.0)
117
101
  mustermann (~> 1.0)
118
102
  rack (~> 2.2)
119
103
  rack-protection (= 2.1.0)
120
104
  tilt (~> 2.0)
121
- syro (3.2.0)
105
+ syro (3.2.1)
122
106
  rack (>= 1.6.0)
123
107
  seg
124
- thread_safe (0.3.6)
125
108
  tilt (2.0.10)
126
- transproc (1.1.1)
127
- tzinfo (1.2.7)
128
- thread_safe (~> 0.1)
109
+ tzinfo (2.0.4)
110
+ concurrent-ruby (~> 1.0)
129
111
  uri_template (0.7.0)
130
- zeitwerk (2.4.0)
112
+ zeitwerk (2.5.1)
131
113
 
132
114
  PLATFORMS
133
- ruby
115
+ x86_64-darwin-20
134
116
 
135
117
  DEPENDENCIES
136
118
  benchmark-ips
@@ -145,4 +127,4 @@ DEPENDENCIES
145
127
  syro
146
128
 
147
129
  BUNDLED WITH
148
- 2.1.4
130
+ 2.2.28
@@ -19,6 +19,8 @@ app = Class.new(Hanami::API) do
19
19
  end
20
20
  end.new
21
21
 
22
- use Committee::Middleware::RequestValidation, schema_path: './apps/openapi.yaml'
22
+ use Committee::Middleware::RequestValidation,
23
+ schema_path: File.absolute_path('./openapi.yaml', __dir__),
24
+ parse_response_by_content_type: true
23
25
 
24
26
  run app
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'multi_json'
4
+ require 'committee'
5
+ require 'hanami/api'
6
+
7
+ app = Class.new(Hanami::API) do
8
+ get '/hello/:id' do
9
+ json(hello: 'world', id: params.fetch(:id))
10
+ end
11
+
12
+ get '/hello' do
13
+ json([{ hello: 'world' }])
14
+ end
15
+
16
+ post '/hello' do
17
+ status 201
18
+ json(hello: 'world')
19
+ end
20
+ end.new
21
+
22
+ use Committee::Middleware::RequestValidation,
23
+ schema_path: File.absolute_path('./openapi.yaml', __dir__),
24
+ parse_response_by_content_type: true
25
+
26
+ use Committee::Middleware::ResponseValidation,
27
+ schema_path: File.absolute_path('./openapi.yaml', __dir__)
28
+
29
+ run app
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'multi_json'
4
+ require 'committee'
5
+ require 'sinatra'
6
+
7
+ class SinatraWithCommiteeExample < Sinatra::Base
8
+ set :environment, :production
9
+
10
+ get '/hello/:id' do
11
+ content_type :json
12
+ MultiJson.dump(hello: 'world', id: params.fetch('id'))
13
+ end
14
+
15
+ get '/hello' do
16
+ content_type :json
17
+ MultiJson.dump([{ hello: 'world' }])
18
+ end
19
+
20
+ post '/hello' do
21
+ content_type :json
22
+ status 201
23
+ MultiJson.dump(hello: 'world')
24
+ end
25
+ end
26
+
27
+ use Committee::Middleware::RequestValidation,
28
+ schema_path: File.absolute_path('./openapi.yaml', __dir__),
29
+ parse_response_by_content_type: true
30
+
31
+ run SinatraWithCommiteeExample