nexmo-oas-renderer 0.11.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +135 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +91 -71
- data/README.md +8 -0
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/lib/nexmo/oas/engine.rb +2 -0
- data/lib/nexmo/oas/renderer.rb +5 -5
- data/lib/nexmo/oas/renderer/app.rb +71 -46
- data/lib/nexmo/oas/renderer/config.ru +4 -2
- data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +18 -18
- data/lib/nexmo/oas/renderer/helpers/navigation.rb +2 -2
- data/lib/nexmo/oas/renderer/helpers/render.rb +2 -1
- data/lib/nexmo/oas/renderer/helpers/summary.rb +4 -1
- data/lib/nexmo/oas/renderer/helpers/url.rb +2 -0
- data/lib/nexmo/oas/renderer/presenters/api_specification.rb +12 -3
- data/lib/nexmo/oas/renderer/presenters/endpoint.rb +2 -0
- data/lib/nexmo/oas/renderer/presenters/groups.rb +4 -0
- data/lib/nexmo/oas/renderer/presenters/navigation.rb +2 -0
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +5 -2
- data/lib/nexmo/oas/renderer/presenters/request_body_raw.rb +141 -0
- data/lib/nexmo/oas/renderer/presenters/response_format.rb +4 -2
- data/lib/nexmo/oas/renderer/presenters/response_tab/link.rb +3 -0
- data/lib/nexmo/oas/renderer/presenters/response_tab/panel.rb +8 -5
- data/lib/nexmo/oas/renderer/presenters/response_tabs.rb +6 -2
- data/lib/nexmo/oas/renderer/presenters/versions.rb +11 -10
- data/lib/nexmo/oas/renderer/public/assets/javascripts/components/format.js +12 -7
- data/lib/nexmo/oas/renderer/public/assets/javascripts/nexmo-oas-renderer.js +61 -27
- data/lib/nexmo/oas/renderer/public/assets/javascripts/popper.min.js +5 -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 +301 -243
- 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 +255 -823
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo-oas-renderer.css.map +2 -2
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +287 -90
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +2 -6
- 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/volta-prism.min.css +1 -1
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta.min.css +1 -1
- data/lib/nexmo/oas/renderer/services/oas_parser.rb +2 -0
- data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +3 -1
- data/lib/nexmo/oas/renderer/version.rb +3 -1
- data/lib/nexmo/oas/renderer/views/layouts/_head.erb +1 -0
- data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +5 -4
- data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +3 -1
- 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_endpoint.erb +18 -27
- data/lib/nexmo/oas/renderer/views/open_api/_callbacks.erb +5 -0
- data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +39 -124
- data/lib/nexmo/oas/renderer/views/open_api/_header.erb +71 -0
- data/lib/nexmo/oas/renderer/views/open_api/_model.erb +31 -26
- data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +54 -78
- data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +2 -5
- data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +98 -153
- 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 +88 -90
- data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +32 -12
- data/lib/nexmo/oas/renderer/views/open_api/_response_fields.erb +1 -16
- data/lib/nexmo/oas/renderer/views/open_api/_response_tabs.erb +2 -2
- data/lib/nexmo/oas/renderer/views/open_api/_responses.erb +50 -0
- data/lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb +15 -4
- 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 +10 -115
- data/nexmo-oas-renderer.gemspec +26 -26
- metadata +61 -49
- data/lib/nexmo/oas/renderer/public/assets/javascripts/components/scroll.js +0 -21
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +0 -137
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/navigation.scss +0 -102
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/nexmo.scss +0 -61
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/syntax.scss +0 -63
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/typography.scss +0 -248
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/volta-templates.scss +0 -119
@@ -0,0 +1,71 @@
|
|
1
|
+
<div class="Vlt-grid">
|
2
|
+
<div class="Vlt-col oas-left-panel header-row" style="padding-top:20px;">
|
3
|
+
<a href="<%= @theme_link %>" class="Vlt-switch Vlt-switch--secondary" style="float:right;">
|
4
|
+
<span class="Vlt-switch__slider"></span>
|
5
|
+
</a>
|
6
|
+
|
7
|
+
|
8
|
+
<div class="Nxd-api__title">
|
9
|
+
<h1>
|
10
|
+
<%= definition.info['title'] %>
|
11
|
+
</h1>
|
12
|
+
<% if definition.info['x-label'] %>
|
13
|
+
<div>
|
14
|
+
<span class="Vlt-badge Vlt-badge--<%= definition.info['x-label'].parameterize %>">
|
15
|
+
<%= definition.info['x-label'] %>
|
16
|
+
</span>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<% if definition.info['description'] %>
|
22
|
+
<p><%= definition.info['description'].render_markdown %></p>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<div class="Vlt-grid">
|
26
|
+
<div class="Vlt-col">
|
27
|
+
<a href=<%= url("#{request.path}.#{definition.format}") %> class='Vlt-btn Vlt-btn--secondary Vlt-btn--app'>
|
28
|
+
<svg><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-download" /></svg>
|
29
|
+
Download OAS 3 Definition
|
30
|
+
</a>
|
31
|
+
</div>
|
32
|
+
<div class="Vlt-col Vlt-right Vlt-right-sm">
|
33
|
+
<a href="<%= Nexmo::OAS::Renderer::API.github_path %>/<%= @specification.definition_name %>.yml" class='Vlt-btn Vlt-btn--tertiary Vlt-btn--app Vlt-right Vlt-bg-grey-lighter'>
|
34
|
+
<svg className="Vlt-icon Vlt-black">
|
35
|
+
<use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-github" />
|
36
|
+
</svg>
|
37
|
+
Improve this specification
|
38
|
+
</a>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<%
|
43
|
+
# If there's only one group, everything is untagged
|
44
|
+
if @specification.groups.size === 1
|
45
|
+
%>
|
46
|
+
<%= erb :'open_api/_available_endpoints', locals: { endpoints: definition.endpoints } %>
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<%
|
52
|
+
has_switcher = @specification.available_versions && @specification.available_versions.count > 1
|
53
|
+
%>
|
54
|
+
|
55
|
+
<div class="oas-right-panel Vlt-col <%= has_switcher ? '' : 'sm-hidden' %>">
|
56
|
+
|
57
|
+
<% if has_switcher %>
|
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>
|
@@ -1,31 +1,35 @@
|
|
1
|
-
<div class="Vlt-grid
|
2
|
-
<div class="Vlt-col
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
properties =
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
<div class="Vlt-grid">
|
2
|
+
<div class="Vlt-col oas-left-panel">
|
3
|
+
|
4
|
+
<h2 id="<%= group['name'].parameterize %>" class='Vlt-grey-dark group-header'><%= group['name'] %></h2>
|
5
|
+
<p class="Vlt-grey-darker"><%= group['description']&.render_markdown %></p>
|
6
|
+
|
7
|
+
|
8
|
+
<%= erb :'open_api/_available_endpoints', locals: { endpoints: endpoints } %>
|
9
|
+
|
10
|
+
<% if group['schema'] %>
|
11
|
+
<% group['schema'].each do |format, schema| %>
|
12
|
+
<div class="js-format" data-format="<%= format %>">
|
13
|
+
<%
|
14
|
+
if schema['properties']
|
15
|
+
properties = schema['properties']
|
16
|
+
elsif schema['allOf']
|
17
|
+
properties = schema['allOf'].map { |o| o['properties'] }.reduce(&:merge)
|
18
|
+
end
|
19
|
+
|
20
|
+
properties = properties.map do |name, definition|
|
21
|
+
OasParser::Property.new(self, schema, name, definition)
|
22
|
+
end
|
23
|
+
%>
|
24
|
+
|
25
|
+
<%= erb :'open_api/_parameters', locals: { parameters: properties, model: true, format: format } %>
|
26
|
+
</div>
|
25
27
|
<% end %>
|
26
|
-
|
28
|
+
<% end %>
|
27
29
|
</div>
|
28
|
-
|
30
|
+
|
31
|
+
<div class="Vlt-col oas-right-panel <%= !group['schema'] ? 'sm-hidden' : '' %>">
|
32
|
+
|
29
33
|
<% if group['schema'] %>
|
30
34
|
<% group['schema'].each do |format, schema| %>
|
31
35
|
<div class="js-format" data-format="<%= format %>">
|
@@ -34,5 +38,6 @@
|
|
34
38
|
</div>
|
35
39
|
<% end %>
|
36
40
|
<% end %>
|
41
|
+
|
37
42
|
</div>
|
38
43
|
</div>
|
@@ -1,92 +1,68 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
<
|
4
|
-
|
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>
|
1
|
+
<header class="oas-navbar oas-navbar-full">
|
2
|
+
<% if @specification.groups.size == 1 %>
|
3
|
+
<a href="#top" class="Vlt-btn Vlt-btn--tertiary group-link">Available Operations</a>
|
4
|
+
<% end %>
|
10
5
|
|
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
6
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<svg class="Vlt-grey-darker"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-code" /></svg>
|
7
|
+
<% @specification.groups.each do |name, endpoints| %>
|
8
|
+
<% next unless name %>
|
9
|
+
<a href="#<%= name.parameterize %>" class="Vlt-btn Vlt-btn--tertiary group-link"><%= name %></a>
|
10
|
+
<% end %>
|
27
11
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
<span class="Vlt-badge Vlt-badge--margin-left Nxd-method-badge Nxd-method-badge--<%= endpoint.method %> Vlt-white Vlt-badge--small"><%= endpoint.method %></span>
|
32
|
-
</a>
|
33
|
-
</li>
|
12
|
+
<% if @specification.definition.raw['x-webhooks'] || definition.webhooks.size.positive? %>
|
13
|
+
<a href="#webhooks" class="Vlt-btn Vlt-btn--tertiary group-link">Webhooks</a>
|
14
|
+
<% end %>
|
34
15
|
|
35
|
-
<% if endpoint.callbacks.any? %>
|
36
|
-
<% endpoint.callbacks.each do |callback| %>
|
37
|
-
<% callback.paths.each do |path| %>
|
38
|
-
<% path.endpoints.each do |endpoint| %>
|
39
|
-
<li class="Nxd-menu__indent">
|
40
|
-
<a href="#<%= endpoint.operationId %>" class="Vlt-sidemenu__link">
|
41
|
-
<svg class="Vlt-grey-darker"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-toggle" /></svg>
|
42
|
-
<span class="Vlt-sidemenu__label"><%= endpoint.summary %></span>
|
43
|
-
</a>
|
44
|
-
</li>
|
45
|
-
<% end %>
|
46
|
-
<% end %>
|
47
|
-
<% end %>
|
48
|
-
<% end %>
|
49
|
-
<% end %>
|
50
16
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<span class="Vlt-sidemenu__label"><%= endpoint.summary %></span>
|
57
|
-
</a>
|
58
|
-
</li>
|
59
|
-
<% end %>
|
17
|
+
<% if @specification.formats.size > 1 %>
|
18
|
+
<div class="Vlt-native-dropdown">
|
19
|
+
<select class="js-format-selector">
|
20
|
+
<% @specification.formats.each do |value, name| %>
|
21
|
+
<option value="<%= value %>"><%= name %> Responses</option>
|
60
22
|
<% end %>
|
23
|
+
</select>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</header>
|
61
27
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
<svg class="Vlt-grey-darker"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-mind-map" /></svg>
|
71
|
-
<span class="Vlt-sidemenu__label"><%= endpoint.summary %></span>
|
72
|
-
</a>
|
73
|
-
</li>
|
74
|
-
<% end %>
|
28
|
+
<header class="oas-navbar oas-navbar-small">
|
29
|
+
<div id="oas-nav-accordion" style="width: 100%;">
|
30
|
+
<span role="link" class="oas-trigger">
|
31
|
+
<% if @specification.formats.size > 1 %>
|
32
|
+
<div class="Vlt-native-dropdown">
|
33
|
+
<select class="js-format-selector">
|
34
|
+
<% @specification.formats.each do |value, name| %>
|
35
|
+
<option value="<%= value %>"><%= name %> Responses</option>
|
75
36
|
<% end %>
|
76
|
-
|
77
|
-
|
37
|
+
</select>
|
38
|
+
</div>
|
39
|
+
<% end %>
|
40
|
+
</span>
|
78
41
|
|
79
|
-
|
80
|
-
|
42
|
+
<div class="oas-trigger-content">
|
43
|
+
<% if @specification.groups.size == 1 %>
|
44
|
+
<a href="#top" class="Vlt-btn Vlt-btn--tertiary group-link">Available Operations</a>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<br />
|
48
|
+
<br />
|
49
|
+
|
50
|
+
<% has_webhooks = @specification.definition.raw['x-webhooks'] || definition.webhooks.size.positive? %>
|
51
|
+
<% if @specification.groups.size > 1 || has_webhooks %>
|
52
|
+
<h4>Endpoints</h4>
|
53
|
+
|
54
|
+
<% @specification.groups.each do |name, endpoints| %>
|
55
|
+
<% next unless name %>
|
56
|
+
<a href="#<%= name.parameterize %>" class="Vlt-btn Vlt-btn--tertiary group-link"><%= name %></a>
|
81
57
|
<% end %>
|
82
58
|
<% end %>
|
83
59
|
|
84
|
-
<% if
|
85
|
-
<
|
86
|
-
<a class="Vlt-sidemenu__link" href="#errors">Errors</a>
|
87
|
-
</li>
|
60
|
+
<% if has_webhooks %>
|
61
|
+
<a href="#webhooks" class="Vlt-btn Vlt-btn--tertiary group-link">Webhooks</a>
|
88
62
|
<% end %>
|
89
|
-
|
90
|
-
</
|
63
|
+
|
64
|
+
</div>
|
91
65
|
</div>
|
92
|
-
</
|
66
|
+
</header>
|
67
|
+
|
68
|
+
<span id="top"></span>
|
@@ -33,17 +33,14 @@
|
|
33
33
|
# We probably want real allOf support in OasParser, but that's more time than I have right now
|
34
34
|
allOf = endpoint.request_body.content[format]['schema']['allOf']
|
35
35
|
if allOf
|
36
|
-
params =
|
37
|
-
params = params['properties'].map do |name, definition|
|
38
|
-
OasParser::Property.new(nil, params, name, definition)
|
39
|
-
end
|
36
|
+
params = endpoint.request_body.handle_all_of(allOf)
|
40
37
|
else
|
41
38
|
params = endpoint.request_body.properties_for_format(format)
|
42
39
|
end
|
43
40
|
if params
|
44
41
|
%>
|
45
42
|
|
46
|
-
<%= erb :'open_api/_parameters', locals: { parameters: params, callback: callback } %>
|
43
|
+
<%= erb :'open_api/_parameters', locals: { endpoint:endpoint, parameters: params, callback: callback } %>
|
47
44
|
<% end %>
|
48
45
|
<% else %>
|
49
46
|
|
@@ -2,169 +2,114 @@
|
|
2
2
|
model = false if model.nil?
|
3
3
|
callback = false if callback.nil?
|
4
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)
|
5
13
|
%>
|
6
14
|
|
7
|
-
|
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.formats.any? %>
|
32
|
-
<% if @specification.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.schema['description'] || '<i>None</i>').render_markdown %>
|
79
|
-
<% end %>
|
80
|
-
<% else %>
|
81
|
-
<%= (parameter.description || parameter.schema['description'] || '<i>None</i>').render_markdown %>
|
82
|
-
<% end %>
|
15
|
+
<% parameters.each do |parameter| %>
|
83
16
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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 %>
|
91
26
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
</small>
|
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>
|
98
32
|
<% end %>
|
99
33
|
|
100
|
-
<% if parameter.
|
101
|
-
<
|
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>
|
34
|
+
<% if parameter.is_xml_text? %>
|
35
|
+
| <span class="xml-flag">Value</span>
|
125
36
|
<% end %>
|
126
|
-
|
37
|
+
</span>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
<div class="oas-parameter-description">
|
127
42
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
<% unless parameter.type == 'object' %>
|
134
|
-
<%= (parameter.default.nil? ? '<i>None</i>' : "<code>#{parameter.default}</code>")%>
|
135
|
-
<% end %>
|
136
|
-
<% end %>
|
137
|
-
</td>
|
43
|
+
<div class="oas-parameter-meta">
|
44
|
+
<em>
|
45
|
+
<%= parameter.type %>
|
46
|
+
<% if parameter.format %>
|
47
|
+
(<%= parameter.format %>)
|
138
48
|
<% end %>
|
139
49
|
|
140
|
-
<%
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
%>
|
145
|
-
<% if parameter.collection? && should_render_row %>
|
146
|
-
|
147
|
-
<tr class="Vlt-table__row--nohighlight">
|
148
|
-
<td colspan="4">
|
149
|
-
<% if parameter.subproperties_are_one_of_many? %>
|
150
|
-
<div style="margin-left: 20px;">
|
151
|
-
<h4>Any one of the following:</h4>
|
152
|
-
<% parameter.properties.each do |property| %>
|
153
|
-
<h5><%= property['description'] %></h5>
|
154
|
-
<%= erb :'open_api/_parameters', locals: { parameters: property['properties'], model: model, format: format, callback: callback } %>
|
155
|
-
<% end %>
|
156
|
-
</div>
|
157
|
-
<% else %>
|
158
|
-
<% if parameter.properties && parameter.object? && parameter.properties.size.positive? %>
|
159
|
-
<%= erb :'open_api/_parameters', locals: { parameters: parameter.properties, model: model, format: format, callback: callback } %>
|
160
|
-
<% end %>
|
161
|
-
<% end %>
|
162
|
-
</td>
|
163
|
-
</tr>
|
50
|
+
<% if parameter.array? %>
|
51
|
+
<% if parameter.items && parameter.items['type'] %>
|
52
|
+
of <%= (parameter.items['type']) %>s
|
53
|
+
<% end %>
|
164
54
|
<% end %>
|
55
|
+
</em>
|
56
|
+
|
57
|
+
<% if parameter.required and parameter.type %>|<% end %>
|
58
|
+
<% if parameter.required %>
|
59
|
+
<span class="constraint">Required</span>
|
165
60
|
<% end %>
|
166
|
-
|
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>
|
167
106
|
<% end %>
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
+
|