nexmo-oas-renderer 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/.github/workflows/push-docker-publish.yml +19 -0
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/.rubocop.yml +135 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +58 -0
- data/CONTRIBUTING.md +46 -0
- data/Dockerfile +6 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +248 -0
- data/LICENSE.txt +21 -0
- data/README.md +103 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/nexmo-oas-renderer +5 -0
- data/lib/nexmo/oas/engine.rb +11 -0
- data/lib/nexmo/oas/renderer.rb +13 -0
- data/lib/nexmo/oas/renderer/app.rb +201 -0
- data/lib/nexmo/oas/renderer/config.ru +9 -0
- data/lib/nexmo/oas/renderer/config/code_languages.yml +138 -0
- data/lib/nexmo/oas/renderer/config/dynamic_content.yml +1 -0
- data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +55 -0
- data/lib/nexmo/oas/renderer/helpers/navigation.rb +66 -0
- data/lib/nexmo/oas/renderer/helpers/render.rb +25 -0
- data/lib/nexmo/oas/renderer/helpers/summary.rb +33 -0
- data/lib/nexmo/oas/renderer/helpers/url.rb +19 -0
- data/lib/nexmo/oas/renderer/presenters/api_specification.rb +54 -0
- data/lib/nexmo/oas/renderer/presenters/endpoint.rb +21 -0
- data/lib/nexmo/oas/renderer/presenters/groups.rb +39 -0
- data/lib/nexmo/oas/renderer/presenters/navigation.rb +26 -0
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +62 -0
- data/lib/nexmo/oas/renderer/presenters/request_body_raw.rb +141 -0
- data/lib/nexmo/oas/renderer/presenters/response_format.rb +29 -0
- data/lib/nexmo/oas/renderer/presenters/response_tab/link.rb +36 -0
- data/lib/nexmo/oas/renderer/presenters/response_tab/panel.rb +45 -0
- data/lib/nexmo/oas/renderer/presenters/response_tabs.rb +58 -0
- data/lib/nexmo/oas/renderer/presenters/versions.rb +51 -0
- data/lib/nexmo/oas/renderer/public/500.html +66 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/android.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/curl.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/dotnet.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/ios.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/java.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/javascript.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/node.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/php.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/python.svg +11 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/ruby.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/lost.svg +37 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/components/format.js +47 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/nexmo-oas-renderer.js +65 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/popper.min.js +5 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/prism.js +22 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/tooltip.min.js +5 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.accordion.js +307 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.core.js +230 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.modal.js +300 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.tabs.js +143 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.tooltip.js +76 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo-oas-renderer.css +287 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo-oas-renderer.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +341 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/mediaqueries.scss +48 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +6 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/themes/dark.scss +89 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/themes/light.scss +68 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/variables.scss +91 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-prism.min.css +1 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta.min.css +1 -0
- data/lib/nexmo/oas/renderer/public/assets/symbol/volta-icons.svg +1 -0
- data/lib/nexmo/oas/renderer/public/favicon.ico +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-Regular.eot +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-Regular.ttf +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-Regular.woff +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-Regular.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiBold.eot +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiBold.ttf +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiBold.woff +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiBold.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiMonoSemiBold.eot +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiMonoSemiBold.ttf +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiMonoSemiBold.woff +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-SemiMonoSemiBold.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-WideMedium.eot +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-WideMedium.ttf +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-WideMedium.woff +0 -0
- data/lib/nexmo/oas/renderer/public/fonts/Spezia-WideMedium.woff2 +0 -0
- data/lib/nexmo/oas/renderer/services/oas_parser.rb +23 -0
- data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +35 -0
- data/lib/nexmo/oas/renderer/version.rb +9 -0
- data/lib/nexmo/oas/renderer/views/api/index.erb +19 -0
- data/lib/nexmo/oas/renderer/views/api/show.erb +1 -0
- data/lib/nexmo/oas/renderer/views/concepts/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/layouts/_head.erb +6 -0
- data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +14 -0
- data/lib/nexmo/oas/renderer/views/layouts/api.erb +23 -0
- data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +12 -0
- data/lib/nexmo/oas/renderer/views/open_api/_auth.erb +74 -0
- data/lib/nexmo/oas/renderer/views/open_api/_available_endpoints.erb +25 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback.erb +5 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback_endpoint.erb +38 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callbacks.erb +5 -0
- data/lib/nexmo/oas/renderer/views/open_api/_code_examples.erb +16 -0
- data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +54 -0
- data/lib/nexmo/oas/renderer/views/open_api/_header.erb +71 -0
- data/lib/nexmo/oas/renderer/views/open_api/_model.erb +43 -0
- data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +68 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +56 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +115 -0
- data/lib/nexmo/oas/renderer/views/open_api/_request_json.erb +4 -0
- data/lib/nexmo/oas/renderer/views/open_api/_request_one_of.erb +70 -0
- data/lib/nexmo/oas/renderer/views/open_api/_request_single.erb +53 -0
- data/lib/nexmo/oas/renderer/views/open_api/_requests.erb +22 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +130 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +45 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_fields.erb +3 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_tabs.erb +18 -0
- data/lib/nexmo/oas/renderer/views/open_api/_responses.erb +51 -0
- data/lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb +64 -0
- data/lib/nexmo/oas/renderer/views/open_api/_tabbed_single_parameter.erb +56 -0
- data/lib/nexmo/oas/renderer/views/open_api/_webhooks.erb +30 -0
- data/lib/nexmo/oas/renderer/views/open_api/show.erb +26 -0
- data/lib/nexmo/oas/renderer/views/static/404.erb +6 -0
- data/nexmo-oas-renderer.gemspec +51 -0
- metadata +397 -0
@@ -0,0 +1,56 @@
|
|
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
|
+
<h4>
|
21
|
+
Request body
|
22
|
+
<span class="Vlt-badge Vlt-badge--blue"><%= format %></span>
|
23
|
+
</h4>
|
24
|
+
|
25
|
+
<% if endpoint.request_body.description %>
|
26
|
+
<%= endpoint.request_body.description.render_markdown %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% unless endpoint.request_body.exhibits_one_of_multiple_schemas?(format) %>
|
30
|
+
|
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
|
40
|
+
if params
|
41
|
+
%>
|
42
|
+
|
43
|
+
<%= erb :'open_api/_parameters', locals: { endpoint:endpoint, parameters: params, callback: callback } %>
|
44
|
+
<% end %>
|
45
|
+
<% else %>
|
46
|
+
|
47
|
+
<%
|
48
|
+
# This can likely be better done as a presenter, but it works for now
|
49
|
+
schema = endpoint.request_body.content[format]['schema']['oneOf']
|
50
|
+
%>
|
51
|
+
<%= erb :'open_api/_tabbed_parameters', locals: { body: endpoint.request_body, schema: schema, format: format, callback: callback } %>
|
52
|
+
<%
|
53
|
+
end
|
54
|
+
end
|
55
|
+
%>
|
56
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
<%
|
2
|
+
model = false if model.nil?
|
3
|
+
callback = false if callback.nil?
|
4
|
+
format = nil if format.nil?
|
5
|
+
|
6
|
+
unless defined?(parent)
|
7
|
+
parent = ""
|
8
|
+
else
|
9
|
+
parent = "#{parent}."
|
10
|
+
end
|
11
|
+
|
12
|
+
isOneOf = false unless defined?(isOneOf)
|
13
|
+
%>
|
14
|
+
|
15
|
+
<% parameters.each do |parameter| %>
|
16
|
+
|
17
|
+
<div class="oas-grid">
|
18
|
+
<div class="oas-parameter-name <%= !parent.blank? ? 'oas-parameter-name-nested' : '' %>">
|
19
|
+
<% if parent.blank? %>
|
20
|
+
<b><%= parameter.name %></b>
|
21
|
+
<% else %>
|
22
|
+
<div class="Vlt-tooltip Vlt-tooltip--top" title="<%= parent %><%= parameter.name %>">
|
23
|
+
<b><%= parameter.name %></b>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<% if @specification.formats.any? %>
|
28
|
+
<% if @specification.formats.include?('text/xml') %>
|
29
|
+
<span class="js-format" data-format="text/xml">
|
30
|
+
<% if parameter.is_xml_attribute? %>
|
31
|
+
| <span class="xml-flag">Attribute</span>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<% if parameter.is_xml_text? %>
|
35
|
+
| <span class="xml-flag">Value</span>
|
36
|
+
<% end %>
|
37
|
+
</span>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
<div class="oas-parameter-description">
|
42
|
+
|
43
|
+
<div class="oas-parameter-meta">
|
44
|
+
<em>
|
45
|
+
<%= parameter.type %>
|
46
|
+
<% if parameter.format %>
|
47
|
+
(<%= parameter.format %>)
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<% if parameter.array? %>
|
51
|
+
<% if parameter.items && parameter.items['type'] %>
|
52
|
+
of <%= (parameter.items['type']) %>s
|
53
|
+
<% end %>
|
54
|
+
<% end %>
|
55
|
+
</em>
|
56
|
+
|
57
|
+
<% if parameter.required and parameter.type %>|<% end %>
|
58
|
+
<% if parameter.required %>
|
59
|
+
<span class="constraint">Required</span>
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
<% if parameter.minimum || parameter.raw['minLength'] %>
|
63
|
+
| <span class="constraint">Min:</span> <%= parameter.minimum || parameter.raw['minLength'] %>
|
64
|
+
<% end %>
|
65
|
+
<% if parameter.maximum || parameter.raw['maxLength'] %>
|
66
|
+
| <span class="constraint">Max:</span> <%= parameter.maximum || parameter.raw['maxLength'] %>
|
67
|
+
<% end %>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<%= (parameter.description || parameter.schema['description'] || '').render_markdown %>
|
71
|
+
|
72
|
+
<% if parameter.enum %>
|
73
|
+
<small class="Vlt-grey-dark">
|
74
|
+
<%= (callback || model) ? "One of:" : "Must be one of:" %>
|
75
|
+
<%= parameter_values(parameter.enum) %>
|
76
|
+
</small>
|
77
|
+
<% end %>
|
78
|
+
|
79
|
+
|
80
|
+
</div>
|
81
|
+
|
82
|
+
<% if parameter.array? && parameter.items && parameter.items['oneOf'] %>
|
83
|
+
|
84
|
+
<%
|
85
|
+
# Handle specific case - an array that contains a oneOf
|
86
|
+
params = parameter.items['oneOf'].map do |p|
|
87
|
+
p['format'] = parameter.format
|
88
|
+
OasParser::Parameter.new(self, p)
|
89
|
+
end
|
90
|
+
|
91
|
+
%>
|
92
|
+
<div class="oas-parameter-nested">
|
93
|
+
<%= erb :'open_api/_tabbed_single_parameter', locals: { parent: "#{parameter.name}[]", parameters: params, format: format, callback: callback } %>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<% end %>
|
97
|
+
|
98
|
+
<% if parameter.array? && parameter.items && !parameter.items['oneOf'] %>
|
99
|
+
<%
|
100
|
+
# mheap: We only want to recurse if there are example properties in the array definition
|
101
|
+
if parameter.items['type'] && parameter.items['type'] == 'object' && parameter.items['properties']
|
102
|
+
%>
|
103
|
+
<div class="oas-parameter-nested">
|
104
|
+
<%= erb :'open_api/_parameters', locals: { parent: "#{parent}#{parameter.name}[]", parameters: parameter.properties, model: model, format: format, callback: callback } %>
|
105
|
+
</div>
|
106
|
+
<% end %>
|
107
|
+
<% end %>
|
108
|
+
<% if parameter.properties && parameter.object? && parameter.properties.size.positive? %>
|
109
|
+
<div class="oas-parameter-nested">
|
110
|
+
<%= erb :'open_api/_parameters', locals: { parent: "#{parent}#{parameter.name}", parameters: parameter.properties, model: model, format: format, callback: callback } %>
|
111
|
+
</div>
|
112
|
+
<% end %>
|
113
|
+
</div>
|
114
|
+
<% end %>
|
115
|
+
|
@@ -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} » #{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} » #{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
|
+
|
@@ -0,0 +1,130 @@
|
|
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
|
+
<% parentField = parentField ? "#{parentField}." : '' %>
|
17
|
+
<% schema['properties'].each do |key, parameter| %>
|
18
|
+
<%
|
19
|
+
next if key == '_links'
|
20
|
+
next if parameter['x-skip-response-description']
|
21
|
+
parent = "#{endpoint.method}_#{endpoint.path.path.gsub("/", "_")[1..-1]}" unless parent
|
22
|
+
responseFieldId = parent + "_" + key
|
23
|
+
%>
|
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>
|
28
|
+
<% else %>
|
29
|
+
<div class="Vlt-tooltip Vlt-tooltip--top" title="<%= parentField %><%= key %>">
|
30
|
+
<b><%= key %></b>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
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'] %>
|
48
|
+
<small class="Vlt-grey-dark">
|
49
|
+
One of:
|
50
|
+
<%= parameter_values(parameter['enum']) %>
|
51
|
+
</small>
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
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
|
+
<%
|
62
|
+
|
63
|
+
if parameter['items']['oneOf']
|
64
|
+
qualifier = 'one'
|
65
|
+
lookupKey = 'oneOf'
|
66
|
+
else
|
67
|
+
qualifier = 'any'
|
68
|
+
lookupKey = 'anyOf'
|
69
|
+
end
|
70
|
+
|
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')
|
75
|
+
end
|
76
|
+
item
|
77
|
+
end
|
78
|
+
%>
|
79
|
+
<% else %>
|
80
|
+
<% parameter['properties'] = parameter['items']['properties'] %>
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
83
|
+
|
84
|
+
<%
|
85
|
+
schemas = [parameter]
|
86
|
+
%>
|
87
|
+
|
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:
|
95
|
+
</div>
|
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 %>
|
105
|
+
>
|
106
|
+
<%= schema['description'] %>
|
107
|
+
</div>
|
108
|
+
<% end %>
|
109
|
+
</div>
|
110
|
+
<div class="Vlt-tabs__content">
|
111
|
+
<% end %>
|
112
|
+
|
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}" } %>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
<% end %>
|
120
|
+
|
121
|
+
<% if needs_tabs %>
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
<% end %>
|
125
|
+
<% end %>
|
126
|
+
</div>
|
127
|
+
<% end %>
|
128
|
+
<% end %>
|
129
|
+
|
130
|
+
|