esplanade 1.5.0 → 1.6.0
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/.github/workflows/ruby.yml +33 -0
- data/.rubocop.yml +10 -3
- data/.tool-versions +1 -1
- data/CHANGELOG.md +10 -1
- data/README.md +164 -38
- data/esplanade.gemspec +1 -1
- data/lib/esplanade/request/doc.rb +3 -2
- data/lib/esplanade/request/error.rb +12 -4
- data/lib/esplanade/request/raw.rb +5 -1
- data/lib/esplanade/request/raw/body.rb +1 -0
- data/lib/esplanade/request/validation.rb +23 -1
- data/lib/esplanade/response/doc.rb +3 -0
- data/lib/esplanade/response/error.rb +11 -3
- data/lib/esplanade/response/raw/body.rb +2 -1
- data/lib/esplanade/response/validation.rb +2 -1
- data/lib/esplanade/version.rb +1 -1
- metadata +7 -8
- data/.github/workflows/gempush.yml +0 -28
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5a2030af1a5071793987d6ee1bab57942a83efd21ae68b6323de133c0667e4b
|
4
|
+
data.tar.gz: 2474417384e61677938e602e48657bb8acffaeed13cdbf1593c64c4d97620f42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 490ca6b622daf918b964966a523d751744923048a5ea78a7eaea7bb4fee5bd6d4623a8951d5255ba0fae49ac78eeba5bc00b6bff876f05c38d9cec88e706a170
|
7
|
+
data.tar.gz: b8bfb543326e2d7789d4a1842c96ae163e1a84ba6b3118ee95b57fe53451a308429dc103f7678b613f081d61e29df9668842e2ef8c9062dcdc139bdfa80a0c65
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
+
# uses: ruby/setup-ruby@v1
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.6
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 2.4
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
Layout/LineLength:
|
6
|
+
Enabled: false
|
6
7
|
|
7
8
|
Style/Documentation:
|
8
9
|
Enabled: false
|
@@ -13,6 +14,12 @@ Style/FrozenStringLiteralComment:
|
|
13
14
|
Metrics/BlockLength:
|
14
15
|
Enabled: false
|
15
16
|
|
17
|
+
Metrics/ParameterLists:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Enabled: false
|
22
|
+
|
16
23
|
Style/IfUnlessModifier:
|
17
24
|
Enabled: false
|
18
25
|
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 2.7.1
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
### 1.
|
3
|
+
### 1.6.0 - 2020-10-12
|
4
|
+
|
5
|
+
* features
|
6
|
+
* in the errors write not only a documented path but also a raw [#11](https://github.com/funbox/esplanade/issues/11)
|
7
|
+
* write in the documentation that the body is empty and nil is skipped [#13](https://github.com/funbox/esplanade/issues/13)
|
8
|
+
* redefine error PrefixNotMatch for response [#17](https://github.com/funbox/esplanade/issues/17)
|
9
|
+
* content-type can contain additional parameters [#21](https://github.com/funbox/esplanade/issues/21)
|
10
|
+
* update esplanade for the new tomograph [#29](https://github.com/funbox/esplanade/issues/29)
|
11
|
+
|
12
|
+
### 1.5.0 - 2020-04-07
|
4
13
|
|
5
14
|
* improvements
|
6
15
|
* updated dependenses
|
data/README.md
CHANGED
@@ -1,16 +1,36 @@
|
|
1
1
|
# Esplanade
|
2
2
|
|
3
|
-
<a href="https://funbox.ru">
|
4
|
-
<img src="https://funbox.ru/badges/sponsored_by_funbox_compact.svg" alt="Sponsored by FunBox" width=250 />
|
5
|
-
</a>
|
6
|
-
|
7
3
|
[](https://badge.fury.io/rb/esplanade)
|
8
|
-
[](https://travis-ci.org/funbox/esplanade)
|
9
4
|
|
10
|
-
This gem
|
5
|
+
This gem helps you to validate and synchronize your API in strict accordance to the documentation in
|
11
6
|
[API Blueprint](https://apiblueprint.org/) format.
|
12
|
-
To do this it automatically searches received
|
13
|
-
|
7
|
+
To do this it automatically searches received requests and responses in the documentation and run
|
8
|
+
JSON-schemas validators.
|
9
|
+
|
10
|
+
## Contents
|
11
|
+
|
12
|
+
- [Installation](#installation)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Middlewares](#middlewares)
|
15
|
+
- [Esplanade::SafeMiddleware](#esplanadesafemiddleware)
|
16
|
+
- [Esplanade::DangerousMiddleware](#esplanadedangerousmiddleware)
|
17
|
+
- [Esplanade::CheckCustomResponseMiddleware](#esplanadecheckcustomresponsemiddleware)
|
18
|
+
- [Esplanade::Error](#esplanadeerror)
|
19
|
+
- [Esplanade::Request::Error](#esplanaderequesterror)
|
20
|
+
- [Esplanade::Request::PrefixNotMatch](#esplanaderequestprefixnotmatch)
|
21
|
+
- [Esplanade::Request::NotDocumented](#esplanaderequestnotdocumented)
|
22
|
+
- [Esplanade::Request::ContentTypeIsNotJson](#esplanaderequestcontenttypeisnotjson)
|
23
|
+
- [Esplanade::Request::BodyIsNotJson](#esplanaderequestbodyisnotjson)
|
24
|
+
- [Esplanade::Request::Invalid](#esplanaderequestinvalid)
|
25
|
+
- [Esplanade::Response::Error](#esplanaderesponseerror)
|
26
|
+
- [Esplanade::Response::NotDocumented](#esplanaderesponsenotdocumented)
|
27
|
+
- [Esplanade::Response::BodyIsNotJson](#esplanaderesponsebodyisnotjson)
|
28
|
+
- [Esplanade::Response::Invalid](#esplanaderesponseinvalid)
|
29
|
+
- [Middleware args](#middleware-args)
|
30
|
+
- [`apib_path`](#apib_path)
|
31
|
+
- [`drafter_yaml_path`](#drafter_yaml_path)
|
32
|
+
- [`prefix`](#prefix)
|
33
|
+
- [License](#license)
|
14
34
|
|
15
35
|
## Installation
|
16
36
|
|
@@ -20,107 +40,213 @@ Add this line to your application's Gemfile:
|
|
20
40
|
gem 'esplanade'
|
21
41
|
```
|
22
42
|
|
23
|
-
|
43
|
+
After that execute:
|
24
44
|
|
25
|
-
|
45
|
+
```bash
|
46
|
+
$ bundle
|
47
|
+
```
|
26
48
|
|
27
|
-
Or install
|
49
|
+
Or install the gem by yourself:
|
28
50
|
|
29
|
-
|
51
|
+
```bash
|
52
|
+
$ gem install esplanade
|
53
|
+
```
|
30
54
|
|
31
55
|
## Usage
|
32
56
|
|
33
|
-
`config/application.rb
|
57
|
+
`config/application.rb`:
|
34
58
|
|
35
59
|
```ruby
|
36
60
|
config.middleware.use Esplanade::SafeMiddleware, apib_path: 'doc.apib'
|
37
61
|
```
|
38
62
|
|
39
|
-
##
|
63
|
+
## Middlewares
|
40
64
|
|
41
65
|
### Esplanade::SafeMiddleware
|
42
66
|
|
43
|
-
|
67
|
+
Debug logger.
|
44
68
|
|
45
69
|
### Esplanade::DangerousMiddleware
|
46
70
|
|
47
|
-
It throws errors, so you
|
71
|
+
It throws errors, so you should add your own middleware for processing.
|
48
72
|
|
49
73
|
```ruby
|
50
|
-
|
51
|
-
|
74
|
+
config.middleware.use YourMiddleware
|
75
|
+
config.middleware.use Esplanade::DangerousMiddleware, apib_path: 'doc.apib'
|
52
76
|
```
|
53
77
|
|
54
78
|
### Esplanade::CheckCustomResponseMiddleware
|
55
79
|
|
56
|
-
|
80
|
+
Use it if you want to be sure that you have documented new custom responses.
|
57
81
|
|
58
82
|
```ruby
|
59
|
-
|
60
|
-
|
61
|
-
|
83
|
+
config.middleware.use Esplanade::CheckCustomResponseMiddleware, apib_path: 'doc.apib'
|
84
|
+
config.middleware.use YourMiddleware
|
85
|
+
config.middleware.use Esplanade::DangerousMiddleware, apib_path: 'doc.apib'
|
62
86
|
```
|
63
87
|
|
64
88
|
## Esplanade::Error
|
65
89
|
|
66
|
-
|
90
|
+
Parent class for those described below.
|
67
91
|
|
68
92
|
### Esplanade::Request::Error
|
69
93
|
|
70
|
-
|
94
|
+
Parent class for those described below. Inherited from `Esplanade::Error`.
|
71
95
|
|
72
96
|
#### Esplanade::Request::PrefixNotMatch
|
73
97
|
|
74
|
-
Error message
|
98
|
+
Error message format:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
{
|
102
|
+
:method => "method",
|
103
|
+
:path => "path",
|
104
|
+
:raw_path => "path",
|
105
|
+
:content_type => "content_type"
|
106
|
+
}
|
107
|
+
```
|
75
108
|
|
76
109
|
#### Esplanade::Request::NotDocumented
|
77
110
|
|
78
|
-
Error message
|
111
|
+
Error message format:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
{
|
115
|
+
:method => "method",
|
116
|
+
:path => "path",
|
117
|
+
:raw_path => "path",
|
118
|
+
:content_type => "content_type"
|
119
|
+
}
|
120
|
+
```
|
79
121
|
|
80
122
|
#### Esplanade::Request::ContentTypeIsNotJson
|
81
123
|
|
82
|
-
Error message
|
124
|
+
Error message format:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
{
|
128
|
+
:method => "method",
|
129
|
+
:path => "path",
|
130
|
+
:raw_path => "path",
|
131
|
+
:content_type => "content_type"
|
132
|
+
}
|
133
|
+
```
|
83
134
|
|
84
135
|
#### Esplanade::Request::BodyIsNotJson
|
85
136
|
|
86
|
-
|
137
|
+
Throws an error also when the body is empty and equal nil.
|
138
|
+
|
139
|
+
Error message format:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
{
|
143
|
+
:method => "method",
|
144
|
+
:path => "path",
|
145
|
+
:raw_path => "path",
|
146
|
+
:content_type => "content_type",
|
147
|
+
:body => "body"
|
148
|
+
}
|
149
|
+
```
|
87
150
|
|
88
151
|
#### Esplanade::Request::Invalid
|
89
152
|
|
90
|
-
Error message
|
153
|
+
Error message format:
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
{
|
157
|
+
:method => "method",
|
158
|
+
:path => "path",
|
159
|
+
:raw_path => "path",
|
160
|
+
:content_type => "content_type",
|
161
|
+
:body => "body",
|
162
|
+
:error => ["error"]
|
163
|
+
}
|
164
|
+
```
|
91
165
|
|
92
166
|
### Esplanade::Response::Error
|
93
167
|
|
94
|
-
|
168
|
+
Parent class for those described below. Inherited from `Esplanade::Error`.
|
169
|
+
|
170
|
+
#### Esplanade::Response::PrefixNotMatch
|
171
|
+
|
172
|
+
Error message format:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
{
|
176
|
+
:request => {
|
177
|
+
:method => "method",
|
178
|
+
:path => "path"
|
179
|
+
},
|
180
|
+
:status => "status"
|
181
|
+
}
|
182
|
+
```
|
95
183
|
|
96
184
|
#### Esplanade::Response::NotDocumented
|
97
185
|
|
98
|
-
Error message
|
186
|
+
Error message format:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
{
|
190
|
+
:request => {
|
191
|
+
:method => "method",
|
192
|
+
:path => "path",
|
193
|
+
:raw_path => "path"
|
194
|
+
},
|
195
|
+
:status => "status"
|
196
|
+
}
|
197
|
+
```
|
99
198
|
|
100
199
|
#### Esplanade::Response::BodyIsNotJson
|
101
200
|
|
102
|
-
|
201
|
+
It's thrown when expected response to request isn't JSON (not `Content-Type: application/json`) and there's no non-JSON responses documented for the endpoint.
|
202
|
+
|
203
|
+
Error message format:
|
103
204
|
|
104
|
-
|
205
|
+
```ruby
|
206
|
+
{
|
207
|
+
:request => {
|
208
|
+
:method => "method",
|
209
|
+
:path => "path",
|
210
|
+
:raw_path => "path"
|
211
|
+
},
|
212
|
+
:status => "status",
|
213
|
+
:body => "body"
|
214
|
+
}
|
215
|
+
```
|
105
216
|
|
106
217
|
#### Esplanade::Response::Invalid
|
107
218
|
|
108
|
-
Error message
|
219
|
+
Error message format:
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
{
|
223
|
+
:request => {
|
224
|
+
:method => "method",
|
225
|
+
:path => "path",
|
226
|
+
:raw_path => "path"
|
227
|
+
},
|
228
|
+
:status => "status",
|
229
|
+
:body => "body",
|
230
|
+
:error => ["error"]
|
231
|
+
}
|
232
|
+
```
|
109
233
|
|
110
234
|
## Middleware args
|
111
235
|
|
112
|
-
### apib_path
|
236
|
+
### `apib_path`
|
113
237
|
|
114
238
|
Path to API Blueprint documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
115
239
|
|
116
|
-
### drafter_yaml_path
|
240
|
+
### `drafter_yaml_path`
|
117
241
|
|
118
242
|
Path to API Blueprint documentation pre-parsed with `drafter` and saved to a YAML file.
|
119
243
|
|
120
|
-
### prefix
|
244
|
+
### `prefix`
|
121
245
|
|
122
|
-
Prefix
|
246
|
+
Prefix for API requests. Example: `'/api'`. The prefix is added to the requests in the documentation.
|
123
247
|
|
124
248
|
## License
|
125
249
|
|
126
250
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
251
|
+
|
252
|
+
[](https://funbox.ru)
|
data/esplanade.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
|
20
20
|
spec.add_runtime_dependency 'multi_json', '~> 1.11', '>= 1.11.1'
|
21
|
-
spec.add_runtime_dependency 'tomograph', '~>
|
21
|
+
spec.add_runtime_dependency 'tomograph', '~> 3.0.0', '>= 3.0.0'
|
22
22
|
spec.add_development_dependency 'byebug', '>= 10.0.0'
|
23
23
|
spec.add_development_dependency 'rake', '~> 13'
|
24
24
|
spec.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
|
@@ -19,8 +19,8 @@ module Esplanade
|
|
19
19
|
@tomogram
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
@
|
22
|
+
def json_schemas
|
23
|
+
@json_schemas ||= tomogram.requests
|
24
24
|
end
|
25
25
|
|
26
26
|
def method
|
@@ -47,6 +47,7 @@ module Esplanade
|
|
47
47
|
{
|
48
48
|
method: @raw.method,
|
49
49
|
path: @raw.path,
|
50
|
+
raw_path: @raw.raw_path,
|
50
51
|
content_type: @raw.content_type
|
51
52
|
}
|
52
53
|
end
|
@@ -5,9 +5,10 @@ module Esplanade
|
|
5
5
|
class PrefixNotMatch < Error; end
|
6
6
|
|
7
7
|
class NotDocumented < Error
|
8
|
-
def initialize(method:, path:, content_type:)
|
8
|
+
def initialize(method:, path:, raw_path:, content_type:)
|
9
9
|
@method = method
|
10
10
|
@path = path
|
11
|
+
@raw_path = raw_path
|
11
12
|
@content_type = content_type
|
12
13
|
|
13
14
|
super(to_hash)
|
@@ -17,14 +18,16 @@ module Esplanade
|
|
17
18
|
{
|
18
19
|
method: @method,
|
19
20
|
path: @path,
|
21
|
+
raw_path: @raw_path,
|
20
22
|
content_type: @content_type
|
21
23
|
}
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
27
|
class ContentTypeIsNotJson < Error
|
26
|
-
def initialize(method:, path:, content_type:)
|
28
|
+
def initialize(method:, path:, raw_path:, content_type:)
|
27
29
|
@method = method
|
30
|
+
@raw_path = raw_path
|
28
31
|
@path = path
|
29
32
|
@content_type = content_type
|
30
33
|
|
@@ -35,15 +38,17 @@ module Esplanade
|
|
35
38
|
{
|
36
39
|
method: @method,
|
37
40
|
path: @path,
|
41
|
+
raw_path: @raw_path,
|
38
42
|
content_type: @content_type
|
39
43
|
}
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
43
47
|
class BodyIsNotJson < Error
|
44
|
-
def initialize(method:, path:, content_type:, body:)
|
48
|
+
def initialize(method:, path:, raw_path:, content_type:, body:)
|
45
49
|
@method = method
|
46
50
|
@path = path
|
51
|
+
@raw_path = raw_path
|
47
52
|
@content_type = content_type
|
48
53
|
@body = body
|
49
54
|
|
@@ -54,6 +59,7 @@ module Esplanade
|
|
54
59
|
{
|
55
60
|
method: @method,
|
56
61
|
path: @path,
|
62
|
+
raw_path: @raw_path,
|
57
63
|
content_type: @content_type,
|
58
64
|
body: @body
|
59
65
|
}
|
@@ -61,9 +67,10 @@ module Esplanade
|
|
61
67
|
end
|
62
68
|
|
63
69
|
class Invalid < Error
|
64
|
-
def initialize(method:, path:, content_type:, body:, error:)
|
70
|
+
def initialize(method:, path:, raw_path:, content_type:, body:, error:)
|
65
71
|
@method = method
|
66
72
|
@path = path
|
73
|
+
@raw_path = raw_path
|
67
74
|
@content_type = content_type
|
68
75
|
@body = body
|
69
76
|
@error = error
|
@@ -75,6 +82,7 @@ module Esplanade
|
|
75
82
|
{
|
76
83
|
method: @method,
|
77
84
|
path: @path,
|
85
|
+
raw_path: @raw_path,
|
78
86
|
content_type: @content_type,
|
79
87
|
body: @body,
|
80
88
|
error: @error
|
@@ -15,12 +15,16 @@ module Esplanade
|
|
15
15
|
@path ||= @env['PATH_INFO']
|
16
16
|
end
|
17
17
|
|
18
|
+
def raw_path
|
19
|
+
@raw_path ||= "#{@env['PATH_INFO']}/#{@env['QUERY_STRING']}"
|
20
|
+
end
|
21
|
+
|
18
22
|
def body
|
19
23
|
@body ||= Body.new(self, @env)
|
20
24
|
end
|
21
25
|
|
22
26
|
def content_type
|
23
|
-
@content_type ||= @env['CONTENT_TYPE']
|
27
|
+
@content_type ||= @env['CONTENT_TYPE'].to_s.split(';').first
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -12,17 +12,38 @@ module Esplanade
|
|
12
12
|
def valid!
|
13
13
|
raise ContentTypeIsNotJson.new(**mini_message) unless @doc.content_type == 'application/json'
|
14
14
|
|
15
|
-
@error ||=
|
15
|
+
@error ||= if @doc.json_schemas.size == 1
|
16
|
+
one_json_schema
|
17
|
+
else
|
18
|
+
more_than_one_json_schema
|
19
|
+
end
|
16
20
|
|
17
21
|
raise Invalid.new(**message) unless @error.empty?
|
18
22
|
end
|
19
23
|
|
20
24
|
private
|
21
25
|
|
26
|
+
def one_json_schema
|
27
|
+
JSON::Validator.fully_validate(@doc.json_schemas.first, @raw.body.to_hash)
|
28
|
+
end
|
29
|
+
|
30
|
+
def more_than_one_json_schema
|
31
|
+
main_res = @doc.json_schemas.each do |json_schema|
|
32
|
+
res = JSON::Validator.fully_validate(json_schema, @raw.body.to_hash)
|
33
|
+
break res if res == []
|
34
|
+
end
|
35
|
+
if main_res != []
|
36
|
+
['invalid']
|
37
|
+
else
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
22
42
|
def mini_message
|
23
43
|
{
|
24
44
|
method: @doc.method,
|
25
45
|
path: @doc.path,
|
46
|
+
raw_path: @raw.raw_path,
|
26
47
|
content_type: @doc.content_type
|
27
48
|
}
|
28
49
|
end
|
@@ -31,6 +52,7 @@ module Esplanade
|
|
31
52
|
{
|
32
53
|
method: @raw.method,
|
33
54
|
path: @raw.path,
|
55
|
+
raw_path: @raw.raw_path,
|
34
56
|
content_type: @raw.content_type,
|
35
57
|
body: @raw.body.to_hash,
|
36
58
|
error: @error
|
@@ -11,6 +11,8 @@ module Esplanade
|
|
11
11
|
raise NotDocumented.new(**message) if @tomogram == []
|
12
12
|
|
13
13
|
@tomogram
|
14
|
+
rescue Esplanade::Request::PrefixNotMatch
|
15
|
+
raise PrefixNotMatch.new(**message)
|
14
16
|
end
|
15
17
|
|
16
18
|
def json_schemas
|
@@ -27,6 +29,7 @@ module Esplanade
|
|
27
29
|
{
|
28
30
|
request: {
|
29
31
|
method: @request.raw.method,
|
32
|
+
raw_path: @request.raw.raw_path,
|
30
33
|
path: @request.raw.path
|
31
34
|
},
|
32
35
|
status: @raw.status
|
@@ -2,10 +2,13 @@ module Esplanade
|
|
2
2
|
class Response
|
3
3
|
class Error < Esplanade::Error; end
|
4
4
|
|
5
|
+
class PrefixNotMatch < Error; end
|
6
|
+
|
5
7
|
class NotDocumented < Error
|
6
8
|
def initialize(request:, status:)
|
7
9
|
@method = request[:method]
|
8
10
|
@path = request[:path]
|
11
|
+
@raw_path = request[:raw_path]
|
9
12
|
@status = status
|
10
13
|
|
11
14
|
super(to_hash)
|
@@ -16,7 +19,8 @@ module Esplanade
|
|
16
19
|
request:
|
17
20
|
{
|
18
21
|
method: @method,
|
19
|
-
path: @path
|
22
|
+
path: @path,
|
23
|
+
raw_path: @raw_path
|
20
24
|
},
|
21
25
|
status: @status
|
22
26
|
}
|
@@ -27,6 +31,7 @@ module Esplanade
|
|
27
31
|
def initialize(request:, status:, body:)
|
28
32
|
@method = request[:method]
|
29
33
|
@path = request[:path]
|
34
|
+
@raw_path = request[:raw_path]
|
30
35
|
@status = status
|
31
36
|
@body = body
|
32
37
|
|
@@ -38,7 +43,8 @@ module Esplanade
|
|
38
43
|
request:
|
39
44
|
{
|
40
45
|
method: @method,
|
41
|
-
path: @path
|
46
|
+
path: @path,
|
47
|
+
raw_path: @raw_path
|
42
48
|
},
|
43
49
|
status: @status,
|
44
50
|
body: @body
|
@@ -50,6 +56,7 @@ module Esplanade
|
|
50
56
|
def initialize(request:, status:, body:, error:)
|
51
57
|
@method = request[:method]
|
52
58
|
@path = request[:path]
|
59
|
+
@raw_path = request[:raw_path]
|
53
60
|
@status = status
|
54
61
|
@body = body
|
55
62
|
@error = error
|
@@ -62,7 +69,8 @@ module Esplanade
|
|
62
69
|
request:
|
63
70
|
{
|
64
71
|
method: @method,
|
65
|
-
path: @path
|
72
|
+
path: @path,
|
73
|
+
raw_path: @raw_path
|
66
74
|
},
|
67
75
|
status: @status,
|
68
76
|
body: @body,
|
data/lib/esplanade/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esplanade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- d.efimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -56,20 +56,20 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 3.0.0
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 3.0.0
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 3.0.0
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
72
|
+
version: 3.0.0
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: byebug
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,12 +165,11 @@ executables: []
|
|
165
165
|
extensions: []
|
166
166
|
extra_rdoc_files: []
|
167
167
|
files:
|
168
|
-
- ".github/workflows/
|
168
|
+
- ".github/workflows/ruby.yml"
|
169
169
|
- ".gitignore"
|
170
170
|
- ".rubocop.yml"
|
171
171
|
- ".ruby-version"
|
172
172
|
- ".tool-versions"
|
173
|
-
- ".travis.yml"
|
174
173
|
- CHANGELOG.md
|
175
174
|
- CODE_OF_CONDUCT.md
|
176
175
|
- Gemfile
|
@@ -1,28 +0,0 @@
|
|
1
|
-
name: Ruby Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build:
|
11
|
-
name: Build + Publish
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@v2
|
16
|
-
- name: Set up Ruby 2.6
|
17
|
-
uses: actions/setup-ruby@v1
|
18
|
-
|
19
|
-
- name: Publish to RubyGems
|
20
|
-
run: |
|
21
|
-
mkdir -p $HOME/.gem
|
22
|
-
touch $HOME/.gem/credentials
|
23
|
-
chmod 0600 $HOME/.gem/credentials
|
24
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
25
|
-
gem build *.gemspec
|
26
|
-
gem push *.gem
|
27
|
-
env:
|
28
|
-
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|