rapipdf 2.1.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -14
- package/dist/chunks/generate-BQLGaRvK.js +386 -0
- package/dist/chunks/generate-BQLGaRvK.js.LICENSE.txt +224 -0
- package/dist/chunks/localize-CRvDVkIz.js +8 -0
- package/dist/node.js +13096 -0
- package/dist/node.js.LICENSE.txt +195 -0
- package/dist/rapipdf-min.js +352 -90
- package/dist/rapipdf-min.js.LICENSE.txt +224 -0
- package/dist/rapipdf.js +69 -0
- package/package.json +58 -52
- package/src/node.d.ts +82 -0
- package/src/rapipdf.d.ts +50 -0
- package/.babelrc +0 -11
- package/.eslintrc +0 -28
- package/dist/index.html +0 -48
- package/dist/index.html.gz +0 -0
- package/dist/rapipdf-min.js.gz +0 -0
- package/dist/rapipdf-min.js.map +0 -1
- package/dist/rapipdf-min.js.map.gz +0 -0
- package/dist/report.html +0 -67
- package/docs/examples/example1.html +0 -68
- package/docs/examples/list.html +0 -27
- package/docs/examples/rapidoc-regular.woff2 +0 -0
- package/docs/examples/rapidoc-semi-bold.woff2 +0 -0
- package/docs/examples/roboto-mono-bold.woff2 +0 -0
- package/docs/examples/roboto-mono-regular.woff2 +0 -0
- package/docs/highlight/CHANGES.md +0 -1803
- package/docs/highlight/LICENSE +0 -24
- package/docs/highlight/README.md +0 -188
- package/docs/highlight/README.ru.md +0 -142
- package/docs/highlight/highlight.pack.js +0 -2
- package/docs/highlight/styles/a11y-dark.css +0 -99
- package/docs/highlight/styles/a11y-light.css +0 -99
- package/docs/highlight/styles/agate.css +0 -108
- package/docs/highlight/styles/an-old-hope.css +0 -89
- package/docs/highlight/styles/androidstudio.css +0 -66
- package/docs/highlight/styles/arduino-light.css +0 -88
- package/docs/highlight/styles/arta.css +0 -73
- package/docs/highlight/styles/ascetic.css +0 -45
- package/docs/highlight/styles/atelier-cave-dark.css +0 -83
- package/docs/highlight/styles/atelier-cave-light.css +0 -85
- package/docs/highlight/styles/atelier-dune-dark.css +0 -69
- package/docs/highlight/styles/atelier-dune-light.css +0 -69
- package/docs/highlight/styles/atelier-estuary-dark.css +0 -84
- package/docs/highlight/styles/atelier-estuary-light.css +0 -84
- package/docs/highlight/styles/atelier-forest-dark.css +0 -69
- package/docs/highlight/styles/atelier-forest-light.css +0 -69
- package/docs/highlight/styles/atelier-heath-dark.css +0 -69
- package/docs/highlight/styles/atelier-heath-light.css +0 -69
- package/docs/highlight/styles/atelier-lakeside-dark.css +0 -69
- package/docs/highlight/styles/atelier-lakeside-light.css +0 -69
- package/docs/highlight/styles/atelier-plateau-dark.css +0 -84
- package/docs/highlight/styles/atelier-plateau-light.css +0 -84
- package/docs/highlight/styles/atelier-savanna-dark.css +0 -84
- package/docs/highlight/styles/atelier-savanna-light.css +0 -84
- package/docs/highlight/styles/atelier-seaside-dark.css +0 -69
- package/docs/highlight/styles/atelier-seaside-light.css +0 -69
- package/docs/highlight/styles/atelier-sulphurpool-dark.css +0 -69
- package/docs/highlight/styles/atelier-sulphurpool-light.css +0 -69
- package/docs/highlight/styles/atom-one-dark-reasonable.css +0 -77
- package/docs/highlight/styles/atom-one-dark.css +0 -96
- package/docs/highlight/styles/atom-one-light.css +0 -96
- package/docs/highlight/styles/brown-paper.css +0 -64
- package/docs/highlight/styles/brown-papersq.png +0 -0
- package/docs/highlight/styles/codepen-embed.css +0 -60
- package/docs/highlight/styles/color-brewer.css +0 -71
- package/docs/highlight/styles/darcula.css +0 -77
- package/docs/highlight/styles/dark.css +0 -63
- package/docs/highlight/styles/darkula.css +0 -6
- package/docs/highlight/styles/default.css +0 -99
- package/docs/highlight/styles/docco.css +0 -97
- package/docs/highlight/styles/dracula.css +0 -76
- package/docs/highlight/styles/far.css +0 -71
- package/docs/highlight/styles/foundation.css +0 -88
- package/docs/highlight/styles/github-gist.css +0 -71
- package/docs/highlight/styles/github.css +0 -99
- package/docs/highlight/styles/gml.css +0 -78
- package/docs/highlight/styles/googlecode.css +0 -89
- package/docs/highlight/styles/grayscale.css +0 -101
- package/docs/highlight/styles/gruvbox-dark.css +0 -108
- package/docs/highlight/styles/gruvbox-light.css +0 -108
- package/docs/highlight/styles/hopscotch.css +0 -83
- package/docs/highlight/styles/hybrid.css +0 -102
- package/docs/highlight/styles/idea.css +0 -97
- package/docs/highlight/styles/ir-black.css +0 -73
- package/docs/highlight/styles/isbl-editor-dark.css +0 -112
- package/docs/highlight/styles/isbl-editor-light.css +0 -112
- package/docs/highlight/styles/kimbie.dark.css +0 -74
- package/docs/highlight/styles/kimbie.light.css +0 -74
- package/docs/highlight/styles/lightfair.css +0 -87
- package/docs/highlight/styles/magula.css +0 -70
- package/docs/highlight/styles/mono-blue.css +0 -59
- package/docs/highlight/styles/monokai-sublime.css +0 -83
- package/docs/highlight/styles/monokai.css +0 -70
- package/docs/highlight/styles/nord.css +0 -309
- package/docs/highlight/styles/obsidian.css +0 -88
- package/docs/highlight/styles/ocean.css +0 -74
- package/docs/highlight/styles/paraiso-dark.css +0 -72
- package/docs/highlight/styles/paraiso-light.css +0 -72
- package/docs/highlight/styles/pojoaque.css +0 -83
- package/docs/highlight/styles/pojoaque.jpg +0 -0
- package/docs/highlight/styles/purebasic.css +0 -96
- package/docs/highlight/styles/qtcreator_dark.css +0 -83
- package/docs/highlight/styles/qtcreator_light.css +0 -83
- package/docs/highlight/styles/railscasts.css +0 -106
- package/docs/highlight/styles/rainbow.css +0 -85
- package/docs/highlight/styles/routeros.css +0 -108
- package/docs/highlight/styles/school-book.css +0 -72
- package/docs/highlight/styles/school-book.png +0 -0
- package/docs/highlight/styles/shades-of-purple.css +0 -97
- package/docs/highlight/styles/solarized-dark.css +0 -84
- package/docs/highlight/styles/solarized-light.css +0 -84
- package/docs/highlight/styles/sunburst.css +0 -102
- package/docs/highlight/styles/tomorrow-night-blue.css +0 -75
- package/docs/highlight/styles/tomorrow-night-bright.css +0 -74
- package/docs/highlight/styles/tomorrow-night-eighties.css +0 -74
- package/docs/highlight/styles/tomorrow-night.css +0 -75
- package/docs/highlight/styles/tomorrow.css +0 -72
- package/docs/highlight/styles/vs.css +0 -68
- package/docs/highlight/styles/vs2015.css +0 -115
- package/docs/highlight/styles/xcode.css +0 -104
- package/docs/highlight/styles/xt256.css +0 -92
- package/docs/highlight/styles/zenburn.css +0 -80
- package/docs/images/console.svg +0 -12
- package/docs/images/dark_ss.png +0 -0
- package/docs/images/easy.svg +0 -14
- package/docs/images/fast.svg +0 -8
- package/docs/images/gears.svg +0 -11
- package/docs/images/light_ss.png +0 -0
- package/docs/images/logo.png +0 -0
- package/docs/images/love.svg +0 -8
- package/docs/images/mask.svg +0 -16
- package/docs/images/mouse.svg +0 -7
- package/docs/images/pdf_sample1.png +0 -0
- package/docs/images/pdf_sample2.png +0 -0
- package/docs/images/webcomponent.svg +0 -13
- package/docs/index.css +0 -254
- package/docs/index.html +0 -376
- package/docs/rapipdf-min.js +0 -95
- package/docs/specs/allof-primitives.json +0 -80
- package/docs/specs/allof.json +0 -73
- package/docs/specs/anyof.json +0 -84
- package/docs/specs/basic.json +0 -75
- package/docs/specs/bitbucket.json +0 -12916
- package/docs/specs/data-types.yaml +0 -168
- package/docs/specs/gcloud.json +0 -1347
- package/docs/specs/no-server.json +0 -1
- package/docs/specs/oneof.json +0 -64
- package/docs/specs/petstore.json +0 -1042
- package/docs/specs/petstore_extended.yaml +0 -889
- package/docs/specs/temp.json +0 -53
- package/docs/specs/test-specs/large-models.json +0 -5998
- package/docs/specs/test-specs/long-descriptions.json +0 -5443
- package/docs/specs/test-specs/long-paths.json +0 -9562
- package/docs/specs/test-specs/oneof-allof-nested.yaml +0 -105
- package/docs/specs/test-specs/partial-spec-main.json +0 -29
- package/docs/specs/test-specs/partial.json +0 -17
- package/docs/specs/test-specs/petstore_complex_request.yaml +0 -335
- package/docs/specs/test-specs/petstore_experimental.yaml +0 -167
- package/docs/specs/test-specs/xxx-of-with-primitives-and-recursive-model.yaml +0 -952
- package/docs/welcome.html +0 -369
- package/index.html +0 -48
- package/logo.png +0 -0
- package/src/index.js +0 -3
- package/src/markdown.js +0 -120
- package/src/object-tree-gen.js +0 -370
- package/src/pdf-gen.js +0 -113
- package/src/pdf-parts-gen.js +0 -488
- package/src/rapipdf.js +0 -246
- package/src/spec-parser.js +0 -162
- package/src/table-layouts.js +0 -35
- package/src/vfs_fonts.js +0 -7
- package/webpack.config.js +0 -118
package/src/rapipdf.js
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import createPdf from '@/pdf-gen';
|
|
2
|
-
|
|
3
|
-
const tmpl = document.createElement('template');
|
|
4
|
-
tmpl.innerHTML = `
|
|
5
|
-
<style>
|
|
6
|
-
:host{
|
|
7
|
-
--primary-color:#0078d7;
|
|
8
|
-
--border-radius:2px;
|
|
9
|
-
--input-bg:#fff;
|
|
10
|
-
--fg:#333;
|
|
11
|
-
--primary-text:#fff;
|
|
12
|
-
--font-size:13px;
|
|
13
|
-
display:block;
|
|
14
|
-
width:350px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.spec-input {
|
|
18
|
-
border-radius:var(--border-radius);
|
|
19
|
-
border:1px solid var(--primary-color);
|
|
20
|
-
background:var(--input-bg);
|
|
21
|
-
font-size: inherit;
|
|
22
|
-
color:var(--fg);
|
|
23
|
-
transition: border .2s;
|
|
24
|
-
outline: none;
|
|
25
|
-
padding:6px 5px;
|
|
26
|
-
box-sizing: border-box;
|
|
27
|
-
flex:1;
|
|
28
|
-
}
|
|
29
|
-
.spec-input:focus {
|
|
30
|
-
outline: 1px dotted var(--fg);
|
|
31
|
-
outline-offset: -3px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.btn-default {
|
|
35
|
-
border-radius: 0 var(--border-radius) var(--border-radius) 0;
|
|
36
|
-
font-size: 85%;
|
|
37
|
-
font-weight: 600;
|
|
38
|
-
display: inline-block;
|
|
39
|
-
padding: 8px 16px;
|
|
40
|
-
outline: none;
|
|
41
|
-
outline-offset: -2px;
|
|
42
|
-
line-height: 1;
|
|
43
|
-
text-align: center;
|
|
44
|
-
white-space: nowrap;
|
|
45
|
-
background-color:var(--primary-color);
|
|
46
|
-
color:var(--primary-text);
|
|
47
|
-
border: 0px solid var(--primary-color);
|
|
48
|
-
transition: background-color 0.2s;
|
|
49
|
-
user-select: none;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
}
|
|
52
|
-
.btn-default:focus{
|
|
53
|
-
outline: 1px solid var(--primary-text);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
</style>
|
|
57
|
-
<div style='display:flex; width:100%; height: 100%;'>
|
|
58
|
-
<input class="spec-input" id="spec-url" type="text" placeholder="Spec URL" value="" tabindex="0">
|
|
59
|
-
<button class="btn-default" type="button" style="margin-left:-1px" tabindex="0">GENERATE PDF</button>
|
|
60
|
-
</div>
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
export default customElements.define('rapi-pdf', class RapiPdf extends HTMLElement {
|
|
64
|
-
constructor() {
|
|
65
|
-
super(); // always call super() first in the constructor.
|
|
66
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
67
|
-
const elFromTemplate = tmpl.content.cloneNode(true);
|
|
68
|
-
this.inputEl = elFromTemplate.querySelector('.spec-input');
|
|
69
|
-
this.btnEl = elFromTemplate.querySelector('.btn-default');
|
|
70
|
-
|
|
71
|
-
// Initialize attributes if not defined
|
|
72
|
-
shadowRoot.appendChild(elFromTemplate);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static get properties() {
|
|
76
|
-
return {
|
|
77
|
-
localize: { type: Object },
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
connectedCallback() {
|
|
82
|
-
// Add Event Listeners
|
|
83
|
-
this.inputEl.addEventListener('change', (e) => this.onChangeInput(e));
|
|
84
|
-
this.inputEl.addEventListener('keyup', (e) => this.onKeyUp(e));
|
|
85
|
-
this.btnEl.addEventListener('click', () => this.generatePdf());
|
|
86
|
-
let localizeObj = {};
|
|
87
|
-
if (this.children[0]) {
|
|
88
|
-
const localizeStr = this.children[0].content.textContent;
|
|
89
|
-
try {
|
|
90
|
-
localizeObj = JSON.parse(localizeStr);
|
|
91
|
-
} catch (e) {
|
|
92
|
-
localizeObj = {};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.localize = {
|
|
97
|
-
index: 'INDEX',
|
|
98
|
-
api: 'API',
|
|
99
|
-
apiList: 'API List',
|
|
100
|
-
apiReference: 'API Reference',
|
|
101
|
-
apiVersion: 'API Version',
|
|
102
|
-
contact: 'CONTACT',
|
|
103
|
-
name: 'NAME',
|
|
104
|
-
email: 'EMAIL',
|
|
105
|
-
url: 'URL',
|
|
106
|
-
termsOfService: 'Terms of service',
|
|
107
|
-
securityAndAuthentication: 'Security and Authentication',
|
|
108
|
-
securitySchemes: 'SECURITY SCHEMES',
|
|
109
|
-
key: 'KEY',
|
|
110
|
-
type: 'TYPE',
|
|
111
|
-
example: 'EXAMPLE',
|
|
112
|
-
description: 'DESCRIPTION',
|
|
113
|
-
request: 'REQUEST',
|
|
114
|
-
requestBody: 'REQUEST BODY',
|
|
115
|
-
response: 'RESPONSE',
|
|
116
|
-
responseModel: 'RESPONSE MODEL',
|
|
117
|
-
statusCode: 'STATUS CODE',
|
|
118
|
-
deprecated: 'DEPRECATED',
|
|
119
|
-
allowed: 'ALLOWED',
|
|
120
|
-
default: 'DEFAULT',
|
|
121
|
-
readOnly: 'READ ONLY',
|
|
122
|
-
writeOnly: 'WRITE ONLY',
|
|
123
|
-
enumValues: 'ENUM',
|
|
124
|
-
pattern: 'PATTERN',
|
|
125
|
-
parameters: 'Parameters',
|
|
126
|
-
noRequestParameters: 'No request parameters',
|
|
127
|
-
method: 'METHOD',
|
|
128
|
-
...localizeObj,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
disconnectedCallback() {
|
|
133
|
-
// Remove Event Listeners
|
|
134
|
-
this.inputEl.removeEventListener('change', this.inputOnChange);
|
|
135
|
-
this.inputEl.removeEventListener('keyup', this.onKeyUp);
|
|
136
|
-
this.btnEl.removeEventListener('click', this.generatePdf);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
static get observedAttributes() {
|
|
140
|
-
return ['spec-url', 'button-bg', 'input-bg', 'button-color', 'input-color', 'button-label', 'hide-input'];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
144
|
-
switch (name) {
|
|
145
|
-
case 'spec-url':
|
|
146
|
-
if (oldValue !== newValue) {
|
|
147
|
-
this.inputEl.value = newValue;
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
151
|
-
case 'button-label':
|
|
152
|
-
if (oldValue !== newValue) {
|
|
153
|
-
this.btnEl.innerText = newValue;
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
case 'hide-input':
|
|
158
|
-
if (oldValue !== newValue) {
|
|
159
|
-
if (newValue === 'true') {
|
|
160
|
-
this.inputEl.style.display = 'none';
|
|
161
|
-
this.btnEl.style.borderRadius = 'var(--border-radius)';
|
|
162
|
-
} else {
|
|
163
|
-
this.inputEl.style.display = 'block';
|
|
164
|
-
this.btnEl.style.borderRadius = '0 var(--border-radius) var(--border-radius) 0';
|
|
165
|
-
}
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
case 'button-bg':
|
|
170
|
-
this.btnEl.style.backgroundColor = newValue;
|
|
171
|
-
this.inputEl.style.borderColor = newValue;
|
|
172
|
-
return true;
|
|
173
|
-
case 'button-color':
|
|
174
|
-
this.btnEl.style.color = newValue;
|
|
175
|
-
return true;
|
|
176
|
-
case 'input-bg':
|
|
177
|
-
this.inputEl.style.backgroundColor = newValue;
|
|
178
|
-
return true;
|
|
179
|
-
case 'input-color':
|
|
180
|
-
this.inputEl.style.color = newValue;
|
|
181
|
-
return true;
|
|
182
|
-
default:
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
get specUrl() {
|
|
189
|
-
return this.getAttribute('spec-url');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
set specUrl(newSpecUrl) {
|
|
193
|
-
this.setAttribute('spec-url', newSpecUrl);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
onChangeInput(e) {
|
|
197
|
-
this.specUrl = e.target.value;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
onKeyUp(e) {
|
|
201
|
-
if (e.keyCode === 13) {
|
|
202
|
-
// In case of input keyup - first change event will fire which will set the new specUrl URL
|
|
203
|
-
this.generatePdf();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
generatePdf(jsonObj) {
|
|
208
|
-
const pdfSortTags = this.getAttribute('pdf-sort-tags') !== 'false';
|
|
209
|
-
const pdfPrimaryColor = this.getAttribute('pdf-primary-color');
|
|
210
|
-
const pdfAlternateColor = this.getAttribute('pdf-alternate-color');
|
|
211
|
-
const pdfTitle = this.getAttribute('pdf-title') === null ? 'API Reference' : this.getAttribute('pdf-title');
|
|
212
|
-
const pdfCoverText = this.getAttribute('pdf-cover-text') ? this.getAttribute('pdf-cover-text') : '';
|
|
213
|
-
const pdfSecurityText = this.getAttribute('pdf-security-text') ? this.getAttribute('pdf-security-text') : '';
|
|
214
|
-
const pdfApiText = this.getAttribute('pdf-api-text') ? this.getAttribute('pdf-api-text') : '';
|
|
215
|
-
const pdfSchemaStyle = this.getAttribute('pdf-schema-style') === 'table' ? 'table' : 'object';
|
|
216
|
-
const pdfFooterText = this.getAttribute('pdf-footer-text') ? this.getAttribute('pdf-footer-text') : '';
|
|
217
|
-
const includeInfo = this.getAttribute('include-info') !== 'false';
|
|
218
|
-
const includeToc = this.getAttribute('include-toc') !== 'false';
|
|
219
|
-
const includeSecurity = this.getAttribute('include-security') !== 'false';
|
|
220
|
-
const includeExample = this.getAttribute('include-example') === 'true';
|
|
221
|
-
const includeApiDetails = this.getAttribute('include-api-details') !== 'false';
|
|
222
|
-
const includeApiList = this.getAttribute('include-api-list') === 'true';
|
|
223
|
-
|
|
224
|
-
const localize = this.localize;
|
|
225
|
-
const options = {
|
|
226
|
-
pdfSortTags,
|
|
227
|
-
pdfPrimaryColor,
|
|
228
|
-
pdfAlternateColor,
|
|
229
|
-
pdfTitle,
|
|
230
|
-
pdfCoverText,
|
|
231
|
-
pdfSecurityText,
|
|
232
|
-
pdfApiText,
|
|
233
|
-
pdfSchemaStyle,
|
|
234
|
-
pdfFooterText,
|
|
235
|
-
includeInfo,
|
|
236
|
-
includeToc,
|
|
237
|
-
includeSecurity,
|
|
238
|
-
includeExample,
|
|
239
|
-
includeApiDetails,
|
|
240
|
-
includeApiList,
|
|
241
|
-
localize,
|
|
242
|
-
};
|
|
243
|
-
const spec = this.specUrl || jsonObj;
|
|
244
|
-
createPdf(spec, options);
|
|
245
|
-
}
|
|
246
|
-
});
|
package/src/spec-parser.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
// import JsonRefs from 'json-refs';
|
|
2
|
-
import Swagger from 'swagger-client';
|
|
3
|
-
import converter from 'swagger2openapi';
|
|
4
|
-
|
|
5
|
-
export default async function ProcessSpec(specUrl, sortTags) {
|
|
6
|
-
let jsonParsedSpec;
|
|
7
|
-
let convertedSpec;
|
|
8
|
-
const convertOptions = { patch: true, warnOnly: true };
|
|
9
|
-
try {
|
|
10
|
-
let specObj;
|
|
11
|
-
if (typeof specUrl === 'string') {
|
|
12
|
-
specObj = await Swagger(specUrl);
|
|
13
|
-
} else {
|
|
14
|
-
specObj = { spec: specUrl };
|
|
15
|
-
}
|
|
16
|
-
jsonParsedSpec = specObj.spec;
|
|
17
|
-
if (specObj.spec.swagger) {
|
|
18
|
-
convertedSpec = await converter.convertObj(specObj.spec, convertOptions);
|
|
19
|
-
jsonParsedSpec = convertedSpec.openapi;
|
|
20
|
-
}
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err); // eslint-disable-line no-console
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
let resolvedRefSpec;
|
|
27
|
-
const resolveOptions = { resolveCirculars: false };
|
|
28
|
-
try {
|
|
29
|
-
if (typeof specUrl === 'string') {
|
|
30
|
-
convertedSpec = await converter.convertUrl(specUrl, convertOptions);
|
|
31
|
-
} else {
|
|
32
|
-
convertedSpec = await converter.convertObj(specUrl, convertOptions);
|
|
33
|
-
}
|
|
34
|
-
resolvedRefSpec = await JsonRefs.resolveRefs(convertedSpec.openapi, resolveOptions);
|
|
35
|
-
jsonParsedSpec = resolvedRefSpec.resolved;
|
|
36
|
-
} catch (err) {
|
|
37
|
-
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err); // eslint-disable-line no-console
|
|
38
|
-
}
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
const openApiSpec = jsonParsedSpec;
|
|
42
|
-
const methods = ['get', 'put', 'post', 'delete', 'patch', 'options', 'head'];
|
|
43
|
-
const tags = [];
|
|
44
|
-
let totalPathCount = 0;
|
|
45
|
-
// For each path find the tag and push it into the corrosponding tag
|
|
46
|
-
for (const path in openApiSpec.paths) {
|
|
47
|
-
const commonParams = openApiSpec.paths[path].parameters;
|
|
48
|
-
const commonPathProp = {
|
|
49
|
-
summary: openApiSpec.paths[path].summary,
|
|
50
|
-
description: openApiSpec.paths[path].description,
|
|
51
|
-
servers: openApiSpec.paths[path].servers ? openApiSpec.paths[path].servers : [],
|
|
52
|
-
parameters: openApiSpec.paths[path].parameters ? openApiSpec.paths[path].parameters : [],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
methods.forEach((methodName) => {
|
|
56
|
-
let tagObj;
|
|
57
|
-
let tagText;
|
|
58
|
-
let tagDescr;
|
|
59
|
-
|
|
60
|
-
if (openApiSpec.paths[path][methodName]) {
|
|
61
|
-
const fullPath = openApiSpec.paths[path][methodName];
|
|
62
|
-
// If path.methods are tagged, else generate it from path
|
|
63
|
-
if (fullPath.tags) {
|
|
64
|
-
tagText = fullPath.tags[0];
|
|
65
|
-
if (openApiSpec.tags) {
|
|
66
|
-
tagDescr = openApiSpec.tags.find((v) => (v.name === tagText));
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
let firstWordEndIndex = path.indexOf('/', 1);
|
|
70
|
-
if (firstWordEndIndex === -1) {
|
|
71
|
-
firstWordEndIndex = (path.length - 1);
|
|
72
|
-
} else {
|
|
73
|
-
firstWordEndIndex -= 1;
|
|
74
|
-
}
|
|
75
|
-
tagText = path.substr(1, firstWordEndIndex);
|
|
76
|
-
}
|
|
77
|
-
tagObj = tags.find((v) => v.name === tagText);
|
|
78
|
-
|
|
79
|
-
if (!tagObj) {
|
|
80
|
-
tagObj = {
|
|
81
|
-
name: tagText,
|
|
82
|
-
description: tagDescr ? tagDescr.description : '',
|
|
83
|
-
paths: [],
|
|
84
|
-
};
|
|
85
|
-
tags.push(tagObj);
|
|
86
|
-
}
|
|
87
|
-
// Generate Path summary and Description if it is missing for a method
|
|
88
|
-
let summary = fullPath.summary ? fullPath.summary : '';
|
|
89
|
-
const description = fullPath.description ? fullPath.description : '';
|
|
90
|
-
if (!summary && description) {
|
|
91
|
-
if (description.length > 100) {
|
|
92
|
-
let charIndex = -1;
|
|
93
|
-
charIndex = description.indexOf('\n');
|
|
94
|
-
if (charIndex === -1 || charIndex > 100) {
|
|
95
|
-
charIndex = description.indexOf('. ');
|
|
96
|
-
}
|
|
97
|
-
if (charIndex === -1 || charIndex > 100) {
|
|
98
|
-
charIndex = description.indexOf('.');
|
|
99
|
-
}
|
|
100
|
-
if (charIndex === -1 || charIndex > 100) {
|
|
101
|
-
summary = description;
|
|
102
|
-
} else {
|
|
103
|
-
summary = description.substr(0, charIndex);
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
summary = description;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Merge Common Parameters with This methods parameters
|
|
111
|
-
let finalParameters = [];
|
|
112
|
-
if (commonParams) {
|
|
113
|
-
if (fullPath.parameters) {
|
|
114
|
-
finalParameters = commonParams.filter((commonParam) => {
|
|
115
|
-
if (!fullPath.parameters.some((param) => (commonParam.name === param.name && commonParam.in === param.in))) {
|
|
116
|
-
return commonParam;
|
|
117
|
-
}
|
|
118
|
-
}).concat(fullPath.parameters);
|
|
119
|
-
} else {
|
|
120
|
-
finalParameters = commonParams.slice(0);
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
finalParameters = fullPath.parameters ? fullPath.parameters.slice(0) : [];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Update Responses
|
|
127
|
-
tagObj.paths.push({
|
|
128
|
-
summary,
|
|
129
|
-
method: methodName,
|
|
130
|
-
description: fullPath.description,
|
|
131
|
-
path,
|
|
132
|
-
operationId: fullPath.operationId,
|
|
133
|
-
requestBody: fullPath.requestBody,
|
|
134
|
-
parameters: finalParameters,
|
|
135
|
-
servers: fullPath.servers ? commonPathProp.servers.concat(fullPath.servers) : commonPathProp.servers,
|
|
136
|
-
responses: fullPath.responses,
|
|
137
|
-
deprecated: fullPath.deprecated,
|
|
138
|
-
security: fullPath.security,
|
|
139
|
-
commonSummary: commonPathProp.summary,
|
|
140
|
-
commonDescription: commonPathProp.description,
|
|
141
|
-
});
|
|
142
|
-
totalPathCount++;
|
|
143
|
-
}
|
|
144
|
-
}); // End of Methods
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
let securitySchemes = {};
|
|
148
|
-
|
|
149
|
-
securitySchemes = (openApiSpec.components ? openApiSpec.components.securitySchemes : {});
|
|
150
|
-
if (sortTags) {
|
|
151
|
-
tags.sort((a, b) => (a.name < b.name ? -1 : (a.name > b.name ? 1 : 0)));
|
|
152
|
-
}
|
|
153
|
-
const parsedSpec = {
|
|
154
|
-
info: openApiSpec.info,
|
|
155
|
-
tags,
|
|
156
|
-
externalDocs: openApiSpec.externalDocs,
|
|
157
|
-
securitySchemes,
|
|
158
|
-
basePath: openApiSpec.basePath, // Only available in swagger V2
|
|
159
|
-
totalPathCount,
|
|
160
|
-
};
|
|
161
|
-
return parsedSpec;
|
|
162
|
-
}
|
package/src/table-layouts.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
export const rowLinesTableLayout = {
|
|
3
|
-
hLineWidth(i, node) {
|
|
4
|
-
return (i === 1 || i === node.table.body.length) ? 1 : 0.5;
|
|
5
|
-
},
|
|
6
|
-
vLineWidth() {
|
|
7
|
-
return 0;
|
|
8
|
-
},
|
|
9
|
-
hLineColor(i, node) {
|
|
10
|
-
return (i === 0 || i === 1 || i === node.table.body.length) ? '#777' : 'lightgray';
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const indentGuideLayout = {
|
|
15
|
-
hLineWidth() {
|
|
16
|
-
return 0;
|
|
17
|
-
},
|
|
18
|
-
hLineColor(i, node) {
|
|
19
|
-
return (i === 0 || i === node.table.body.length) ? 'black' : 'lightgray';
|
|
20
|
-
},
|
|
21
|
-
vLineWidth(i, node) {
|
|
22
|
-
return (i === 0 && node.table.body.length > 3) ? 1 : 0;
|
|
23
|
-
},
|
|
24
|
-
vLineColor() { return '#F9EBEA'; },
|
|
25
|
-
paddingTop() { return 0; },
|
|
26
|
-
paddingBottom() { return 0; },
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const noBorderLayout = {
|
|
30
|
-
defaultBorder: false,
|
|
31
|
-
hLineWidth() { return 0; },
|
|
32
|
-
vLineWidth() { return 0; },
|
|
33
|
-
paddingTop() { return 0; },
|
|
34
|
-
paddingBottom() { return 0; },
|
|
35
|
-
};
|