nexmo-oas-renderer 2.0.0 → 2.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c59677181d5a5a5582488555f1857e61b54dc7aab95f7e159c6345d623997b0
4
- data.tar.gz: da45cf0fc8a2fc1307580f52f3ede113a1de3d4d7dbd0efbda71f5121b919756
3
+ metadata.gz: faadea352082b3d76c8da570d39ba77aa64f5de16b4ac62f8875d7750c3a8e94
4
+ data.tar.gz: 0b9b036687ce18bb6bbd810526bf148ecb827d8a0a4b8657208b62321141e52e
5
5
  SHA512:
6
- metadata.gz: dee724d81371ec9f67d58bd31702db2398f0b176eaf35574c2fc7ca505290935d0a27495c0752452552aa57c73e45098fd36c61a4ea4dc55e54cf021f4f0ba88
7
- data.tar.gz: d2f8a7a80acf92c00a71c20fc43a6fb637860c287902be8a23d48054c177e739a999e1083485323463b21a03b4840fa78007cd74eb359e096caef1108182af6d
6
+ metadata.gz: 98fd531733f922f6e4eb15419ee3bc2392f39e1079ef95f6bcf657303269439b8a6c93b76e50735489869b76cf1b5497a105bb44a1f3e2edc087e666b73da5a9
7
+ data.tar.gz: 6d566a1770a5edc2f8b12c074374b34bc2758fd7d391a221c84397e9d5bbb9ac6664e654c58f7d54736411da44947e9e8671a231de407c8a377cd17b9f20f6d6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nexmo-oas-renderer (2.0.0)
4
+ nexmo-oas-renderer (2.1.3)
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)
@@ -120,7 +120,7 @@ GEM
120
120
  nio4r (2.5.2)
121
121
  nokogiri (1.10.9)
122
122
  mini_portile2 (~> 2.4.0)
123
- oas_parser (0.25.2)
123
+ oas_parser (0.25.1)
124
124
  activesupport (>= 4.0.0)
125
125
  addressable (~> 2.3)
126
126
  builder (~> 3.2.3)
@@ -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.0'
6
+ VERSION = '2.1.3'
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">
@@ -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>
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.0
4
+ version: 2.1.3
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-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel