tomograph 2.0.1 → 2.1.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/.travis.yml +5 -0
- data/CHANGELOG.md +6 -0
- data/README.md +18 -1
- data/lib/tomograph/api_blueprint/yaml.rb +1 -0
- data/lib/tomograph/api_blueprint/yaml/action.rb +8 -1
- data/lib/tomograph/tomogram.rb +8 -0
- data/lib/tomograph/tomogram/action.rb +4 -2
- data/lib/tomograph/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6bd7ef6a03950f113a0492c08e4d9aa17f26eb
|
4
|
+
data.tar.gz: bd068832137f783a9d50b5d42b73824f7355f0a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 580304b7f2e90c5ed4f34e016549277025fef310ddb97deb758787e73376243da3e96fa58abd4d48adabcdb4751c4facaf47c02ccc2d97f5050ca2718fd6dd9a
|
7
|
+
data.tar.gz: fef696a261c995d5fa8c44cc8b553742271a99486738a8a70bca989f3b95341cf4b4f71fe3ed81ebe16dfb6d90f01eacba7b3fe7d840391729cfc7b6575646fc
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Tomograph
|
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
|
+
[](https://badge.fury.io/rb/tomograph)
|
8
|
+
[](https://travis-ci.org/funbox/tomograph)
|
2
9
|
|
3
10
|
Convert API Blueprint to JSON Schema and search.
|
4
11
|
|
@@ -82,6 +89,7 @@ Example output:
|
|
82
89
|
{
|
83
90
|
"path": "/sessions",
|
84
91
|
"method": "POST",
|
92
|
+
"content-type": "application/json",
|
85
93
|
"request": {
|
86
94
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
87
95
|
"type": "object",
|
@@ -104,14 +112,17 @@ Example output:
|
|
104
112
|
"responses": [
|
105
113
|
{
|
106
114
|
"status": "401",
|
115
|
+
"content-type": "application/json",
|
107
116
|
"body": {}
|
108
117
|
},
|
109
118
|
{
|
110
119
|
"status": "429",
|
120
|
+
"content-type": "application/json",
|
111
121
|
"body": {}
|
112
122
|
},
|
113
123
|
{
|
114
124
|
"status": "201",
|
125
|
+
"content-type": "application/json",
|
115
126
|
"body": {
|
116
127
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
117
128
|
"type": "object",
|
@@ -157,6 +168,12 @@ Example output:
|
|
157
168
|
request = tomogram.find_request(method: 'GET', path: '/status/1?qwe=rty')
|
158
169
|
```
|
159
170
|
|
171
|
+
### find_request
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
request = tomogram.find_request_with_content_type(method: 'GET', path: '/status/1?qwe=rty', content_type: 'application/json')
|
175
|
+
```
|
176
|
+
|
160
177
|
### find_responses
|
161
178
|
|
162
179
|
|
@@ -97,6 +97,7 @@ module Tomograph
|
|
97
97
|
{
|
98
98
|
path: "#{@prefix}#{related_actions.first.path}",
|
99
99
|
method: related_actions.first.method,
|
100
|
+
content_type: related_actions.first.content_type,
|
100
101
|
request: related_actions.first.request,
|
101
102
|
responses: related_actions.map(&:responses).flatten,
|
102
103
|
resource: related_actions.first.resource
|
@@ -16,6 +16,11 @@ module Tomograph
|
|
16
16
|
@method ||= @content.first['attributes']['method']
|
17
17
|
end
|
18
18
|
|
19
|
+
def content_type
|
20
|
+
@content_type ||= @content.first['attributes'].has_key?('headers') ?
|
21
|
+
@content.first['attributes']['headers']['content'][0]['content']['value']['content'] : nil
|
22
|
+
end
|
23
|
+
|
19
24
|
def request
|
20
25
|
return @request if @request
|
21
26
|
|
@@ -44,7 +49,9 @@ module Tomograph
|
|
44
49
|
@responses = @responses.map do |response|
|
45
50
|
{
|
46
51
|
'status' => response['attributes']['statusCode'],
|
47
|
-
'body' => json_schema(response['content'])
|
52
|
+
'body' => json_schema(response['content']),
|
53
|
+
'content-type' => response['attributes'].has_key?('headers') ?
|
54
|
+
response['attributes']['headers']['content'][0]['content']['value']['content'] : nil
|
48
55
|
}
|
49
56
|
end
|
50
57
|
end
|
data/lib/tomograph/tomogram.rb
CHANGED
@@ -25,6 +25,14 @@ module Tomograph
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def find_request_with_content_type(method:, path:, content_type:)
|
29
|
+
path = Tomograph::Path.new(path).to_s
|
30
|
+
|
31
|
+
@documentation.to_tomogram.find do |action|
|
32
|
+
action.method == method && action.path.match(path) && action.content_type == content_type
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
28
36
|
def to_resources
|
29
37
|
@documentation.to_resources
|
30
38
|
end
|
@@ -3,11 +3,12 @@ require 'tomograph/path'
|
|
3
3
|
module Tomograph
|
4
4
|
class Tomogram
|
5
5
|
class Action
|
6
|
-
attr_reader :path, :method, :request, :responses
|
6
|
+
attr_reader :path, :method, :content_type, :request, :responses
|
7
7
|
|
8
|
-
def initialize(path:, method:, request:, responses:, resource:)
|
8
|
+
def initialize(path:, method:, content_type:, request:, responses:, resource:)
|
9
9
|
@path ||= Tomograph::Path.new(path)
|
10
10
|
@method ||= method
|
11
|
+
@content_type ||= content_type
|
11
12
|
@request ||= request
|
12
13
|
@responses ||= responses
|
13
14
|
@resource ||= resource
|
@@ -23,6 +24,7 @@ module Tomograph
|
|
23
24
|
@action ||= {
|
24
25
|
'path' => path,
|
25
26
|
'method' => method,
|
27
|
+
'content-type': content_type,
|
26
28
|
'request' => request,
|
27
29
|
'responses' => responses
|
28
30
|
}
|
data/lib/tomograph/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomograph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.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: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -147,6 +147,7 @@ extra_rdoc_files: []
|
|
147
147
|
files:
|
148
148
|
- ".gitignore"
|
149
149
|
- ".rubocop.yml"
|
150
|
+
- ".travis.yml"
|
150
151
|
- CHANGELOG.md
|
151
152
|
- CODE_OF_CONDUCT.md
|
152
153
|
- Gemfile
|
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
186
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.5
|
187
|
+
rubygems_version: 2.4.5
|
187
188
|
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: Convert API Blueprint to JSON Schema and search
|