openapi_first 0.13.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ffea2d2aacb32af3f0253ff3bf149b63c65d2cc18a91b688d631021b120612f
4
- data.tar.gz: 36c3a76640b9a2210da41a165b5254d719c226dd67b32bc7867dbdc809338b50
3
+ metadata.gz: a3791f0c4bae9c39517b960e99ea3581740eaca9ad10b6189242d7690defd621
4
+ data.tar.gz: bfb77aabdba80a0406ff8909e6fcf98ef7c850465fbf562bb6dd8574bd0dd1e2
5
5
  SHA512:
6
- metadata.gz: 1acb6eb311fb503b30c182e16c37fbdfe4e8ed8219a6900bdc8602d9e4ab83762bb755bbf6a78a5ea7783d39441d3aa15bf49f7a5e631326955e4eb38b03e6ea
7
- data.tar.gz: a899dcf6876cc3b8f81d5d4be7bbdc5f9cdd0e04aa67bcd7e74fad7d29a5497e882864e87d7895db88678c5d48a7b6132effc624d36b214c2ccb391a79bbbf06
6
+ metadata.gz: b40805c6536ad7bfe932f8d42bea8580493099afdbd12667f3d646c27d2ac8cd9efe4a3dfd2a44e1460322215bfc184d4cbcf69a8b45f3b84efbcc0bfc6c2ad5
7
+ data.tar.gz: ed34c78c3b0960aa670876af49124d08175ceb163b503939c0668d4d6104b20931ca823db606503cfe9a95047cf9303a2bee597f5e97ccc3d9625dc1df02c349
data/.rubocop.yml CHANGED
@@ -1,54 +1,14 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
+ NewCops: enable
4
+ SuggestExtensions: false
3
5
  Style/Documentation:
4
6
  Enabled: false
5
7
  Style/ExponentialNotation:
6
8
  Enabled: true
7
9
  Metrics/BlockLength:
8
10
  Exclude:
9
- - 'spec/**/*.rb'
10
- - '*.gemspec'
11
- Layout/EmptyLinesAroundAttributeAccessor:
12
- Enabled: true
13
- Layout/SpaceAroundMethodCallOperator:
14
- Enabled: true
15
- Lint/DeprecatedOpenSSLConstant:
16
- Enabled: true
17
- Lint/DuplicateElsifCondition:
18
- Enabled: true
19
- Lint/RaiseException:
20
- Enabled: true
21
- Lint/MixedRegexpCaptureTypes:
22
- Enabled: true
23
- Style/RedundantRegexpCharacterClass:
24
- Enabled: true
25
- Style/RedundantRegexpEscape:
26
- Enabled: true
27
- Style/SlicingWithRange:
28
- Enabled: true
29
- Lint/StructNewOverride:
30
- Enabled: true
31
- Style/HashEachMethods:
32
- Enabled: false
33
- Style/AccessorGrouping:
34
- Enabled: true
35
- Style/ArrayCoercion:
36
- Enabled: true
37
- Style/BisectedAttrAccessor:
38
- Enabled: true
39
- Style/CaseLikeIf:
40
- Enabled: true
41
- Style/HashAsLastArrayItem:
42
- Enabled: true
43
- Style/HashLikeCase:
44
- Enabled: true
45
- Style/HashTransformKeys:
46
- Enabled: true
47
- Style/HashTransformValues:
48
- Enabled: true
49
- Style/RedundantAssignment:
50
- Enabled: true
51
- Style/RedundantFetchBlock:
52
- Enabled: true
53
- Style/RedundantFileExtensionInRequire:
54
- Enabled: true
11
+ - "spec/**/*.rb"
12
+ - "*.gemspec"
13
+ Metrics/MethodLength:
14
+ Max: 20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## 0.14.1
5
+ - Bugfix: Don't mix path- and operation-level parameters for request validation
6
+
7
+ ## 0.14.0
8
+ - Handle custom x-handler field in the API description to find a handler method not based on operationId
9
+ - Add `resolver` option to provide a custom resolver to find a handler method
10
+
11
+ ## 0.13.3
12
+ - Better error message if string does not match format
13
+ - readOnly and writeOnly just works when used inside allOf
14
+
15
+ ## 0.13.2
16
+ - Return indicator (`source: { parameter: 'list/1' }`) in error response body when array item in query parameter is invalid
17
+
3
18
  ## 0.13.0
4
19
  - Add support for arrays in query parameters (style: form, explode: false)
5
20
  - Remove warning when handler is not implemented
@@ -19,7 +34,7 @@
19
34
 
20
35
  ## 0.12.1
21
36
  - Fix response when handler returns 404 or 405
22
- - Don't validate the response content if status is 205 (no content)
37
+ - Don't validate the response content if status is 204 (no content)
23
38
 
24
39
  ## 0.12.0
25
40
  - Change `ResponseValidator` to raise an exception if it found a problem
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_first (0.13.0)
4
+ openapi_first (0.14.1)
5
5
  deep_merge (>= 1.2.1)
6
6
  hanami-router (~> 2.0.alpha3)
7
7
  hanami-utils (~> 2.0.alpha1)
8
- json_schemer (~> 0.2)
8
+ json_schemer (~> 0.2.16)
9
9
  multi_json (~> 1.14)
10
10
  oas_parser (~> 0.25.1)
11
11
  rack (~> 2.2)
@@ -13,51 +13,53 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.0.3.2)
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)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
22
+ addressable (2.8.0)
23
23
  public_suffix (>= 2.0.2, < 5.0)
24
- ast (2.4.1)
24
+ ast (2.4.2)
25
25
  builder (3.2.4)
26
26
  coderay (1.1.3)
27
- concurrent-ruby (1.1.7)
27
+ concurrent-ruby (1.1.9)
28
28
  deep_merge (1.2.1)
29
29
  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)
30
+ dry-transformer (0.1.1)
31
+ ecma-re-validator (0.3.0)
32
+ regexp_parser (~> 2.0)
33
+ hana (1.3.7)
34
+ hanami-router (2.0.0.alpha5)
34
35
  mustermann (~> 1.0)
35
36
  mustermann-contrib (~> 1.0)
36
37
  rack (~> 2.0)
37
- hanami-utils (2.0.0.alpha1)
38
+ hanami-utils (2.0.0.alpha2)
38
39
  concurrent-ruby (~> 1.0)
39
- transproc (~> 1.0)
40
+ dry-transformer (~> 0.1)
40
41
  hansi (0.2.0)
41
42
  hash-deep-merge (0.1.1)
42
- i18n (1.8.5)
43
+ i18n (1.8.10)
43
44
  concurrent-ruby (~> 1.0)
44
- json_schemer (0.2.13)
45
- ecma-re-validator (~> 0.2)
45
+ json_schemer (0.2.18)
46
+ ecma-re-validator (~> 0.3)
46
47
  hana (~> 1.3)
47
- regexp_parser (~> 1.5)
48
+ regexp_parser (~> 2.0)
48
49
  uri_template (~> 0.7)
49
50
  method_source (1.0.0)
50
- mini_portile2 (2.4.0)
51
- minitest (5.14.1)
51
+ mini_portile2 (2.6.1)
52
+ minitest (5.14.4)
52
53
  multi_json (1.15.0)
53
54
  mustermann (1.1.1)
54
55
  ruby2_keywords (~> 0.0.1)
55
56
  mustermann-contrib (1.1.1)
56
57
  hansi (~> 0.2.0)
57
58
  mustermann (= 1.1.1)
58
- nokogiri (1.10.10)
59
- mini_portile2 (~> 2.4.0)
60
- oas_parser (0.25.1)
59
+ nokogiri (1.12.5)
60
+ mini_portile2 (~> 2.6.1)
61
+ racc (~> 1.4)
62
+ oas_parser (0.25.4)
61
63
  activesupport (>= 4.0.0)
62
64
  addressable (~> 2.3)
63
65
  builder (~> 3.2.3)
@@ -65,53 +67,52 @@ GEM
65
67
  hash-deep-merge
66
68
  mustermann-contrib (~> 1.1.1)
67
69
  nokogiri
68
- parallel (1.19.2)
69
- parser (2.7.1.4)
70
+ parallel (1.21.0)
71
+ parser (3.0.2.0)
70
72
  ast (~> 2.4.1)
71
- pry (0.13.1)
73
+ pry (0.14.1)
72
74
  coderay (~> 1.1)
73
75
  method_source (~> 1.0)
74
- public_suffix (4.0.5)
76
+ public_suffix (4.0.6)
77
+ racc (1.5.2)
75
78
  rack (2.2.3)
76
79
  rack-test (1.1.0)
77
80
  rack (>= 1.0, < 3)
78
81
  rainbow (3.0.0)
79
- rake (13.0.1)
80
- regexp_parser (1.7.1)
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.2)
87
- rspec-support (~> 3.9.3)
88
- rspec-expectations (3.9.2)
82
+ rake (13.0.6)
83
+ regexp_parser (2.1.1)
84
+ rexml (3.2.5)
85
+ rspec (3.10.0)
86
+ rspec-core (~> 3.10.0)
87
+ rspec-expectations (~> 3.10.0)
88
+ rspec-mocks (~> 3.10.0)
89
+ rspec-core (3.10.1)
90
+ rspec-support (~> 3.10.0)
91
+ rspec-expectations (3.10.1)
89
92
  diff-lcs (>= 1.2.0, < 2.0)
90
- rspec-support (~> 3.9.0)
91
- rspec-mocks (3.9.1)
93
+ rspec-support (~> 3.10.0)
94
+ rspec-mocks (3.10.2)
92
95
  diff-lcs (>= 1.2.0, < 2.0)
93
- rspec-support (~> 3.9.0)
94
- rspec-support (3.9.3)
95
- rubocop (0.88.0)
96
+ rspec-support (~> 3.10.0)
97
+ rspec-support (3.10.2)
98
+ rubocop (1.22.1)
96
99
  parallel (~> 1.10)
97
- parser (>= 2.7.1.1)
100
+ parser (>= 3.0.0.0)
98
101
  rainbow (>= 2.2.2, < 4.0)
99
- regexp_parser (>= 1.7)
102
+ regexp_parser (>= 1.8, < 3.0)
100
103
  rexml
101
- rubocop-ast (>= 0.1.0, < 1.0)
104
+ rubocop-ast (>= 1.12.0, < 2.0)
102
105
  ruby-progressbar (~> 1.7)
103
- unicode-display_width (>= 1.4.0, < 2.0)
104
- rubocop-ast (0.2.0)
105
- parser (>= 2.7.0.1)
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.7)
111
- thread_safe (~> 0.1)
112
- unicode-display_width (1.7.0)
106
+ unicode-display_width (>= 1.4.0, < 3.0)
107
+ rubocop-ast (1.12.0)
108
+ parser (>= 3.0.1.1)
109
+ ruby-progressbar (1.11.0)
110
+ ruby2_keywords (0.0.5)
111
+ tzinfo (2.0.4)
112
+ concurrent-ruby (~> 1.0)
113
+ unicode-display_width (2.1.0)
113
114
  uri_template (0.7.0)
114
- zeitwerk (2.4.0)
115
+ zeitwerk (2.4.2)
115
116
 
116
117
  PLATFORMS
117
118
  ruby
@@ -126,4 +127,4 @@ DEPENDENCIES
126
127
  rubocop
127
128
 
128
129
  BUNDLED WITH
129
- 2.1.4
130
+ 2.2.28
data/README.md CHANGED
@@ -19,7 +19,7 @@ OpenapiFirst consists of these Rack middlewares:
19
19
 
20
20
  - [`OpenapiFirst::Router`](#OpenapiFirst::Router) – Finds the OpenAPI operation for the current request or returns 404 if no operation was found. This can be customized.
21
21
  - [`OpenapiFirst::RequestValidation`](#OpenapiFirst::RequestValidation) – Validates the request against the API description and returns 400 if the request is invalid.
22
- - [`OpenapiFirst::Responder`](#OpenapiFirst::Responder) calls the [handler](#handlers) found for the operation.
22
+ - [`OpenapiFirst::Responder`](#OpenapiFirst::Responder) calls the [handler](#handlers) found for the operation, sets the correct content-type and serialized the response body to json if needed.
23
23
  - [`OpenapiFirst::ResponseValidation`](#OpenapiFirst::ResponseValidation) Validates the response and raises an exception if the response body is invalid.
24
24
 
25
25
  ## OpenapiFirst::Router
@@ -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
  |:---|---|---|---|
@@ -99,20 +99,29 @@ This will also add the parsed request body to `env[OpenapiFirst::REQUEST_BODY]`.
99
99
 
100
100
  tbd.
101
101
 
102
+ ### readOnly / writeOnly properties
103
+
104
+ Request validation fails if request includes a property with `readOnly: true`.
105
+
106
+ Response validation fails if response body includes a property with `writeOnly: true`.
107
+
102
108
  ## OpenapiFirst::Responder
103
109
 
104
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.
105
111
 
106
- Currently there are no customization options for this part. Please [share your ideas](#contributing) on how to best meet your needs and preferred style.
107
-
108
112
  ```ruby
109
113
  run OpenapiFirst::Responder, spec: OpenapiFirst.load('./openapi/openapi.yaml')
110
114
  ```
111
115
 
116
+ ### Options
112
117
  | Name | Description
113
118
  |:---|---|
114
- |`spec:`| The spec loaded via `OpenapiFirst.load` |
115
- | `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.
116
125
 
117
126
  It works like this:
118
127
 
@@ -170,7 +179,7 @@ The above will use the mentioned Rack middlewares to:
170
179
  - Map the request to a method call `Pets.find_pet` based on the `operationId` in the API description
171
180
  - Set the response content type according to your spec (here with the default status code `200`)
172
181
 
173
- ### Options and their defaults:
182
+ ### Options and defaults
174
183
 
175
184
  | Name | Possible values | Description | Default
176
185
  |:---|---|---|---|
@@ -179,6 +188,7 @@ The above will use the mentioned Rack middlewares to:
179
188
  | `response_validation:` | `true`, `false` | If set to true it raises an exception if the response is invalid. This is useful during testing. | `false`
180
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`
181
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.
182
192
 
183
193
 
184
194
  Handler functions (`find_pet`) are called with two arguments:
data/benchmarks/Gemfile CHANGED
@@ -6,7 +6,8 @@ gem 'benchmark-ips'
6
6
  gem 'benchmark-memory'
7
7
  gem 'committee'
8
8
  gem 'grape'
9
- gem 'hanami-router', '~> 2.0.0.alpha2'
9
+ gem 'hanami-api'
10
+ gem 'hanami-router', '~> 2.0.0.alpha3'
10
11
  gem 'multi_json'
11
12
  gem 'openapi_first', path: '../'
12
13
  gem 'sinatra'
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- openapi_first (0.13.0)
4
+ openapi_first (0.14.1)
5
5
  deep_merge (>= 1.2.1)
6
6
  hanami-router (~> 2.0.alpha3)
7
7
  hanami-utils (~> 2.0.alpha1)
8
- json_schemer (~> 0.2)
8
+ json_schemer (~> 0.2.16)
9
9
  multi_json (~> 1.14)
10
10
  oas_parser (~> 0.25.1)
11
11
  rack (~> 2.2)
@@ -13,76 +13,75 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.0.3.2)
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)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
22
+ addressable (2.8.0)
23
23
  public_suffix (>= 2.0.2, < 5.0)
24
- benchmark-ips (2.8.2)
24
+ benchmark-ips (2.9.1)
25
25
  benchmark-memory (0.1.2)
26
26
  memory_profiler (~> 0.9)
27
27
  builder (3.2.4)
28
- committee (4.2.0)
28
+ committee (4.4.0)
29
29
  json_schema (~> 0.14, >= 0.14.3)
30
- openapi_parser (>= 0.11.1)
30
+ openapi_parser (>= 0.11.1, < 1.0)
31
31
  rack (>= 1.5)
32
- concurrent-ruby (1.1.7)
32
+ concurrent-ruby (1.1.9)
33
33
  deep_merge (1.2.1)
34
- dry-configurable (0.11.6)
34
+ dry-configurable (0.13.0)
35
35
  concurrent-ruby (~> 1.0)
36
- dry-core (~> 0.4, >= 0.4.7)
37
- dry-equalizer (~> 0.2)
38
- dry-container (0.7.2)
36
+ dry-core (~> 0.6)
37
+ dry-container (0.9.0)
39
38
  concurrent-ruby (~> 1.0)
40
- dry-configurable (~> 0.1, >= 0.1.3)
41
- dry-core (0.4.9)
39
+ dry-configurable (~> 0.13, >= 0.13.0)
40
+ dry-core (0.7.1)
42
41
  concurrent-ruby (~> 1.0)
43
- dry-equalizer (0.3.0)
44
- dry-inflector (0.2.0)
45
- dry-logic (1.0.7)
42
+ dry-inflector (0.2.1)
43
+ dry-logic (1.2.0)
46
44
  concurrent-ruby (~> 1.0)
47
- dry-core (~> 0.2)
48
- dry-equalizer (~> 0.2)
49
- dry-types (1.4.0)
45
+ dry-core (~> 0.5, >= 0.5)
46
+ dry-transformer (0.1.1)
47
+ dry-types (1.5.1)
50
48
  concurrent-ruby (~> 1.0)
51
49
  dry-container (~> 0.3)
52
- dry-core (~> 0.4, >= 0.4.4)
53
- dry-equalizer (~> 0.3)
50
+ dry-core (~> 0.5, >= 0.5)
54
51
  dry-inflector (~> 0.1, >= 0.1.2)
55
52
  dry-logic (~> 1.0, >= 1.0.2)
56
- ecma-re-validator (0.2.1)
57
- regexp_parser (~> 1.2)
58
- grape (1.4.0)
53
+ ecma-re-validator (0.3.0)
54
+ regexp_parser (~> 2.0)
55
+ grape (1.6.0)
59
56
  activesupport
60
57
  builder
61
58
  dry-types (>= 1.1)
62
59
  mustermann-grape (~> 1.0.0)
63
60
  rack (>= 1.3.0)
64
61
  rack-accept
65
- hana (1.3.6)
66
- hanami-router (2.0.0.alpha3)
62
+ hana (1.3.7)
63
+ hanami-api (0.2.0)
64
+ hanami-router (~> 2.0.alpha)
65
+ hanami-router (2.0.0.alpha5)
67
66
  mustermann (~> 1.0)
68
67
  mustermann-contrib (~> 1.0)
69
68
  rack (~> 2.0)
70
- hanami-utils (2.0.0.alpha1)
69
+ hanami-utils (2.0.0.alpha2)
71
70
  concurrent-ruby (~> 1.0)
72
- transproc (~> 1.0)
71
+ dry-transformer (~> 0.1)
73
72
  hansi (0.2.0)
74
73
  hash-deep-merge (0.1.1)
75
- i18n (1.8.5)
74
+ i18n (1.8.10)
76
75
  concurrent-ruby (~> 1.0)
77
- json_schema (0.20.9)
78
- json_schemer (0.2.13)
79
- ecma-re-validator (~> 0.2)
76
+ json_schema (0.21.0)
77
+ json_schemer (0.2.18)
78
+ ecma-re-validator (~> 0.3)
80
79
  hana (~> 1.3)
81
- regexp_parser (~> 1.5)
80
+ regexp_parser (~> 2.0)
82
81
  uri_template (~> 0.7)
83
82
  memory_profiler (0.9.14)
84
- mini_portile2 (2.4.0)
85
- minitest (5.14.1)
83
+ mini_portile2 (2.6.1)
84
+ minitest (5.14.4)
86
85
  multi_json (1.15.0)
87
86
  mustermann (1.1.1)
88
87
  ruby2_keywords (~> 0.0.1)
@@ -91,9 +90,10 @@ GEM
91
90
  mustermann (= 1.1.1)
92
91
  mustermann-grape (1.0.1)
93
92
  mustermann (>= 1.0.0)
94
- nokogiri (1.10.10)
95
- mini_portile2 (~> 2.4.0)
96
- oas_parser (0.25.1)
93
+ nokogiri (1.12.5)
94
+ mini_portile2 (~> 2.6.1)
95
+ racc (~> 1.4)
96
+ oas_parser (0.25.4)
97
97
  activesupport (>= 4.0.0)
98
98
  addressable (~> 2.3)
99
99
  builder (~> 3.2.3)
@@ -101,31 +101,30 @@ GEM
101
101
  hash-deep-merge
102
102
  mustermann-contrib (~> 1.1.1)
103
103
  nokogiri
104
- openapi_parser (0.12.1)
105
- public_suffix (4.0.5)
104
+ openapi_parser (0.15.0)
105
+ public_suffix (4.0.6)
106
+ racc (1.5.2)
106
107
  rack (2.2.3)
107
108
  rack-accept (0.4.5)
108
109
  rack (>= 0.4)
109
- rack-protection (2.0.8.1)
110
+ rack-protection (2.1.0)
110
111
  rack
111
- regexp_parser (1.7.1)
112
- ruby2_keywords (0.0.2)
112
+ regexp_parser (2.1.1)
113
+ ruby2_keywords (0.0.5)
113
114
  seg (1.2.0)
114
- sinatra (2.0.8.1)
115
+ sinatra (2.1.0)
115
116
  mustermann (~> 1.0)
116
- rack (~> 2.0)
117
- rack-protection (= 2.0.8.1)
117
+ rack (~> 2.2)
118
+ rack-protection (= 2.1.0)
118
119
  tilt (~> 2.0)
119
- syro (3.2.0)
120
+ syro (3.2.1)
120
121
  rack (>= 1.6.0)
121
122
  seg
122
- thread_safe (0.3.6)
123
123
  tilt (2.0.10)
124
- transproc (1.1.1)
125
- tzinfo (1.2.7)
126
- thread_safe (~> 0.1)
124
+ tzinfo (2.0.4)
125
+ concurrent-ruby (~> 1.0)
127
126
  uri_template (0.7.0)
128
- zeitwerk (2.4.0)
127
+ zeitwerk (2.4.2)
129
128
 
130
129
  PLATFORMS
131
130
  ruby
@@ -135,11 +134,12 @@ DEPENDENCIES
135
134
  benchmark-memory
136
135
  committee
137
136
  grape
138
- hanami-router (~> 2.0.0.alpha2)
137
+ hanami-api
138
+ hanami-router (~> 2.0.0.alpha3)
139
139
  multi_json
140
140
  openapi_first!
141
141
  sinatra
142
142
  syro
143
143
 
144
144
  BUNDLED WITH
145
- 2.1.4
145
+ 2.2.3
@@ -1,30 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'committee'
4
- require 'syro'
5
3
  require 'multi_json'
4
+ require 'committee'
5
+ require 'hanami/api'
6
6
 
7
- app = Syro.new do
8
- on 'hello' do
9
- on :id do
10
- get do
11
- res.json MultiJson.dump(hello: 'world', id: inbox[:id])
12
- end
13
- end
7
+ app = Class.new(Hanami::API) do
8
+ get '/hello/:id' do
9
+ json(hello: 'world', id: params.fetch(:id))
10
+ end
14
11
 
15
- get do
16
- res.json [MultiJson.dump(hello: 'world')]
17
- end
12
+ get '/hello' do
13
+ json([{ hello: 'world' }])
14
+ end
18
15
 
19
- post do
20
- res.status = 201
21
- res.json MultiJson.dump(hello: 'world')
22
- end
16
+ post '/hello' do
17
+ status 201
18
+ json(hello: 'world')
23
19
  end
24
- end
20
+ end.new
25
21
 
26
22
  use Committee::Middleware::RequestValidation,
27
23
  schema_path: './apps/openapi.yaml',
28
- coerce_date_times: false
24
+ parse_response_by_content_type: true
29
25
 
30
26
  run app
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'multi_json'
4
+ require 'hanami/api'
5
+
6
+ app = Class.new(Hanami::API) do
7
+ get '/hello/:id' do
8
+ json(hello: 'world', id: params.fetch(:id))
9
+ end
10
+
11
+ get '/hello' do
12
+ json([{ hello: 'world' }])
13
+ end
14
+
15
+ post '/hello' do
16
+ status 201
17
+ json(hello: 'world')
18
+ end
19
+ end.new
20
+
21
+ run app
@@ -4,7 +4,7 @@ require 'hanami/router'
4
4
  require 'multi_json'
5
5
 
6
6
  app = Hanami::Router.new do
7
- get '/hello', to: ->(_env) { [200, {}, [MultiJson.dump(hello: 'world')]] }
7
+ get '/hello', to: ->(_env) { [200, {}, [MultiJson.dump([{ hello: 'world' }])]] }
8
8
  get '/hello/:id', to: lambda { |env|
9
9
  [200, {}, [MultiJson.dump(hello: 'world', id: env['router.params'][:id])]]
10
10
  }
@@ -13,7 +13,7 @@ class SinatraExample < Sinatra::Base
13
13
 
14
14
  get '/hello' do
15
15
  content_type :json
16
- [MultiJson.dump(hello: 'world')]
16
+ MultiJson.dump([{ hello: 'world' }])
17
17
  end
18
18
 
19
19
  post '/hello' do