openapi_first 0.14.2 → 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 +4 -4
- data/CHANGELOG.md +30 -1
- data/Gemfile.lock +9 -37
- data/README.md +4 -0
- data/benchmarks/Gemfile.lock +12 -27
- data/benchmarks/apps/committee.ru +1 -1
- data/benchmarks/apps/committee_with_response_validation.ru +29 -0
- data/benchmarks/apps/committee_with_sinatra.ru +31 -0
- data/benchmarks/apps/openapi.yaml +14 -14
- data/benchmarks/apps/openapi_first_with_hanami_api.ru +26 -0
- data/benchmarks/apps/openapi_first_with_response_validation.ru +22 -0
- data/lib/openapi_first/app.rb +0 -1
- data/lib/openapi_first/operation.rb +0 -1
- data/lib/openapi_first/request_validation.rb +0 -1
- data/lib/openapi_first/responder.rb +1 -0
- data/lib/openapi_first/response_object.rb +0 -1
- data/lib/openapi_first/response_validation.rb +1 -2
- data/lib/openapi_first/response_validator.rb +1 -3
- data/lib/openapi_first/router.rb +0 -1
- data/lib/openapi_first/version.rb +1 -1
- data/lib/openapi_first.rb +14 -12
- data/openapi_first.gemspec +5 -2
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b6acd9051ff71dbc3980ec2547e6597992b4970f2aef176c4e118227f6ede01
|
4
|
+
data.tar.gz: d8f7a2142aaf4c2d07f951c75500bf1790fc7e9bee0006242a075de6f35ed405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca8769be4df5874bd1c4c36c80df6a9301c06687385cd6105f6c0acbcbcb39ff903b55a16df36aad3933e7f490ea8817975bf601c37b10d8b8489946e01cc1c
|
7
|
+
data.tar.gz: '08588cfd43470ed9181b2420731e86ef2fdc99cb90dafd55af6228cd67d0e94c4eea9d7a9b3695a0034bd88c0d0a3ce071081579aeac66cf96ae995a8869d53f'
|
data/CHANGELOG.md
CHANGED
@@ -1,44 +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
|
+
|
3
7
|
## 0.14.2
|
8
|
+
|
4
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.
|
5
10
|
|
6
11
|
## 0.14.1
|
12
|
+
|
7
13
|
- Bugfix: Don't mix path- and operation-level parameters for request validation
|
8
14
|
|
9
15
|
## 0.14.0
|
16
|
+
|
10
17
|
- Handle custom x-handler field in the API description to find a handler method not based on operationId
|
11
18
|
- Add `resolver` option to provide a custom resolver to find a handler method
|
12
19
|
|
13
20
|
## 0.13.3
|
21
|
+
|
14
22
|
- Better error message if string does not match format
|
15
23
|
- readOnly and writeOnly just works when used inside allOf
|
16
24
|
|
17
25
|
## 0.13.2
|
26
|
+
|
18
27
|
- Return indicator (`source: { parameter: 'list/1' }`) in error response body when array item in query parameter is invalid
|
19
28
|
|
20
29
|
## 0.13.0
|
30
|
+
|
21
31
|
- Add support for arrays in query parameters (style: form, explode: false)
|
22
32
|
- Remove warning when handler is not implemented
|
23
33
|
|
24
34
|
## 0.12.5
|
35
|
+
|
25
36
|
- Add `not_found: :continue` option to Router to make it do nothing if request is unknown
|
26
37
|
|
27
38
|
## 0.12.4
|
39
|
+
|
28
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`)
|
29
41
|
- Support wildcard mime-types when finding the content-type
|
30
42
|
|
31
43
|
## 0.12.3
|
44
|
+
|
32
45
|
- Add `response_validation:`, `router_raise_error` options to standalone mode.
|
33
46
|
|
34
47
|
## 0.12.2
|
48
|
+
|
35
49
|
- Allow response to have no media type object specified
|
36
50
|
|
37
51
|
## 0.12.1
|
52
|
+
|
38
53
|
- Fix response when handler returns 404 or 405
|
39
54
|
- Don't validate the response content if status is 204 (no content)
|
40
55
|
|
41
56
|
## 0.12.0
|
57
|
+
|
42
58
|
- Change `ResponseValidator` to raise an exception if it found a problem
|
43
59
|
- Params have symbolized keys now
|
44
60
|
- Remove `not_found` option from Router. Return 405 if HTTP verb is not allowed (via Hanami::Router)
|
@@ -50,6 +66,7 @@
|
|
50
66
|
- Add `Operation#name` that returns a human readable name for an operation
|
51
67
|
|
52
68
|
## 0.11.0
|
69
|
+
|
53
70
|
- Raise error if you forgot to add the Router middleware
|
54
71
|
- Make OpenapiFirst.app raise an error in test env when request path is not specified
|
55
72
|
- Rename OperationResolver to Responder
|
@@ -58,48 +75,60 @@
|
|
58
75
|
- Move namespace option from Router to OperationResolver
|
59
76
|
|
60
77
|
## 0.10.2
|
78
|
+
|
61
79
|
- Return 400 if request body has invalid JSON ([issue](https://github.com/ahx/openapi_first/issues/73)) thanks Thomas Frütel
|
62
80
|
|
63
81
|
## 0.10.1
|
82
|
+
|
64
83
|
- Fix duplicated key in `required` when generating JSON schema for `some[thing]` parameters
|
65
84
|
|
66
85
|
## 0.10.0
|
86
|
+
|
67
87
|
- Add support for query parameters named `"some[thing]"` ([issue](https://github.com/ahx/openapi_first/issues/40))
|
68
88
|
|
69
89
|
## 0.9.0
|
90
|
+
|
70
91
|
- Make request validation usable standalone
|
71
92
|
|
72
93
|
## 0.8.0
|
94
|
+
|
73
95
|
- Add merged parameter and request body available to env at `env[OpenapiFirst::INBOX]` in request validation
|
74
96
|
- Path and query parameters with `type: boolean` now get converted to `true`/`false`
|
75
97
|
- Rename `OpenapiFirst::PARAMS` to `OpenapiFirst::PARAMETERS`
|
76
98
|
|
77
99
|
## 0.7.1
|
100
|
+
|
78
101
|
- Add missing `require` to work with new version of `oas_parser`
|
79
102
|
|
80
103
|
## 0.7.0
|
104
|
+
|
81
105
|
- Make use of hanami-router, because it's fast
|
82
106
|
- Remove option `allow_unknown_query_paramerters`
|
83
107
|
- Move the namespace option to Router
|
84
|
-
- Convert numeric path and query parameters
|
108
|
+
- Convert numeric path and query parameters to `Integer` or `Float`
|
85
109
|
- Pass the Rack env if your action class' initializers accepts an argument
|
86
110
|
- Respec rack's `env['SCRIPT_NAME']` in router
|
87
111
|
- Add MIT license
|
88
112
|
|
89
113
|
## 0.6.10
|
114
|
+
|
90
115
|
- Bugfix: params.env['unknown'] now returns `nil` as expected. Thanks @tristandruyen.
|
91
116
|
|
92
117
|
## 0.6.9
|
118
|
+
|
93
119
|
- Removed radix tree, because of a bug (https://github.com/namusyaka/r2ree-ruby/issues/2)
|
94
120
|
|
95
121
|
## 0.6.8
|
122
|
+
|
96
123
|
- Performance: About 25% performance increase (i/s) with help of c++ based radix-tree and some optimizations
|
97
124
|
- Update dependencies
|
98
125
|
|
99
126
|
## 0.6.7
|
127
|
+
|
100
128
|
- Fix: version number of oas_parser
|
101
129
|
|
102
130
|
## 0.6.6
|
131
|
+
|
103
132
|
- Remove warnings for Ruby 2.7
|
104
133
|
|
105
134
|
## 0.6.5
|
data/Gemfile.lock
CHANGED
@@ -3,26 +3,17 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
openapi_first (0.14.2)
|
5
5
|
deep_merge (>= 1.2.1)
|
6
|
-
hanami-router (~> 2.0.
|
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.1.4.1)
|
17
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>= 1.6, < 2)
|
19
|
-
minitest (>= 5.1)
|
20
|
-
tzinfo (~> 2.0)
|
21
|
-
zeitwerk (~> 2.3)
|
22
|
-
addressable (2.8.0)
|
23
|
-
public_suffix (>= 2.0.2, < 5.0)
|
24
16
|
ast (2.4.2)
|
25
|
-
builder (3.2.4)
|
26
17
|
coderay (1.1.3)
|
27
18
|
concurrent-ruby (1.1.9)
|
28
19
|
deep_merge (1.2.1)
|
@@ -35,46 +26,30 @@ GEM
|
|
35
26
|
mustermann (~> 1.0)
|
36
27
|
mustermann-contrib (~> 1.0)
|
37
28
|
rack (~> 2.0)
|
38
|
-
hanami-utils (2.0.0.
|
29
|
+
hanami-utils (2.0.0.alpha3)
|
39
30
|
concurrent-ruby (~> 1.0)
|
40
31
|
dry-transformer (~> 0.1)
|
41
32
|
hansi (0.2.0)
|
42
|
-
|
43
|
-
|
44
|
-
concurrent-ruby (~> 1.0)
|
33
|
+
json_refs (0.1.7)
|
34
|
+
hana
|
45
35
|
json_schemer (0.2.18)
|
46
36
|
ecma-re-validator (~> 0.3)
|
47
37
|
hana (~> 1.3)
|
48
38
|
regexp_parser (~> 2.0)
|
49
39
|
uri_template (~> 0.7)
|
50
40
|
method_source (1.0.0)
|
51
|
-
mini_portile2 (2.6.1)
|
52
|
-
minitest (5.14.4)
|
53
41
|
multi_json (1.15.0)
|
54
42
|
mustermann (1.1.1)
|
55
43
|
ruby2_keywords (~> 0.0.1)
|
56
44
|
mustermann-contrib (1.1.1)
|
57
45
|
hansi (~> 0.2.0)
|
58
46
|
mustermann (= 1.1.1)
|
59
|
-
nokogiri (1.12.5)
|
60
|
-
mini_portile2 (~> 2.6.1)
|
61
|
-
racc (~> 1.4)
|
62
|
-
oas_parser (0.25.4)
|
63
|
-
activesupport (>= 4.0.0)
|
64
|
-
addressable (~> 2.3)
|
65
|
-
builder (~> 3.2.3)
|
66
|
-
deep_merge (~> 1.2.1)
|
67
|
-
hash-deep-merge
|
68
|
-
mustermann-contrib (~> 1.1.1)
|
69
|
-
nokogiri
|
70
47
|
parallel (1.21.0)
|
71
48
|
parser (3.0.2.0)
|
72
49
|
ast (~> 2.4.1)
|
73
50
|
pry (0.14.1)
|
74
51
|
coderay (~> 1.1)
|
75
52
|
method_source (~> 1.0)
|
76
|
-
public_suffix (4.0.6)
|
77
|
-
racc (1.5.2)
|
78
53
|
rack (2.2.3)
|
79
54
|
rack-test (1.1.0)
|
80
55
|
rack (>= 1.0, < 3)
|
@@ -94,8 +69,8 @@ GEM
|
|
94
69
|
rspec-mocks (3.10.2)
|
95
70
|
diff-lcs (>= 1.2.0, < 2.0)
|
96
71
|
rspec-support (~> 3.10.0)
|
97
|
-
rspec-support (3.10.
|
98
|
-
rubocop (1.
|
72
|
+
rspec-support (3.10.3)
|
73
|
+
rubocop (1.23.0)
|
99
74
|
parallel (~> 1.10)
|
100
75
|
parser (>= 3.0.0.0)
|
101
76
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -104,18 +79,15 @@ GEM
|
|
104
79
|
rubocop-ast (>= 1.12.0, < 2.0)
|
105
80
|
ruby-progressbar (~> 1.7)
|
106
81
|
unicode-display_width (>= 1.4.0, < 3.0)
|
107
|
-
rubocop-ast (1.
|
82
|
+
rubocop-ast (1.13.0)
|
108
83
|
parser (>= 3.0.1.1)
|
109
84
|
ruby-progressbar (1.11.0)
|
110
85
|
ruby2_keywords (0.0.5)
|
111
|
-
tzinfo (2.0.4)
|
112
|
-
concurrent-ruby (~> 1.0)
|
113
86
|
unicode-display_width (2.1.0)
|
114
87
|
uri_template (0.7.0)
|
115
|
-
zeitwerk (2.4.2)
|
116
88
|
|
117
89
|
PLATFORMS
|
118
|
-
|
90
|
+
x86_64-darwin-20
|
119
91
|
|
120
92
|
DEPENDENCIES
|
121
93
|
bundler (~> 2)
|
data/README.md
CHANGED
data/benchmarks/Gemfile.lock
CHANGED
@@ -3,11 +3,11 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
openapi_first (0.14.2)
|
5
5
|
deep_merge (>= 1.2.1)
|
6
|
-
hanami-router (~> 2.0.
|
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
|
@@ -19,11 +19,9 @@ GEM
|
|
19
19
|
minitest (>= 5.1)
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
zeitwerk (~> 2.3)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
benchmark-memory (0.1.2)
|
26
|
-
memory_profiler (~> 0.9)
|
22
|
+
benchmark-ips (2.9.2)
|
23
|
+
benchmark-memory (0.2.0)
|
24
|
+
memory_profiler (~> 1)
|
27
25
|
builder (3.2.4)
|
28
26
|
committee (4.4.0)
|
29
27
|
json_schema (~> 0.14, >= 0.14.3)
|
@@ -66,21 +64,21 @@ GEM
|
|
66
64
|
mustermann (~> 1.0)
|
67
65
|
mustermann-contrib (~> 1.0)
|
68
66
|
rack (~> 2.0)
|
69
|
-
hanami-utils (2.0.0.
|
67
|
+
hanami-utils (2.0.0.alpha3)
|
70
68
|
concurrent-ruby (~> 1.0)
|
71
69
|
dry-transformer (~> 0.1)
|
72
70
|
hansi (0.2.0)
|
73
|
-
|
74
|
-
i18n (1.8.10)
|
71
|
+
i18n (1.8.11)
|
75
72
|
concurrent-ruby (~> 1.0)
|
73
|
+
json_refs (0.1.7)
|
74
|
+
hana
|
76
75
|
json_schema (0.21.0)
|
77
76
|
json_schemer (0.2.18)
|
78
77
|
ecma-re-validator (~> 0.3)
|
79
78
|
hana (~> 1.3)
|
80
79
|
regexp_parser (~> 2.0)
|
81
80
|
uri_template (~> 0.7)
|
82
|
-
memory_profiler (0.
|
83
|
-
mini_portile2 (2.6.1)
|
81
|
+
memory_profiler (1.0.0)
|
84
82
|
minitest (5.14.4)
|
85
83
|
multi_json (1.15.0)
|
86
84
|
mustermann (1.1.1)
|
@@ -90,20 +88,7 @@ GEM
|
|
90
88
|
mustermann (= 1.1.1)
|
91
89
|
mustermann-grape (1.0.1)
|
92
90
|
mustermann (>= 1.0.0)
|
93
|
-
nokogiri (1.12.5)
|
94
|
-
mini_portile2 (~> 2.6.1)
|
95
|
-
racc (~> 1.4)
|
96
|
-
oas_parser (0.25.4)
|
97
|
-
activesupport (>= 4.0.0)
|
98
|
-
addressable (~> 2.3)
|
99
|
-
builder (~> 3.2.3)
|
100
|
-
deep_merge (~> 1.2.1)
|
101
|
-
hash-deep-merge
|
102
|
-
mustermann-contrib (~> 1.1.1)
|
103
|
-
nokogiri
|
104
91
|
openapi_parser (0.15.0)
|
105
|
-
public_suffix (4.0.6)
|
106
|
-
racc (1.5.2)
|
107
92
|
rack (2.2.3)
|
108
93
|
rack-accept (0.4.5)
|
109
94
|
rack (>= 0.4)
|
@@ -124,10 +109,10 @@ GEM
|
|
124
109
|
tzinfo (2.0.4)
|
125
110
|
concurrent-ruby (~> 1.0)
|
126
111
|
uri_template (0.7.0)
|
127
|
-
zeitwerk (2.
|
112
|
+
zeitwerk (2.5.1)
|
128
113
|
|
129
114
|
PLATFORMS
|
130
|
-
|
115
|
+
x86_64-darwin-20
|
131
116
|
|
132
117
|
DEPENDENCIES
|
133
118
|
benchmark-ips
|
@@ -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
|
@@ -28,15 +28,13 @@ paths:
|
|
28
28
|
content:
|
29
29
|
application/json:
|
30
30
|
schema:
|
31
|
-
type:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
id:
|
39
|
-
type: string
|
31
|
+
type: object
|
32
|
+
required: [hello, id]
|
33
|
+
properties:
|
34
|
+
hello:
|
35
|
+
type: string
|
36
|
+
id:
|
37
|
+
type: string
|
40
38
|
/hello:
|
41
39
|
get:
|
42
40
|
operationId: find_things
|
@@ -61,11 +59,13 @@ paths:
|
|
61
59
|
content:
|
62
60
|
application/json:
|
63
61
|
schema:
|
64
|
-
type:
|
65
|
-
|
66
|
-
|
67
|
-
hello
|
68
|
-
|
62
|
+
type: array
|
63
|
+
items:
|
64
|
+
type: object
|
65
|
+
required: [hello]
|
66
|
+
properties:
|
67
|
+
hello:
|
68
|
+
type: string
|
69
69
|
default:
|
70
70
|
description: Error response
|
71
71
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'multi_json'
|
4
|
+
require 'openapi_first'
|
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
|
+
oas_path = File.absolute_path('./openapi.yaml', __dir__)
|
23
|
+
use OpenapiFirst::Router, spec: OpenapiFirst.load(oas_path)
|
24
|
+
use OpenapiFirst::RequestValidation
|
25
|
+
|
26
|
+
run app
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'multi_json'
|
4
|
+
require 'openapi_first'
|
5
|
+
|
6
|
+
namespace = Module.new do
|
7
|
+
def self.find_thing(params, _res)
|
8
|
+
{ hello: 'world', id: params.fetch(:id) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_things(_params, _res)
|
12
|
+
[{ hello: 'world' }]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create_thing(_params, res)
|
16
|
+
res.status = 201
|
17
|
+
{ hello: 'world' }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
oas_path = File.absolute_path('./openapi.yaml', __dir__)
|
22
|
+
run OpenapiFirst.app(oas_path, namespace: namespace, response_validation: true)
|
data/lib/openapi_first/app.rb
CHANGED
data/lib/openapi_first/router.rb
CHANGED
data/lib/openapi_first.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
require 'json_refs'
|
5
|
+
require_relative 'openapi_first/definition'
|
6
|
+
require_relative 'openapi_first/version'
|
7
|
+
require_relative 'openapi_first/inbox'
|
8
|
+
require_relative 'openapi_first/router'
|
9
|
+
require_relative 'openapi_first/request_validation'
|
10
|
+
require_relative 'openapi_first/response_validator'
|
11
|
+
require_relative 'openapi_first/response_validation'
|
12
|
+
require_relative 'openapi_first/responder'
|
13
|
+
require_relative 'openapi_first/app'
|
14
14
|
|
15
15
|
module OpenapiFirst
|
16
16
|
OPERATION = 'openapi_first.operation'
|
@@ -24,8 +24,10 @@ module OpenapiFirst
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.load(spec_path, only: nil)
|
27
|
-
|
28
|
-
|
27
|
+
resolved = Dir.chdir(File.dirname(spec_path)) do
|
28
|
+
content = YAML.load_file(File.basename(spec_path))
|
29
|
+
JsonRefs.call(content, resolve_local_ref: true, resolve_file_ref: true)
|
30
|
+
end
|
29
31
|
resolved['paths'].filter!(&->(key, _) { only.call(key) }) if only
|
30
32
|
Definition.new(resolved, spec_path)
|
31
33
|
end
|
data/openapi_first.gemspec
CHANGED
@@ -35,15 +35,18 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.required_ruby_version = '>= 2.6.0'
|
36
36
|
|
37
37
|
spec.add_runtime_dependency 'deep_merge', '>= 1.2.1'
|
38
|
-
spec.add_runtime_dependency 'hanami-router', '~> 2.0.
|
38
|
+
spec.add_runtime_dependency 'hanami-router', '~> 2.0.alpha4'
|
39
39
|
spec.add_runtime_dependency 'hanami-utils', '~> 2.0.alpha1'
|
40
|
+
spec.add_runtime_dependency 'json_refs', '>= 0.1.7'
|
40
41
|
spec.add_runtime_dependency 'json_schemer', '~> 0.2.16'
|
41
42
|
spec.add_runtime_dependency 'multi_json', '~> 1.14'
|
42
|
-
spec.add_runtime_dependency 'oas_parser', '~> 0.25.1'
|
43
43
|
spec.add_runtime_dependency 'rack', '~> 2.2'
|
44
44
|
|
45
45
|
spec.add_development_dependency 'bundler', '~> 2'
|
46
46
|
spec.add_development_dependency 'rack-test', '~> 1'
|
47
47
|
spec.add_development_dependency 'rake', '~> 13'
|
48
48
|
spec.add_development_dependency 'rspec', '~> 3'
|
49
|
+
spec.metadata = {
|
50
|
+
'rubygems_mfa_required' => 'true'
|
51
|
+
}
|
49
52
|
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.14.
|
4
|
+
version: 0.14.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Haller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.
|
33
|
+
version: 2.0.alpha4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0.
|
40
|
+
version: 2.0.alpha4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hanami-utils
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,47 +53,47 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.0.alpha1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: json_refs
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.1.7
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.1.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: json_schemer
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.2.16
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.2.16
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: multi_json
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '1.14'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '1.14'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rack
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,11 +185,15 @@ files:
|
|
185
185
|
- benchmarks/Gemfile
|
186
186
|
- benchmarks/Gemfile.lock
|
187
187
|
- benchmarks/apps/committee.ru
|
188
|
+
- benchmarks/apps/committee_with_response_validation.ru
|
189
|
+
- benchmarks/apps/committee_with_sinatra.ru
|
188
190
|
- benchmarks/apps/grape.ru
|
189
191
|
- benchmarks/apps/hanami_api.ru
|
190
192
|
- benchmarks/apps/hanami_router.ru
|
191
193
|
- benchmarks/apps/openapi.yaml
|
192
194
|
- benchmarks/apps/openapi_first.ru
|
195
|
+
- benchmarks/apps/openapi_first_with_hanami_api.ru
|
196
|
+
- benchmarks/apps/openapi_first_with_response_validation.ru
|
193
197
|
- benchmarks/apps/sinatra.ru
|
194
198
|
- benchmarks/apps/syro.ru
|
195
199
|
- benchmarks/benchmarks.rb
|
@@ -223,9 +227,7 @@ homepage: https://github.com/ahx/openapi_first
|
|
223
227
|
licenses:
|
224
228
|
- MIT
|
225
229
|
metadata:
|
226
|
-
|
227
|
-
source_code_uri: https://github.com/ahx/openapi_first
|
228
|
-
changelog_uri: https://github.com/ahx/openapi_first/blob/master/CHANGELOG.md
|
230
|
+
rubygems_mfa_required: 'true'
|
229
231
|
post_install_message:
|
230
232
|
rdoc_options: []
|
231
233
|
require_paths:
|