openapi_first 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +32 -32
- data/README.md +3 -4
- data/benchmarks/Gemfile.lock +101 -53
- data/lib/openapi_first.rb +4 -3
- data/lib/openapi_first/app.rb +3 -2
- data/lib/openapi_first/operation_resolver.rb +2 -2
- data/lib/openapi_first/request_validation.rb +5 -5
- data/lib/openapi_first/router.rb +3 -3
- data/lib/openapi_first/version.rb +1 -1
- data/openapi_first.gemspec +5 -3
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 350892d725288c6799c622640c8ae33aebfadc12484d6fa577d4244686c9ea0e
|
4
|
+
data.tar.gz: 9bd806ad99abeb2fe4778469f89835e18cce6af0e0ebfe6ced69f7115a847dfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da2d420704d001650bd8a08ce845b6eaa3766ca933cb9864bf2c1e09b908dac0fea600e8e6c2b9632b04a0b45e21cdd8eff60aea1cc1778a12fd90abb6976806
|
7
|
+
data.tar.gz: 7cfc0228fb4cba90caa2fba005ec08c292059eb733c80090a11aeb5a6e6eb90163a8a1856fc056a57a9a9a000113f77c834ccf00911a21975d7996848b60cf55
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openapi_first (0.6.
|
4
|
+
openapi_first (0.6.6)
|
5
5
|
json_schemer (~> 0.2)
|
6
6
|
multi_json (~> 1.13)
|
7
|
-
oas_parser (~> 0.
|
8
|
-
rack (~> 2)
|
7
|
+
oas_parser (~> 0.2)
|
8
|
+
rack (~> 2.1)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (6.0.
|
13
|
+
activesupport (6.0.2.1)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
|
-
zeitwerk (~> 2.
|
18
|
+
zeitwerk (~> 2.2)
|
19
19
|
addressable (2.7.0)
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
21
21
|
ast (2.4.0)
|
22
|
-
builder (3.2.
|
22
|
+
builder (3.2.4)
|
23
23
|
coderay (1.1.2)
|
24
24
|
concurrent-ruby (1.1.5)
|
25
25
|
deep_merge (1.2.1)
|
@@ -29,9 +29,9 @@ GEM
|
|
29
29
|
hana (1.3.5)
|
30
30
|
hansi (0.2.0)
|
31
31
|
hash-deep-merge (0.1.1)
|
32
|
-
i18n (1.
|
32
|
+
i18n (1.8.2)
|
33
33
|
concurrent-ruby (~> 1.0)
|
34
|
-
jaro_winkler (1.5.
|
34
|
+
jaro_winkler (1.5.4)
|
35
35
|
json_schemer (0.2.8)
|
36
36
|
ecma-re-validator (~> 0.2)
|
37
37
|
hana (~> 1.3)
|
@@ -39,15 +39,15 @@ GEM
|
|
39
39
|
uri_template (~> 0.7)
|
40
40
|
method_source (0.9.2)
|
41
41
|
mini_portile2 (2.4.0)
|
42
|
-
minitest (5.
|
42
|
+
minitest (5.14.0)
|
43
43
|
multi_json (1.14.1)
|
44
44
|
mustermann (1.0.3)
|
45
45
|
mustermann-contrib (1.0.3)
|
46
46
|
hansi (~> 0.2.0)
|
47
47
|
mustermann (= 1.0.3)
|
48
|
-
nokogiri (1.10.
|
48
|
+
nokogiri (1.10.7)
|
49
49
|
mini_portile2 (~> 2.4.0)
|
50
|
-
oas_parser (0.
|
50
|
+
oas_parser (0.23.0)
|
51
51
|
activesupport (>= 4.0.0)
|
52
52
|
addressable (~> 2.3)
|
53
53
|
builder (~> 3.2.3)
|
@@ -55,46 +55,46 @@ GEM
|
|
55
55
|
hash-deep-merge
|
56
56
|
mustermann-contrib (~> 1.0.3s)
|
57
57
|
nokogiri
|
58
|
-
parallel (1.
|
59
|
-
parser (2.
|
58
|
+
parallel (1.19.1)
|
59
|
+
parser (2.7.0.2)
|
60
60
|
ast (~> 2.4.0)
|
61
61
|
pry (0.12.2)
|
62
62
|
coderay (~> 1.1.0)
|
63
63
|
method_source (~> 0.9.0)
|
64
|
-
public_suffix (4.0.
|
65
|
-
rack (2.
|
64
|
+
public_suffix (4.0.3)
|
65
|
+
rack (2.1.1)
|
66
66
|
rack-test (1.1.0)
|
67
67
|
rack (>= 1.0, < 3)
|
68
68
|
rainbow (3.0.0)
|
69
69
|
rake (10.5.0)
|
70
70
|
regexp_parser (1.6.0)
|
71
|
-
rspec (3.
|
72
|
-
rspec-core (~> 3.
|
73
|
-
rspec-expectations (~> 3.
|
74
|
-
rspec-mocks (~> 3.
|
75
|
-
rspec-core (3.
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-expectations (3.
|
71
|
+
rspec (3.9.0)
|
72
|
+
rspec-core (~> 3.9.0)
|
73
|
+
rspec-expectations (~> 3.9.0)
|
74
|
+
rspec-mocks (~> 3.9.0)
|
75
|
+
rspec-core (3.9.1)
|
76
|
+
rspec-support (~> 3.9.1)
|
77
|
+
rspec-expectations (3.9.0)
|
78
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-mocks (3.
|
79
|
+
rspec-support (~> 3.9.0)
|
80
|
+
rspec-mocks (3.9.1)
|
81
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-support (3.
|
84
|
-
rubocop (0.
|
82
|
+
rspec-support (~> 3.9.0)
|
83
|
+
rspec-support (3.9.2)
|
84
|
+
rubocop (0.79.0)
|
85
85
|
jaro_winkler (~> 1.5.1)
|
86
86
|
parallel (~> 1.10)
|
87
|
-
parser (>= 2.
|
87
|
+
parser (>= 2.7.0.1)
|
88
88
|
rainbow (>= 2.2.2, < 4.0)
|
89
89
|
ruby-progressbar (~> 1.7)
|
90
90
|
unicode-display_width (>= 1.4.0, < 1.7)
|
91
91
|
ruby-progressbar (1.10.1)
|
92
92
|
thread_safe (0.3.6)
|
93
|
-
tzinfo (1.2.
|
93
|
+
tzinfo (1.2.6)
|
94
94
|
thread_safe (~> 0.1)
|
95
|
-
unicode-display_width (1.6.
|
95
|
+
unicode-display_width (1.6.1)
|
96
96
|
uri_template (0.7.0)
|
97
|
-
zeitwerk (2.2.
|
97
|
+
zeitwerk (2.2.2)
|
98
98
|
|
99
99
|
PLATFORMS
|
100
100
|
ruby
|
@@ -109,4 +109,4 @@ DEPENDENCIES
|
|
109
109
|
rubocop
|
110
110
|
|
111
111
|
BUNDLED WITH
|
112
|
-
2.
|
112
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# OpenapiFirst
|
2
2
|
|
3
|
-
OpenapiFirst helps to implement HTTP APIs based on an [OpenApi](https://www.openapis.org/) API description. The idea is that you create an API description first, then add
|
3
|
+
OpenapiFirst helps to implement HTTP APIs based on an [OpenApi](https://www.openapis.org/) API description. The idea is that you create an API description first, then add a method that returns data and implements your business logic and be done.
|
4
4
|
|
5
5
|
## TL;DR
|
6
6
|
|
7
7
|
Start with writing an OpenAPI file that describes the API, which you are about to write. Use a [validator](http://speccy.io/) to make sure the file is valid.
|
8
|
-
|
9
|
-
We recommend saving the file as `openapi/openapi.yaml`.
|
8
|
+
In the following examples, the OpenAPI file is named `openapi/openapi.yaml`.
|
10
9
|
|
11
10
|
Now implement your API:
|
12
11
|
|
@@ -31,7 +30,7 @@ The above will:
|
|
31
30
|
- Map the request to a method call `Pets.find_pet` based on the `operationId` in the API description
|
32
31
|
- Set the response content type according to your spec (here with the default status code `200`)
|
33
32
|
|
34
|
-
|
33
|
+
Handler functions (`find_pet`) are called with two arguments:
|
35
34
|
|
36
35
|
- `params` - Holds the parsed request body, filtered query params and path parameters
|
37
36
|
- `res` - Holds a Rack::Response that you can modify if needed
|
data/benchmarks/Gemfile.lock
CHANGED
@@ -1,52 +1,81 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
openapi_first (0.6.
|
4
|
+
openapi_first (0.6.5)
|
5
5
|
json_schemer (~> 0.2)
|
6
6
|
multi_json (~> 1.13)
|
7
|
-
oas_parser (~> 0.
|
8
|
-
rack (~> 2)
|
7
|
+
oas_parser (~> 0.2)
|
8
|
+
rack (~> 2.1)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (6.0.
|
13
|
+
activesupport (6.0.2.1)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
|
-
zeitwerk (~> 2.
|
18
|
+
zeitwerk (~> 2.2)
|
19
19
|
addressable (2.7.0)
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
21
|
-
axiom-types (0.1.1)
|
22
|
-
descendants_tracker (~> 0.0.4)
|
23
|
-
ice_nine (~> 0.11.0)
|
24
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
25
21
|
benchmark-ips (2.7.2)
|
26
22
|
benchmark-memory (0.1.2)
|
27
23
|
memory_profiler (~> 0.9)
|
28
|
-
builder (3.2.
|
29
|
-
|
30
|
-
|
31
|
-
committee (3.2.1)
|
24
|
+
builder (3.2.4)
|
25
|
+
coderay (1.1.2)
|
26
|
+
committee (3.3.0)
|
32
27
|
json_schema (~> 0.14, >= 0.14.3)
|
33
28
|
openapi_parser (>= 0.6.1)
|
34
29
|
rack (>= 1.5)
|
35
30
|
concurrent-ruby (1.1.5)
|
36
31
|
deep_merge (1.2.1)
|
37
|
-
|
38
|
-
|
32
|
+
diff-lcs (1.3)
|
33
|
+
dry-configurable (0.9.0)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
dry-core (~> 0.4, >= 0.4.7)
|
36
|
+
dry-container (0.7.2)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
39
|
+
dry-core (0.4.9)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
dry-equalizer (0.3.0)
|
39
42
|
dry-inflector (0.2.0)
|
43
|
+
dry-logic (1.0.5)
|
44
|
+
concurrent-ruby (~> 1.0)
|
45
|
+
dry-core (~> 0.2)
|
46
|
+
dry-equalizer (~> 0.2)
|
47
|
+
dry-types (1.2.2)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
dry-container (~> 0.3)
|
50
|
+
dry-core (~> 0.4, >= 0.4.4)
|
51
|
+
dry-equalizer (~> 0.3)
|
52
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
53
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
40
54
|
ecma-re-validator (0.2.0)
|
41
55
|
regexp_parser (~> 1.2)
|
42
|
-
|
43
|
-
|
56
|
+
ffi (1.12.1)
|
57
|
+
formatador (0.2.5)
|
58
|
+
grape (1.3.0)
|
44
59
|
activesupport
|
45
60
|
builder
|
61
|
+
dry-types (>= 1.1)
|
46
62
|
mustermann-grape (~> 1.0.0)
|
47
63
|
rack (>= 1.3.0)
|
48
64
|
rack-accept
|
49
|
-
|
65
|
+
guard (2.16.1)
|
66
|
+
formatador (>= 0.2.4)
|
67
|
+
listen (>= 2.7, < 4.0)
|
68
|
+
lumberjack (>= 1.0.12, < 2.0)
|
69
|
+
nenv (~> 0.1)
|
70
|
+
notiffany (~> 0.0)
|
71
|
+
pry (>= 0.9.12)
|
72
|
+
shellany (~> 0.0)
|
73
|
+
thor (>= 0.18.1)
|
74
|
+
guard-compat (1.2.1)
|
75
|
+
guard-rspec (4.7.3)
|
76
|
+
guard (~> 2.1)
|
77
|
+
guard-compat (~> 1.1)
|
78
|
+
rspec (>= 2.99.0, < 4.0)
|
50
79
|
hana (1.3.5)
|
51
80
|
hanami-router (2.0.0.alpha1)
|
52
81
|
dry-inflector (~> 0.1)
|
@@ -58,65 +87,84 @@ GEM
|
|
58
87
|
concurrent-ruby (~> 1.0)
|
59
88
|
transproc (~> 1.0)
|
60
89
|
hansi (0.2.0)
|
61
|
-
|
62
|
-
i18n (1.7.0)
|
90
|
+
i18n (1.8.2)
|
63
91
|
concurrent-ruby (~> 1.0)
|
64
|
-
|
65
|
-
|
66
|
-
json_schemer (0.2.7)
|
92
|
+
json_schema (0.15.0)
|
93
|
+
json_schemer (0.2.8)
|
67
94
|
ecma-re-validator (~> 0.2)
|
68
95
|
hana (~> 1.3)
|
69
96
|
regexp_parser (~> 1.5)
|
70
97
|
uri_template (~> 0.7)
|
98
|
+
listen (3.2.1)
|
99
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
100
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
101
|
+
lumberjack (1.1.1)
|
71
102
|
memory_profiler (0.9.14)
|
72
|
-
|
73
|
-
minitest (5.
|
103
|
+
method_source (0.9.2)
|
104
|
+
minitest (5.14.0)
|
74
105
|
multi_json (1.14.1)
|
75
|
-
mustermann (1.
|
76
|
-
|
106
|
+
mustermann (1.1.1)
|
107
|
+
ruby2_keywords (~> 0.0.1)
|
108
|
+
mustermann-contrib (1.1.1)
|
77
109
|
hansi (~> 0.2.0)
|
78
|
-
mustermann (= 1.
|
79
|
-
mustermann-grape (1.0.
|
80
|
-
mustermann (
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
110
|
+
mustermann (= 1.1.1)
|
111
|
+
mustermann-grape (1.0.1)
|
112
|
+
mustermann (>= 1.0.0)
|
113
|
+
nenv (0.3.0)
|
114
|
+
notiffany (0.1.3)
|
115
|
+
nenv (~> 0.1)
|
116
|
+
shellany (~> 0.0)
|
117
|
+
oas_parser (0.2.0)
|
85
118
|
addressable (~> 2.3)
|
86
|
-
builder (~> 3.2.3)
|
87
119
|
deep_merge (~> 1.2.1)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
120
|
+
guard-rspec (~> 4.7.3)
|
121
|
+
json_schema (~> 0.15.0)
|
122
|
+
openapi_parser (0.7.0)
|
123
|
+
pry (0.12.2)
|
124
|
+
coderay (~> 1.1.0)
|
125
|
+
method_source (~> 0.9.0)
|
126
|
+
public_suffix (4.0.3)
|
127
|
+
rack (2.1.1)
|
94
128
|
rack-accept (0.4.5)
|
95
129
|
rack (>= 0.4)
|
96
|
-
rack-protection (2.0.
|
130
|
+
rack-protection (2.0.8.1)
|
97
131
|
rack
|
132
|
+
rb-fsevent (0.10.3)
|
133
|
+
rb-inotify (0.10.1)
|
134
|
+
ffi (~> 1.0)
|
98
135
|
regexp_parser (1.6.0)
|
136
|
+
rspec (3.9.0)
|
137
|
+
rspec-core (~> 3.9.0)
|
138
|
+
rspec-expectations (~> 3.9.0)
|
139
|
+
rspec-mocks (~> 3.9.0)
|
140
|
+
rspec-core (3.9.1)
|
141
|
+
rspec-support (~> 3.9.1)
|
142
|
+
rspec-expectations (3.9.0)
|
143
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
144
|
+
rspec-support (~> 3.9.0)
|
145
|
+
rspec-mocks (3.9.1)
|
146
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
147
|
+
rspec-support (~> 3.9.0)
|
148
|
+
rspec-support (3.9.2)
|
149
|
+
ruby2_keywords (0.0.2)
|
99
150
|
seg (1.2.0)
|
100
|
-
|
151
|
+
shellany (0.0.1)
|
152
|
+
sinatra (2.0.8.1)
|
101
153
|
mustermann (~> 1.0)
|
102
154
|
rack (~> 2.0)
|
103
|
-
rack-protection (= 2.0.
|
155
|
+
rack-protection (= 2.0.8.1)
|
104
156
|
tilt (~> 2.0)
|
105
157
|
syro (3.1.1)
|
106
158
|
rack (>= 1.6.0)
|
107
159
|
seg
|
160
|
+
thor (1.0.1)
|
108
161
|
thread_safe (0.3.6)
|
109
162
|
tilt (2.0.10)
|
110
|
-
transproc (1.1.
|
111
|
-
tzinfo (1.2.
|
163
|
+
transproc (1.1.1)
|
164
|
+
tzinfo (1.2.6)
|
112
165
|
thread_safe (~> 0.1)
|
113
166
|
uri_template (0.7.0)
|
114
|
-
|
115
|
-
axiom-types (~> 0.1)
|
116
|
-
coercible (~> 1.0)
|
117
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
118
|
-
equalizer (~> 0.0, >= 0.0.9)
|
119
|
-
zeitwerk (2.2.0)
|
167
|
+
zeitwerk (2.2.2)
|
120
168
|
|
121
169
|
PLATFORMS
|
122
170
|
ruby
|
@@ -133,4 +181,4 @@ DEPENDENCIES
|
|
133
181
|
syro
|
134
182
|
|
135
183
|
BUNDLED WITH
|
136
|
-
2.
|
184
|
+
2.1.4
|
data/lib/openapi_first.rb
CHANGED
@@ -26,7 +26,7 @@ module OpenapiFirst
|
|
26
26
|
|
27
27
|
def self.app(spec, namespace:)
|
28
28
|
spec = OpenapiFirst.load(spec) if spec.is_a?(String)
|
29
|
-
App.new(spec, namespace: namespace)
|
29
|
+
App.new(nil, spec, namespace: namespace)
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.middleware(spec, namespace:)
|
@@ -35,12 +35,13 @@ module OpenapiFirst
|
|
35
35
|
end
|
36
36
|
|
37
37
|
class AppWithOptions
|
38
|
-
def initialize(
|
38
|
+
def initialize(spec, options)
|
39
|
+
@spec = spec
|
39
40
|
@options = options
|
40
41
|
end
|
41
42
|
|
42
43
|
def new(app)
|
43
|
-
App.new(app,
|
44
|
+
App.new(app, @spec, **@options)
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
data/lib/openapi_first/app.rb
CHANGED
@@ -5,12 +5,13 @@ require 'rack'
|
|
5
5
|
module OpenapiFirst
|
6
6
|
class App
|
7
7
|
def initialize(
|
8
|
-
app
|
8
|
+
app,
|
9
9
|
spec,
|
10
10
|
namespace:,
|
11
11
|
allow_unknown_operation: !app.nil?
|
12
12
|
)
|
13
|
-
@stack = Rack::Builder.
|
13
|
+
@stack = Rack::Builder.app do
|
14
|
+
freeze_app
|
14
15
|
use OpenapiFirst::Router,
|
15
16
|
spec: spec,
|
16
17
|
allow_unknown_operation: allow_unknown_operation
|
@@ -7,9 +7,9 @@ module OpenapiFirst
|
|
7
7
|
NOT_FOUND = Rack::Response.new('', 404).finish.freeze
|
8
8
|
DEFAULT_APP = ->(_env) { NOT_FOUND }
|
9
9
|
|
10
|
-
def initialize(app = DEFAULT_APP,
|
10
|
+
def initialize(app = DEFAULT_APP, options) # rubocop:disable Style/OptionalArguments
|
11
11
|
@app = app
|
12
|
-
@namespace = namespace
|
12
|
+
@namespace = options.fetch(:namespace)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env) # rubocop:disable Metrics/AbcSize
|
@@ -8,9 +8,11 @@ require_relative 'validation_format'
|
|
8
8
|
|
9
9
|
module OpenapiFirst
|
10
10
|
class RequestValidation
|
11
|
-
def initialize(app,
|
11
|
+
def initialize(app, options = {})
|
12
12
|
@app = app
|
13
|
-
@allow_unknown_query_parameters =
|
13
|
+
@allow_unknown_query_parameters = options.fetch(
|
14
|
+
:allow_unknown_query_parameters, false
|
15
|
+
)
|
14
16
|
end
|
15
17
|
|
16
18
|
def call(env) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
@@ -125,9 +127,7 @@ module OpenapiFirst
|
|
125
127
|
def serialize_query_parameter_errors(validation_errors)
|
126
128
|
validation_errors.map do |error|
|
127
129
|
{
|
128
|
-
source: {
|
129
|
-
parameter: File.basename(error['data_pointer'])
|
130
|
-
}
|
130
|
+
source: { parameter: File.basename(error['data_pointer']) }
|
131
131
|
}.update(ValidationFormat.error_details(error))
|
132
132
|
end
|
133
133
|
end
|
data/lib/openapi_first/router.rb
CHANGED
@@ -9,10 +9,10 @@ module OpenapiFirst
|
|
9
9
|
class Router
|
10
10
|
NOT_FOUND = Rack::Response.new('', 404).finish.freeze
|
11
11
|
|
12
|
-
def initialize(app,
|
12
|
+
def initialize(app, options)
|
13
13
|
@app = app
|
14
|
-
@spec = spec
|
15
|
-
@allow_unknown_operation = allow_unknown_operation
|
14
|
+
@spec = options.fetch(:spec)
|
15
|
+
@allow_unknown_operation = options.fetch(:allow_unknown_operation, false)
|
16
16
|
end
|
17
17
|
|
18
18
|
def call(env)
|
data/openapi_first.gemspec
CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
if spec.respond_to?(:metadata)
|
18
18
|
spec.metadata['https://github.com/ahx/openapi_first'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/ahx/openapi_first'
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/ahx/openapi_first/blob/master/CHANGELOG.md'
|
19
21
|
else
|
20
22
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
21
23
|
'public gem pushes.'
|
@@ -25,15 +27,15 @@ Gem::Specification.new do |spec|
|
|
25
27
|
`git ls-files -z`
|
26
28
|
.split("\x0")
|
27
29
|
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
-
.reject { |f| %w[Dockerfile Jenkinsfile].include?(f) }
|
30
|
+
.reject { |f| %w[Dockerfile Jenkinsfile .tool-versions].include?(f) }
|
29
31
|
end
|
30
32
|
spec.bindir = 'exe'
|
31
33
|
spec.require_paths = ['lib']
|
32
34
|
|
33
35
|
spec.add_dependency 'json_schemer', '~> 0.2'
|
34
36
|
spec.add_dependency 'multi_json', '~> 1.13'
|
35
|
-
spec.add_dependency 'oas_parser', '~> 0.
|
36
|
-
spec.add_dependency 'rack', '~> 2'
|
37
|
+
spec.add_dependency 'oas_parser', '~> 0.2'
|
38
|
+
spec.add_dependency 'rack', '~> 2.1'
|
37
39
|
|
38
40
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
39
41
|
spec.add_development_dependency 'rack-test', '~> 1'
|
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.6.
|
4
|
+
version: 0.6.6
|
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: 2020-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_schemer
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2'
|
61
|
+
version: '2.1'
|
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: '2'
|
68
|
+
version: '2.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +175,8 @@ licenses:
|
|
175
175
|
- MIT
|
176
176
|
metadata:
|
177
177
|
https://github.com/ahx/openapi_first: https://github.com/ahx/openapi_first
|
178
|
+
source_code_uri: https://github.com/ahx/openapi_first
|
179
|
+
changelog_uri: https://github.com/ahx/openapi_first/blob/master/CHANGELOG.md
|
178
180
|
post_install_message:
|
179
181
|
rdoc_options: []
|
180
182
|
require_paths:
|
@@ -190,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
192
|
- !ruby/object:Gem::Version
|
191
193
|
version: '0'
|
192
194
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
195
|
+
rubygems_version: 3.1.2
|
194
196
|
signing_key:
|
195
197
|
specification_version: 4
|
196
198
|
summary: Implement REST APIs based on OpenApi.
|