nexmo-oas-renderer 0.11.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +135 -0
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +12 -0
  5. data/Gemfile +2 -2
  6. data/Gemfile.lock +92 -72
  7. data/README.md +8 -0
  8. data/Rakefile +2 -2
  9. data/bin/console +3 -3
  10. data/lib/nexmo/oas/engine.rb +2 -0
  11. data/lib/nexmo/oas/renderer.rb +5 -5
  12. data/lib/nexmo/oas/renderer/app.rb +71 -46
  13. data/lib/nexmo/oas/renderer/config.ru +4 -2
  14. data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +18 -18
  15. data/lib/nexmo/oas/renderer/helpers/navigation.rb +2 -2
  16. data/lib/nexmo/oas/renderer/helpers/render.rb +2 -1
  17. data/lib/nexmo/oas/renderer/helpers/summary.rb +4 -1
  18. data/lib/nexmo/oas/renderer/helpers/url.rb +2 -0
  19. data/lib/nexmo/oas/renderer/presenters/api_specification.rb +2 -1
  20. data/lib/nexmo/oas/renderer/presenters/endpoint.rb +2 -0
  21. data/lib/nexmo/oas/renderer/presenters/groups.rb +4 -0
  22. data/lib/nexmo/oas/renderer/presenters/navigation.rb +2 -0
  23. data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +5 -2
  24. data/lib/nexmo/oas/renderer/presenters/request_body_raw.rb +141 -0
  25. data/lib/nexmo/oas/renderer/presenters/response_format.rb +4 -2
  26. data/lib/nexmo/oas/renderer/presenters/response_tab/link.rb +3 -0
  27. data/lib/nexmo/oas/renderer/presenters/response_tab/panel.rb +8 -5
  28. data/lib/nexmo/oas/renderer/presenters/response_tabs.rb +6 -2
  29. data/lib/nexmo/oas/renderer/presenters/versions.rb +11 -10
  30. data/lib/nexmo/oas/renderer/public/assets/javascripts/components/format.js +12 -7
  31. data/lib/nexmo/oas/renderer/public/assets/javascripts/nexmo-oas-renderer.js +51 -24
  32. data/lib/nexmo/oas/renderer/public/assets/javascripts/popper.min.js +5 -0
  33. data/lib/nexmo/oas/renderer/public/assets/javascripts/tooltip.min.js +5 -0
  34. data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.accordion.js +301 -243
  35. data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.tooltip.js +76 -0
  36. data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo-oas-renderer.css +255 -823
  37. data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo-oas-renderer.css.map +2 -2
  38. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +287 -90
  39. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +2 -6
  40. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/themes/dark.scss +89 -0
  41. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/themes/light.scss +68 -0
  42. data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-prism.min.css +1 -1
  43. data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta.min.css +1 -1
  44. data/lib/nexmo/oas/renderer/services/oas_parser.rb +2 -0
  45. data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +3 -1
  46. data/lib/nexmo/oas/renderer/version.rb +3 -1
  47. data/lib/nexmo/oas/renderer/views/layouts/_head.erb +1 -0
  48. data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +5 -4
  49. data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +3 -1
  50. data/lib/nexmo/oas/renderer/views/open_api/_auth.erb +74 -0
  51. data/lib/nexmo/oas/renderer/views/open_api/_available_endpoints.erb +25 -0
  52. data/lib/nexmo/oas/renderer/views/open_api/_callback_endpoint.erb +18 -27
  53. data/lib/nexmo/oas/renderer/views/open_api/_callbacks.erb +5 -0
  54. data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +39 -124
  55. data/lib/nexmo/oas/renderer/views/open_api/_header.erb +71 -0
  56. data/lib/nexmo/oas/renderer/views/open_api/_model.erb +31 -26
  57. data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +54 -78
  58. data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +2 -5
  59. data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +98 -153
  60. data/lib/nexmo/oas/renderer/views/open_api/_request_json.erb +4 -0
  61. data/lib/nexmo/oas/renderer/views/open_api/_request_one_of.erb +70 -0
  62. data/lib/nexmo/oas/renderer/views/open_api/_request_single.erb +53 -0
  63. data/lib/nexmo/oas/renderer/views/open_api/_requests.erb +22 -0
  64. data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +88 -90
  65. data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +17 -12
  66. data/lib/nexmo/oas/renderer/views/open_api/_response_fields.erb +1 -16
  67. data/lib/nexmo/oas/renderer/views/open_api/_response_tabs.erb +2 -2
  68. data/lib/nexmo/oas/renderer/views/open_api/_responses.erb +35 -0
  69. data/lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb +15 -4
  70. data/lib/nexmo/oas/renderer/views/open_api/_tabbed_single_parameter.erb +56 -0
  71. data/lib/nexmo/oas/renderer/views/open_api/_webhooks.erb +30 -0
  72. data/lib/nexmo/oas/renderer/views/open_api/show.erb +10 -115
  73. data/nexmo-oas-renderer.gemspec +26 -26
  74. metadata +61 -49
  75. data/lib/nexmo/oas/renderer/public/assets/javascripts/components/scroll.js +0 -21
  76. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +0 -137
  77. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/navigation.scss +0 -102
  78. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/nexmo.scss +0 -61
  79. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/syntax.scss +0 -63
  80. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/typography.scss +0 -248
  81. data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/volta-templates.scss +0 -119
@@ -0,0 +1,4 @@
1
+ <% output = Nexmo::OAS::Renderer::Presenters::RequestBodyRaw.new(parameters) %>
2
+
3
+ <h4>Example Request</h4>
4
+ <pre class="highlight javascript" style="white-space: pre-wrap"><code><%= output.to_json %></code></pre>
@@ -0,0 +1,70 @@
1
+ <%
2
+ body = endpoint.request_body
3
+
4
+ # If we're calling this recursively (a oneOf a oneOf) then schema is passed in
5
+ # rather than pulling it from the body
6
+ schema ||= endpoint.request_body.content[format]['schema']['oneOf']
7
+
8
+ # Handle any cases where the top level of the oneOf is an allOf
9
+ schemas = schema.map do |s|
10
+ if s['allOf']
11
+ newSchema = body.handle_all_of(s)
12
+ s.each do |k,v|
13
+ newSchema[k] = v
14
+ end
15
+
16
+ next newSchema
17
+ end
18
+ s
19
+ end
20
+
21
+ panels = []
22
+
23
+ schemas.each_with_index do |schema, index|
24
+ if schema['properties']
25
+ schema['properties'] = schema['properties'].map do |name, definition|
26
+ # Sometimes we get in to a weird situation where we already have a Property
27
+ next name if name.instance_of?(OasParser::Property)
28
+ OasParser::Property.new(self, schema, name, definition)
29
+ end
30
+ .sort_by do |prop|
31
+ prop.required ? -1 : 1
32
+ end
33
+ end
34
+
35
+ subtitle = schema['title'] || schema['description']
36
+
37
+ if defined?(parent)
38
+ subtitle = "#{parent} &raquo; #{subtitle}"
39
+ end
40
+
41
+ panels.push({
42
+ 'title' => subtitle,
43
+ 'description' => schema['title'] || schema['description'],
44
+ 'parameters' => schema['properties'],
45
+ 'oneOf' => schema['oneOf'],
46
+ 'x-tab-id' => schema['x-tab-id'] || schema['title'].parameterize,
47
+ 'active' => index == 0
48
+ })
49
+ end
50
+ %>
51
+
52
+ <div class="Vlt-tabs js-format" data-format="<%= format %>">
53
+ <div class="Vlt-tabs__header" style="display:none;" role="tablist" aria-label="Responses">
54
+ <% panels.each do |panel| %>
55
+ <span data-tab-link="<%= panel['x-tab-id'] %>" class="Vlt-tabs__link <%= panel['active'] ? 'Vlt-tabs__link_active' : '' %>">
56
+ </span>
57
+ <% end %>
58
+ </div>
59
+ <div class="Vlt-tabs__content">
60
+ <% panels.each do |panel| %>
61
+ <div class="Vlt-tabs__panel <%= panel['active'] ? 'Vlt-tabs__panel_active' : '' %>">
62
+ <% unless panel['oneOf'] %>
63
+ <%= erb :'open_api/_request_single', locals: { title: title, subtitle: panel['title'], endpoint: endpoint, params: panel['parameters'], format: format } %>
64
+ <% else %>
65
+ <%= erb :'open_api/_request_one_of', locals: { title: title, parent: panel['title'], endpoint: endpoint, schema: panel['oneOf'], format: format } %>
66
+ <% end %>
67
+ </div>
68
+ <% end %>
69
+ </div>
70
+ </div>
@@ -0,0 +1,53 @@
1
+ <%
2
+ renderer = Nexmo::OAS::Renderer::Presenters::RequestBodyRaw
3
+ params ||= endpoint.request_body.properties_for_format(format)
4
+
5
+ requests = []
6
+
7
+ # Only show the required fields tab if there are any required fields
8
+ required_params = params.select do |param|
9
+ param.required
10
+ end
11
+
12
+ requests.push(
13
+ {
14
+ 'title' => 'Required Fields Only',
15
+ 'id' => 'required-only',
16
+ 'value' => renderer.new(params, { 'required_only' => true }, endpoint)
17
+ }) if required_params.any?
18
+
19
+ # Always show the all fields tab
20
+ requests.push(
21
+ {
22
+ 'title' => 'All Fields',
23
+ 'id' => 'all-fields',
24
+ 'value' => renderer.new(params, { 'required_only' => false }, endpoint)
25
+ }
26
+ )
27
+
28
+ # Remove the "required only" option if the two request bodies are identical
29
+ unique_requests = requests.map { |r| r['value'].to_format('application/json') }.to_set.size
30
+ requests.shift if (unique_requests == 1 && requests.size != unique_requests)
31
+
32
+ title = "Example Request" unless title
33
+ if defined?(subtitle)
34
+ title = "#{title} &raquo; #{subtitle}"
35
+ end
36
+
37
+ %>
38
+
39
+ <h4 class="Vlt-grey-light"><%= title %></h4>
40
+ <div class="Vlt-tabs">
41
+ <div class="Vlt-tabs__header" role="tablist" aria-label="Responses">
42
+ <% requests.each_with_index do |request, index| %>
43
+ <div role='tab' tabindex="-1" data-tab-link="<%= request['id'] %>" class="<%= index === 0 ? 'Vlt-tabs__link_active' : '' %> Vlt-tabs__link tab-sync"><%= request['title'] %></div>
44
+ <% end %>
45
+ </div>
46
+ <div class="Vlt-tabs__content">
47
+ <% requests.each_with_index do |request, index| %>
48
+ <div role='tabpanel' class="Vlt-js-tabs__panel <%= index === 0 ? 'Vlt-tabs__panel_active' : '' %>">
49
+ <pre class="<%= format == 'application/json' ? 'language-json' : 'language-shell' %> Vlt-prism--copy-disabled <%= @theme_light ? 'Vlt-prism--dark' : '' %>"><code><%= request['value'].to_format(format) %></code></pre>
50
+ </div>
51
+ <% end %>
52
+ </div>
53
+ </div>
@@ -0,0 +1,22 @@
1
+ <%
2
+ return unless endpoint.request_body
3
+ return if endpoint.request_body.raw['x-hide-request']
4
+ title = defined?(title) ? title : nil
5
+
6
+ renderer = Nexmo::OAS::Renderer::Presenters::RequestBodyRaw
7
+
8
+ # The first format defined is preferred. This is usually application/json
9
+ format = endpoint.request_body.formats[0]
10
+ %>
11
+
12
+ <%
13
+ if endpoint.request_body.exhibits_one_of_multiple_schemas?(format)
14
+ %>
15
+ <%= erb :'open_api/_request_one_of', locals: { endpoint: endpoint, format: format, title: title } %>
16
+
17
+ <% else %>
18
+ <%= erb :'open_api/_request_single', locals: { endpoint: endpoint, format: format, title: title} %>
19
+ <%
20
+ end
21
+ %>
22
+
@@ -13,120 +13,118 @@
13
13
  %>
14
14
 
15
15
  <% if schema['properties'] %>
16
- <% schema['properties'].each do |key, value| %>
16
+ <% parentField = parentField ? "#{parentField}." : '' %>
17
+ <% schema['properties'].each do |key, parameter| %>
17
18
  <%
18
19
  next if key == '_links'
19
- next if value['x-skip-response-description']
20
+ next if parameter['x-skip-response-description']
20
21
  parent = "#{endpoint.method}_#{endpoint.path.path.gsub("/", "_")[1..-1]}" unless parent
21
22
  responseFieldId = parent + "_" + key
22
23
  %>
23
- <tr id="<%= responseFieldId %>" <% if value['properties'] %> class=" Vlt-table__row--noline" <% end %>>
24
- <td>
25
- <b><%= key %></b>
26
- <% if value['items'] %>
27
- <br />
28
- <small>array of <%= value['items']['type'] %>s</small>
24
+ <div class="oas-grid">
25
+ <div id="<%= responseFieldId %>" class="oas-parameter-name <%= !parentField.blank? ? 'oas-parameter-name-nested' : '' %>">
26
+ <% if parentField.blank? %>
27
+ <b><%= key %></b>
29
28
  <% else %>
30
- <br />
31
- <small>
32
- <i><%= value['type'] %></i>
33
- </small>
29
+ <div class="Vlt-tooltip Vlt-tooltip--top" title="<%= parentField %><%= key %>">
30
+ <b><%= key %></b>
31
+ </div>
34
32
  <% end %>
35
- </td>
36
- <td>
37
- <%= value['description'] ? value['description'].render_markdown : '' %>
38
- <% if value['enum']%>
33
+ </div>
34
+
35
+ <div class="oas-parameter-description">
36
+ <div class="oas-parameter-meta">
37
+ <%= parameter['type'] %>
38
+ <% if parameter['type'] == 'array' %>
39
+ <% if parameter['items'] && parameter['items']['type'] %>
40
+ of <%= (parameter['items']['type']) %>s
41
+ <% end %>
42
+ <% end %>
43
+ </div>
44
+
45
+ <%= (parameter['description'] || '' ).render_markdown %>
46
+
47
+ <% if parameter['enum'] %>
39
48
  <small class="Vlt-grey-dark">
40
- One of: <%= parameter_values(value['enum']) %>
49
+ One of:
50
+ <%= parameter_values(parameter['enum']) %>
41
51
  </small>
42
52
  <% end %>
43
53
 
54
+ </div>
44
55
 
45
- <% if value['items'] # If this is an array, we need to show the structure of the children %>
46
56
 
47
- <% if value['items']['oneOf'] || value['items']['anyOf'] # If it's a oneOf/anyOf, we need tabs! %>
48
- <%
57
+ <% arrayMarker = "" %>
58
+ <% if parameter['items'] # If this is an array, we need to show the structure of the children %>
59
+ <% arrayMarker = "[]" %>
60
+ <% if parameter['items']['oneOf'] || parameter['items']['anyOf'] # If it's a oneOf/anyOf, we need tabs! %>
61
+ <%
49
62
 
50
- if value['items']['oneOf']
51
- qualifier = 'one'
52
- key = 'oneOf'
53
- else
54
- qualifier = 'any'
55
- key = 'anyOf'
56
- end
63
+ if parameter['items']['oneOf']
64
+ qualifier = 'one'
65
+ lookupKey = 'oneOf'
66
+ else
67
+ qualifier = 'any'
68
+ lookupKey = 'anyOf'
69
+ end
57
70
 
58
- schemas = value['items'][key].map do |item|
59
- if item['allOf']
60
- item = item.deep_merge(item['allOf'].reduce { |a,b| a.deep_merge(b) })
61
- item.delete('allOf')
62
- end
63
- item
71
+ schemas = parameter['items'][lookupKey].map do |item|
72
+ if item['allOf']
73
+ item = item.deep_merge(item['allOf'].reduce { |a,b| a.deep_merge(b) })
74
+ item.delete('allOf')
64
75
  end
65
- %>
66
- <% else %>
67
- <% value['properties'] = value['items']['properties'] %>
68
- <% schemas = [value] %>
69
- <% end %>
70
-
76
+ item
77
+ end
78
+ %>
71
79
  <% else %>
72
- <% schemas = [value] if value['properties'] %>
80
+ <% parameter['properties'] = parameter['items']['properties'] %>
73
81
  <% end %>
82
+ <% end %>
74
83
 
75
- <% if schemas %>
76
- <% needs_tabs = schemas.size > 1 %>
77
- </td>
78
- </tr>
79
-
80
- <tr class="Vlt-table__row--nohighlight">
81
- <td colspan="2">
84
+ <%
85
+ schemas = [parameter]
86
+ %>
82
87
 
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>
88
+ <% if schemas %>
89
+ <% needs_tabs = schemas.size > 1 %>
90
+ <% if needs_tabs %>
91
+ <div class="Vlt-callout Vlt-callout--shoutout">
92
+ <i></i>
93
+ <div class="Vlt-callout__content">
94
+ This array contains <strong><%= qualifier %></strong> of the following objects:
89
95
  </div>
90
- <div class="Vlt-tabs js-format">
91
- <div class="Vlt-tabs__header Vlt-tabs__header--bordered" 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 %>
96
+ </div>
97
+ <div class="Vlt-tabs js-format">
98
+ <div class="Vlt-tabs__header Vlt-tabs__header--bordered" role="tablist" aria-label="Responses">
99
+ <% schemas.each_with_index do |schema, index| %>
100
+ <div
101
+ class="Vlt-tabs__link <%= index == 0 ? 'Vlt-tabs__link_active' : '' %> <%= schema['x-tab-id'] ? "tab-sync" : '' %>"
102
+ <% if schema['x-tab-id'] %>
103
+ data-tab-link="<%= schema['x-tab-id'] %>"
104
+ <% end %>
98
105
  >
99
- <%= schema['description'] %>
100
- </div>
101
- <% end %>
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--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
- </div>
106
+ <%= schema['description'] %>
107
+ </div>
108
+ <% end %>
121
109
  </div>
122
- <% end %>
110
+ <div class="Vlt-tabs__content">
111
+ <% end %>
123
112
 
124
- <% if needs_tabs %>
113
+ <% schemas.each_with_index do |value, index| %>
114
+ <div class="Vlt-tabs__panel <%= index == 0 ? 'Vlt-tabs__panel_active' : '' %>">
115
+ <div class="oas-parameter-nested">
116
+ <%= erb :'open_api/_response_description_parameters', locals: { endpoint: endpoint, schema: value, parent: responseFieldId, parentField: "#{parentField}#{key}#{arrayMarker}" } %>
125
117
  </div>
126
- </div>
127
- <% end %>
128
- <% end %>
129
- </td>
130
- </tr>
118
+ </div>
119
+ <% end %>
120
+
121
+ <% if needs_tabs %>
122
+ </div>
123
+ </div>
124
+ <% end %>
125
+ <% end %>
126
+ </div>
131
127
  <% end %>
132
128
  <% end %>
129
+
130
+
@@ -1,18 +1,22 @@
1
- <% endpoint.responses.each do |response| %>
2
- <% next unless response.success? %>
3
- <% next if response.code.to_i == 204 %>
4
- <% next unless response.content %>
1
+ <%
2
+ responses = endpoint.responses.select do |response|
3
+ next false unless response.success?
4
+ next false unless response.content
5
+ true
6
+ end
7
+
8
+ return unless responses.size.positive?
9
+ %>
10
+ <h4>Responses</h4>
11
+
12
+ <% responses.each do |response| %>
5
13
  <% id = SecureRandom.hex %>
6
- <p class="collapsible">
7
- <a class="Vlt-js-accordion__trigger Nxd-accordion-button" data-accordion="acc<%= id %>">
8
- <span class="response-description-toggle Vlt-btn Vlt-btn--tertiary Vlt-btn--block Vlt-bg-grey-lighter">
9
- <%= @specification.auto_expand_responses ? 'Hide' : 'View' %> response field descriptions
10
- </span>
11
- </a>
12
- </p>
14
+ <div class="Vlt-accordion--chevron-left">
15
+ <div role="button" style="padding: 12px;" class="response-description-toggle Vlt-bg-<%= response.code[0] == "2" ? 'green' : 'red' %> Vlt-accordion__trigger Vlt-js-accordion__trigger Nxd-accordion-button" data-accordion="acc<%= id %>">
16
+ <strong><%= response.code %></strong> <%= response.description %>
17
+ </div>
13
18
 
14
19
  <div id="acc<%= id %>" class="Vlt-js-accordion__content <%= @specification.auto_expand_responses ? 'Vlt-js-accordion__content_open' : '' %>">
15
- <h4>Response Fields</h4>
16
20
  <% response.formats.each_with_index do |format, index| %>
17
21
  <% if response.exhibits_one_of_multiple_schemas?(format) %>
18
22
  <%= erb :'open_api/_response_tabs', locals: { endpoint: endpoint, format: format, response: response, content: :descriptions } %>
@@ -22,4 +26,5 @@
22
26
  <% end %>
23
27
  <% end %>
24
28
  </div>
29
+ </div>
25
30
  <% end %>
@@ -1,18 +1,3 @@
1
1
  <div class="js-format Nxd-api__response" data-format="<%= format %>">
2
- <div class="Vlt-table Vlt-table--bordered">
3
- <table>
4
- <thead>
5
- <% if index %>
6
- <tr><th colspan="2"><%= schema['description'] || "Response #{index + 1}"%></th></tr>
7
- <% end %>
8
- <tr>
9
- <th>Field</th>
10
- <th>Description</th>
11
- </tr>
12
- </thead>
13
- <tbody>
14
- <%= erb :'open_api/_response_description_parameters', locals: { response: response, endpoint: endpoint, schema: schema } %>
15
- </tbody>
16
- </table>
17
- </div>
2
+ <%= erb :'open_api/_response_description_parameters', locals: { response: response, endpoint: endpoint, schema: schema } %>
18
3
  </div>
@@ -1,7 +1,7 @@
1
- <% tabs = Nexmo::OAS::Renderer::Presenters::ResponseTabs.new(format, response, content, endpoint) %>
1
+ <% tabs = Nexmo::OAS::Renderer::Presenters::ResponseTabs.new(format, response, content, endpoint, theme_light: @theme_light) %>
2
2
 
3
3
  <div class='Vlt-tabs js-format' data-format='<%= tabs.format %>'>
4
- <div class='Vlt-tabs__header Vlt-tabs__header--bordered' role='tablist' aria-label='Responses'>
4
+ <div class='Vlt-tabs__header' role='tablist' aria-label='Responses'>
5
5
  <% tabs.tab_links.each do |link| %>
6
6
  <div role='tab' class='<%= link.css_classes %>' <% if link.data_tab_link %>data-tab-link="<%= link.data_tab_link %>"<% end %>>
7
7
  <%= link.content %>
@@ -0,0 +1,35 @@
1
+ <h4 class="Vlt-grey-light">Example Responses</h4>
2
+
3
+ <div class="response-tabs-selector" data-tab-content="response-tabs-<%= endpoint.operationId.parameterize %>">
4
+ <% endpoint.responses.each_with_index do |response, index| %>
5
+ <span role="tab" class="<%= index === 0 ? 'Vlt-js-tabs__link_active' : '' %> Vlt-bg-<%= response.code[0] == '2' ? 'green' : response.code[0] == '3' ? 'yellow' : 'red' %> Vlt-js-tabs__link response-tabs-selector-item"><%= response.code %></span>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div id="response-tabs-<%= endpoint.operationId.parameterize %>" style="margin-bottom: 64px;">
10
+ <% endpoint.responses.each_with_index do |response, index| %>
11
+ <div class="Vlt-js-tabs__panel <%= index === 0 ? 'Vlt-js-tabs__panel_active' : '' %>">
12
+ <% response.formats.each do |format| %>
13
+ <div class="js-format" data-format="<%= format %>">
14
+ <% if response.exhibits_one_of_multiple_schemas?(format) %>
15
+ <%= erb :'open_api/_response_tabs', locals: { format: format, endpoint: endpoint, response: response, content: :responses } %>
16
+ <% else %>
17
+ <% schema = response.schema(format) %>
18
+ <% if ['application/json', 'application/xml', 'text/xml'].include?(format) %>
19
+ <%= Nexmo::OAS::Renderer::ResponseParserDecorator.new(schema).html(format, xml_options: schema['xml'], theme_light: @theme_light) %>
20
+ <% else %>
21
+ <% content = response.description ? response.description : 'No content' %>
22
+ <pre class="language-json Vlt-prism--copy-disabled <%= @theme_light ? 'Vlt-prism--dark' : '' %>"><code><%= content %></code></pre>
23
+ <% end %>
24
+ <% end %>
25
+ </div>
26
+ <% end %>
27
+
28
+ <% if response.code == '204' || response.formats.empty? %>
29
+ <% content = response.description ? response.description : 'No content' %>
30
+ <pre class="language-json Vlt-prism--copy-disabled <%= @theme_light ? 'Vlt-prism--dark' : '' %>"><code><%= content %></code></pre>
31
+ <% end %>
32
+ </div>
33
+
34
+ <% end %>
35
+ </div>