openapi_first 0.13.2 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -46
- data/CHANGELOG.md +15 -1
- data/Gemfile.lock +60 -59
- data/README.md +19 -9
- data/benchmarks/Gemfile +2 -1
- data/benchmarks/Gemfile.lock +59 -59
- data/benchmarks/apps/committee.ru +14 -18
- data/benchmarks/apps/hanami_api.ru +21 -0
- data/benchmarks/apps/hanami_router.ru +1 -1
- data/benchmarks/apps/sinatra.ru +1 -1
- data/benchmarks/apps/syro.ru +3 -3
- data/benchmarks/benchmarks.rb +11 -14
- data/lib/openapi_first/app.rb +3 -5
- data/lib/openapi_first/{find_handler.rb → default_operation_resolver.rb} +5 -11
- data/lib/openapi_first/definition.rb +9 -8
- data/lib/openapi_first/operation.rb +65 -25
- data/lib/openapi_first/request_validation.rb +14 -27
- data/lib/openapi_first/responder.rb +4 -4
- data/lib/openapi_first/response_validation.rb +2 -1
- data/lib/openapi_first/router.rb +6 -4
- data/lib/openapi_first/schema_validation.rb +36 -0
- data/lib/openapi_first/utils.rb +7 -14
- data/lib/openapi_first/validation_format.rb +22 -0
- data/lib/openapi_first/version.rb +1 -1
- data/lib/openapi_first.rb +9 -4
- data/openapi_first.gemspec +4 -2
- metadata +13 -12
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66ead7e4fbab79bf30196cd2a0bbb095e767d7a5e44ca0306a6e7ece3e652b32
|
4
|
+
data.tar.gz: 4e55a3541f13b9086c5cfab83a159cda8533fbc3dccf1b2a532752dbbeb36fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc7bcb84d54684ef9d017463428926e4814018491c276ef1fc4ccc3e40394c347444951be2b994d137a33f1c69c1ddb9f96658ca71e498c7c5085afd758c4b1
|
7
|
+
data.tar.gz: 7e983ce8c1893910e61217b279970f0790879a02d8d72bda60b0eb8dbcd635eeff6928302dc29b93058a3395fc4a223883e2b2cbc2f9c7b4f47e74955f68b9cf
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.14.2
|
4
|
+
- 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.
|
5
|
+
|
6
|
+
## 0.14.1
|
7
|
+
- Bugfix: Don't mix path- and operation-level parameters for request validation
|
8
|
+
|
9
|
+
## 0.14.0
|
10
|
+
- Handle custom x-handler field in the API description to find a handler method not based on operationId
|
11
|
+
- Add `resolver` option to provide a custom resolver to find a handler method
|
12
|
+
|
13
|
+
## 0.13.3
|
14
|
+
- Better error message if string does not match format
|
15
|
+
- readOnly and writeOnly just works when used inside allOf
|
16
|
+
|
3
17
|
## 0.13.2
|
4
18
|
- Return indicator (`source: { parameter: 'list/1' }`) in error response body when array item in query parameter is invalid
|
5
19
|
|
@@ -22,7 +36,7 @@
|
|
22
36
|
|
23
37
|
## 0.12.1
|
24
38
|
- Fix response when handler returns 404 or 405
|
25
|
-
- Don't validate the response content if status is
|
39
|
+
- Don't validate the response content if status is 204 (no content)
|
26
40
|
|
27
41
|
## 0.12.0
|
28
42
|
- 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.
|
4
|
+
openapi_first (0.14.2)
|
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.
|
16
|
+
activesupport (6.1.4.1)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>=
|
19
|
-
minitest (
|
20
|
-
tzinfo (~>
|
21
|
-
zeitwerk (~> 2.
|
22
|
-
addressable (2.
|
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.
|
24
|
+
ast (2.4.2)
|
25
25
|
builder (3.2.4)
|
26
26
|
coderay (1.1.3)
|
27
|
-
concurrent-ruby (1.1.
|
27
|
+
concurrent-ruby (1.1.9)
|
28
28
|
deep_merge (1.2.1)
|
29
29
|
diff-lcs (1.4.4)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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.
|
38
|
+
hanami-utils (2.0.0.alpha2)
|
38
39
|
concurrent-ruby (~> 1.0)
|
39
|
-
|
40
|
+
dry-transformer (~> 0.1)
|
40
41
|
hansi (0.2.0)
|
41
42
|
hash-deep-merge (0.1.1)
|
42
|
-
i18n (1.8.
|
43
|
+
i18n (1.8.10)
|
43
44
|
concurrent-ruby (~> 1.0)
|
44
|
-
json_schemer (0.2.
|
45
|
-
ecma-re-validator (~> 0.
|
45
|
+
json_schemer (0.2.18)
|
46
|
+
ecma-re-validator (~> 0.3)
|
46
47
|
hana (~> 1.3)
|
47
|
-
regexp_parser (~>
|
48
|
+
regexp_parser (~> 2.0)
|
48
49
|
uri_template (~> 0.7)
|
49
50
|
method_source (1.0.0)
|
50
|
-
mini_portile2 (2.
|
51
|
-
minitest (5.14.
|
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.
|
59
|
-
mini_portile2 (~> 2.
|
60
|
-
|
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.
|
69
|
-
parser (
|
70
|
+
parallel (1.21.0)
|
71
|
+
parser (3.0.2.0)
|
70
72
|
ast (~> 2.4.1)
|
71
|
-
pry (0.
|
73
|
+
pry (0.14.1)
|
72
74
|
coderay (~> 1.1)
|
73
75
|
method_source (~> 1.0)
|
74
|
-
public_suffix (4.0.
|
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.
|
80
|
-
regexp_parser (1.
|
81
|
-
rexml (3.2.
|
82
|
-
rspec (3.
|
83
|
-
rspec-core (~> 3.
|
84
|
-
rspec-expectations (~> 3.
|
85
|
-
rspec-mocks (~> 3.
|
86
|
-
rspec-core (3.
|
87
|
-
rspec-support (~> 3.
|
88
|
-
rspec-expectations (3.
|
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.
|
91
|
-
rspec-mocks (3.
|
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.
|
94
|
-
rspec-support (3.
|
95
|
-
rubocop (
|
96
|
+
rspec-support (~> 3.10.0)
|
97
|
+
rspec-support (3.10.2)
|
98
|
+
rubocop (1.22.1)
|
96
99
|
parallel (~> 1.10)
|
97
|
-
parser (>=
|
100
|
+
parser (>= 3.0.0.0)
|
98
101
|
rainbow (>= 2.2.2, < 4.0)
|
99
|
-
regexp_parser (>= 1.
|
102
|
+
regexp_parser (>= 1.8, < 3.0)
|
100
103
|
rexml
|
101
|
-
rubocop-ast (>=
|
104
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
102
105
|
ruby-progressbar (~> 1.7)
|
103
|
-
unicode-display_width (>= 1.4.0, <
|
104
|
-
rubocop-ast (
|
105
|
-
parser (>=
|
106
|
-
ruby-progressbar (1.
|
107
|
-
ruby2_keywords (0.0.
|
108
|
-
|
109
|
-
|
110
|
-
|
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.
|
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.
|
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
|
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
|
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
|
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
|
-
|
115
|
-
| `
|
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
|
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
data/benchmarks/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
openapi_first (0.
|
4
|
+
openapi_first (0.14.2)
|
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.
|
16
|
+
activesupport (6.1.4.1)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>=
|
19
|
-
minitest (
|
20
|
-
tzinfo (~>
|
21
|
-
zeitwerk (~> 2.
|
22
|
-
addressable (2.
|
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.
|
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.
|
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.
|
32
|
+
concurrent-ruby (1.1.9)
|
33
33
|
deep_merge (1.2.1)
|
34
|
-
dry-configurable (0.
|
34
|
+
dry-configurable (0.13.0)
|
35
35
|
concurrent-ruby (~> 1.0)
|
36
|
-
dry-core (~> 0.
|
37
|
-
|
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.
|
41
|
-
dry-core (0.
|
39
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
40
|
+
dry-core (0.7.1)
|
42
41
|
concurrent-ruby (~> 1.0)
|
43
|
-
dry-
|
44
|
-
dry-
|
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.
|
48
|
-
|
49
|
-
dry-types (1.
|
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.
|
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.
|
57
|
-
regexp_parser (~>
|
58
|
-
grape (1.
|
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.
|
66
|
-
hanami-
|
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.
|
69
|
+
hanami-utils (2.0.0.alpha2)
|
71
70
|
concurrent-ruby (~> 1.0)
|
72
|
-
|
71
|
+
dry-transformer (~> 0.1)
|
73
72
|
hansi (0.2.0)
|
74
73
|
hash-deep-merge (0.1.1)
|
75
|
-
i18n (1.8.
|
74
|
+
i18n (1.8.10)
|
76
75
|
concurrent-ruby (~> 1.0)
|
77
|
-
json_schema (0.
|
78
|
-
json_schemer (0.2.
|
79
|
-
ecma-re-validator (~> 0.
|
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 (~>
|
80
|
+
regexp_parser (~> 2.0)
|
82
81
|
uri_template (~> 0.7)
|
83
82
|
memory_profiler (0.9.14)
|
84
|
-
mini_portile2 (2.
|
85
|
-
minitest (5.14.
|
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.
|
95
|
-
mini_portile2 (~> 2.
|
96
|
-
|
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.
|
105
|
-
public_suffix (4.0.
|
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
|
110
|
+
rack-protection (2.1.0)
|
110
111
|
rack
|
111
|
-
regexp_parser (1.
|
112
|
-
ruby2_keywords (0.0.
|
112
|
+
regexp_parser (2.1.1)
|
113
|
+
ruby2_keywords (0.0.5)
|
113
114
|
seg (1.2.0)
|
114
|
-
sinatra (2.0
|
115
|
+
sinatra (2.1.0)
|
115
116
|
mustermann (~> 1.0)
|
116
|
-
rack (~> 2.
|
117
|
-
rack-protection (= 2.0
|
117
|
+
rack (~> 2.2)
|
118
|
+
rack-protection (= 2.1.0)
|
118
119
|
tilt (~> 2.0)
|
119
|
-
syro (3.2.
|
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
|
-
|
125
|
-
|
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.
|
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-
|
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.
|
145
|
+
2.2.28
|
@@ -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 =
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
12
|
+
get '/hello' do
|
13
|
+
json([{ hello: 'world' }])
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
}
|