nexmo-oas-renderer 0.1.0
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/.gitignore +5 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +183 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -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 +9 -0
- data/lib/nexmo/oas/renderer.rb +13 -0
- data/lib/nexmo/oas/renderer/app.rb +116 -0
- data/lib/nexmo/oas/renderer/config.ru +7 -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/config/redirects.yml +8 -0
- data/lib/nexmo/oas/renderer/constraints/open_api.rb +76 -0
- data/lib/nexmo/oas/renderer/constraints/redirector.rb +17 -0
- data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +55 -0
- data/lib/nexmo/oas/renderer/filters/anchor.rb +17 -0
- data/lib/nexmo/oas/renderer/filters/audio.rb +21 -0
- data/lib/nexmo/oas/renderer/filters/block_escape.rb +24 -0
- data/lib/nexmo/oas/renderer/filters/break.rb +13 -0
- data/lib/nexmo/oas/renderer/filters/code.rb +64 -0
- data/lib/nexmo/oas/renderer/filters/code_snippet.rb +194 -0
- data/lib/nexmo/oas/renderer/filters/code_snippet_list.rb +33 -0
- data/lib/nexmo/oas/renderer/filters/code_snippets.rb +158 -0
- data/lib/nexmo/oas/renderer/filters/collapsible.rb +27 -0
- data/lib/nexmo/oas/renderer/filters/columns.rb +50 -0
- data/lib/nexmo/oas/renderer/filters/concept_list.rb +33 -0
- data/lib/nexmo/oas/renderer/filters/dynamic_content.rb +30 -0
- data/lib/nexmo/oas/renderer/filters/external_link.rb +32 -0
- data/lib/nexmo/oas/renderer/filters/frontmatter.rb +14 -0
- data/lib/nexmo/oas/renderer/filters/heading.rb +61 -0
- data/lib/nexmo/oas/renderer/filters/icon.rb +22 -0
- data/lib/nexmo/oas/renderer/filters/indent.rb +20 -0
- data/lib/nexmo/oas/renderer/filters/inline_escape.rb +17 -0
- data/lib/nexmo/oas/renderer/filters/js_sequence_diagram.rb +21 -0
- data/lib/nexmo/oas/renderer/filters/label.rb +32 -0
- data/lib/nexmo/oas/renderer/filters/language.rb +15 -0
- data/lib/nexmo/oas/renderer/filters/markdown.rb +85 -0
- data/lib/nexmo/oas/renderer/filters/modal.rb +41 -0
- data/lib/nexmo/oas/renderer/filters/partial.rb +28 -0
- data/lib/nexmo/oas/renderer/filters/php_inliner.rb +15 -0
- data/lib/nexmo/oas/renderer/filters/screenshot.rb +26 -0
- data/lib/nexmo/oas/renderer/filters/tab.rb +250 -0
- data/lib/nexmo/oas/renderer/filters/techio.rb +24 -0
- data/lib/nexmo/oas/renderer/filters/tooltip.rb +22 -0
- data/lib/nexmo/oas/renderer/filters/tutorial_link.rb +27 -0
- data/lib/nexmo/oas/renderer/filters/tutorials.rb +28 -0
- data/lib/nexmo/oas/renderer/filters/unfreeze.rb +20 -0
- data/lib/nexmo/oas/renderer/filters/user_personalization.rb +43 -0
- data/lib/nexmo/oas/renderer/helpers/navigation.rb +66 -0
- data/lib/nexmo/oas/renderer/helpers/render.rb +24 -0
- data/lib/nexmo/oas/renderer/helpers/summary.rb +30 -0
- data/lib/nexmo/oas/renderer/helpers/url.rb +17 -0
- data/lib/nexmo/oas/renderer/lib/core_ext/string.rb +14 -0
- data/lib/nexmo/oas/renderer/lib/redcarpet.rb +14 -0
- data/lib/nexmo/oas/renderer/models/code_snippet.rb +75 -0
- data/lib/nexmo/oas/renderer/models/tutorial.rb +83 -0
- data/lib/nexmo/oas/renderer/pipelines/markdown_pipeline.rb +52 -0
- data/lib/nexmo/oas/renderer/presenters/api_specification.rb +42 -0
- data/lib/nexmo/oas/renderer/presenters/groups.rb +35 -0
- data/lib/nexmo/oas/renderer/presenters/navigation.rb +24 -0
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +68 -0
- data/lib/nexmo/oas/renderer/presenters/versions.rb +40 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff2 +0 -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 +42 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.accordion.js +249 -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 +139 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/api.css +95 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/buttons.css +80 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/core.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/navigation.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo.css +68 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +147 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +133 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/mediaqueries.scss +48 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/navigation.scss +106 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/nexmo.scss +61 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +10 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/syntax.scss +63 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/typography.scss +248 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/variables.scss +91 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/volta-templates.scss +119 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/syntax.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/typography.css +86 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css.map +7 -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/services/code_language_api.rb +98 -0
- data/lib/nexmo/oas/renderer/services/oas_parser.rb +21 -0
- data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +33 -0
- data/lib/nexmo/oas/renderer/version.rb +7 -0
- data/lib/nexmo/oas/renderer/views/api/show.erb +1 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_messages_dispatch.html.erb +9 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_rtc.html.erb +41 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_voice.html.erb +24 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_code_only.html.erb +6 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_configure_client.html.erb +20 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_dependencies.html.erb +11 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_write_code.html.erb +13 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/list/plain.html.erb +10 -0
- data/lib/nexmo/oas/renderer/views/concepts/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/layouts/_head.erb +4 -0
- data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +9 -0
- data/lib/nexmo/oas/renderer/views/layouts/api.erb +23 -0
- data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +10 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback.erb +5 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback_endpoint.erb +48 -0
- data/lib/nexmo/oas/renderer/views/open_api/_code_examples.erb +16 -0
- data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +156 -0
- data/lib/nexmo/oas/renderer/views/open_api/_model.erb +38 -0
- data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +80 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +50 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +165 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +61 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +41 -0
- data/lib/nexmo/oas/renderer/views/open_api/show.erb +104 -0
- data/lib/nexmo/oas/renderer/views/static/404.erb +6 -0
- data/lib/nexmo/oas/renderer/views/tutorials/_index.html.erb +32 -0
- data/lib/nexmo/oas/renderer/views/tutorials/index.html.erb +7 -0
- data/lib/nexmo/oas/renderer/views/tutorials/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/tutorials/show.html.erb +8 -0
- data/nexmo-oas-renderer.gemspec +49 -0
- metadata +399 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative './oas_parser'
|
2
|
+
|
3
|
+
module Nexmo
|
4
|
+
module OAS
|
5
|
+
module Renderer
|
6
|
+
class OpenApiDefinitionResolver
|
7
|
+
def self.find(name)
|
8
|
+
path = paths(name).detect do |p|
|
9
|
+
break p if File.file? p
|
10
|
+
end
|
11
|
+
|
12
|
+
return resolve(path) if path
|
13
|
+
|
14
|
+
raise "Could not find definition '#{name}' in '#{API.oas_path}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.paths(name)
|
18
|
+
['json', 'yaml', 'yml'].map do |format|
|
19
|
+
path(name, format)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.path(name, format)
|
24
|
+
"#{API.oas_path}/definitions/#{name}.#{format}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.resolve(path)
|
28
|
+
OasParser::Definition.resolve(path)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @specification.content.html_safe %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
+
<h5 class="Vlt-js-accordion__trigger Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
|
+
<%= app['use_existing'] ? 'Use your existing application' : 'Create an application' %>
|
4
|
+
</h5>
|
5
|
+
|
6
|
+
<div id="acc<%=id %>" class="Vlt-js-accordion__content Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
|
+
If you do not have an application you can <a href="/messages/code-snippets/create-an-application">create one</a>. Make sure you also <a href="/messages/code-snippets/configure-webhooks">configure your webhooks</a>.
|
8
|
+
</div>
|
9
|
+
</div>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
+
<h5 class="Vlt-js-accordion__trigger Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
|
+
Create an application
|
4
|
+
</h5>
|
5
|
+
|
6
|
+
<div id="acc<%=id %>" class="Vlt-js-accordion__content Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
|
+
<p>A Nexmo application contains the required configuration for your project. You can create an application
|
8
|
+
using the <a href="https://github.com/Nexmo/nexmo-cli">Nexmo CLI</a> (see below) or <a href="https://dashboard.nexmo.com/voice/create-application">via
|
9
|
+
the dashboard</a>. To learn more about applications <a href="/concepts/guides/applications">see our
|
10
|
+
Nexmo concepts guide</a>.</p>
|
11
|
+
<h4>Install the CLI</h4>
|
12
|
+
<pre class="highlight shell"><code>$ npm install -g nexmo-cli</code></pre>
|
13
|
+
|
14
|
+
<h4>Create an application</h4>
|
15
|
+
<p>Once you have the CLI installed you can use it to create a Nexmo application. Run the following command and
|
16
|
+
make a note of the application ID that it returns. This is the value to use in <code>NEXMO_APPLICATION_ID</code>
|
17
|
+
in the example below. It will also create <code>private.key</code> in the current directory which you will
|
18
|
+
need in the <em>Initialize your dependencies</em> step</p>
|
19
|
+
|
20
|
+
<% unless app['disable_ngrok'] %>
|
21
|
+
<p>Nexmo needs to connect to your local machine to access your <code>answer_url</code>. We recommend using <a
|
22
|
+
href="https://www.nexmo.com/blog/2017/07/04/local-development-nexmo-ngrok-tunnel-dr/">ngrok</a> to do
|
23
|
+
this. Make sure to change <code>demo.ngrok.io</code> in the examples below to your own ngrok URL.</p>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<pre class="highlight shell"><code>$ nexmo app:create "<%=app['name'] %>" <%=app['answer_url'] %> <%=app['event_url'] %> --keyfile=private.key --type=rtc</code></pre>
|
27
|
+
|
28
|
+
<h4>Or to use your existing Nexmo application</h4>
|
29
|
+
|
30
|
+
<p>You will need to use an existing Nexmo application and
|
31
|
+
authenticate a User in order to achieve results here.</p>
|
32
|
+
<p>See the <a href="https://developer.nexmo.com/conversation/overview">Conversation API docs</a>
|
33
|
+
for information
|
34
|
+
on how to create an Application and Users on your backend server.</p>
|
35
|
+
<p>Alternatively you can review the <a href="https://developer.nexmo.com/tutorials/client-sdk-generate-test-credentials">tutorial
|
36
|
+
on getting started with generating an Application and
|
37
|
+
credentials</a>.</p>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
|
41
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
+
<h5 class="Vlt-js-accordion__trigger Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
|
+
<%= app['use_existing'] ? 'Use your existing application' : 'Create an application' %>
|
4
|
+
</h5>
|
5
|
+
|
6
|
+
<div id="acc<%=id %>" class="Vlt-js-accordion__content Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
|
+
<% if app['use_existing'] %>
|
8
|
+
<p><%= app['use_existing'] %></p>
|
9
|
+
<% else %>
|
10
|
+
<p>A Nexmo application contains the required configuration for your project. You can create an application using the <a href="https://github.com/Nexmo/nexmo-cli">Nexmo CLI</a> (see below) or <a href="https://dashboard.nexmo.com/voice/create-application">via the dashboard</a>. To learn more about applications <a href="/concepts/guides/applications">see our Nexmo concepts guide</a>.</p>
|
11
|
+
<h4>Install the CLI</h4>
|
12
|
+
<pre class="highlight bash dependencies"><code>npm install -g nexmo-cli</code></pre>
|
13
|
+
|
14
|
+
<h4>Create an application</h4>
|
15
|
+
<p>Once you have the CLI installed you can use it to create a Nexmo application. Run the following command and make a note of the application ID that it returns. This is the value to use in <code>NEXMO_APPLICATION_ID</code> in the example below. It will also create <code>private.key</code> in the current directory which you will need in the <em>Initialize your dependencies</em> step</p>
|
16
|
+
|
17
|
+
<% unless app['disable_ngrok'] %>
|
18
|
+
<p>Nexmo needs to connect to your local machine to access your <code>answer_url</code>. We recommend using <a href="https://www.nexmo.com/blog/2017/07/04/local-development-nexmo-ngrok-tunnel-dr/">ngrok</a> to do this. Make sure to change <code>demo.ngrok.io</code> in the examples below to your own ngrok URL.</p>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<pre class="highlight bash dependencies"><code>nexmo app:create "<%=app['name'] %>" <%=app['answer_url'] %> <%=app['event_url'] %> --keyfile private.key</code></pre>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="copy-wrapper">
|
2
|
+
<div class="copy-button" data-lang="<%= lang %>" data-block="<%= config['source'] %>" data-section="code">
|
3
|
+
<%= octicon "clippy", :class => 'top left' %> <span>Copy to Clipboard</span>
|
4
|
+
</div>
|
5
|
+
<pre class="highlight <%= lexer.tag %> main-code"><code><%= highlighted_code_source %></code></pre>
|
6
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
+
<h5 class="Vlt-js-accordion__trigger Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
|
+
Initialize your dependencies
|
4
|
+
</h5>
|
5
|
+
|
6
|
+
<div id="acc<%=id %>" class="Vlt-js-accordion__content Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
|
+
<%= create_instructions %>
|
8
|
+
<div class="copy-wrapper">
|
9
|
+
|
10
|
+
<div class="copy-button" data-lang="<%= lang %>" data-block="<%= config['source'] %>" data-section="configure">
|
11
|
+
<%= octicon "clippy", :class => 'top left' %> <span>Copy to Clipboard</span>
|
12
|
+
</div>
|
13
|
+
<pre class="highlight copy-to-clipboard <%= config['title'] %>"><code><%= highlighted_client_source %></code></pre>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<p><a data-section="configure" data-lang="<%= lang %>" data-block="<%= config['source'] %>" href="<%= client_url %>">View full source</a></p>
|
17
|
+
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
+
<h5 class="Vlt-js-accordion__trigger Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0"><%= title %></h5>
|
3
|
+
|
4
|
+
<div id="acc<%= id %>" class="Vlt-js-accordion__content Vlt-accordion__content Vlt-accordion__content--noborder">
|
5
|
+
<p><%=deps['text']%></p>
|
6
|
+
<% if deps['code'] %>
|
7
|
+
<pre class="highlight <%= deps['type'] || 'bash' %> dependencies"><code><%=deps['code']%></code></pre>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h2 class="Vlt-title--margin-top3">Write the code</h2>
|
2
|
+
<%= add_instructions %>
|
3
|
+
|
4
|
+
<div class="copy-wrapper">
|
5
|
+
<div class="copy-button" data-lang="<%= lang %>" data-block="<%= config['source'] %>" data-section="code">
|
6
|
+
<%= octicon "clippy", :class => 'top left' %> <span>Copy to Clipboard</span>
|
7
|
+
</div>
|
8
|
+
<pre class="highlight <%= lexer.tag %> main-code"><code><%= highlighted_code_source %></code></pre>
|
9
|
+
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<p><a data-section="code" data-lang="<%= lang %>" data-block="<%= config['source'] %>" href="<%= source_url %>">View full source</a></p>
|
13
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<ul class="Vlt-list Vlt-list--simple">
|
2
|
+
<% @concepts.each do |concept| %>
|
3
|
+
<li><a href="<%= concept.url %>"><%= concept.title %></a><% if concept.description %>: <%= concept.description.render_markdown.gsub(%r{^<p>},'').gsub(%r{^</p>}, '').strip %><% end %></li>
|
4
|
+
<% end %>
|
5
|
+
</ul>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<script src="/assets/javascripts/volta.core.js"></script>
|
2
|
+
<script src="/assets/javascripts/volta.accordion.js"></script>
|
3
|
+
<script src="/assets/javascripts/volta.tabs.js"></script>
|
4
|
+
<script src="/assets/javascripts/volta.modal.js"></script>
|
5
|
+
<script src="/assets/javascripts/components/format.js"></script>
|
6
|
+
<script type="text/javascript">
|
7
|
+
Volta.init(["accordion", "tab", "modal"]);
|
8
|
+
new Format
|
9
|
+
</script>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<%= erb :'layouts/_head' %>
|
4
|
+
|
5
|
+
<body class="Nxd-template">
|
6
|
+
<nav class="Vlt-sidenav Vlt-sidenav--light" id="Vlt-sidenav">
|
7
|
+
<div class="Vlt-sidenav__scroll">
|
8
|
+
<% begin %>
|
9
|
+
<%= erb :"layouts/#{@specification.side_navigation}" %>
|
10
|
+
<% rescue Errno::ENOENT %>
|
11
|
+
<%= @navigation.navigation_from_content %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
</nav>
|
15
|
+
<main class="Vlt-main Vlt-main--light Nxd-main" tabindex="2">
|
16
|
+
<div class="Vlt-card" id="primary-content">
|
17
|
+
<%= yield %>
|
18
|
+
</div>
|
19
|
+
</main>
|
20
|
+
|
21
|
+
<%= erb :"layouts/_javascripts" %>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<div class="Vlt-grid">
|
2
|
+
<div class="Vlt-col Vlt-col--2of3 Nxd-api__docs">
|
3
|
+
<div>
|
4
|
+
<h3 id="<%= endpoint.operationId %>" class="Vlt-title--icon">
|
5
|
+
<%= endpoint.summary %>
|
6
|
+
<% if webhook %>
|
7
|
+
<span class="Vlt-badge Vlt-badge--orange">
|
8
|
+
<i class="icon icon-webhook"></i> Webhook
|
9
|
+
</span>
|
10
|
+
<% else %>
|
11
|
+
<span class="Vlt-badge Vlt-badge--green">
|
12
|
+
<i class="icon icon-callback"></i> Callback
|
13
|
+
</span>
|
14
|
+
<% end %>
|
15
|
+
</h3>
|
16
|
+
<% if endpoint.description %>
|
17
|
+
<p><%= endpoint.description.render_markdown %></p>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<div class="Vlt-badge-combined">
|
21
|
+
<code class="Vlt-badge Vlt-badge--large Nxd-method-badge Nxd-method-badge--<%= endpoint.method %>"><%= endpoint.method.upcase %></code>
|
22
|
+
<code class="Vlt-badge Vlt-badge--large Vlt-badge--grey">
|
23
|
+
<span class="api-path-host">https://example.com</span>
|
24
|
+
<%= (endpoint.raw['x-example-path'] || '/webhooks/event').gsub(/\{(.+?)\}/, '<span class="api-path-parameter">:\1</span>') %>
|
25
|
+
</code>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<%= erb :'open_api/_parameter_groups', locals: { endpoint: endpoint, callback: true } %>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class="Vlt-col Vlt-col--1of3 Nxd-api__code">
|
33
|
+
<%= erb :'open_api/_code_examples', locals: { endpoint: endpoint } %>
|
34
|
+
|
35
|
+
<h5>Request model</h5>
|
36
|
+
|
37
|
+
<% endpoint.request_body.formats.each_with_index do |format, index| %>
|
38
|
+
<div class="js-format" data-format="<%= format %>">
|
39
|
+
<% schema = endpoint.request_body.schema(format) %>
|
40
|
+
<%= Nexmo::OAS::Renderer::ResponseParserDecorator.new(schema).html(format, xml_options: schema['xml']) %>
|
41
|
+
</div>
|
42
|
+
<% end %>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<% endpoint.callbacks.each do |callback| %>
|
47
|
+
<%= erb :'open_api/callback', locals: { callback: callback } %>
|
48
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%
|
2
|
+
# @todo Re-enable code examples once we decide how to handle them in OAS
|
3
|
+
false && if endpoint.raw['x-code-example-path']
|
4
|
+
%>
|
5
|
+
<h5>Example request</h5>
|
6
|
+
<%=
|
7
|
+
markdown = <<~HEREDOC
|
8
|
+
```tabbed_examples
|
9
|
+
config: #{endpoint.raw['x-code-example-path']}
|
10
|
+
```
|
11
|
+
HEREDOC
|
12
|
+
|
13
|
+
markdown.render_markdown
|
14
|
+
%>
|
15
|
+
<% end %>
|
16
|
+
|
@@ -0,0 +1,156 @@
|
|
1
|
+
<div class="Vlt-grid">
|
2
|
+
<div class="Vlt-col Vlt-col--2of3 Nxd-api__docs">
|
3
|
+
<div>
|
4
|
+
<h3 id='<%= endpoint.operationId %>'><%= endpoint.summary %></h3>
|
5
|
+
<% if endpoint.description %>
|
6
|
+
<p><%= endpoint.description.render_markdown %></p>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<div class="Vlt-badge-combined">
|
10
|
+
<code class="Vlt-badge Vlt-badge--large Nxd-method-badge Nxd-method-badge--<%= endpoint.method %>"><%= endpoint.method.upcase %></code>
|
11
|
+
<code class="Vlt-badge Vlt-badge--large Vlt-badge--grey">
|
12
|
+
<% servers = endpoint.path.servers ? endpoint.path.servers : endpoint.definition.servers %>
|
13
|
+
<span><%= servers[0]['url'] %></span><%= endpoint.path.path.gsub(/\{(.+?)\}/, '<span class="api-path-parameter">:\1</span>') %>
|
14
|
+
</code>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<% if endpoint.jwt? || endpoint.basic_auth? || endpoint.oauth? %>
|
18
|
+
<h4>Authentication</h4>
|
19
|
+
|
20
|
+
<% if endpoint.jwt? && endpoint.basic_auth? %>
|
21
|
+
<p>This API supports both JWT and Basic authentication. Basic authentication is easier to get started with, but does not support advanced features such as ACLs.</p>
|
22
|
+
|
23
|
+
<p>You can use <em>either</em> JWT or Basic authentication, but not both at the same time.</p>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<div class="Vlt-table Vlt-table--data Vlt-table--bordered">
|
27
|
+
<table>
|
28
|
+
<thead>
|
29
|
+
<tr>
|
30
|
+
<th>Key</th>
|
31
|
+
<th>Description</th>
|
32
|
+
<th>Example</th>
|
33
|
+
<th>Default</th>
|
34
|
+
</tr>
|
35
|
+
</thead>
|
36
|
+
<tbody>
|
37
|
+
<% if endpoint.oauth? %>
|
38
|
+
<tr>
|
39
|
+
<td>
|
40
|
+
<b>Authorization</b>
|
41
|
+
</td>
|
42
|
+
<td>
|
43
|
+
<b>Your OAuth token.</b><br>
|
44
|
+
<small><a href="/vonage-business-cloud/vbc-apis/getting-started/authentication">Read more about OAuth tokens</a></small>
|
45
|
+
</td>
|
46
|
+
<td><code>Bearer <access_token></code></td>
|
47
|
+
<td>
|
48
|
+
<em>None</em>
|
49
|
+
</td>
|
50
|
+
</tr>
|
51
|
+
<% end %>
|
52
|
+
|
53
|
+
<% if endpoint.jwt? %>
|
54
|
+
<tr>
|
55
|
+
<td>
|
56
|
+
<b>Authorization</b>
|
57
|
+
</td>
|
58
|
+
<td>
|
59
|
+
<b>Your JSON web token.</b><br>
|
60
|
+
<small><a href="/concepts/guides/authentication#json-web-tokens-jwt">Read more about JWTs</a></small>
|
61
|
+
</td>
|
62
|
+
<td><code>Bearer <JWT></code></td>
|
63
|
+
<td>
|
64
|
+
<em>None</em>
|
65
|
+
</td>
|
66
|
+
</tr>
|
67
|
+
<% end %>
|
68
|
+
|
69
|
+
<% if endpoint.basic_auth? %>
|
70
|
+
<tr>
|
71
|
+
<td>
|
72
|
+
<b>Authorization</b>
|
73
|
+
</td>
|
74
|
+
<td>
|
75
|
+
<b>Base64 encoded API key and secret joined by a colon.</b><br>
|
76
|
+
<small><a href="/concepts/guides/authentication#header-based-api-key-and-secret-authentication">Read more</a></small>
|
77
|
+
</td>
|
78
|
+
<td><code>Basic <base64></code></td>
|
79
|
+
<td>
|
80
|
+
<i>None</i>
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
<% end %>
|
84
|
+
</tbody>
|
85
|
+
</table>
|
86
|
+
</div>
|
87
|
+
<% end %>
|
88
|
+
|
89
|
+
<%= erb :'open_api/_parameter_groups', locals: { endpoint: endpoint } %>
|
90
|
+
<%= erb :'open_api/_response_descriptions', locals: { endpoint: endpoint, anchor_prefix: "response-#{endpoint.operationId}", auto_expand_responses: @auto_expand_responses } %>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
<div class="Vlt-col Vlt-col--1of3 Nxd-api__code">
|
96
|
+
<%= erb :'open_api/_code_examples', locals: { endpoint: endpoint } %>
|
97
|
+
|
98
|
+
<% endpoint.responses.each do |response| %>
|
99
|
+
<%
|
100
|
+
id = SecureRandom.hex
|
101
|
+
expand_response = response.code[0] == '2' && response.raw['x-expand-response'] != false
|
102
|
+
expand_response = true if response.raw['x-expand-response']
|
103
|
+
%>
|
104
|
+
|
105
|
+
<div class="Vlt-accordion">
|
106
|
+
<button tabindex="0" class="Vlt-accordion__trigger <%= expand_response ? 'Vlt-accordion__trigger_active' : '' %>">
|
107
|
+
<h5 class="Vlt-title--nomargin">HTTP response
|
108
|
+
<span class="Vlt-badge Vlt-badge--<%= response.code[0] == '2' ? 'green' : response.code[0] == '3' ? 'yellow' : 'red' %>"><%= response.code %></span>
|
109
|
+
</h5>
|
110
|
+
</button>
|
111
|
+
|
112
|
+
<div class="Vlt-accordion__content <%= expand_response ? 'Vlt-accordion__content_open' : '' %>">
|
113
|
+
<% response.formats.each_with_index do |format, index| %>
|
114
|
+
<div class="js-format" data-format="<%= format %>">
|
115
|
+
<% if response.exhibits_one_of_multiple_schemas?(format) %>
|
116
|
+
<%
|
117
|
+
schema_tab_ids = []
|
118
|
+
id = SecureRandom.hex
|
119
|
+
response.split_schemas(format).each { schema_tab_ids << SecureRandom.hex }
|
120
|
+
%>
|
121
|
+
|
122
|
+
<div class="Vlt-tabs">
|
123
|
+
<div class="Vlt-tabs__header">
|
124
|
+
<% response.split_schemas(format).each_with_index do |schema, index| %>
|
125
|
+
<div tabindex="<%= schema_tab_ids[index] %>" <% if index.zero? %>class="Vlt-tabs__link Vlt-tabs__link_active" aria-selected="true"<% else %>class="Vlt-tabs__link"<% end %>>
|
126
|
+
<%= schema['description'] || "Response #{index + 1}" %>
|
127
|
+
</div>
|
128
|
+
<% end %>
|
129
|
+
</div>
|
130
|
+
<div class="Vlt-tabs__content">
|
131
|
+
<% response.split_schemas(format).each_with_index do |schema, index| %>
|
132
|
+
<div class="Vlt-tabs__panel <% if index.zero? %>Vlt-tabs__panel_active<% end %>">
|
133
|
+
<%= Nexmo::OAS::Renderer::ResponseParserDecorator.new(schema).html(format, xml_options: schema['xml']) %>
|
134
|
+
</div>
|
135
|
+
<% end %>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
<% else %>
|
139
|
+
<% schema = response.schema(format) %>
|
140
|
+
<%= Nexmo::OAS::Renderer::ResponseParserDecorator.new(schema).html(format, xml_options: schema['xml']) %>
|
141
|
+
<% end %>
|
142
|
+
</div>
|
143
|
+
<% end %>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
<% if response.code == '204' || response.formats.empty? %>
|
147
|
+
<pre class="highlight"><code>No content</code></pre>
|
148
|
+
<% end %>
|
149
|
+
</div>
|
150
|
+
<% end %>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<% endpoint.callbacks.each do |callback| %>
|
155
|
+
<%= erb :'open_api/_callback', locals: { callback: callback, webhook: false } %>
|
156
|
+
<% end %>
|