nexmo-oas-renderer 0.10.0 → 2.0.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 +15 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +94 -74
- 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 +79 -40
- 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 +2 -1
- 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 +51 -24
- 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 +17 -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 +35 -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
@@ -4,246 +4,304 @@
|
|
4
4
|
* Accordions (requires core)
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
Volta.accordion = function () {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
7
|
+
"use strict";
|
8
|
+
|
9
|
+
Volta.accordion = (function () {
|
10
|
+
var _class = {
|
11
|
+
standard: {
|
12
|
+
container: "Vlt-accordion",
|
13
|
+
containerGroup: "Vlt-accordion--group",
|
14
|
+
trigger: "Vlt-accordion__trigger",
|
15
|
+
triggerActive: "Vlt-accordion__trigger_active",
|
16
|
+
content: "Vlt-accordion__content",
|
17
|
+
contentOpen: "Vlt-accordion__content_open",
|
18
|
+
contentOpening: "Vlt-accordion__content_opening",
|
19
|
+
contentClosing: "Vlt-accordion__content_closing",
|
20
|
+
},
|
21
|
+
js: {
|
22
|
+
content: "Vlt-js-accordion__content",
|
23
|
+
contentOpen: "Vlt-js-accordion__content_open",
|
24
|
+
contentOpening: "Vlt-js-accordion__content_opening",
|
25
|
+
contentClosing: "Vlt-js-accordion__content_closing",
|
26
|
+
trigger: "Vlt-js-accordion__trigger",
|
27
|
+
triggerActive: "Vlt-js-accordion__trigger_active",
|
28
|
+
},
|
29
|
+
};
|
30
|
+
|
31
|
+
function Accordion() {}
|
32
|
+
|
33
|
+
Accordion.prototype = {
|
34
|
+
init: function (element, suppressClickHandler, triggerElem) {
|
35
|
+
if (this.isStandard) {
|
36
|
+
this._initStandard(element, suppressClickHandler);
|
37
|
+
} else {
|
38
|
+
this._initJs(element, suppressClickHandler, triggerElem);
|
39
|
+
}
|
40
|
+
},
|
41
|
+
_initStandard: function (element, suppressClickHandler) {
|
42
|
+
var self = this;
|
43
|
+
|
44
|
+
if (!suppressClickHandler) {
|
45
|
+
element
|
46
|
+
.querySelectorAll("." + _class.standard.trigger)
|
47
|
+
.forEach(function (trigger) {
|
48
|
+
var parent = Volta._closest(
|
49
|
+
trigger,
|
50
|
+
"." + _class.standard.container,
|
51
|
+
_class.standard.container
|
52
|
+
);
|
53
|
+
|
54
|
+
if (parent && parent == element) {
|
55
|
+
trigger.addEventListener("click", function () {
|
56
|
+
self.toggle(trigger);
|
57
|
+
});
|
58
|
+
trigger.addEventListener("toggle", function () {
|
59
|
+
self.toggle(trigger);
|
60
|
+
});
|
61
|
+
}
|
62
|
+
});
|
63
|
+
}
|
64
|
+
},
|
65
|
+
_initJs: function (element, suppressClickHandler, triggerElem) {
|
66
|
+
this._content = element;
|
67
|
+
|
68
|
+
if (triggerElem) {
|
69
|
+
this.trigger = triggerElem;
|
70
|
+
} else if (this._content.dataset.trigger) {
|
71
|
+
var triggerId = this._content.dataset.trigger;
|
72
|
+
this.trigger = document.querySelector("#" + triggerId);
|
73
|
+
} else {
|
74
|
+
console.warn("Volta: js accordion trigger missing");
|
75
|
+
}
|
76
|
+
|
77
|
+
var self = this;
|
78
|
+
if (!suppressClickHandler && this.trigger) {
|
79
|
+
this.trigger.addEventListener("click", function () {
|
80
|
+
self.toggle();
|
81
|
+
});
|
82
|
+
}
|
83
|
+
},
|
84
|
+
close: function (trigger) {
|
85
|
+
var panel = this._content || trigger.nextElementSibling;
|
86
|
+
var trigger = this.trigger || trigger;
|
87
|
+
var classes = this.trigger ? _class.js : _class.standard;
|
88
|
+
|
89
|
+
trigger.classList.remove(classes.triggerActive);
|
90
|
+
panel.classList.add(classes.contentClosing);
|
91
|
+
|
92
|
+
panel.style.height = window.getComputedStyle(panel).height;
|
93
|
+
panel.offsetHeight; // force repaint
|
94
|
+
panel.style.height = "0px";
|
95
|
+
panel.classList.remove(classes.contentOpen);
|
96
|
+
|
97
|
+
var self = this;
|
98
|
+
panel.addEventListener(
|
99
|
+
"transitionend",
|
100
|
+
function closingTransitionEndEvent(event) {
|
101
|
+
if (
|
102
|
+
event.propertyName == "height" &&
|
103
|
+
Volta._hasClass(panel, classes.contentClosing)
|
104
|
+
) {
|
105
|
+
panel.classList.remove(classes.contentClosing);
|
106
|
+
panel.style.height = "0px";
|
107
|
+
panel.removeEventListener(
|
108
|
+
"transitionend",
|
109
|
+
closingTransitionEndEvent,
|
110
|
+
false
|
111
|
+
);
|
112
|
+
|
113
|
+
if (self.isGroup && self._isTriggerActive(trigger, true)) {
|
114
|
+
self._activeGroupTrigger = undefined;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
},
|
118
|
+
{ passive: true, once: true }
|
119
|
+
);
|
120
|
+
},
|
121
|
+
isOpening: false,
|
122
|
+
_activeGroupTrigger: undefined,
|
123
|
+
_isTriggerActive: function (trigger, match) {
|
124
|
+
return (
|
125
|
+
(this.isGroup &&
|
126
|
+
this._activeGroupTrigger &&
|
127
|
+
(!match || this._activeGroupTrigger === trigger)) ||
|
128
|
+
Volta._hasClass(trigger, _class.standard.triggerActive)
|
129
|
+
);
|
130
|
+
},
|
131
|
+
open: function (trigger) {
|
132
|
+
if (!this.trigger) {
|
133
|
+
if (this._isTriggerActive(trigger, false)) {
|
134
|
+
this.close(this._activeGroupTrigger || trigger);
|
135
|
+
}
|
136
|
+
if (this.isGroup) {
|
137
|
+
this._activeGroupTrigger = trigger;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
var trig = this.trigger || trigger;
|
142
|
+
var classes = this.trigger ? _class.js : _class.standard;
|
143
|
+
var panel = this._content || trig.nextElementSibling;
|
144
|
+
|
145
|
+
this.isOpening = true;
|
146
|
+
|
147
|
+
trig.classList.add(classes.triggerActive);
|
148
|
+
panel.classList.add(classes.contentOpening);
|
149
|
+
|
150
|
+
var startHeight = panel.style.height;
|
151
|
+
panel.style.height = "auto";
|
152
|
+
var endHeight = window.getComputedStyle(panel).height;
|
153
|
+
panel.style.height = startHeight;
|
154
|
+
panel.offsetHeight; // force repaint
|
155
|
+
panel.style.height = endHeight;
|
156
|
+
|
157
|
+
var self = this;
|
158
|
+
panel.addEventListener(
|
159
|
+
"transitionend",
|
160
|
+
function openingTransitionEndEvent(event) {
|
161
|
+
if (
|
162
|
+
event.propertyName == "height" &&
|
163
|
+
Volta._hasClass(panel, classes.contentOpening)
|
164
|
+
) {
|
165
|
+
panel.style.height = "auto";
|
166
|
+
panel.classList.remove(classes.contentOpening);
|
167
|
+
panel.classList.add(classes.contentOpen);
|
168
|
+
panel.removeEventListener(
|
169
|
+
"transitionend",
|
170
|
+
openingTransitionEndEvent,
|
171
|
+
false
|
172
|
+
);
|
173
|
+
self.isOpening = false;
|
174
|
+
}
|
175
|
+
},
|
176
|
+
{ passive: true, once: true }
|
177
|
+
);
|
178
|
+
},
|
179
|
+
toggle: function (trigger) {
|
180
|
+
if (this.isOpening) {
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
if (
|
184
|
+
(this.trigger &&
|
185
|
+
Volta._hasClass(this._content, _class.js.contentOpen)) ||
|
186
|
+
(!this.trigger && this._isTriggerActive(trigger, true))
|
187
|
+
) {
|
188
|
+
this.close(trigger);
|
189
|
+
} else {
|
190
|
+
this.open(trigger);
|
191
|
+
}
|
192
|
+
},
|
193
|
+
};
|
194
|
+
|
195
|
+
return {
|
196
|
+
create: create,
|
197
|
+
init: initialise,
|
198
|
+
};
|
199
|
+
|
200
|
+
/**
|
201
|
+
* @public
|
202
|
+
*
|
203
|
+
* @description Create an individual accordion object
|
204
|
+
* @param {Element|string} elementOrId Reference to the accordion content element or the id
|
205
|
+
* @param {Boolean} suppressClickHandler Whether click events should be attached on creation
|
206
|
+
* @param {Element} trigger Private required for legacy accordions
|
207
|
+
* @param {Boolean} isGroup Private required for legacy accordions
|
208
|
+
* @return {Object}
|
209
|
+
*/
|
210
|
+
function create(
|
211
|
+
elementOrId,
|
212
|
+
suppressClickHandler,
|
213
|
+
trigger,
|
214
|
+
isGroup,
|
215
|
+
isStandard
|
216
|
+
) {
|
217
|
+
if (!elementOrId) {
|
218
|
+
console.warn("Volta: no parameter supplied to accordion.create()");
|
219
|
+
}
|
220
|
+
var accordion = Object.create(Accordion.prototype, {});
|
221
|
+
var element = getElement(elementOrId);
|
222
|
+
|
223
|
+
Object.defineProperties(accordion, {
|
224
|
+
isStandard: {
|
225
|
+
value:
|
226
|
+
isStandard || Volta._hasClass(element, _class.standard.container),
|
227
|
+
writable: false,
|
228
|
+
},
|
229
|
+
});
|
230
|
+
|
231
|
+
Object.defineProperties(accordion, {
|
232
|
+
isGroup: {
|
233
|
+
value: isGroup,
|
234
|
+
writable: false,
|
235
|
+
},
|
236
|
+
});
|
237
|
+
|
238
|
+
accordion.init(element, suppressClickHandler, trigger);
|
239
|
+
|
240
|
+
return accordion;
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* @public
|
245
|
+
*
|
246
|
+
* @description Initialise all the accordions on the current screen
|
247
|
+
*/
|
248
|
+
function initialise() {
|
249
|
+
//standard
|
250
|
+
var standardAccordions = document.querySelectorAll(
|
251
|
+
"." + _class.standard.container
|
252
|
+
);
|
253
|
+
|
254
|
+
if (standardAccordions.length) {
|
255
|
+
standardAccordions.forEach(function (accordion) {
|
256
|
+
create(
|
257
|
+
accordion,
|
258
|
+
false,
|
259
|
+
null,
|
260
|
+
Volta._hasClass(accordion, _class.standard.containerGroup),
|
261
|
+
true
|
262
|
+
);
|
263
|
+
});
|
264
|
+
}
|
265
|
+
|
266
|
+
//js
|
267
|
+
var triggers = document.querySelectorAll(
|
268
|
+
"." + _class.js.trigger + "[data-accordion]"
|
269
|
+
);
|
270
|
+
if (triggers.length > 0) {
|
271
|
+
triggers.forEach(function (trigger) {
|
272
|
+
var accordionId = trigger.dataset.accordion;
|
273
|
+
if (!accordionId) {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
create(accordionId, false, trigger);
|
277
|
+
});
|
278
|
+
}
|
279
|
+
|
280
|
+
//js - legacy
|
281
|
+
var jsAccordions = document.querySelectorAll(
|
282
|
+
"." + _class.js.content + "[data-trigger]"
|
283
|
+
);
|
284
|
+
if (jsAccordions.length > 0) {
|
285
|
+
jsAccordions.forEach(function (jsLegacy) {
|
286
|
+
create(jsLegacy);
|
287
|
+
});
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
/**
|
292
|
+
* @private
|
293
|
+
*/
|
294
|
+
function getElement(elementOrId) {
|
295
|
+
var element;
|
296
|
+
|
297
|
+
if (elementOrId.classList) {
|
298
|
+
element = elementOrId;
|
299
|
+
} else if (elementOrId.substring(0, 1) === "#") {
|
300
|
+
element = document.querySelector(elementOrId);
|
301
|
+
} else {
|
302
|
+
element = document.querySelector("#" + elementOrId);
|
303
|
+
}
|
304
|
+
|
305
|
+
return element;
|
306
|
+
}
|
307
|
+
})();
|