nexmo-oas-renderer 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd8d4b2e48a2f59827cedcc768e575bfd2c3cb017a956fda2f1229737c56ffe0
4
- data.tar.gz: 40cd40d5fca9582ea435fb73046f147275f98d0c2e97f9c9d842afe27a5a4472
3
+ metadata.gz: 19ccae4e6d539f56ca8ca52481c61af67998c187b0ac5834c8993ccdd8b0675d
4
+ data.tar.gz: 46e60565d3cd1753aa511e867bd3e4f59f0199d08a96e4ab14fde7b6be9d9e11
5
5
  SHA512:
6
- metadata.gz: 28e38f0b3ee339407c713b27479973be7ddd5e298a4a71a4910ca5e51ffee8d75ca579903941662cf2d7114543be2f9f51016e67f3028ae14c59bbadfd0a83d2
7
- data.tar.gz: d9bac1035bda4b54418617e29c626b2efa39410cc772eab34faa5a719abee6864d2ca753af0225fd01df4925606e30c612c763a90d17bb56af5be7b00941c2b0
6
+ metadata.gz: d86d119465ca5d726529c17c22f0c59ce1f103bb14089f3c25a698e154d72a381e5d11cd04620abe3dd828bb8ce8e1bdba972e283ddf088735b0e788b4f858a7
7
+ data.tar.gz: 238a727261fca54fe7f18513265cdb33f2d63db6edee9bfeb1afc8dd26fdf3f4a48ca6223da74582292a5b3345f5a7175c95e8b336bfeb5fa06c99dbd2f20b09
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nexmo-oas-renderer (0.5.2)
4
+ nexmo-oas-renderer (0.5.4)
5
5
  activemodel (~> 5.2)
6
6
  activesupport (~> 5.2)
7
7
  banzai (~> 0.1.2)
8
8
  dotenv (~> 2.7)
9
9
  neatjson (~> 0.8)
10
- oas_parser (= 0.22.1)
10
+ oas_parser (= 0.22.2)
11
11
  octicons_helper (~> 8.2)
12
12
  redcarpet (= 3.4.0)
13
13
  rouge (= 2.0.7)
@@ -97,7 +97,7 @@ GEM
97
97
  nio4r (2.5.1)
98
98
  nokogiri (1.10.4)
99
99
  mini_portile2 (~> 2.4.0)
100
- oas_parser (0.22.1)
100
+ oas_parser (0.22.2)
101
101
  activesupport (>= 4.0.0)
102
102
  addressable (~> 2.3)
103
103
  builder (~> 3.2.3)
@@ -118,8 +118,10 @@ module Nexmo
118
118
  @document = 'verify/templates'
119
119
  elsif params[:code_language] == 'ncco'
120
120
  @document = 'voice/ncco'
121
- else
121
+ elsif CodeLanguage.exists?(params[:code_language])
122
122
  @document = params[:document]
123
+ else
124
+ @document = "#{params[:document]}/#{params[:code_language]}"
123
125
  end
124
126
  end
125
127
 
@@ -12,11 +12,16 @@ module Nexmo
12
12
  end
13
13
 
14
14
  def css_classes
15
- classes = ['Vlt-tabs__link']
15
+ classes = ['tab-sync Vlt-tabs__link']
16
16
  classes << 'Vlt-tabs__link_active' if @index.zero?
17
17
  classes.join(' ')
18
18
  end
19
19
 
20
+ def data_tab_link
21
+ return nil unless @schema['x-tab-id']
22
+ @schema['x-tab-id']
23
+ end
24
+
20
25
  def content
21
26
  @schema['description'] || "Response #{@index + 1}"
22
27
  end
@@ -17,6 +17,7 @@ module Nexmo
17
17
 
18
18
  def tab_links
19
19
  @tab_links ||= @response.split_schemas(@format).map.with_index do |schema, index|
20
+ schema = handle_all_of(schema)
20
21
  ResponseTab::Link.new(
21
22
  index: index,
22
23
  schema: schema
@@ -26,6 +27,7 @@ module Nexmo
26
27
 
27
28
  def tab_panels
28
29
  @tab_panels ||= @response.split_schemas(@format).map.with_index do |schema, index|
30
+ schema = handle_all_of(schema)
29
31
  ResponseTab::Panel.new(
30
32
  schema: schema,
31
33
  index: index,
@@ -35,6 +37,16 @@ module Nexmo
35
37
  )
36
38
  end
37
39
  end
40
+
41
+ def handle_all_of(schema)
42
+ if schema['allOf']
43
+ schema['allOf'].each do |p|
44
+ schema.deep_merge!(p)
45
+ end
46
+ schema.delete('allOf')
47
+ end
48
+ schema
49
+ end
38
50
  end
39
51
  end
40
52
  end
@@ -16,4 +16,16 @@ document.addEventListener("DOMContentLoaded", function() {
16
16
  });
17
17
  });
18
18
 
19
+ // Handle people clicking on oneOf tabs by changing every one on the page
20
+ var oneOfTabs = document.querySelectorAll('[data-tab-link]');
21
+ Array.from(oneOfTabs).forEach(function(element) {
22
+ element.addEventListener('click', function (event) {
23
+ var link = event.target.getAttribute('data-tab-link');
24
+ var matchingTabs = document.querySelectorAll('[data-tab-link="'+link+'"]');
25
+ Array.from(matchingTabs).forEach(function(element) {
26
+ element.click();
27
+ });
28
+ });
29
+ });
30
+
19
31
  });
@@ -1,7 +1,7 @@
1
1
  module Nexmo
2
2
  module OAS
3
3
  module Renderer
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.4"
5
5
  end
6
6
  end
7
7
  end
@@ -10,6 +10,7 @@
10
10
  <code class="Vlt-badge Vlt-badge--large Nxd-method-badge Nxd-method-badge--<%= endpoint.method %>"><%= endpoint.method.upcase %></code>
11
11
  <code class="Vlt-badge Vlt-badge--large Vlt-badge--grey">
12
12
  <% servers = endpoint.path.servers ? endpoint.path.servers : endpoint.definition.servers %>
13
+ <% raise "`servers` parameter not provided at either the path level or document root" unless servers.size.positive? %>
13
14
  <span><%= servers[0]['url'] %></span><%= endpoint.path.path.gsub(/\{(.+?)\}/, '<span class="api-path-parameter">:\1</span>') %>
14
15
  </code>
15
16
  </div>
@@ -20,6 +20,7 @@
20
20
  <% end %>
21
21
 
22
22
  <% endpoints.each do |endpoint| %>
23
+ <% raise "Missing `operationId` on #{endpoint.path.path} path" unless endpoint.operationId %>
23
24
  <li>
24
25
  <a href="#<%= endpoint.operationId %>" class="Vlt-sidemenu__link">
25
26
  <svg class="Vlt-green"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-code" /></svg>
@@ -137,11 +137,16 @@
137
137
  </td>
138
138
  <% end %>
139
139
 
140
- <% if parameter.collection? %>
140
+ <%
141
+ should_render_row = false
142
+ should_render_row = should_render_row || parameter.subproperties_are_one_of_many?
143
+ should_render_row = should_render_row || (parameter.properties && parameter.object? && parameter.properties.size.positive?)
144
+ %>
145
+ <% if parameter.collection? && should_render_row %>
146
+
141
147
  <tr class="Vlt-table__row--nohighlight">
142
148
  <td colspan="4">
143
149
  <% if parameter.subproperties_are_one_of_many? %>
144
-
145
150
  <div style="margin-left: 20px;">
146
151
  <h4>Any one of the following:</h4>
147
152
  <% parameter.properties.each do |property| %>
@@ -150,7 +155,7 @@
150
155
  <% end %>
151
156
  </div>
152
157
  <% else %>
153
- <% if parameter.properties && parameter.object? %>
158
+ <% if parameter.properties && parameter.object? && parameter.properties.size.positive? %>
154
159
  <%= erb :'open_api/_parameters', locals: { parameters: parameter.properties, model: model, format: format, callback: callback } %>
155
160
  <% end %>
156
161
  <% end %>
@@ -42,9 +42,6 @@
42
42
  <% end %>
43
43
 
44
44
 
45
-
46
-
47
-
48
45
  <% if value['items'] # If this is an array, we need to show the structure of the children %>
49
46
 
50
47
  <% if value['items']['oneOf'] || value['items']['anyOf'] # If it's a oneOf/anyOf, we need tabs! %>
@@ -54,8 +51,8 @@
54
51
  qualifier = 'one'
55
52
  key = 'oneOf'
56
53
  else
57
- qualifier = 'any'
58
- key = 'anyOf'
54
+ qualifier = 'any'
55
+ key = 'anyOf'
59
56
  end
60
57
 
61
58
  schemas = value['items'][key].map do |item|
@@ -71,55 +68,63 @@
71
68
  <% schemas = [value] %>
72
69
  <% end %>
73
70
 
74
- <% if schemas %>
75
- <% needs_tabs = schemas.size > 1 %>
76
- </td>
77
- </tr>
71
+ <% else %>
72
+ <% schemas = [value] if value['properties'] %>
73
+ <% end %>
78
74
 
79
- <tr class="Vlt-table__row--nohighlight">
80
- <td colspan="2">
75
+ <% if schemas %>
76
+ <% needs_tabs = schemas.size > 1 %>
77
+ </td>
78
+ </tr>
81
79
 
82
- <% if needs_tabs %>
83
- <div class="Vlt-callout Vlt-callout--shoutout">
84
- <i></i>
85
- <div class="Vlt-callout__content">
86
- This array contains <strong><%= qualifier %></strong> of the following objects:
87
- </div>
88
- </div>
89
- <div class="Vlt-tabs js-format">
90
- <div class="Vlt-tabs__header" role="tablist" aria-label="Responses">
91
- <% schemas.each_with_index do |schema, index| %>
92
- <div class="Vlt-tabs__link <%= index == 0 ? 'Vlt-tabs__link_active' : '' %>">
93
- <%= schema['description'] %>
94
- </div>
95
- <% end %>
96
- </div>
97
- <div class="Vlt-tabs__content">
98
- <% end %>
80
+ <tr class="Vlt-table__row--nohighlight">
81
+ <td colspan="2">
99
82
 
100
- <% schemas.each_with_index do |value, index| %>
101
- <div class="Vlt-tabs__panel <%= index == 0 ? 'Vlt-tabs__panel_active' : '' %>">
102
- <div class="Vlt-table Vlt-table--data Vlt-table--bordered">
103
- <table>
104
- <thead>
105
- <tr>
106
- <th>Field</th>
107
- <th>Description</th>
108
- </tr>
109
- </thead>
110
- <tbody>
111
- <%= erb :'open_api/_response_description_parameters', locals: { endpoint: endpoint, schema: value, parent: responseFieldId } %>
112
- </tbody>
113
- </table>
83
+ <% if needs_tabs %>
84
+ <div class="Vlt-callout Vlt-callout--shoutout">
85
+ <i></i>
86
+ <div class="Vlt-callout__content">
87
+ This array contains <strong><%= qualifier %></strong> of the following objects:
88
+ </div>
89
+ </div>
90
+ <div class="Vlt-tabs js-format">
91
+ <div class="Vlt-tabs__header" role="tablist" aria-label="Responses">
92
+ <% schemas.each_with_index do |schema, index| %>
93
+ <div
94
+ class="Vlt-tabs__link <%= index == 0 ? 'Vlt-tabs__link_active' : '' %> <%= schema['x-tab-id'] ? "tab-sync" : '' %>"
95
+ <% if schema['x-tab-id'] %>
96
+ data-tab-link="<%= schema['x-tab-id'] %>"
97
+ <% end %>
98
+ >
99
+ <%= schema['description'] %>
114
100
  </div>
115
- </div>
116
- <% end %>
117
-
118
- <% if needs_tabs %>
101
+ <% end %>
119
102
  </div>
103
+ <div class="Vlt-tabs__content">
104
+ <% end %>
105
+
106
+ <% schemas.each_with_index do |value, index| %>
107
+ <div class="Vlt-tabs__panel <%= index == 0 ? 'Vlt-tabs__panel_active' : '' %>">
108
+ <div class="Vlt-table Vlt-table--data Vlt-table--bordered">
109
+ <table>
110
+ <thead>
111
+ <tr>
112
+ <th>Field</th>
113
+ <th>Description</th>
114
+ </tr>
115
+ </thead>
116
+ <tbody>
117
+ <%= erb :'open_api/_response_description_parameters', locals: { endpoint: endpoint, schema: value, parent: responseFieldId } %>
118
+ </tbody>
119
+ </table>
120
120
  </div>
121
- <% end %>
122
- <% end %>
121
+ </div>
122
+ <% end %>
123
+
124
+ <% if needs_tabs %>
125
+ </div>
126
+ </div>
127
+ <% end %>
123
128
  <% end %>
124
129
  </td>
125
130
  </tr>
@@ -3,7 +3,7 @@
3
3
  <div class='Vlt-tabs js-format' data-format='<%= tabs.format %>'>
4
4
  <div class='Vlt-tabs__header' role='tablist' aria-label='Responses'>
5
5
  <% tabs.tab_links.each do |link| %>
6
- <div class='<%= link.css_classes %>'>
6
+ <div class='<%= link.css_classes %>' <% if link.data_tab_link %>data-tab-link="<%= link.data_tab_link %>"<% end %>>
7
7
  <%= link.content %>
8
8
  </div>
9
9
  <% end %>
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency 'sinatra', '~> 2.0'
35
35
  spec.add_runtime_dependency 'shotgun', '~> 0.9'
36
36
  spec.add_runtime_dependency 'rouge', '2.0.7'
37
- spec.add_runtime_dependency 'oas_parser', '0.22.1'
37
+ spec.add_runtime_dependency 'oas_parser', '0.22.2'
38
38
  spec.add_runtime_dependency 'neatjson', '~> 0.8'
39
39
  spec.add_runtime_dependency 'activesupport', '~> 5.2'
40
40
  spec.add_runtime_dependency 'banzai', '~> 0.1.2'
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.5.2
4
+ version: 0.5.4
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-09-11 00:00:00.000000000 Z
11
+ date: 2019-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.22.1
61
+ version: 0.22.2
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.22.1
68
+ version: 0.22.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: neatjson
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -403,8 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
403
403
  - !ruby/object:Gem::Version
404
404
  version: '0'
405
405
  requirements: []
406
- rubyforge_project:
407
- rubygems_version: 2.7.6.2
406
+ rubygems_version: 3.0.3
408
407
  signing_key:
409
408
  specification_version: 4
410
409
  summary: OpenAPI Specification renderer.