nexmo-oas-renderer 0.3.7 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +7 -7
- data/README.md +5 -0
- data/lib/nexmo/oas/renderer/app.rb +1 -0
- data/lib/nexmo/oas/renderer/filters/external_link.rb +1 -1
- data/lib/nexmo/oas/renderer/filters/heading.rb +1 -1
- data/lib/nexmo/oas/renderer/filters/icon.rb +3 -3
- data/lib/nexmo/oas/renderer/filters/tooltip.rb +1 -1
- data/lib/nexmo/oas/renderer/presenters/response_tab/link.rb +28 -0
- data/lib/nexmo/oas/renderer/presenters/response_tab/panel.rb +40 -0
- data/lib/nexmo/oas/renderer/presenters/response_tabs.rb +40 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/application.js +19 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/components/scroll.js +21 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +11 -1
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +4 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css +862 -1
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css.map +1 -1
- data/lib/nexmo/oas/renderer/version.rb +1 -1
- data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +3 -0
- data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +34 -53
- data/lib/nexmo/oas/renderer/views/open_api/_model.erb +1 -1
- data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +3 -3
- data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +2 -3
- data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +9 -25
- data/lib/nexmo/oas/renderer/views/open_api/_response_fields.erb +18 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_tabs.erb +18 -0
- data/lib/nexmo/oas/renderer/views/open_api/show.erb +2 -2
- metadata +11 -16
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/api.css +0 -95
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/buttons.css +0 -80
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/core.css +0 -79
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css +0 -2
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css.map +0 -7
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/navigation.css +0 -79
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo.css +0 -68
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/syntax.css +0 -79
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/typography.css +0 -86
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css +0 -2
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css.map +0 -7
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css +0 -2
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css.map +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c0e7a8af2769d4a4ebd3984ac00658f0d02a22a3680136bd04253cbbaf270a3
|
4
|
+
data.tar.gz: 0e40b9e68b9255c70178a4140c31fe47a5c5bbae71d8a8a6170ae10452a16fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3220559808b157b8cdbad65e9538569d6edc0dfeb06bca8caafed1ae0b63b47d3f3e5b9e08b6261f77b27efaf1eea50efdc454fa8a52402b449fa3eacb892a71
|
7
|
+
data.tar.gz: 8573dc0aaa3412c81f5b2ca29d80611d92e410948cc1f0da1067a786d33c11b11976cf00bbcbe212dc456d53170dbcac51c65866d9a97c27c6ea419474ee65a1
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nexmo-oas-renderer (0.
|
4
|
+
nexmo-oas-renderer (0.4.0)
|
5
5
|
activemodel (~> 5.2)
|
6
6
|
activesupport (~> 5.2)
|
7
7
|
banzai (~> 0.1.2)
|
@@ -68,7 +68,7 @@ GEM
|
|
68
68
|
crass (1.0.4)
|
69
69
|
deep_merge (1.2.1)
|
70
70
|
diff-lcs (1.3)
|
71
|
-
dotenv (2.7.
|
71
|
+
dotenv (2.7.5)
|
72
72
|
erubi (1.8.0)
|
73
73
|
ffi (1.11.1)
|
74
74
|
globalid (0.4.2)
|
@@ -92,7 +92,7 @@ GEM
|
|
92
92
|
mustermann-contrib (1.0.3)
|
93
93
|
hansi (~> 0.2.0)
|
94
94
|
mustermann (= 1.0.3)
|
95
|
-
neatjson (0.
|
95
|
+
neatjson (0.9)
|
96
96
|
nio4r (2.4.0)
|
97
97
|
nokogiri (1.10.4)
|
98
98
|
mini_portile2 (~> 2.4.0)
|
@@ -110,7 +110,7 @@ GEM
|
|
110
110
|
rails
|
111
111
|
public_suffix (3.1.1)
|
112
112
|
rack (2.0.7)
|
113
|
-
rack-protection (2.0.
|
113
|
+
rack-protection (2.0.7)
|
114
114
|
rack
|
115
115
|
rack-test (1.1.0)
|
116
116
|
rack (>= 1.0, < 3)
|
@@ -130,7 +130,7 @@ GEM
|
|
130
130
|
rails-dom-testing (2.0.3)
|
131
131
|
activesupport (>= 4.2.0)
|
132
132
|
nokogiri (>= 1.6)
|
133
|
-
rails-html-sanitizer (1.0
|
133
|
+
rails-html-sanitizer (1.2.0)
|
134
134
|
loofah (~> 2.2, >= 2.2.2)
|
135
135
|
railties (5.2.3)
|
136
136
|
actionpack (= 5.2.3)
|
@@ -164,10 +164,10 @@ GEM
|
|
164
164
|
rb-inotify (~> 0.9, >= 0.9.7)
|
165
165
|
shotgun (0.9.2)
|
166
166
|
rack (>= 1.0)
|
167
|
-
sinatra (2.0.
|
167
|
+
sinatra (2.0.7)
|
168
168
|
mustermann (~> 1.0)
|
169
169
|
rack (~> 2.0)
|
170
|
-
rack-protection (= 2.0.
|
170
|
+
rack-protection (= 2.0.7)
|
171
171
|
tilt (~> 2.0)
|
172
172
|
sprockets (3.7.2)
|
173
173
|
concurrent-ruby (~> 1.0)
|
data/README.md
CHANGED
@@ -27,6 +27,11 @@ And simply run the executable with the corresponding env variables set (see [Not
|
|
27
27
|
$ nexmo-oas-renderer
|
28
28
|
```
|
29
29
|
|
30
|
+
Or, if you want to make code changes, just run the following command which will start the web server on http://localhost:9393:
|
31
|
+
``` shell
|
32
|
+
OAS_PATH=... bundle exec shotgun lib/nexmo/oas/renderer/config.ru
|
33
|
+
```
|
34
|
+
|
30
35
|
### Mounted into a Rails Application
|
31
36
|
|
32
37
|
Add this to your application's `Gemfile`:
|
@@ -10,6 +10,7 @@ require_relative'./pipelines/markdown_pipeline'
|
|
10
10
|
require_relative'./presenters/api_specification'
|
11
11
|
require_relative'./presenters/open_api_specification'
|
12
12
|
require_relative'./presenters/navigation'
|
13
|
+
require_relative'./presenters/response_tabs'
|
13
14
|
require_relative'./helpers/render'
|
14
15
|
require_relative'./helpers/navigation'
|
15
16
|
require_relative'./helpers/summary'
|
@@ -11,7 +11,7 @@ module Nexmo
|
|
11
11
|
link['target'] = '_blank'
|
12
12
|
if link.css('svg').empty?
|
13
13
|
link.add_child <<~HEREDOC
|
14
|
-
<svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue-dark"><use xlink:href="/symbol/volta-icons.svg#Vlt-icon-open"></use></svg>
|
14
|
+
<svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue-dark"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-open"></use></svg>
|
15
15
|
HEREDOC
|
16
16
|
end
|
17
17
|
end
|
@@ -21,7 +21,7 @@ module Nexmo
|
|
21
21
|
|
22
22
|
heading.prepend_child <<~HEREDOC
|
23
23
|
<a href="##{parameterized_heading}" class="heading-permalink">
|
24
|
-
<svg class="Vlt-grey"><use xlink:href=\"/symbol/volta-icons.svg#Vlt-icon-link\" /></svg>
|
24
|
+
<svg class="Vlt-grey"><use xlink:href=\"/assets/symbol/volta-icons.svg#Vlt-icon-link\" /></svg>
|
25
25
|
</a>
|
26
26
|
HEREDOC
|
27
27
|
end
|
@@ -4,12 +4,12 @@ module Nexmo
|
|
4
4
|
module Filters
|
5
5
|
class Icon < Banzai::Filter
|
6
6
|
def call(input)
|
7
|
-
input.gsub!('✅', '<svg class="Vlt-green Vlt-icon Vlt-icon--small"><use xlink:href="/symbol/volta-icons.svg#Vlt-icon-check" /></svg>')
|
8
|
-
input.gsub!('❌', '<svg class="Vlt-red Vlt-icon Vlt-icon--small"><use xlink:href="/symbol/volta-icons.svg#Vlt-icon-cross" /></svg>')
|
7
|
+
input.gsub!('✅', '<svg class="Vlt-green Vlt-icon Vlt-icon--small"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-check" /></svg>')
|
8
|
+
input.gsub!('❌', '<svg class="Vlt-red Vlt-icon Vlt-icon--small"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-cross" /></svg>')
|
9
9
|
|
10
10
|
input.gsub!(/\[icon="(.+?)"\]/) do
|
11
11
|
<<~HEREDOC
|
12
|
-
<svg class="Vlt-green Vlt-icon Vlt-icon--small"><use xlink:href="/symbol/volta-icons.svg#Vlt-icon-#{$1}" /></svg>
|
12
|
+
<svg class="Vlt-green Vlt-icon Vlt-icon--small"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-#{$1}" /></svg>
|
13
13
|
HEREDOC
|
14
14
|
end
|
15
15
|
|
@@ -8,7 +8,7 @@ module Nexmo
|
|
8
8
|
tooltip = <<~HEREDOC
|
9
9
|
<span class="Vlt-tooltip Vlt-tooltip--top" title="#{$2}" tabindex="0">
|
10
10
|
#{$1}
|
11
|
-
<svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue" aria-hidden="true"><use xlink:href="/symbol/volta-icons.svg#Vlt-icon-help-negative"/></svg>
|
11
|
+
<svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue" aria-hidden="true"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-help-negative"/></svg>
|
12
12
|
</span>
|
13
13
|
HEREDOC
|
14
14
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module OAS
|
3
|
+
module Renderer
|
4
|
+
module Presenters
|
5
|
+
module ResponseTab
|
6
|
+
class Link
|
7
|
+
attr_reader :index
|
8
|
+
|
9
|
+
def initialize(index:, schema:)
|
10
|
+
@index = index
|
11
|
+
@schema = schema
|
12
|
+
end
|
13
|
+
|
14
|
+
def css_classes
|
15
|
+
classes = ['Vlt-tabs__link']
|
16
|
+
classes << 'Vlt-tabs__link_active' if @index.zero?
|
17
|
+
classes.join(' ')
|
18
|
+
end
|
19
|
+
|
20
|
+
def content
|
21
|
+
@schema['description'] || "Response #{@index + 1}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module OAS
|
3
|
+
module Renderer
|
4
|
+
module Presenters
|
5
|
+
module ResponseTab
|
6
|
+
class Panel
|
7
|
+
attr_reader :index
|
8
|
+
|
9
|
+
def initialize(schema:, index:, format:, content:)
|
10
|
+
@schema = schema
|
11
|
+
@index = index
|
12
|
+
@format = format
|
13
|
+
@content = content
|
14
|
+
end
|
15
|
+
|
16
|
+
def css_classes
|
17
|
+
classes = ['Vlt-tabs__panel']
|
18
|
+
classes << 'Vlt-tabs__panel_active' if @index.zero?
|
19
|
+
classes.join(' ')
|
20
|
+
end
|
21
|
+
|
22
|
+
def content
|
23
|
+
if @content == :responses
|
24
|
+
Nexmo::OAS::Renderer::ResponseParserDecorator.
|
25
|
+
new(@schema).
|
26
|
+
html(@format, xml_options: @schema['xml'])
|
27
|
+
else
|
28
|
+
[:'open_api/_response_fields', locals: {
|
29
|
+
schema: @schema,
|
30
|
+
index: @index,
|
31
|
+
format: @format,
|
32
|
+
}]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative './response_tab/link'
|
2
|
+
require_relative './response_tab/panel'
|
3
|
+
|
4
|
+
module Nexmo
|
5
|
+
module OAS
|
6
|
+
module Renderer
|
7
|
+
module Presenters
|
8
|
+
class ResponseTabs
|
9
|
+
attr_reader :format
|
10
|
+
|
11
|
+
def initialize(format, response, content)
|
12
|
+
@format = format
|
13
|
+
@response = response
|
14
|
+
@content = content
|
15
|
+
end
|
16
|
+
|
17
|
+
def tab_links
|
18
|
+
@tab_links ||= @response.split_schemas(@format).map.with_index do |schema, index|
|
19
|
+
ResponseTab::Link.new(
|
20
|
+
index: index,
|
21
|
+
schema: schema
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def tab_panels
|
27
|
+
@tab_panels ||= @response.split_schemas(@format).map.with_index do |schema, index|
|
28
|
+
ResponseTab::Panel.new(
|
29
|
+
schema: schema,
|
30
|
+
index: index,
|
31
|
+
format: @format,
|
32
|
+
content: @content
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function() {
|
2
|
+
|
3
|
+
// Toggle text on accordion button for response fields
|
4
|
+
let responseDescriptionTogglers = document.getElementsByClassName('response-description-toggle');
|
5
|
+
|
6
|
+
[...responseDescriptionTogglers].forEach(function(element) {
|
7
|
+
element.addEventListener('click', function(event) {
|
8
|
+
let text = event.target.textContent;
|
9
|
+
let newText;
|
10
|
+
if (text.indexOf('View') != -1) {
|
11
|
+
newText = text.replace("View", "Hide");
|
12
|
+
} else {
|
13
|
+
newText = text.replace("Hide", "View");
|
14
|
+
}
|
15
|
+
event.target.textContent = newText;
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Scroll {
|
2
|
+
constructor() {
|
3
|
+
const self = this;
|
4
|
+
const body = document.getElementsByClassName('Vlt-main')[0];
|
5
|
+
|
6
|
+
document.addEventListener('DOMContentLoaded', function() {
|
7
|
+
body.addEventListener('scroll', self.onScroll);
|
8
|
+
});
|
9
|
+
}
|
10
|
+
|
11
|
+
onScroll(event) {
|
12
|
+
const scrollTop = event.target.scrollTop;
|
13
|
+
const codeNav = document.getElementsByClassName('Nxd-api__code__header')[0];
|
14
|
+
|
15
|
+
if (scrollTop > 70 && codeNav) {
|
16
|
+
codeNav.classList.add('Nxd-api__code__header--sticky');
|
17
|
+
} else if (codeNav) {
|
18
|
+
codeNav.classList.remove('Nxd-api__code__header--sticky');
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -1,3 +1,6 @@
|
|
1
|
+
@import "./variables";
|
2
|
+
@import "./mediaqueries";
|
3
|
+
|
1
4
|
.Nxd-content {
|
2
5
|
display: flex;
|
3
6
|
}
|
@@ -57,6 +60,13 @@
|
|
57
60
|
padding-left: $unit2;
|
58
61
|
}
|
59
62
|
|
63
|
+
&__responses {
|
64
|
+
top: 30px;
|
65
|
+
position: sticky;
|
66
|
+
display: block;
|
67
|
+
overflow: scroll;
|
68
|
+
}
|
69
|
+
|
60
70
|
&__code {
|
61
71
|
background: $grey-light;
|
62
72
|
border-bottom: 1px solid $grey-lighter;
|
@@ -77,7 +87,7 @@
|
|
77
87
|
|
78
88
|
&--sticky {
|
79
89
|
position: fixed;
|
80
|
-
top:
|
90
|
+
top: 30px;
|
81
91
|
width: 27.5%;
|
82
92
|
z-index: 1000;
|
83
93
|
|