nexmo-oas-renderer 2.0.1 → 2.2.0

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: a22719a6b2e7e60899cc1a2965f89278bd648b376ab5bbec05754ce47081db56
4
- data.tar.gz: f9c09adf0d6f266a301f324446211b4ce9b2cb6a22e0a91fb1639c503fb7bcb7
3
+ metadata.gz: 1a463231ba72ba74bc9a6555449eb2d2cba6155c32a2506235b04b8bf332678b
4
+ data.tar.gz: 9c8ed923712ff7e677c6f36b532e77fb41ef6120057d52635f7b1a892102aacc
5
5
  SHA512:
6
- metadata.gz: 3b90abee001838f0e8885609eaf1a0b9a11e33988ccfdbb109734d7ab70c13ab241a22605a3db0c6115e2245c2b8ab6a8b16526a4b0fcd8ecf8dc17669e2a7ce
7
- data.tar.gz: 711bb7ef04c84fe1f1222030dd56113699be627c3d086189b55fae418ea98b53649cd2f770b9972e8e8497564e450b6147fb89bf906d7f8e1f318d37d0d082c6
6
+ metadata.gz: b3e4c30d89a5cc22fd66491751235b49d4b56a5a63ce8e9a3d303e8c4989f5e3a47cc8964c5d78b6cc4f1d33467e1ca83065a00e399fcfc076607a81633b7c3e
7
+ data.tar.gz: df6590d1e2de8eb3771dcec2c0cf3617a7453e81e83a34318989d2f42d0513032dfd5c4a35ea3f991a8d1785f6871f6b800e5fb79a863f4c8890ebff89cd2754
@@ -1,3 +1,6 @@
1
+ # 2.2.0
2
+ * Add error list to API reference
3
+
1
4
  # 0.11.3
2
5
  * Change oas url constructor to be entire config parameter and not only partial
3
6
  * Bump websocket-extensions, fixes CVE-2020-7663
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nexmo-oas-renderer (2.0.1)
4
+ nexmo-oas-renderer (2.2.0)
5
5
  activemodel (~> 6.0)
6
6
  activesupport (~> 6.0)
7
7
  banzai (~> 0.1.2)
@@ -82,7 +82,7 @@ GEM
82
82
  crass (1.0.6)
83
83
  deep_merge (1.2.1)
84
84
  diff-lcs (1.4.2)
85
- dotenv (2.7.5)
85
+ dotenv (2.7.6)
86
86
  erubi (1.9.0)
87
87
  ffi (1.13.1)
88
88
  globalid (0.4.2)
@@ -109,7 +109,7 @@ GEM
109
109
  hansi (~> 0.2.0)
110
110
  mustermann (= 1.1.1)
111
111
  neatjson (0.9)
112
- nexmo_markdown_renderer (0.4.0)
112
+ nexmo_markdown_renderer (0.4.1)
113
113
  activemodel (~> 6.0)
114
114
  banzai (~> 0.1.2)
115
115
  i18n (~> 1.7)
@@ -136,9 +136,9 @@ GEM
136
136
  parallel (1.19.2)
137
137
  parser (2.7.1.4)
138
138
  ast (~> 2.4.1)
139
- public_suffix (4.0.5)
139
+ public_suffix (4.0.6)
140
140
  rack (2.2.3)
141
- rack-protection (2.0.8.1)
141
+ rack-protection (2.1.0)
142
142
  rack
143
143
  rack-test (1.1.0)
144
144
  rack (>= 1.0, < 3)
@@ -210,10 +210,10 @@ GEM
210
210
  rb-inotify (~> 0.9, >= 0.9.7)
211
211
  shotgun (0.9.2)
212
212
  rack (>= 1.0)
213
- sinatra (2.0.8.1)
213
+ sinatra (2.1.0)
214
214
  mustermann (~> 1.0)
215
- rack (~> 2.0)
216
- rack-protection (= 2.0.8.1)
215
+ rack (~> 2.2)
216
+ rack-protection (= 2.1.0)
217
217
  tilt (~> 2.0)
218
218
  sprockets (4.0.2)
219
219
  concurrent-ruby (~> 1.0)
@@ -11,11 +11,19 @@ module Nexmo
11
11
  end
12
12
 
13
13
  def side_navigation
14
- "api/#{@document_name}"
14
+ if defined?(NexmoDeveloper::Application)
15
+ "#{Rails.configuration.docs_base_path}/api/#{@document_name}"
16
+ else
17
+ "api/#{@document_name}"
18
+ end
15
19
  end
16
20
 
17
21
  def document_path
18
- "_api/#{@document_name}.md"
22
+ if defined?(NexmoDeveloper::Application)
23
+ "#{Rails.configuration.docs_base_path}/_api/#{@document_name}.md"
24
+ else
25
+ "_api/#{@document_name}.md"
26
+ end
19
27
  end
20
28
 
21
29
  def document
@@ -1,11 +1,17 @@
1
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
2
- var h = window.location.href;
3
- if (h.indexOf("?theme=") === -1) {
4
- window.location.href = h + "?theme=dark";
1
+ document.addEventListener("DOMContentLoaded", function() {
2
+ // Only run this JS on OAS pages
3
+ if(!document.querySelector(".oas-wrapper")){
4
+ return;
5
+ }
6
+
7
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
8
+ var queryString = new URLSearchParams(window.location.search);
9
+ if (!queryString.get('theme')) {
10
+ queryString.set("theme", "dark");
11
+ window.location.search = queryString.toString();
12
+ }
5
13
  }
6
- }
7
14
 
8
- document.addEventListener("DOMContentLoaded", function() {
9
15
  // Handle people clicking on oneOf tabs by changing every one on the page
10
16
  var oneOfTabs = document.querySelectorAll('[data-tab-link]');
11
17
  Array.from(oneOfTabs).forEach(function (element) {
@@ -33,7 +39,10 @@ document.addEventListener("DOMContentLoaded", function() {
33
39
  }
34
40
  c.style.display = c.style.display == 'block' ? 'none' : "block";
35
41
  };
36
- document.querySelector('.oas-trigger').addEventListener("click", toggleTopNav);
42
+
43
+ if (document.querySelector('.oas-trigger')) {
44
+ document.querySelector('.oas-trigger').addEventListener("click", toggleTopNav);
45
+ }
37
46
 
38
47
  document.querySelectorAll('a').forEach((element) => {
39
48
  var href = element.getAttribute("href");
@@ -54,5 +63,5 @@ document.addEventListener("DOMContentLoaded", function() {
54
63
 
55
64
  });
56
65
  });
57
-
58
66
  });
67
+
@@ -3,7 +3,7 @@
3
3
  module Nexmo
4
4
  module OAS
5
5
  module Renderer
6
- VERSION = '2.0.1'
6
+ VERSION = '2.2.0'
7
7
  end
8
8
  end
9
9
  end
@@ -10,7 +10,7 @@
10
10
  <% raise "`servers` parameter not provided at either the path level or document root" unless servers.size.positive? %>
11
11
 
12
12
  <%
13
- path = endpoint.path.path.gsub(/\{(.+?)\}/, ':\1')
13
+ path = endpoint.path.path.gsub(/\{(.+?)\}/, ':\1').chomp("/")
14
14
  uri = URI("#{servers[0]['url']}#{path}")
15
15
  %>
16
16
  <div class="oas-path-full Vlt-badge-combined">
@@ -0,0 +1,34 @@
1
+ <% if definition.raw['x-errors'] %>
2
+ <div>
3
+ <div class="Vlt-grid">
4
+ <div class="Vlt-col oas-left-panel" style="padding-bottom: 36px;">
5
+ <h2 id="errors">Errors</h2>
6
+ <p>
7
+ The following is a non-exhaustive list of error codes that may occur while using this API. These codes are in addition to any of our <a href="/api-errors">generic error codes</a>.
8
+ </p>
9
+ </div>
10
+ <div class="Vlt-col oas-right-panel"></div>
11
+ </div>
12
+ <div class="Vlt-grid">
13
+ <div class="Vlt-col Vlt-table oas-left-panel">
14
+ <table>
15
+ <thead>
16
+ <tr>
17
+ <th>Code</th>
18
+ <th>Details</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% definition.raw['x-errors'].each do |name, body| %>
23
+ <tr>
24
+ <td><a href="/api-errors/<%= @specification.definition_name %>#<%= name %>"><b><%= name %></b></a></td>
25
+ <td><%= body['description'].render_markdown %> </td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
30
+ </div>
31
+ <div class="Vlt-col oas-right-panel"></div>
32
+ </div>
33
+ </div>
34
+ <% end %>
@@ -13,6 +13,9 @@
13
13
  <a href="#webhooks" class="Vlt-btn Vlt-btn--tertiary group-link">Webhooks</a>
14
14
  <% end %>
15
15
 
16
+ <% if definition.raw['x-errors'] %>
17
+ <a href="#errors" class="Vlt-btn Vlt-btn--tertiary group-link">Errors</a>
18
+ <% end %>
16
19
 
17
20
  <% if @specification.formats.size > 1 %>
18
21
  <div class="Vlt-native-dropdown">
@@ -44,6 +47,10 @@
44
47
  <a href="#top" class="Vlt-btn Vlt-btn--tertiary group-link">Available Operations</a>
45
48
  <% end %>
46
49
 
50
+ <% if definition.raw['x-errors'] %>
51
+ <a href="#errors" class="Vlt-btn Vlt-btn--tertiary group-link">Errors</a>
52
+ <% end %>
53
+
47
54
  <br />
48
55
  <br />
49
56
 
@@ -29,14 +29,7 @@
29
29
  <% unless endpoint.request_body.exhibits_one_of_multiple_schemas?(format) %>
30
30
 
31
31
  <%
32
- # @mheap: This is hacky handling for allOf, but it works for now
33
- # We probably want real allOf support in OasParser, but that's more time than I have right now
34
- allOf = endpoint.request_body.content[format]['schema']['allOf']
35
- if allOf
36
- params = endpoint.request_body.handle_all_of(allOf)
37
- else
38
- params = endpoint.request_body.properties_for_format(format)
39
- end
32
+ params = endpoint.request_body.properties_for_format(format)
40
33
  if params
41
34
  %>
42
35
 
@@ -59,11 +59,11 @@
59
59
  <span class="constraint">Required</span>
60
60
  <% end %>
61
61
 
62
- <% if parameter.minimum %>
63
- | <span class="constraint">Min:</span> <%= parameter.minimum %>
62
+ <% if parameter.minimum || parameter.raw['minLength'] %>
63
+ | <span class="constraint">Min:</span> <%= parameter.minimum || parameter.raw['minLength'] %>
64
64
  <% end %>
65
- <% if parameter.maximum %>
66
- | <span class="constraint">Max:</span> <%= parameter.maximum %>
65
+ <% if parameter.maximum || parameter.raw['maxLength'] %>
66
+ | <span class="constraint">Max:</span> <%= parameter.maximum || parameter.raw['maxLength'] %>
67
67
  <% end %>
68
68
  </div>
69
69
 
@@ -17,7 +17,11 @@
17
17
  </div>
18
18
 
19
19
  <div id="acc<%= id %>" class="Vlt-js-accordion__content <%= @specification.auto_expand_responses ? 'Vlt-js-accordion__content_open' : '' %>">
20
+ <% missing = @specification.formats.keys %>
21
+
20
22
  <% response.formats.each_with_index do |format, index| %>
23
+ <% missing.delete(format) %>
24
+
21
25
  <% if response.exhibits_one_of_multiple_schemas?(format) %>
22
26
  <%= erb :'open_api/_response_tabs', locals: { endpoint: endpoint, format: format, response: response, content: :descriptions } %>
23
27
  <% else %>
@@ -25,6 +29,17 @@
25
29
  <%= erb :'open_api/_response_fields', locals: { endpoint: endpoint, schema: schema, format: format, index: nil } %>
26
30
  <% end %>
27
31
  <% end %>
32
+
33
+ <% missing.each do |format| %>
34
+ <div class="js-format Nxd-api__response" data-format="<%= format %>">
35
+ <div class="Vlt-callout Vlt-callout--warning" style="margin-top: 8px;">
36
+ <i></i>
37
+ <div class="Vlt-callout__content">
38
+ <p>This endpoint does not support <code><%= format %></code></p>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ <% end %>
28
43
  </div>
29
44
  </div>
30
45
  <% end %>
@@ -9,7 +9,11 @@
9
9
  <div id="response-tabs-<%= endpoint.operationId.parameterize %>" style="margin-bottom: 64px;">
10
10
  <% endpoint.responses.each_with_index do |response, index| %>
11
11
  <div class="Vlt-js-tabs__panel <%= index === 0 ? 'Vlt-js-tabs__panel_active' : '' %>">
12
+
13
+ <% missing = @specification.formats.keys %>
14
+
12
15
  <% response.formats.each do |format| %>
16
+ <% missing.delete(format) %>
13
17
  <div class="js-format" data-format="<%= format %>">
14
18
  <% if response.exhibits_one_of_multiple_schemas?(format) %>
15
19
  <%= erb :'open_api/_response_tabs', locals: { format: format, endpoint: endpoint, response: response, content: :responses } %>
@@ -25,11 +29,23 @@
25
29
  </div>
26
30
  <% end %>
27
31
 
28
- <% if response.code == '204' || response.formats.empty? %>
32
+ <% if response.code == '204' %>
29
33
  <% content = response.description ? response.description : 'No content' %>
30
34
  <pre class="language-json Vlt-prism--copy-disabled <%= @theme_light ? 'Vlt-prism--dark' : '' %>"><code><%= content %></code></pre>
35
+ <% else %>
36
+ <% missing.each do |format| %>
37
+ <div class="js-format Nxd-api__response" data-format="<%= format %>">
38
+ <div class="Vlt-callout Vlt-callout--warning">
39
+ <i></i>
40
+ <div class="Vlt-callout__content">
41
+ <p>This endpoint does not support <code><%= format %></code></p>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ <% end %>
31
46
  <% end %>
32
- </div>
47
+
48
+ </div>
33
49
 
34
50
  <% end %>
35
51
  </div>
@@ -21,6 +21,6 @@
21
21
  <% end %>
22
22
 
23
23
  <%= erb :'open_api/_webhooks', locals: { definition: definition } %>
24
-
24
+ <%= erb :'open_api/_errors', locals: {definition: definition } %>
25
25
  </div>
26
26
  </div>
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: 2.0.1
4
+ version: 2.2.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: 2020-07-01 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -348,6 +348,7 @@ files:
348
348
  - lib/nexmo/oas/renderer/views/open_api/_callbacks.erb
349
349
  - lib/nexmo/oas/renderer/views/open_api/_code_examples.erb
350
350
  - lib/nexmo/oas/renderer/views/open_api/_endpoint.erb
351
+ - lib/nexmo/oas/renderer/views/open_api/_errors.erb
351
352
  - lib/nexmo/oas/renderer/views/open_api/_header.erb
352
353
  - lib/nexmo/oas/renderer/views/open_api/_model.erb
353
354
  - lib/nexmo/oas/renderer/views/open_api/_navigation.erb
@@ -389,8 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
389
390
  - !ruby/object:Gem::Version
390
391
  version: '0'
391
392
  requirements: []
392
- rubyforge_project:
393
- rubygems_version: 2.7.6.2
393
+ rubygems_version: 3.1.4
394
394
  signing_key:
395
395
  specification_version: 4
396
396
  summary: OpenAPI Specification renderer.