nexmo-oas-renderer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +1 -0
  3. data/.gitignore +5 -0
  4. data/CHANGELOG.md +2 -0
  5. data/CONTRIBUTING.md +46 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +183 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +73 -0
  10. data/Rakefile +2 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/exe/nexmo-oas-renderer +5 -0
  14. data/lib/nexmo/oas/engine.rb +9 -0
  15. data/lib/nexmo/oas/renderer.rb +13 -0
  16. data/lib/nexmo/oas/renderer/app.rb +116 -0
  17. data/lib/nexmo/oas/renderer/config.ru +7 -0
  18. data/lib/nexmo/oas/renderer/config/code_languages.yml +138 -0
  19. data/lib/nexmo/oas/renderer/config/dynamic_content.yml +1 -0
  20. data/lib/nexmo/oas/renderer/config/redirects.yml +8 -0
  21. data/lib/nexmo/oas/renderer/constraints/open_api.rb +76 -0
  22. data/lib/nexmo/oas/renderer/constraints/redirector.rb +17 -0
  23. data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +55 -0
  24. data/lib/nexmo/oas/renderer/filters/anchor.rb +17 -0
  25. data/lib/nexmo/oas/renderer/filters/audio.rb +21 -0
  26. data/lib/nexmo/oas/renderer/filters/block_escape.rb +24 -0
  27. data/lib/nexmo/oas/renderer/filters/break.rb +13 -0
  28. data/lib/nexmo/oas/renderer/filters/code.rb +64 -0
  29. data/lib/nexmo/oas/renderer/filters/code_snippet.rb +194 -0
  30. data/lib/nexmo/oas/renderer/filters/code_snippet_list.rb +33 -0
  31. data/lib/nexmo/oas/renderer/filters/code_snippets.rb +158 -0
  32. data/lib/nexmo/oas/renderer/filters/collapsible.rb +27 -0
  33. data/lib/nexmo/oas/renderer/filters/columns.rb +50 -0
  34. data/lib/nexmo/oas/renderer/filters/concept_list.rb +33 -0
  35. data/lib/nexmo/oas/renderer/filters/dynamic_content.rb +30 -0
  36. data/lib/nexmo/oas/renderer/filters/external_link.rb +32 -0
  37. data/lib/nexmo/oas/renderer/filters/frontmatter.rb +14 -0
  38. data/lib/nexmo/oas/renderer/filters/heading.rb +61 -0
  39. data/lib/nexmo/oas/renderer/filters/icon.rb +22 -0
  40. data/lib/nexmo/oas/renderer/filters/indent.rb +20 -0
  41. data/lib/nexmo/oas/renderer/filters/inline_escape.rb +17 -0
  42. data/lib/nexmo/oas/renderer/filters/js_sequence_diagram.rb +21 -0
  43. data/lib/nexmo/oas/renderer/filters/label.rb +32 -0
  44. data/lib/nexmo/oas/renderer/filters/language.rb +15 -0
  45. data/lib/nexmo/oas/renderer/filters/markdown.rb +85 -0
  46. data/lib/nexmo/oas/renderer/filters/modal.rb +41 -0
  47. data/lib/nexmo/oas/renderer/filters/partial.rb +28 -0
  48. data/lib/nexmo/oas/renderer/filters/php_inliner.rb +15 -0
  49. data/lib/nexmo/oas/renderer/filters/screenshot.rb +26 -0
  50. data/lib/nexmo/oas/renderer/filters/tab.rb +250 -0
  51. data/lib/nexmo/oas/renderer/filters/techio.rb +24 -0
  52. data/lib/nexmo/oas/renderer/filters/tooltip.rb +22 -0
  53. data/lib/nexmo/oas/renderer/filters/tutorial_link.rb +27 -0
  54. data/lib/nexmo/oas/renderer/filters/tutorials.rb +28 -0
  55. data/lib/nexmo/oas/renderer/filters/unfreeze.rb +20 -0
  56. data/lib/nexmo/oas/renderer/filters/user_personalization.rb +43 -0
  57. data/lib/nexmo/oas/renderer/helpers/navigation.rb +66 -0
  58. data/lib/nexmo/oas/renderer/helpers/render.rb +24 -0
  59. data/lib/nexmo/oas/renderer/helpers/summary.rb +30 -0
  60. data/lib/nexmo/oas/renderer/helpers/url.rb +17 -0
  61. data/lib/nexmo/oas/renderer/lib/core_ext/string.rb +14 -0
  62. data/lib/nexmo/oas/renderer/lib/redcarpet.rb +14 -0
  63. data/lib/nexmo/oas/renderer/models/code_snippet.rb +75 -0
  64. data/lib/nexmo/oas/renderer/models/tutorial.rb +83 -0
  65. data/lib/nexmo/oas/renderer/pipelines/markdown_pipeline.rb +52 -0
  66. data/lib/nexmo/oas/renderer/presenters/api_specification.rb +42 -0
  67. data/lib/nexmo/oas/renderer/presenters/groups.rb +35 -0
  68. data/lib/nexmo/oas/renderer/presenters/navigation.rb +24 -0
  69. data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +68 -0
  70. data/lib/nexmo/oas/renderer/presenters/versions.rb +40 -0
  71. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff +0 -0
  72. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff2 +0 -0
  73. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff +0 -0
  74. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff2 +0 -0
  75. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff +0 -0
  76. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff2 +0 -0
  77. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff +0 -0
  78. data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff2 +0 -0
  79. data/lib/nexmo/oas/renderer/public/assets/images/brands/android.svg +1 -0
  80. data/lib/nexmo/oas/renderer/public/assets/images/brands/curl.svg +1 -0
  81. data/lib/nexmo/oas/renderer/public/assets/images/brands/dotnet.svg +1 -0
  82. data/lib/nexmo/oas/renderer/public/assets/images/brands/ios.svg +1 -0
  83. data/lib/nexmo/oas/renderer/public/assets/images/brands/java.svg +1 -0
  84. data/lib/nexmo/oas/renderer/public/assets/images/brands/javascript.svg +1 -0
  85. data/lib/nexmo/oas/renderer/public/assets/images/brands/node.svg +1 -0
  86. data/lib/nexmo/oas/renderer/public/assets/images/brands/php.svg +1 -0
  87. data/lib/nexmo/oas/renderer/public/assets/images/brands/python.svg +11 -0
  88. data/lib/nexmo/oas/renderer/public/assets/images/brands/ruby.svg +1 -0
  89. data/lib/nexmo/oas/renderer/public/assets/images/lost.svg +37 -0
  90. data/lib/nexmo/oas/renderer/public/assets/javascripts/components/format.js +42 -0
  91. data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.accordion.js +249 -0
  92. data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.core.js +230 -0
  93. data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.modal.js +300 -0
  94. data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.tabs.js +139 -0
  95. data/lib/nexmo/oas/renderer/public/assets/stylesheets/api.css +95 -0
  96. data/lib/nexmo/oas/renderer/public/assets/stylesheets/buttons.css +80 -0
  97. data/lib/nexmo/oas/renderer/public/assets/stylesheets/core.css +79 -0
  98. data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css +2 -0
  99. data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css.map +7 -0
  100. data/lib/nexmo/oas/renderer/public/assets/stylesheets/navigation.css +79 -0
  101. data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo.css +68 -0
  102. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +147 -0
  103. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +133 -0
  104. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/mediaqueries.scss +48 -0
  105. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/navigation.scss +106 -0
  106. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/nexmo.scss +61 -0
  107. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +10 -0
  108. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/syntax.scss +63 -0
  109. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/typography.scss +248 -0
  110. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/variables.scss +91 -0
  111. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/volta-templates.scss +119 -0
  112. data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css +2 -0
  113. data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css.map +7 -0
  114. data/lib/nexmo/oas/renderer/public/assets/stylesheets/syntax.css +79 -0
  115. data/lib/nexmo/oas/renderer/public/assets/stylesheets/typography.css +86 -0
  116. data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css +2 -0
  117. data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css.map +7 -0
  118. data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css +2 -0
  119. data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css.map +7 -0
  120. data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta.min.css +1 -0
  121. data/lib/nexmo/oas/renderer/public/assets/symbol/volta-icons.svg +1 -0
  122. data/lib/nexmo/oas/renderer/public/favicon.ico +0 -0
  123. data/lib/nexmo/oas/renderer/services/code_language_api.rb +98 -0
  124. data/lib/nexmo/oas/renderer/services/oas_parser.rb +21 -0
  125. data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +33 -0
  126. data/lib/nexmo/oas/renderer/version.rb +7 -0
  127. data/lib/nexmo/oas/renderer/views/api/show.erb +1 -0
  128. data/lib/nexmo/oas/renderer/views/code_snippets/_application_messages_dispatch.html.erb +9 -0
  129. data/lib/nexmo/oas/renderer/views/code_snippets/_application_rtc.html.erb +41 -0
  130. data/lib/nexmo/oas/renderer/views/code_snippets/_application_voice.html.erb +24 -0
  131. data/lib/nexmo/oas/renderer/views/code_snippets/_code_only.html.erb +6 -0
  132. data/lib/nexmo/oas/renderer/views/code_snippets/_configure_client.html.erb +20 -0
  133. data/lib/nexmo/oas/renderer/views/code_snippets/_dependencies.html.erb +11 -0
  134. data/lib/nexmo/oas/renderer/views/code_snippets/_write_code.html.erb +13 -0
  135. data/lib/nexmo/oas/renderer/views/code_snippets/list/plain.html.erb +10 -0
  136. data/lib/nexmo/oas/renderer/views/concepts/list/plain.html.erb +5 -0
  137. data/lib/nexmo/oas/renderer/views/layouts/_head.erb +4 -0
  138. data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +9 -0
  139. data/lib/nexmo/oas/renderer/views/layouts/api.erb +23 -0
  140. data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +10 -0
  141. data/lib/nexmo/oas/renderer/views/open_api/_callback.erb +5 -0
  142. data/lib/nexmo/oas/renderer/views/open_api/_callback_endpoint.erb +48 -0
  143. data/lib/nexmo/oas/renderer/views/open_api/_code_examples.erb +16 -0
  144. data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +156 -0
  145. data/lib/nexmo/oas/renderer/views/open_api/_model.erb +38 -0
  146. data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +80 -0
  147. data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +50 -0
  148. data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +165 -0
  149. data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +61 -0
  150. data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +41 -0
  151. data/lib/nexmo/oas/renderer/views/open_api/show.erb +104 -0
  152. data/lib/nexmo/oas/renderer/views/static/404.erb +6 -0
  153. data/lib/nexmo/oas/renderer/views/tutorials/_index.html.erb +32 -0
  154. data/lib/nexmo/oas/renderer/views/tutorials/index.html.erb +7 -0
  155. data/lib/nexmo/oas/renderer/views/tutorials/list/plain.html.erb +5 -0
  156. data/lib/nexmo/oas/renderer/views/tutorials/show.html.erb +8 -0
  157. data/nexmo-oas-renderer.gemspec +49 -0
  158. metadata +399 -0
@@ -0,0 +1,38 @@
1
+ <div class="Vlt-grid <% if !group['schema'] %> Nxd-api--noborder Vlt-article--reverse<% end %>">
2
+ <div class="Vlt-col Vlt-col--2of3 Nxd-api__docs">
3
+ <div>
4
+ <h1 id="<%= group['name'].parameterize %>" class='Vlt-grey-dark'><%= group['name'] %></h1>
5
+ <p class: "Vlt-grey-darker"><%= group['description'] %></p>
6
+
7
+ <% if group['schema'] %>
8
+ <% group['schema'].each do |format, schema| %>
9
+ <div class="js-format" data-format="<%= format %>">
10
+ <%
11
+ if schema['properties']
12
+ properties = schema['properties']
13
+ elsif schema['allOf']
14
+ properties = schema['allOf'].map { |o| o['properties'] }.reduce(&:merge)
15
+ end
16
+
17
+ properties = properties.map do |name, definition|
18
+ OasParser::Property.new(self, schema, name, definition)
19
+ end
20
+ %>
21
+
22
+ <%= erb :'open_api/_parameters', locals: { parameters: properties, model: true, format: format } %>
23
+ </div>
24
+ <% end %>
25
+ <% end %>
26
+ </div>
27
+ </div>
28
+ <div class="Vlt-col Vlt-col--1of3 Nxd-api__code">
29
+ <% if group['schema'] %>
30
+ <% group['schema'].each do |format, schema| %>
31
+ <div class="js-format" data-format="<%= format %>">
32
+ <h5>Example Model</h5>
33
+ <%= ResponseParserDecorator.new(schema).html(format, xml_options: schema['xml']) %>
34
+ </div>
35
+ <% end %>
36
+ <% end %>
37
+ </div>
38
+ </div>
@@ -0,0 +1,80 @@
1
+ <div id="Vlt-sidenav" class="Vlt-sidenav Vlt-sidenav--light">
2
+ <div class="Vlt-sidenav__scroll">
3
+ <ul class="Vlt-sidemenu Vlt-sidemenu--rounded navigation">
4
+ <li>
5
+ <h5 class="Vlt-sidemenu__title Vlt-sidemenu__title--border"><%= definition.info['title'] %></h5>
6
+ </li>
7
+ <li>
8
+ <a class="Vlt-sidemenu__link" href="#overview">Overview</a>
9
+ </li>
10
+
11
+ <% @specification.groups.each do |name, endpoints| %>
12
+ <% if name %>
13
+ <%
14
+ group = definition.raw['tags'].select { |tag| tag['name'].capitalize == name.capitalize }.first
15
+ raise "Could not find 'tags' entry for #{name.capitalize}" unless group
16
+ %>
17
+ <li>
18
+ <h5 class="Vlt-sidemenu__title Vlt-sidemenu__title--border"><%= group['name'] %></h5>
19
+ </li>
20
+ <% end %>
21
+
22
+ <% endpoints.each do |endpoint| %>
23
+ <li>
24
+ <a href="#<%= endpoint.operationId %>" class="Vlt-sidemenu__link">
25
+ <svg class="Vlt-green"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-code" /></svg>
26
+
27
+ <span class="Vlt-sidemenu__label">
28
+ <%= normalize_summary_title(endpoint.summary, endpoint.operationId) %>
29
+ </span>
30
+ <span class="Vlt-badge Vlt-badge--margin-left Nxd-method-badge Nxd-method-badge--<%= endpoint.method %>"><code class="Vlt-white"><%= endpoint.method %></code></span>
31
+ </a>
32
+ </li>
33
+
34
+ <% if endpoint.callbacks.any? %>
35
+ <% endpoint.callbacks.each do |callback| %>
36
+ <% callback.paths.each do |path| %>
37
+ <% path.endpoints.each do |endpoint| %>
38
+ <li class="Nxd-menu__indent">
39
+ <a href="#<%= endpoint.operationId %>" class="Vlt-sidemenu__link">
40
+ <svg class="Vlt-blue"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-toggle" /></svg>
41
+ <span class="Vlt-sidemenu__label"><%= endpoint.summary %></span>
42
+ </a>
43
+ </li>
44
+ <% end %>
45
+ <% end %>
46
+ <% end %>
47
+ <% end %>
48
+ <% end %>
49
+
50
+ <% if definition.raw['x-webhooks'] %>
51
+ <% definition.raw['x-webhooks'].each do |name, definition| %>
52
+ <% callback = OasParser::Callback.new(self, name, definition) %>
53
+
54
+ <% callback.paths.each do |path| %>
55
+ <% path.endpoints.each do |endpoint| %>
56
+ <li>
57
+ <a href="#<%= name %>" class="Vlt-sidemenu__link">
58
+ <svg class="Vlt-orange"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-mind-map" /></svg>
59
+ <span class="Vlt-sidemenu__label"><%= endpoint.summary %></span>
60
+ </a>
61
+ </li>
62
+ <% end %>
63
+ <% end %>
64
+ <% end %>
65
+ <% end %>
66
+
67
+ <% if name %>
68
+ </li>
69
+ <% end %>
70
+ <% end %>
71
+
72
+ <% if @specification.definition_errors %>
73
+ <li>
74
+ <a class="Vlt-sidemenu__link" href="#errors">Errors</a>
75
+ </li>
76
+ <% end %>
77
+ </li>
78
+ </ul>
79
+ </div>
80
+ </div>
@@ -0,0 +1,50 @@
1
+ <% callback = false if callback.nil? %>
2
+
3
+ <% if endpoint.parameters.select { |p| p.in == 'header'}.any? %>
4
+ <h4>Header Parameters</h4>
5
+ <%= erb :'open_api/_parameters', locals: { parameters: endpoint.parameters.select { |p| p.in == 'header' }, callback: callback } %>
6
+ <% end %>
7
+
8
+ <% if endpoint.path_parameters.any? %>
9
+ <h4>Path Parameters</h4>
10
+ <%= erb :'open_api/_parameters', locals: { parameters: endpoint.path_parameters, callback: callback } %>
11
+ <% end %>
12
+
13
+ <% if endpoint.query_parameters.any? %>
14
+ <h4>Query Parameter</h4>
15
+ <%= erb :'open_api/_parameters', locals: { parameters: endpoint.query_parameters, callback: callback } %>
16
+ <% end %>
17
+
18
+ <% if endpoint.request_body %>
19
+ <% format = endpoint.request_body.formats[0] %>
20
+ <% unless endpoint.request_body.exhibits_one_of_multiple_schemas?(format) %>
21
+
22
+ <%
23
+ # @mheap: This is hacky handling for allOf, but it works for now
24
+ # We probably want real allOf support in OasParser, but that's more time than I have right now
25
+ allOf = endpoint.request_body.content[format]['schema']['allOf']
26
+ if allOf
27
+ params = allOf.reduce { |a,b| a.deep_merge(b) }
28
+ params = params['properties'].map do |name, definition|
29
+ OasParser::Property.new(nil, params, name, definition)
30
+ end
31
+ else
32
+ params = endpoint.request_body.properties_for_format(format)
33
+ end
34
+ if params
35
+ %>
36
+
37
+ <h4>
38
+ Request body
39
+ <span class="Vlt-badge Vlt-badge--blue"><%= format %></span>
40
+ </h4>
41
+
42
+ <%= erb :'open_api/_parameters', locals: { parameters: params, callback: callback } %>
43
+ <% end %>
44
+ <% else %>
45
+ <% endpoint.request_body.split_properties_for_format(format).each_with_index do |parameters, index| %>
46
+ <h4><%= parameters[0].schema['oneOf'][index]['description'] %></h4>
47
+ <%= erb :'open_api/_parameters', locals: { parameters: parameters, callback: callback } %>
48
+ <% end %>
49
+ <% end %>
50
+ <% end %>
@@ -0,0 +1,165 @@
1
+ <%
2
+ model = false if model.nil?
3
+ callback = false if callback.nil?
4
+ format = nil if format.nil?
5
+ %>
6
+
7
+ <div class="Vlt-table Vlt-section Vlt-table--data Vlt-table--bordered">
8
+ <table>
9
+ <thead>
10
+ <tr>
11
+ <th>Key</th>
12
+ <th>Description</th>
13
+ <% unless model %>
14
+ <th>Example</th>
15
+ <% unless callback %>
16
+ <th>Default</th>
17
+ <% end %>
18
+ <% end %>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% parameters.each do |parameter| %>
23
+ <tr class="<% if parameter.collection? %> Vlt-table__row--noline <% end %>">
24
+ <td class="Vlt-table__cell--nowrap">
25
+ <b><%= parameter.name %></b><br>
26
+ <small>
27
+ <% if parameter.required %>
28
+ <span class="flag flag--strong">Required</span>
29
+ <% end %>
30
+
31
+ <% if @specification.initialization_config && @specification.initialization_config['formats'] %>
32
+ <% if @specification.initialization_config['formats'].include? 'text/xml' %>
33
+ <span class="js-format" data-format="text/xml">
34
+ <% if parameter.is_xml_attribute? %>
35
+ | <span class="flag">Attribute</span>
36
+ <% end %>
37
+
38
+ <% if parameter.is_xml_text? %>
39
+ | <span class="flag">Value</span>
40
+ <% end %>
41
+ </span>
42
+ <% end %>
43
+ <% end %>
44
+
45
+ <i>
46
+ <% if parameter.required and parameter.type %>|<% end %> <%= parameter.type %>
47
+ <% if parameter.format %>
48
+ | (<%= parameter.format %>)
49
+ <% end %>
50
+ <% if parameter.array? %>
51
+ <br>
52
+ <% if parameter.items && parameter.items['type'] %>
53
+ of <%= (parameter.items['type']) %>s
54
+ <% end %>
55
+ <% end %>
56
+ </i>
57
+ </small>
58
+ </td>
59
+
60
+ <%
61
+ # If it's a oneOf we show a list rather than description/example/default
62
+ if parameter.oneOf?
63
+ %>
64
+ <td colspan="3">
65
+ <h4>Any one of the following:</h4>
66
+ <% parameter.properties.each do |property| %>
67
+ <h5><%= property['description'] %></h5>
68
+ <%= erb :'open_api/_parameters', locals: { parameters: property['properties'], model: model, format: format, callback: callback } %>
69
+ <% end %>
70
+ </td>
71
+ <%
72
+ # Otherwise we show the remaining 3 columns
73
+ else
74
+ %>
75
+ <td>
76
+ <% if parameter.collection? || parameter.oneOf? %>
77
+ <% if parameter.raw['x-nexmo-developer-collection-description-shown'] %>
78
+ <%= (parameter.description ? "#{parameter.description}" : '<i>None</i>').render_markdown %>
79
+ <% end %>
80
+ <% else %>
81
+ <%= (parameter.description ? "#{parameter.description}" : '<i>None</i>').render_markdown %>
82
+ <% end %>
83
+
84
+ <% if parameter.enum %>
85
+ <br>
86
+ <small class="Vlt-grey-dark">
87
+ <%= (callback || model) ? "One of:" : "Must be one of:" %>
88
+ <%= parameter_values(parameter.enum) %>
89
+ </small>
90
+ <% end %>
91
+
92
+ <% if parameter.raw['x-possible-values'] %>
93
+ <br>
94
+ <small class="Vlt-grey-dark">
95
+ Will be one of:
96
+ <%= parameter_values(parameter.raw['x-possible-values']) %>
97
+ </small>
98
+ <% end %>
99
+
100
+ <% if parameter.minimum || parameter.maximum %>
101
+ <br>
102
+ <small class="Vlt-grey-dark">
103
+ <% if parameter.minimum && parameter.maximum %>
104
+ Must be between <%= "<code>#{parameter.minimum}</code>"%> and <%= "<code>#{parameter.maximum}</code>"%>
105
+ <% elsif parameter.minimum %>
106
+ Must be at least <%= "<code>#{parameter.minimum}</code>"%>
107
+ <% else %>
108
+ Must be at most <%= "<code>#{parameter.maximum}</code>"%>
109
+ <% end %>
110
+ </small>
111
+ <% end %>
112
+ </td>
113
+
114
+ <% unless model %>
115
+ <% if parameter.collection? || parameter.oneOf? %>
116
+ <% if parameter.raw['x-nexmo-developer-collection-description-shown'] %>
117
+ <td>
118
+ <%= (parameter.example ? "<code><pre>#{parameter.example}</pre></code>" : '')%>
119
+ </td>
120
+ <% end %>
121
+ <% else %>
122
+ <td>
123
+ <%= (parameter.example ? "<code>#{parameter.example.to_s.gsub("\n", "<br />")}</code>" : '<i>None</i>')%>
124
+ </td>
125
+ <% end %>
126
+ <% end %>
127
+
128
+ <% unless model || callback %>
129
+ <td>
130
+ <% if parameter.raw['x-default-is-meta'] %>
131
+ <i><%= (parameter.default.nil? ? 'None' : parameter.default) %></i>
132
+ <% else %>
133
+ <% unless parameter.type == 'object' %>
134
+ <%= (parameter.default.nil? ? '<i>None</i>' : "<code>#{parameter.default}</code>")%>
135
+ <% end %>
136
+ <% end %>
137
+ </td>
138
+ <% end %>
139
+
140
+ <% if parameter.collection? %>
141
+ <tr class="Vlt-table__row--nohighlight">
142
+ <td colspan="4">
143
+ <% if parameter.subproperties_are_one_of_many? %>
144
+
145
+ <div style="margin-left: 20px;">
146
+ <h4>Any one of the following:</h4>
147
+ <% parameter.properties.each do |property| %>
148
+ <h5><%= property['description'] %></h5>
149
+ <%= erb :'open_api/_parameters', locals: { parameters: property['properties'], model: model, format: format, callback: callback } %>
150
+ <% end %>
151
+ </div>
152
+ <% else %>
153
+ <% if parameter.properties && parameter.object? %>
154
+ <%= erb :'open_api/_parameters', locals: { parameters: parameter.properties, model: model, format: format, callback: callback } %>
155
+ <% end %>
156
+ <% end %>
157
+ </td>
158
+ </tr>
159
+ <% end %>
160
+ <% end %>
161
+ </tr>
162
+ <% end %>
163
+ </tbody>
164
+ </table>
165
+ </div>
@@ -0,0 +1,61 @@
1
+ <%
2
+ # @mheap: This is hacky handling for allOf, but it works for now
3
+ allOf = schema['allOf']
4
+ if allOf
5
+ schema = allOf.reduce { |a,b| a.deep_merge(b) }
6
+ end
7
+ %>
8
+
9
+ <%
10
+ # If it's an array, look at the items for the response schema as all items within
11
+ # the array are expected to be identical
12
+ schema = schema['items'] if schema['type'] == 'array'
13
+ %>
14
+
15
+ <% if schema['properties'] %>
16
+ <% schema['properties'].each do |key, value| %>
17
+ <% next if key == '_links' %>
18
+ <% next if value['x-skip-response-description'] %>
19
+ <% anchor_value = "#{anchor_prefix}-#{key}" %>
20
+ <tr<% if value['properties'] %> class=" Vlt-table__row--noline" <% end %>>
21
+ <td id="<%= anchor_value %>">
22
+ <b><%= key %></b>
23
+ <% if value['items'] %>
24
+ <br />
25
+ <small>array of <%= value['items']['type'] %>s</small>
26
+ <% end %>
27
+ </td>
28
+ <td>
29
+ <%= value['description'] ? value['description'].render_markdown : '' %>
30
+ <% if value['enum']%>
31
+ <small class="Vlt-grey-dark">
32
+ One of: <%= parameter_values(value['enum']) %>
33
+ </small>
34
+ <% end %>
35
+
36
+ <% if value['items'] # If this is an array, we need to show the structure of the children %>
37
+ <% value['properties'] = value['items']['properties'] %>
38
+ <% end %>
39
+ <% if value['properties'] %>
40
+ </td>
41
+ </tr>
42
+ <tr class="Vlt-table__row--nohighlight">
43
+ <td colspan="2">
44
+ <div class="Vlt-table Vlt-table--data Vlt-table--bordered">
45
+ <table>
46
+ <thead>
47
+ <tr>
48
+ <th>Field</th>
49
+ <th>Description</th>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+ <%= erb :'open_api/_response_description_parameters', locals: { schema: value, anchor_prefix: anchor_value } %>
54
+ </tbody>
55
+ </table>
56
+ </div>
57
+ <% end %>
58
+ </td>
59
+ </tr>
60
+ <% end %>
61
+ <% end %>
@@ -0,0 +1,41 @@
1
+ <% endpoint.responses.each do |response| %>
2
+ <% next unless response.success? %>
3
+ <% next if response.code.to_i == 204 %>
4
+ <% next unless response.content %>
5
+ <% id = SecureRandom.hex %>
6
+ <p class="collapsible">
7
+ <a class="Vlt-js-accordion__trigger Nxd-accordion-button" data-accordion="acc<%= id %>">
8
+ <span class="Vlt-btn Vlt-btn--tertiary Vlt-btn--block">
9
+ View response field descriptions
10
+ </span>
11
+ </a>
12
+ </p>
13
+
14
+ <div id="acc<%= id %>" class="Vlt-js-accordion__content <%= auto_expand_responses ? 'Vlt-js-accordion__content_open' : '' %>">
15
+ <h4 id="<%= anchor_prefix %>">Response Fields</h4>
16
+ <% response.formats.each_with_index do |format, index| %>
17
+ <div class="js-format" data-format="<%= format %>">
18
+ <div class="Vlt-table">
19
+ <table>
20
+ <thead>
21
+ <tr>
22
+ <th>Field</th>
23
+ <th>Description</th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ <% if response.exhibits_one_of_multiple_schemas?(format) %>
28
+ <% response.split_schemas(format).each_with_index do |schema, index| %>
29
+ <%= erb :'open_api/_response_description_parameters', locals: { schema: schema, anchor_prefix: anchor_prefix } %>
30
+ <% end %>
31
+ <% else %>
32
+ <% schema = response.schema(format) %>
33
+ <%= erb :'open_api/_response_description_parameters', locals: { schema: schema, anchor_prefix: anchor_prefix } %>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+ </div>
38
+ </div>
39
+ <% end %>
40
+ </div>
41
+ <% end %>
@@ -0,0 +1,104 @@
1
+ <% definition = @specification.definition %>
2
+ <%= erb :'open_api/_navigation', locals: { definition: definition } %>
3
+
4
+ <div class="Vlt-main Vlt-main--light Nxd-main" tabindex="2">
5
+ <div class="Vlt-card Vlt-article Nxd-api">
6
+ <div id="overview" class="Vlt-grid">
7
+ <div class="Vlt-col Vlt-col--2of3 Nxd-api__docs">
8
+ <div>
9
+ <h1>
10
+ <%= definition.info['title'] %>
11
+ <% if definition.info['x-label'] %>
12
+ <span class="Vlt-badge Vlt-badge--<%= definition.info['x-label'].parameterize %>">
13
+ <%= definition.info['x-label'] %>
14
+ </span>
15
+ <% end %>
16
+ </h1>
17
+
18
+ <% if definition.info['description'] %>
19
+ <p><%= definition.info['description'].render_markdown %></p>
20
+ <% end %>
21
+
22
+ <div class="Vlt-grid">
23
+ <div class="Vlt-col">
24
+ <a href=<%= url("#{request.url}.#{definition.format}", params: request.params) %> class='Vlt-btn Vlt-btn--secondary Vlt-btn--app'>
25
+ <svg><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-download" /></svg>
26
+ Download OpenAPI 3 Definition
27
+ </a>
28
+ </div>
29
+ <div class="Vlt-col Vlt-right">
30
+ <a href="https://github.com/Nexmo/api-specification/blob/master/definitions/<%= @specification.definition_name %>.yml" class='Vlt-btn Vlt-btn--tertiary Vlt-btn--app Vlt-right'>
31
+ <svg className="Vlt-icon Vlt-black">
32
+ <use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-github" />
33
+ </svg>
34
+ Improve this specification
35
+ </a>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <div class="Vlt-col Vlt-col--1of3 Nxd-api__code Nxd-api__code--install">
41
+
42
+ <% if @specification.display_initialization? %>
43
+ <div class="Nxd-api__code__header">
44
+ <% if @specification.initialization_config && @specification.initialization_config['formats'] %>
45
+ <div class="Vlt-native-dropdown">
46
+ <select class="js-format-selector">
47
+ <% @specification.initialization_config['formats'].each do |value, name| %>
48
+ <option value="<%= value %>"><%= name %></option>
49
+ <% end %>
50
+ </select>
51
+ </div>
52
+ <% end %>
53
+ </div>
54
+ <%= @specification.initialization_content %>
55
+ <% end %>
56
+
57
+ <% if @specification.available_versions && @specification.available_versions.count > 1 %>
58
+ <div class="Vlt-callout Vlt-callout--shoutout Nxd-version">
59
+ <i></i>
60
+ <div class="Vlt-callout__content">
61
+ <h4>There are multiple versions of this API available</h4>
62
+ <p>
63
+ <% @specification.available_versions.each do |v| %>
64
+ <a href="/api/<%= v['name'] %>" <%= v['version'] == @specification.current_version ? 'class=active':'' %>>Version <%= v['version'] %></a> <%= '|' unless v == @specification.available_versions.last %>
65
+ <% end %>
66
+ </p>
67
+ </div>
68
+ </div>
69
+ <% end %>
70
+ </div>
71
+ </div>
72
+
73
+ <% @specification.groups.each do |name, endpoints| %>
74
+ <% if name %>
75
+ <% group = definition.raw['tags'].select { |tag| tag['name'].capitalize == name.capitalize }.first %>
76
+ <%= erb :'open_api/_model', locals: { group: group } %>
77
+ <% end %>
78
+
79
+ <% endpoints.each do |endpoint| %>
80
+ <%= erb :'open_api/_endpoint', locals: { endpoint: endpoint } %>
81
+ <% end %>
82
+ <% end %>
83
+
84
+ <% if @specification.definition.raw['x-webhooks'] %>
85
+ <% @specification.definition.raw['x-webhooks'].each do |name, definition| %>
86
+ <%= erb :'open_api/_callback', locals: { callback: OasParser::Callback.new(self, name, definition), webhook: true } %>
87
+ <% end %>
88
+ <% end %>
89
+
90
+ <% if @specification.definition_errors %>
91
+ <div class="Vlt-grid" id="errors">
92
+ <div class="Vlt-col Vlt-col--2of3 Nxd-api__docs">
93
+ <div>
94
+ <%= @specification.definition_errors %>
95
+ </div>
96
+ </div>
97
+ <div class="Vlt-col Vlt-col--1of3 Nxd-api__code">
98
+ <h5>Example response</h5>
99
+ <%= Nexmo::OAS::Renderer::ResponseParserDecorator.new(definition.raw['components']['schemas']['Error']).html %>
100
+ </div>
101
+ </div>
102
+ <% end %>
103
+ </div>
104
+ </div>