rapidoc 9.3.8 → 10.0.1

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.
Files changed (69) hide show
  1. package/README.md +193 -61
  2. package/dist/rapidoc-min.js +279 -3914
  3. package/package.json +23 -46
  4. package/.babelrc.json +0 -42
  5. package/.eslintrc +0 -53
  6. package/.github/FUNDING.yml +0 -13
  7. package/.github/workflow/words.yaml +0 -22
  8. package/CONTRIBUTING.md +0 -35
  9. package/dist/index.html +0 -1010
  10. package/dist/index.html.gz +0 -0
  11. package/dist/rapidoc-min.js.LICENSE.txt +0 -64
  12. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  13. package/dist/rapidoc-min.js.gz +0 -0
  14. package/dist/rapidoc-min.js.map +0 -1
  15. package/dist/rapidoc-min.js.map.gz +0 -0
  16. package/dist/rapidoc.js +0 -21603
  17. package/dist/report.html +0 -39
  18. package/index-hashroute.html +0 -65
  19. package/index.html +0 -1045
  20. package/index_bak.html +0 -251
  21. package/jsconfig.json +0 -11
  22. package/logo.png +0 -0
  23. package/performance.html +0 -31
  24. package/src/components/api-request.js +0 -1793
  25. package/src/components/api-response.js +0 -335
  26. package/src/components/dialog-box.js +0 -73
  27. package/src/components/json-tree.js +0 -145
  28. package/src/components/schema-table.js +0 -367
  29. package/src/components/schema-tree.js +0 -381
  30. package/src/components/tag-input.js +0 -135
  31. package/src/index.js +0 -7
  32. package/src/json-schema-viewer.js +0 -346
  33. package/src/oauth-receiver.js +0 -56
  34. package/src/rapidoc-mini.js +0 -382
  35. package/src/rapidoc.js +0 -1083
  36. package/src/styles/border-styles.js +0 -24
  37. package/src/styles/custom-styles.js +0 -10
  38. package/src/styles/dialog-box-styles.js +0 -75
  39. package/src/styles/endpoint-styles.js +0 -202
  40. package/src/styles/flex-styles.js +0 -15
  41. package/src/styles/font-styles.js +0 -268
  42. package/src/styles/info-styles.js +0 -21
  43. package/src/styles/input-styles.js +0 -207
  44. package/src/styles/nav-styles.js +0 -198
  45. package/src/styles/prism-styles.js +0 -105
  46. package/src/styles/schema-styles.js +0 -121
  47. package/src/styles/tab-styles.js +0 -47
  48. package/src/styles/table-styles.js +0 -58
  49. package/src/templates/advance-search-template.js +0 -72
  50. package/src/templates/callback-template.js +0 -75
  51. package/src/templates/code-samples-template.js +0 -34
  52. package/src/templates/components-template.js +0 -76
  53. package/src/templates/endpoint-template.js +0 -251
  54. package/src/templates/expanded-endpoint-template.js +0 -199
  55. package/src/templates/focused-endpoint-template.js +0 -110
  56. package/src/templates/header-template.js +0 -66
  57. package/src/templates/json-schema-viewer-template.js +0 -185
  58. package/src/templates/logo-template.js +0 -18
  59. package/src/templates/main-body-template.js +0 -110
  60. package/src/templates/navbar-template.js +0 -272
  61. package/src/templates/overview-template.js +0 -79
  62. package/src/templates/security-scheme-template.js +0 -612
  63. package/src/templates/server-template.js +0 -115
  64. package/src/utils/color-utils.js +0 -59
  65. package/src/utils/common-utils.js +0 -168
  66. package/src/utils/schema-utils.js +0 -1086
  67. package/src/utils/spec-parser.js +0 -462
  68. package/src/utils/theme.js +0 -288
  69. package/webpack.config.js +0 -142
@@ -1,346 +0,0 @@
1
- import { css, LitElement } from 'lit';
2
- import { marked } from 'marked';
3
- import Prism from 'prismjs';
4
- import 'prismjs/components/prism-css';
5
- import 'prismjs/components/prism-yaml';
6
- import 'prismjs/components/prism-go';
7
- import 'prismjs/components/prism-java';
8
- import 'prismjs/components/prism-json';
9
- import 'prismjs/components/prism-bash';
10
- import 'prismjs/components/prism-python';
11
- import 'prismjs/components/prism-http';
12
- import 'prismjs/components/prism-csharp';
13
-
14
- // Styles
15
- import FontStyles from '~/styles/font-styles';
16
- import InputStyles from '~/styles/input-styles';
17
- import FlexStyles from '~/styles/flex-styles';
18
- import TableStyles from '~/styles/table-styles';
19
- import PrismStyles from '~/styles/prism-styles';
20
- import TabStyles from '~/styles/tab-styles';
21
- import NavStyles from '~/styles/nav-styles';
22
- import InfoStyles from '~/styles/info-styles';
23
-
24
- import EndpointStyles from '~/styles/endpoint-styles';
25
- import ProcessSpec from '~/utils/spec-parser';
26
- import jsonSchemaViewerTemplate from '~/templates/json-schema-viewer-template';
27
-
28
- export default class JsonSchemaViewer extends LitElement {
29
- constructor() {
30
- super();
31
- this.isMini = false;
32
- this.updateRoute = 'false';
33
- this.renderStyle = 'focused';
34
- this.showHeader = 'true';
35
- this.allowAdvancedSearch = 'false';
36
- this.selectedExampleForEachSchema = {};
37
- }
38
-
39
- static get properties() {
40
- return {
41
- // Spec
42
- specUrl: { type: String, attribute: 'spec-url' },
43
-
44
- // Schema Styles
45
- schemaStyle: { type: String, attribute: 'schema-style' },
46
- schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
47
- schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
48
- allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
49
-
50
- // Hide/show Sections
51
- showHeader: { type: String, attribute: 'show-header' },
52
- showSideNav: { type: String, attribute: 'show-side-nav' },
53
- showInfo: { type: String, attribute: 'show-info' },
54
-
55
- // Allow or restrict features
56
- allowSpecUrlLoad: { type: String, attribute: 'allow-spec-url-load' },
57
- allowSpecFileLoad: { type: String, attribute: 'allow-spec-file-load' },
58
- allowSpecFileDownload: { type: String, attribute: 'allow-spec-file-download' },
59
- allowSearch: { type: String, attribute: 'allow-search' },
60
-
61
- // Main Colors and Font
62
- theme: { type: String },
63
- bgColor: { type: String, attribute: 'bg-color' },
64
- textColor: { type: String, attribute: 'text-color' },
65
- primaryColor: { type: String, attribute: 'primary-color' },
66
- fontSize: { type: String, attribute: 'font-size' },
67
- regularFont: { type: String, attribute: 'regular-font' },
68
- monoFont: { type: String, attribute: 'mono-font' },
69
- loadFonts: { type: String, attribute: 'load-fonts' },
70
-
71
- // Internal Properties
72
- loading: { type: Boolean }, // indicates spec is being loaded
73
- };
74
- }
75
-
76
- static get styles() {
77
- return [
78
- FontStyles,
79
- InputStyles,
80
- FlexStyles,
81
- TableStyles,
82
- EndpointStyles,
83
- PrismStyles,
84
- TabStyles,
85
- NavStyles,
86
- InfoStyles,
87
- css`
88
- :host {
89
- all: initial;
90
- display:flex;
91
- flex-direction: column;
92
- min-width:360px;
93
- width:100%;
94
- height:100%;
95
- margin:0;
96
- padding:0;
97
- overflow: hidden;
98
- letter-spacing:normal;
99
- color:var(--fg);
100
- background-color:var(--bg);
101
- font-family:var(--font-regular);
102
- container-type: inline-size;
103
- }
104
- .body {
105
- display:flex;
106
- height:100%;
107
- width:100%;
108
- overflow:hidden;
109
- }
110
- .nav-bar {
111
- width: 230px;
112
- display:flex;
113
- }
114
-
115
- .main-content {
116
- margin:0;
117
- padding: 16px;
118
- display:block;
119
- flex:1;
120
- height:100%;
121
- overflow-y: auto;
122
- overflow-x: hidden;
123
- scrollbar-width: thin;
124
- scrollbar-color: var(--border-color) transparent;
125
- }
126
- .main-content-inner--view-mode {
127
- padding: 0 8px;
128
- }
129
- .main-content::-webkit-scrollbar {
130
- width: 8px;
131
- height: 8px;
132
- }
133
- .main-content::-webkit-scrollbar-track {
134
- background:transparent;
135
- }
136
- .main-content::-webkit-scrollbar-thumb {
137
- background-color: var(--border-color);
138
- }
139
- .main-header {
140
- background-color:var(--header-bg);
141
- color:var(--header-fg);
142
- width:100%;
143
- }
144
- .header-title {
145
- font-size:calc(var(--font-size-regular) + 8px);
146
- padding:0 8px;
147
- }
148
- input.header-input{
149
- background:var(--header-color-darker);
150
- color:var(--header-fg);
151
- border:1px solid var(--header-color-border);
152
- flex:1;
153
- padding-right:24px;
154
- border-radius:3px;
155
- }
156
- input.header-input::placeholder {
157
- opacity:0.4;
158
- }
159
- .loader {
160
- margin: 16px auto 16px auto;
161
- border: 4px solid var(--bg3);
162
- border-radius: 50%;
163
- border-top: 4px solid var(--primary-color);
164
- width: 36px;
165
- height: 36px;
166
- animation: spin 2s linear infinite;
167
- }
168
- @container (min-width: 768px) {
169
- .only-large-screen{
170
- display:block;
171
- }
172
- .only-large-screen-flex {
173
- display:flex;
174
- }
175
- }`,
176
- ];
177
- }
178
-
179
- // Startup
180
- connectedCallback() {
181
- super.connectedCallback();
182
- const parent = this.parentElement;
183
- if (parent) {
184
- if (parent.offsetWidth === 0 && parent.style.width === '') {
185
- parent.style.width = '100vw';
186
- }
187
- if (parent.offsetHeight === 0 && parent.style.height === '') {
188
- parent.style.height = '100vh';
189
- }
190
- if (parent.tagName === 'BODY') {
191
- if (!parent.style.marginTop) { parent.style.marginTop = '0'; }
192
- if (!parent.style.marginRight) { parent.style.marginRight = '0'; }
193
- if (!parent.style.marginBottom) { parent.style.marginBottom = '0'; }
194
- if (!parent.style.marginLeft) { parent.style.marginLeft = '0'; }
195
- }
196
- }
197
-
198
- if (this.loadFonts !== 'false') {
199
- const fontDescriptor = {
200
- family: 'Open Sans',
201
- style: 'normal',
202
- weight: '300',
203
- unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
204
- };
205
- const fontWeight300 = new FontFace(
206
- 'Open Sans',
207
- "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UN_r8OUuhpKKSTjw.woff2) format('woff2')",
208
- fontDescriptor,
209
- );
210
- fontDescriptor.weight = '600';
211
- const fontWeight600 = new FontFace(
212
- 'Open Sans',
213
- "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2) format('woff2')",
214
- fontDescriptor,
215
- );
216
- fontWeight300.load().then((font) => { document.fonts.add(font); });
217
- fontWeight600.load().then((font) => { document.fonts.add(font); });
218
- }
219
-
220
- this.renderStyle = 'focused';
221
- this.pathsExpanded = this.pathsExpanded === 'true';
222
-
223
- if (!this.showInfo || !'true, false,'.includes(`${this.showInfo},`)) { this.showInfo = 'true'; }
224
- if (!this.showSideNav || !'true false'.includes(this.showSideNav)) { this.showSideNav = 'true'; }
225
- if (!this.showHeader || !'true, false,'.includes(`${this.showHeader},`)) { this.showHeader = 'true'; }
226
-
227
- if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) { this.schemaStyle = 'tree'; }
228
- if (!this.theme || !'light, dark,'.includes(`${this.theme},`)) {
229
- this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
230
- }
231
- if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
232
- if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
233
- if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
234
- if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
235
- if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
236
- if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
237
-
238
- marked.setOptions({
239
- highlight: (code, lang) => {
240
- if (Prism.languages[lang]) {
241
- return Prism.highlight(code, Prism.languages[lang], lang);
242
- }
243
- return code;
244
- },
245
- });
246
- }
247
-
248
- render() {
249
- return jsonSchemaViewerTemplate.call(this, true, false, false, this.pathsExpanded);
250
- }
251
-
252
- attributeChangedCallback(name, oldVal, newVal) {
253
- if (name === 'spec-url') {
254
- if (oldVal !== newVal) {
255
- // put it at the end of event-loop to load all the attributes
256
- window.setTimeout(async () => {
257
- await this.loadSpec(newVal);
258
- }, 0);
259
- }
260
- }
261
- super.attributeChangedCallback(name, oldVal, newVal);
262
- }
263
-
264
- onSpecUrlChange() {
265
- this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
266
- }
267
-
268
- onSearchChange(e) {
269
- // Todo: Filter Search
270
- this.matchPaths = e.target.value;
271
- }
272
-
273
- // Public Method
274
- async loadSpec(specUrl) {
275
- if (!specUrl) {
276
- return;
277
- }
278
- try {
279
- this.resolvedSpec = {
280
- specLoadError: false,
281
- isSpecLoading: true,
282
- tags: [],
283
- };
284
- this.loading = true;
285
- this.loadFailed = false;
286
- this.requestUpdate();
287
- const spec = await ProcessSpec.call(
288
- this,
289
- specUrl,
290
- this.generateMissingTags === 'true',
291
- this.sortTags === 'true',
292
- this.sortSchemas === 'true',
293
- this.getAttribute('sort-endpoints-by'),
294
- this.getAttribute('match-paths'),
295
- this.getAttribute('match-type'),
296
- this.getAttribute('remove-endpoints-with-badge-label-as'),
297
- );
298
- this.loading = false;
299
- this.afterSpecParsedAndValidated(spec);
300
- } catch (err) {
301
- this.loading = false;
302
- this.loadFailed = true;
303
- this.resolvedSpec = null;
304
- console.error(`RapiDoc: Unable to resolve the API spec.. ${err.message}`); // eslint-disable-line no-console
305
- }
306
- }
307
-
308
- async afterSpecParsedAndValidated(spec) {
309
- this.resolvedSpec = spec;
310
- const specLoadedEvent = new CustomEvent('spec-loaded', { detail: spec });
311
- this.dispatchEvent(specLoadedEvent);
312
- }
313
-
314
- // Called by anchor tags created using markdown
315
- handleHref(e) {
316
- if (e.target.tagName.toLowerCase() === 'a') {
317
- if (e.target.getAttribute('href').startsWith('#')) {
318
- const gotoEl = this.shadowRoot.getElementById(e.target.getAttribute('href').replace('#', ''));
319
- if (gotoEl) {
320
- gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
321
- }
322
- }
323
- }
324
- }
325
-
326
- // Example Dropdown @change Handler
327
- onSelectExample(e) {
328
- const exampleContainerEl = e.target.closest('.json-schema-example-panel');
329
- const exampleEls = [...exampleContainerEl.querySelectorAll('.example')];
330
- exampleEls.forEach((v) => {
331
- v.style.display = v.dataset.example === e.target.value ? 'flex' : 'none';
332
- });
333
- }
334
-
335
- async scrollToEventTarget(event) {
336
- const navEl = event.currentTarget;
337
- if (!navEl.dataset.contentId) {
338
- return;
339
- }
340
- const contentEl = this.shadowRoot.getElementById(navEl.dataset.contentId);
341
- if (contentEl) {
342
- contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
343
- }
344
- }
345
- }
346
- customElements.define('json-schema-viewer', JsonSchemaViewer);
@@ -1,56 +0,0 @@
1
- export default class OauthReceiver extends HTMLElement {
2
- connectedCallback() {
3
- this.receiveAuthParms();
4
- window.addEventListener('storage', (e) => this.receiveStorage(e), true);
5
- }
6
-
7
- /**
8
- * Read OAuth2 parameters and sends them off
9
- * to the window opener through `window.postMessage`.
10
- */
11
- receiveAuthParms() {
12
- let authData = {};
13
- if (document.location.search) { // Applies to authorizationCode flow
14
- const params = new URLSearchParams(document.location.search);
15
- const code = params.get('code');
16
- const error = params.get('error');
17
- const state = params.get('state');
18
- authData = {
19
- code,
20
- error,
21
- state,
22
- responseType: 'code',
23
- };
24
- } else if (window.location.hash) { // Applies to Implicit flow
25
- const token_type = this.parseQueryString(window.location.hash.substring(1), 'token_type'); // eslint-disable-line camelcase
26
- const access_token = this.parseQueryString(window.location.hash.substring(1), 'access_token'); // eslint-disable-line camelcase
27
- authData = { token_type, access_token, responseType: 'token' }; // eslint-disable-line camelcase
28
- }
29
-
30
- if (window.opener) {
31
- window.opener.postMessage(authData, this.target);
32
- return;
33
- }
34
- sessionStorage.setItem('rapidoc-oauth-data', JSON.stringify(authData)); // Fallback to session storage if window.opener dont exist
35
- }
36
-
37
- relayAuthParams(e) {
38
- if (window.parent) {
39
- if (e.key === 'rapidoc-oauth-data') {
40
- const authData = JSON.parse(e.newValue);
41
- window.parent.postMessage(authData, this.target);
42
- }
43
- }
44
- }
45
-
46
- parseQueryString(queryString, key) {
47
- const vars = queryString.split('&');
48
- for (let i = 0; i < vars.length; i++) {
49
- const pair = vars[i].split('=');
50
- if (decodeURIComponent(pair[0]) === key) {
51
- return decodeURIComponent(pair[1]);
52
- }
53
- }
54
- }
55
- }
56
- customElements.define('oauth-receiver', OauthReceiver);