nexmo-oas-renderer 0.2.2 → 0.3.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/.rspec +1 -0
- data/Gemfile.lock +17 -2
- data/lib/nexmo/oas/renderer/constraints/open_api.rb +0 -1
- data/lib/nexmo/oas/renderer/presenters/endpoint.rb +19 -0
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +13 -22
- data/lib/nexmo/oas/renderer/presenters/response_format.rb +27 -0
- data/lib/nexmo/oas/renderer/version.rb +1 -1
- data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +2 -2
- data/lib/nexmo/oas/renderer/views/open_api/show.erb +8 -11
- data/nexmo-oas-renderer.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61ed0dc132ea2e036d74356190d452e7930585ab72c15f06e699f8c23edbb0f6
|
4
|
+
data.tar.gz: 5a2d2d38e8b9053b1445f85e31e37f21c0777b62f61cf2a33ae725ff3d7ad2c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 734bfb200fa5eff30b5da856b3ac0809a49687b04cb865dc9dc279dc5f12eebc78d44a0413a83488855eb4169bbd280d3ff559e135d3fdf36fba758744347bac
|
7
|
+
data.tar.gz: 25551f90bbb9be46b994994497bb7d3d25bc5c9f3c3754695c25670994d1e52ea040bae927401feec9c386cd3896b880138226581337d388b735c7cd72f2e583
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nexmo-oas-renderer (0.
|
4
|
+
nexmo-oas-renderer (0.3.0)
|
5
5
|
activemodel (~> 5.2)
|
6
6
|
activesupport (~> 5.2)
|
7
7
|
banzai (~> 0.1.2)
|
@@ -67,6 +67,7 @@ GEM
|
|
67
67
|
concurrent-ruby (1.1.5)
|
68
68
|
crass (1.0.4)
|
69
69
|
deep_merge (1.2.1)
|
70
|
+
diff-lcs (1.3)
|
70
71
|
dotenv (2.7.4)
|
71
72
|
erubi (1.8.0)
|
72
73
|
ffi (1.11.1)
|
@@ -143,6 +144,19 @@ GEM
|
|
143
144
|
ffi (~> 1.0)
|
144
145
|
redcarpet (3.4.0)
|
145
146
|
rouge (2.0.7)
|
147
|
+
rspec (3.8.0)
|
148
|
+
rspec-core (~> 3.8.0)
|
149
|
+
rspec-expectations (~> 3.8.0)
|
150
|
+
rspec-mocks (~> 3.8.0)
|
151
|
+
rspec-core (3.8.2)
|
152
|
+
rspec-support (~> 3.8.0)
|
153
|
+
rspec-expectations (3.8.4)
|
154
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
155
|
+
rspec-support (~> 3.8.0)
|
156
|
+
rspec-mocks (3.8.1)
|
157
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
158
|
+
rspec-support (~> 3.8.0)
|
159
|
+
rspec-support (3.8.2)
|
146
160
|
sass (3.7.4)
|
147
161
|
sass-listen (~> 4.0.0)
|
148
162
|
sass-listen (4.0.0)
|
@@ -178,6 +192,7 @@ DEPENDENCIES
|
|
178
192
|
bundler (~> 2.0)
|
179
193
|
nexmo-oas-renderer!
|
180
194
|
rake (~> 10.0)
|
195
|
+
rspec (~> 3.8)
|
181
196
|
|
182
197
|
BUNDLED WITH
|
183
|
-
2.0.
|
198
|
+
2.0.2
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative './response_format'
|
2
|
+
|
3
|
+
module Nexmo
|
4
|
+
module OAS
|
5
|
+
module Renderer
|
6
|
+
module Presenters
|
7
|
+
class Endpoint
|
8
|
+
def initialize(endpoint)
|
9
|
+
@endpoint = endpoint
|
10
|
+
end
|
11
|
+
|
12
|
+
def formats
|
13
|
+
@formats ||= ResponseFormat.new(@endpoint.responses).extract
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'forwardable'
|
2
|
+
require_relative './endpoint'
|
3
|
+
require_relative './response_format'
|
2
4
|
require_relative './groups'
|
3
5
|
require_relative './versions'
|
4
6
|
require_relative '../services/open_api_definition_resolver'
|
@@ -23,28 +25,8 @@ module Nexmo
|
|
23
25
|
@groups = Groups.new(definition)
|
24
26
|
end
|
25
27
|
|
26
|
-
def display_initialization?
|
27
|
-
initialization? && initialization_content && initialization_config
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialization?
|
31
|
-
File.file? "#{API.oas_path}/../initialization/#{@definition_name}.md"
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialization_content
|
35
|
-
@initialization_content ||= MarkdownPipeline.new.call(
|
36
|
-
File.read("#{API.oas_path}/../initialization/#{@definition_name}.md")
|
37
|
-
) if initialization?
|
38
|
-
end
|
39
|
-
|
40
|
-
def initialization_config
|
41
|
-
@initialization_config ||= YAML.safe_load(
|
42
|
-
File.read("#{API.oas_path}/../initialization/#{@definition_name}.md")
|
43
|
-
) if initialization?
|
44
|
-
end
|
45
|
-
|
46
28
|
def errors?
|
47
|
-
|
29
|
+
File.exist?("#{API.oas_path}/../errors/#{@definition_name}.md")
|
48
30
|
end
|
49
31
|
|
50
32
|
def definition_errors
|
@@ -60,8 +42,17 @@ module Nexmo
|
|
60
42
|
def auto_expand_responses
|
61
43
|
@expand_responses
|
62
44
|
end
|
63
|
-
end
|
64
45
|
|
46
|
+
def formats
|
47
|
+
@formats ||= ResponseFormat.to_dropdown(endpoints.flat_map(&:formats).uniq)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def endpoints
|
53
|
+
@endpoints ||= definition.endpoints.map { |e| Endpoint.new(e) }
|
54
|
+
end
|
55
|
+
end
|
65
56
|
end
|
66
57
|
end
|
67
58
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module OAS
|
3
|
+
module Renderer
|
4
|
+
module Presenters
|
5
|
+
class ResponseFormat
|
6
|
+
MAPPINGS = {
|
7
|
+
'application/json' => 'JSON',
|
8
|
+
'application/xml' => 'XML',
|
9
|
+
'text/xml' => 'XML',
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.to_dropdown(formats)
|
13
|
+
MAPPINGS.slice(*formats)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(responses)
|
17
|
+
@responses = responses
|
18
|
+
end
|
19
|
+
|
20
|
+
def extract
|
21
|
+
@formats ||= @responses.flat_map(&:formats).uniq
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -28,8 +28,8 @@
|
|
28
28
|
<span class="flag flag--strong">Required</span>
|
29
29
|
<% end %>
|
30
30
|
|
31
|
-
<% if @specification.
|
32
|
-
<% if @specification.
|
31
|
+
<% if @specification.formats.any? %>
|
32
|
+
<% if @specification.formats.include?('text/xml') %>
|
33
33
|
<span class="js-format" data-format="text/xml">
|
34
34
|
<% if parameter.is_xml_attribute? %>
|
35
35
|
| <span class="flag">Attribute</span>
|
@@ -39,19 +39,16 @@
|
|
39
39
|
</div>
|
40
40
|
<div class="Vlt-col Vlt-col--1of3 Nxd-api__code Nxd-api__code--install">
|
41
41
|
|
42
|
-
<% if @specification.
|
42
|
+
<% if @specification.formats.any? %>
|
43
43
|
<div class="Nxd-api__code__header">
|
44
|
-
|
45
|
-
<
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
</div>
|
52
|
-
<% end %>
|
44
|
+
<div class="Vlt-native-dropdown">
|
45
|
+
<select class="js-format-selector">
|
46
|
+
<% @specification.formats.each do |value, name| %>
|
47
|
+
<option value="<%= value %>"><%= name %></option>
|
48
|
+
<% end %>
|
49
|
+
</select>
|
50
|
+
</div>
|
53
51
|
</div>
|
54
|
-
<%= @specification.initialization_content %>
|
55
52
|
<% end %>
|
56
53
|
|
57
54
|
<% if @specification.available_versions && @specification.available_versions.count > 1 %>
|
data/nexmo-oas-renderer.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexmo-oas-renderer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Rodriguez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '10.0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rspec
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '3.8'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '3.8'
|
209
223
|
description:
|
210
224
|
email:
|
211
225
|
- fabian.rodriguez@vonage.com
|
@@ -216,6 +230,7 @@ extra_rdoc_files: []
|
|
216
230
|
files:
|
217
231
|
- ".env.example"
|
218
232
|
- ".gitignore"
|
233
|
+
- ".rspec"
|
219
234
|
- CHANGELOG.md
|
220
235
|
- CONTRIBUTING.md
|
221
236
|
- Gemfile
|
@@ -279,9 +294,11 @@ files:
|
|
279
294
|
- lib/nexmo/oas/renderer/models/tutorial.rb
|
280
295
|
- lib/nexmo/oas/renderer/pipelines/markdown_pipeline.rb
|
281
296
|
- lib/nexmo/oas/renderer/presenters/api_specification.rb
|
297
|
+
- lib/nexmo/oas/renderer/presenters/endpoint.rb
|
282
298
|
- lib/nexmo/oas/renderer/presenters/groups.rb
|
283
299
|
- lib/nexmo/oas/renderer/presenters/navigation.rb
|
284
300
|
- lib/nexmo/oas/renderer/presenters/open_api_specification.rb
|
301
|
+
- lib/nexmo/oas/renderer/presenters/response_format.rb
|
285
302
|
- lib/nexmo/oas/renderer/presenters/versions.rb
|
286
303
|
- lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff
|
287
304
|
- lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff2
|