nexmo-oas-renderer 0.11.2 → 2.1.1
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/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 -169
- 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 +51 -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 +59 -48
- 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,185 +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
|
-
<% next if parameter.name == "_links" %>
|
24
|
-
<tr class="<% if parameter.collection? %> Vlt-table__row--noline <% end %>">
|
25
|
-
<td class="Vlt-table__cell--nowrap">
|
26
|
-
<b><%= parameter.name %></b><br>
|
27
|
-
<small>
|
28
|
-
<% if parameter.required %>
|
29
|
-
<span class="flag flag--strong">Required</span>
|
30
|
-
<% end %>
|
31
|
-
|
32
|
-
<% if @specification.formats.any? %>
|
33
|
-
<% if @specification.formats.include?('text/xml') %>
|
34
|
-
<span class="js-format" data-format="text/xml">
|
35
|
-
<% if parameter.is_xml_attribute? %>
|
36
|
-
| <span class="flag">Attribute</span>
|
37
|
-
<% end %>
|
38
|
-
|
39
|
-
<% if parameter.is_xml_text? %>
|
40
|
-
| <span class="flag">Value</span>
|
41
|
-
<% end %>
|
42
|
-
</span>
|
43
|
-
<% end %>
|
44
|
-
<% end %>
|
45
|
-
|
46
|
-
<i>
|
47
|
-
<% if parameter.required and parameter.type %>|<% end %> <%= parameter.type %>
|
48
|
-
<% if parameter.format %>
|
49
|
-
| (<%= parameter.format %>)
|
50
|
-
<% end %>
|
51
|
-
<% if parameter.array? %>
|
52
|
-
<br>
|
53
|
-
<% if parameter.items && parameter.items['type'] %>
|
54
|
-
of <%= (parameter.items['type']) %>s
|
55
|
-
<% end %>
|
56
|
-
<% end %>
|
57
|
-
</i>
|
58
|
-
</small>
|
59
|
-
</td>
|
60
|
-
|
61
|
-
<%
|
62
|
-
# If it's a oneOf we show a list rather than description/example/default
|
63
|
-
if parameter.oneOf?
|
64
|
-
%>
|
65
|
-
<td colspan="3">
|
66
|
-
<h4>Any one of the following:</h4>
|
67
|
-
<% parameter.properties.each do |property| %>
|
68
|
-
<h5><%= property['description'] %></h5>
|
69
|
-
<%= erb :'open_api/_parameters', locals: { parameters: property['properties'], model: model, format: format, callback: callback } %>
|
70
|
-
<% end %>
|
71
|
-
</td>
|
72
|
-
<%
|
73
|
-
# Otherwise we show the remaining 3 columns
|
74
|
-
else
|
75
|
-
%>
|
76
|
-
<td>
|
77
|
-
<% if parameter.collection? || parameter.oneOf? %>
|
78
|
-
<% if parameter.raw['x-nexmo-developer-collection-description-shown'] %>
|
79
|
-
<%= (parameter.description || parameter.schema['description'] || '<i>None</i>').render_markdown %>
|
80
|
-
<% end %>
|
81
|
-
<% else %>
|
82
|
-
<%= (parameter.description || parameter.schema['description'] || '<i>None</i>').render_markdown %>
|
83
|
-
<% end %>
|
15
|
+
<% parameters.each do |parameter| %>
|
84
16
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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 %>
|
92
26
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
</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>
|
99
32
|
<% end %>
|
100
33
|
|
101
|
-
<% if parameter.
|
102
|
-
<
|
103
|
-
<small class="Vlt-grey-dark">
|
104
|
-
<% if parameter.minimum && parameter.maximum %>
|
105
|
-
Must be between <%= "<code>#{parameter.minimum}</code>"%> and <%= "<code>#{parameter.maximum}</code>"%>
|
106
|
-
<% elsif parameter.minimum %>
|
107
|
-
Must be at least <%= "<code>#{parameter.minimum}</code>"%>
|
108
|
-
<% else %>
|
109
|
-
Must be at most <%= "<code>#{parameter.maximum}</code>"%>
|
110
|
-
<% end %>
|
111
|
-
</small>
|
112
|
-
<% end %>
|
113
|
-
</td>
|
114
|
-
|
115
|
-
<% unless model %>
|
116
|
-
<% if parameter.collection? || parameter.oneOf? %>
|
117
|
-
<% if parameter.raw['x-nexmo-developer-collection-description-shown'] %>
|
118
|
-
<td>
|
119
|
-
<%= (parameter.example ? "<code><pre>#{parameter.example}</pre></code>" : '')%>
|
120
|
-
</td>
|
121
|
-
<% end %>
|
122
|
-
<% else %>
|
123
|
-
<td>
|
124
|
-
<%= (parameter.example ? "<code>#{parameter.example.to_s.gsub("\n", "<br />")}</code>" : '<i>None</i>')%>
|
125
|
-
</td>
|
34
|
+
<% if parameter.is_xml_text? %>
|
35
|
+
| <span class="xml-flag">Value</span>
|
126
36
|
<% end %>
|
127
|
-
|
37
|
+
</span>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
<div class="oas-parameter-description">
|
128
42
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
<% unless parameter.type == 'object' %>
|
135
|
-
<%= (parameter.default.nil? ? '<i>None</i>' : "<code>#{parameter.default}</code>")%>
|
136
|
-
<% end %>
|
137
|
-
<% end %>
|
138
|
-
</td>
|
43
|
+
<div class="oas-parameter-meta">
|
44
|
+
<em>
|
45
|
+
<%= parameter.type %>
|
46
|
+
<% if parameter.format %>
|
47
|
+
(<%= parameter.format %>)
|
139
48
|
<% end %>
|
140
49
|
|
141
|
-
<%
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
should_render_row = should_render_row || (parameter.array? && parameter.items['properties'])
|
146
|
-
%>
|
147
|
-
<% if parameter.collection? && should_render_row %>
|
148
|
-
|
149
|
-
<tr class="Vlt-table__row--nohighlight">
|
150
|
-
<td colspan="4">
|
151
|
-
<% if parameter.subproperties_are_one_of_many? %>
|
152
|
-
<div style="margin-left: 20px;">
|
153
|
-
<h4>Any one of the following:</h4>
|
154
|
-
<% parameter.properties.each do |property| %>
|
155
|
-
<h5><%= property['description'] %></h5>
|
156
|
-
<%= erb :'open_api/_parameters', locals: { parameters: property['properties'], model: model, format: format, callback: callback } %>
|
157
|
-
<% end %>
|
158
|
-
</div>
|
159
|
-
<% else %>
|
160
|
-
<% if parameter.properties && parameter.object? && parameter.properties.size.positive? %>
|
161
|
-
<%= erb :'open_api/_parameters', locals: { parameters: parameter.properties, model: model, format: format, callback: callback } %>
|
162
|
-
<% end %>
|
163
|
-
<% if parameter.array?
|
164
|
-
items = parameter.items
|
165
|
-
# Merge allOf entries
|
166
|
-
if items['allOf']
|
167
|
-
items = items['allOf'].reduce { |a,b| a.deep_merge(b) }
|
168
|
-
end
|
169
|
-
# Cast back to properties
|
170
|
-
next unless items['properties']
|
171
|
-
items['properties'] = items['properties'].map do |name, definition|
|
172
|
-
OasParser::Property.new(nil, items, name, definition)
|
173
|
-
end
|
174
|
-
%>
|
175
|
-
<%= erb :'open_api/_parameters', locals: { parameters: items['properties'], model: model, format: format, callback: callback } %>
|
176
|
-
<% end %>
|
177
|
-
<% end %>
|
178
|
-
</td>
|
179
|
-
</tr>
|
50
|
+
<% if parameter.array? %>
|
51
|
+
<% if parameter.items && parameter.items['type'] %>
|
52
|
+
of <%= (parameter.items['type']) %>s
|
53
|
+
<% end %>
|
180
54
|
<% end %>
|
55
|
+
</em>
|
56
|
+
|
57
|
+
<% if parameter.required and parameter.type %>|<% end %>
|
58
|
+
<% if parameter.required %>
|
59
|
+
<span class="constraint">Required</span>
|
181
60
|
<% end %>
|
182
|
-
|
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>
|
183
106
|
<% end %>
|
184
|
-
|
185
|
-
|
186
|
-
|
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
|
+
|