nexmo-oas-renderer 2.0.1 → 2.1.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: 5b5e0e8b5fa6f2398fce6e27b89653e00b1b6cf7b2fc0b89b00e466c59ff7010
4
+ data.tar.gz: 899fd7a44676aef146f525466edb0bf0bcccd49accd2d4ebb04f21fb06f2318f
5
5
  SHA512:
6
- metadata.gz: 3b90abee001838f0e8885609eaf1a0b9a11e33988ccfdbb109734d7ab70c13ab241a22605a3db0c6115e2245c2b8ab6a8b16526a4b0fcd8ecf8dc17669e2a7ce
7
- data.tar.gz: 711bb7ef04c84fe1f1222030dd56113699be627c3d086189b55fae418ea98b53649cd2f770b9972e8e8497564e450b6147fb89bf906d7f8e1f318d37d0d082c6
6
+ metadata.gz: dea762339636ed621dbf8b44267fb6eeee6be97d8f20be236193ff2d8bdfc9e432cca22ec30ed150fa78c8f97d9e318ecc3ab1263c23f47bb54601f65edee995
7
+ data.tar.gz: 8decb45d42b106fc52bc46e9f4575f2b58f4273e7d425ff9478259cb0c1ffd4603156957998abbb15d94515060f05e96a52960051dffc59610df8048ffd59dee
@@ -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.1.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)
@@ -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,58 +1,65 @@
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
+ if(document.querySelector(".oas-wrapper")){
2
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
3
+ var queryString = new URLSearchParams(window.location.search);
4
+ if (!queryString.get('theme')) {
5
+ queryString.set("theme", "dark");
6
+ window.location.search = queryString.toString();
7
+ }
5
8
  }
6
- }
7
9
 
8
- document.addEventListener("DOMContentLoaded", function() {
9
- // Handle people clicking on oneOf tabs by changing every one on the page
10
- var oneOfTabs = document.querySelectorAll('[data-tab-link]');
11
- Array.from(oneOfTabs).forEach(function (element) {
12
- element.addEventListener('click', function (event) {
13
- var link = event.target.getAttribute('data-tab-link');
14
- var matchingTabs = document.querySelectorAll('[data-tab-link="' + link + '"]');
15
- Array.from(matchingTabs).forEach(function (element) {
16
- element.dispatchEvent(new Event('toggle'));
10
+ document.addEventListener("DOMContentLoaded", function() {
11
+ // Handle people clicking on oneOf tabs by changing every one on the page
12
+ var oneOfTabs = document.querySelectorAll('[data-tab-link]');
13
+ Array.from(oneOfTabs).forEach(function (element) {
14
+ element.addEventListener('click', function (event) {
15
+ var link = event.target.getAttribute('data-tab-link');
16
+ var matchingTabs = document.querySelectorAll('[data-tab-link="' + link + '"]');
17
+ Array.from(matchingTabs).forEach(function (element) {
18
+ element.dispatchEvent(new Event('toggle'));
19
+ });
17
20
  });
18
21
  });
19
- });
20
22
 
21
- var toggleTopNav = function(event, closeOnly) {
23
+ var toggleTopNav = function(event, closeOnly) {
24
+
25
+ if (event) {
26
+ if (!Array.from(event.target.classList).includes("oas-trigger")) {
27
+ return;
28
+ }
29
+ }
22
30
 
23
- if (event) {
24
- if (!Array.from(event.target.classList).includes("oas-trigger")) {
31
+ var c = document.querySelector('.oas-trigger-content');
32
+ if (closeOnly === true) {
33
+ c.style.display = "none";
25
34
  return;
26
35
  }
27
- }
36
+ c.style.display = c.style.display == 'block' ? 'none' : "block";
37
+ };
28
38
 
29
- var c = document.querySelector('.oas-trigger-content');
30
- if (closeOnly === true) {
31
- c.style.display = "none";
32
- return;
39
+ if (document.querySelector('.oas-trigger')) {
40
+ document.querySelector('.oas-trigger').addEventListener("click", toggleTopNav);
33
41
  }
34
- c.style.display = c.style.display == 'block' ? 'none' : "block";
35
- };
36
- document.querySelector('.oas-trigger').addEventListener("click", toggleTopNav);
37
42
 
38
- document.querySelectorAll('a').forEach((element) => {
39
- var href = element.getAttribute("href");
40
- if (!href){ return; }
41
- if (href.slice(0,1) !== "#"){ return; }
42
- element.addEventListener('click', function (event) {
43
- event.preventDefault();
43
+ document.querySelectorAll('a').forEach((element) => {
44
+ var href = element.getAttribute("href");
45
+ if (!href){ return; }
46
+ if (href.slice(0,1) !== "#"){ return; }
47
+ element.addEventListener('click', function (event) {
48
+ event.preventDefault();
44
49
 
45
- toggleTopNav(null, true);
50
+ toggleTopNav(null, true);
46
51
 
47
- var to = document.querySelector(event.target.hash)
48
- history.pushState({}, '', event.target.href);
49
- window.scrollTo({
50
- top: (window.scrollY + to.getBoundingClientRect().y) - 70,
51
- left: 0,
52
- })
52
+ var to = document.querySelector(event.target.hash)
53
+ history.pushState({}, '', event.target.href);
54
+ window.scrollTo({
55
+ top: (window.scrollY + to.getBoundingClientRect().y) - 70,
56
+ left: 0,
57
+ })
53
58
 
54
59
 
60
+ });
55
61
  });
62
+
56
63
  });
64
+ }
57
65
 
58
- });
@@ -3,7 +3,7 @@
3
3
  module Nexmo
4
4
  module OAS
5
5
  module Renderer
6
- VERSION = '2.0.1'
6
+ VERSION = '2.1.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">
@@ -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,7 +29,18 @@
25
29
  </div>
26
30
  <% end %>
27
31
 
28
- <% if response.code == '204' || response.formats.empty? %>
32
+ <% missing.each do |format| %>
33
+ <div class="js-format Nxd-api__response" data-format="<%= format %>">
34
+ <div class="Vlt-callout Vlt-callout--warning">
35
+ <i></i>
36
+ <div class="Vlt-callout__content">
37
+ <p>This endpoint does not support <code><%= format %></code></p>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ <% end %>
42
+
43
+ <% if response.code == '204' %>
29
44
  <% content = response.description ? response.description : 'No content' %>
30
45
  <pre class="language-json Vlt-prism--copy-disabled <%= @theme_light ? 'Vlt-prism--dark' : '' %>"><code><%= content %></code></pre>
31
46
  <% end %>
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.1.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-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel