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,382 +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 { rapidocApiKey } from '~/utils/common-utils';
26
- import ProcessSpec from '~/utils/spec-parser';
27
- import mainBodyTemplate from '~/templates/main-body-template';
28
- import { applyApiKey, onClearAllApiKeys } from '~/templates/security-scheme-template';
29
- import { setApiServer } from '~/templates/server-template';
30
-
31
- export default class RapiDocMini extends LitElement {
32
- constructor() {
33
- super();
34
- this.isMini = true;
35
- this.updateRoute = 'false';
36
- this.renderStyle = 'view';
37
- this.showHeader = 'false';
38
- this.allowAdvancedSearch = 'false';
39
- }
40
-
41
- static get properties() {
42
- return {
43
- // Spec
44
- specUrl: { type: String, attribute: 'spec-url' },
45
- sortEndpointsBy: { type: String, attribute: 'sort-endpoints-by' },
46
-
47
- // UI Layouts
48
- layout: { type: String },
49
- pathsExpanded: { type: String, attribute: 'paths-expanded' },
50
- defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
51
- responseAreaHeight: { type: String, attribute: 'response-area-height' },
52
- showSummaryWhenCollapsed: { type: String, attribute: 'show-summary-when-collapsed' },
53
- fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
54
- persistAuth: { type: String, attribute: 'persist-auth' },
55
-
56
- // Schema Styles
57
- schemaStyle: { type: String, attribute: 'schema-style' },
58
- schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
59
- schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
60
-
61
- // API Server
62
- apiKeyName: { type: String, attribute: 'api-key-name' },
63
- apiKeyLocation: { type: String, attribute: 'api-key-location' },
64
- apiKeyValue: { type: String, attribute: 'api-key-value' },
65
- defaultApiServerUrl: { type: String, attribute: 'default-api-server' },
66
- serverUrl: { type: String, attribute: 'server-url' },
67
- oauthReceiver: { type: String, attribute: 'oauth-receiver' },
68
-
69
- allowTry: { type: String, attribute: 'allow-try' },
70
- showCurlBeforeTry: { type: String, attribute: 'show-curl-before-try' },
71
-
72
- // Main Colors and Font
73
- theme: { type: String },
74
- bgColor: { type: String, attribute: 'bg-color' },
75
- textColor: { type: String, attribute: 'text-color' },
76
- primaryColor: { type: String, attribute: 'primary-color' },
77
- fontSize: { type: String, attribute: 'font-size' },
78
- regularFont: { type: String, attribute: 'regular-font' },
79
- monoFont: { type: String, attribute: 'mono-font' },
80
- loadFonts: { type: String, attribute: 'load-fonts' },
81
-
82
- // Fetch Options
83
- fetchCredentials: { type: String, attribute: 'fetch-credentials' },
84
-
85
- // Filters
86
- matchPaths: { type: String, attribute: 'match-paths' },
87
- matchType: { type: String, attribute: 'match-type' },
88
- removeEndpointsWithBadgeLabelAs: { type: String, attribute: 'remove-endpoints-with-badge-label-as' },
89
-
90
- // Internal Properties
91
- loading: { type: Boolean }, // indicates spec is being loaded
92
- };
93
- }
94
-
95
- static get styles() {
96
- return [
97
- FontStyles,
98
- InputStyles,
99
- FlexStyles,
100
- TableStyles,
101
- EndpointStyles,
102
- PrismStyles,
103
- TabStyles,
104
- NavStyles,
105
- InfoStyles,
106
- css`
107
- :host {
108
- all: initial;
109
- display:flex;
110
- flex-direction: column;
111
- min-width:360px;
112
- width:100%;
113
- height:100%;
114
- margin:0;
115
- padding:0;
116
- overflow: hidden;
117
- letter-spacing:normal;
118
- color:var(--fg);
119
- background-color:var(--bg);
120
- font-family:var(--font-regular);
121
- container-type: inline-size;
122
- }
123
-
124
- @container (min-width: 768px) {
125
- .only-large-screen {
126
- display:block;
127
- }
128
- .only-large-screen-flex {
129
- display:flex;
130
- }
131
- }`,
132
- ];
133
- }
134
-
135
- // Startup
136
- connectedCallback() {
137
- super.connectedCallback();
138
-
139
- if (this.loadFonts !== 'false') {
140
- const fontDescriptor = {
141
- family: 'Open Sans',
142
- style: 'normal',
143
- weight: '300',
144
- 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',
145
- };
146
- const fontWeight300 = new FontFace(
147
- 'Open Sans',
148
- "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UN_r8OUuhpKKSTjw.woff2) format('woff2')",
149
- fontDescriptor,
150
- );
151
- fontDescriptor.weight = '600';
152
- const fontWeight600 = new FontFace(
153
- 'Open Sans',
154
- "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2) format('woff2')",
155
- fontDescriptor,
156
- );
157
- fontWeight300.load().then((font) => { document.fonts.add(font); });
158
- fontWeight600.load().then((font) => { document.fonts.add(font); });
159
- }
160
-
161
- if (!this.showSummaryWhenCollapsed || !'true, false,'.includes(`${this.showSummaryWhenCollapsed},`)) { this.showSummaryWhenCollapsed = 'true'; }
162
- if (!this.layout || !'row, column,'.includes(`${this.layout},`)) { this.layout = 'row'; }
163
- if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) { this.schemaStyle = 'tree'; }
164
- if (!this.theme || !'light, dark,'.includes(`${this.theme},`)) {
165
- this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
166
- }
167
- if (!this.defaultSchemaTab || !'example, schema, model,'.includes(`${this.defaultSchemaTab},`)) {
168
- this.defaultSchemaTab = 'example';
169
- } else if (this.defaultSchemaTab === 'model') {
170
- this.defaultSchemaTab = 'schema';
171
- }
172
- this.pathsExpanded = this.pathsExpanded === 'true';
173
- if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
174
- if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
175
- if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
176
- if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
177
- if (!this.responseAreaHeight) { this.responseAreaHeight = '300px'; }
178
-
179
- if (!this.allowTry || !'true, false,'.includes(`${this.allowTry},`)) { this.allowTry = 'true'; }
180
- if (!this.apiKeyValue) { this.apiKeyValue = '-'; }
181
- if (!this.apiKeyLocation) { this.apiKeyLocation = 'header'; }
182
- if (!this.apiKeyName) { this.apiKeyName = ''; }
183
-
184
- if (!this.oauthReceiver) { this.oauthReceiver = 'oauth-receiver.html'; }
185
- if (!this.sortTags || !'true, false,'.includes(`${this.sortTags},`)) { this.sortTags = 'false'; }
186
- if (!this.sortEndpointsBy || !'method, path, summary,'.includes(`${this.sortEndpointsBy},`)) { this.sortEndpointsBy = 'path'; }
187
- if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
188
-
189
- if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
190
- if (!this.matchPaths) { this.matchPaths = ''; }
191
- if (!this.removeEndpointsWithBadgeLabelAs) { this.removeEndpointsWithBadgeLabelAs = ''; }
192
-
193
- if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
194
- if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) { this.fetchCredentials = ''; }
195
-
196
- marked.setOptions({
197
- highlight: (code, lang) => {
198
- if (Prism.languages[lang]) {
199
- return Prism.highlight(code, Prism.languages[lang], lang);
200
- }
201
- return code;
202
- },
203
- });
204
- }
205
-
206
- render() {
207
- return mainBodyTemplate.call(this, true, this.pathsExpanded);
208
- }
209
-
210
- attributeChangedCallback(name, oldVal, newVal) {
211
- if (name === 'spec-url') {
212
- if (oldVal !== newVal) {
213
- // put it at the end of event-loop to load all the attributes
214
- window.setTimeout(async () => {
215
- await this.loadSpec(newVal);
216
- }, 0);
217
- }
218
- }
219
- if (name === 'match-paths' || name === 'match-type' || name === 'remove-endpoints-with-badge-label-as') {
220
- if (oldVal !== newVal) {
221
- window.setTimeout(async () => {
222
- await this.loadSpec(this.specUrl);
223
- }, 0);
224
- }
225
- }
226
- if (name === 'api-key-name' || name === 'api-key-location' || name === 'api-key-value') {
227
- let updateSelectedApiKey = false;
228
- let apiKeyName = '';
229
- let apiKeyLocation = '';
230
- let apiKeyValue = '';
231
-
232
- if (name === 'api-key-name') {
233
- if (this.getAttribute('api-key-location') && this.getAttribute('api-key-value')) {
234
- apiKeyName = newVal;
235
- apiKeyLocation = this.getAttribute('api-key-location');
236
- apiKeyValue = this.getAttribute('api-key-value');
237
- updateSelectedApiKey = true;
238
- }
239
- } else if (name === 'api-key-location') {
240
- if (this.getAttribute('api-key-name') && this.getAttribute('api-key-value')) {
241
- apiKeyLocation = newVal;
242
- apiKeyName = this.getAttribute('api-key-name');
243
- apiKeyValue = this.getAttribute('api-key-value');
244
- updateSelectedApiKey = true;
245
- }
246
- } else if (name === 'api-key-value') {
247
- if (this.getAttribute('api-key-name') && this.getAttribute('api-key-location')) {
248
- apiKeyValue = newVal;
249
- apiKeyLocation = this.getAttribute('api-key-location');
250
- apiKeyName = this.getAttribute('api-key-name');
251
- updateSelectedApiKey = true;
252
- }
253
- }
254
-
255
- if (updateSelectedApiKey) {
256
- if (this.resolvedSpec) {
257
- const rapiDocApiKey = this.resolvedSpec.securitySchemes.find((v) => v.securitySchemeId === rapidocApiKey);
258
- if (!rapiDocApiKey) {
259
- this.resolvedSpec.securitySchemes.push({
260
- apiKeyId: rapidocApiKey,
261
- description: 'api-key provided in rapidoc element attributes',
262
- type: 'apiKey',
263
- name: apiKeyName,
264
- in: apiKeyLocation,
265
- value: apiKeyValue,
266
- finalKeyValue: apiKeyValue,
267
- });
268
- } else {
269
- rapiDocApiKey.name = apiKeyName;
270
- rapiDocApiKey.in = apiKeyLocation;
271
- rapiDocApiKey.value = apiKeyValue;
272
- rapiDocApiKey.finalKeyValue = apiKeyValue;
273
- }
274
- this.requestUpdate();
275
- }
276
- }
277
- }
278
- super.attributeChangedCallback(name, oldVal, newVal);
279
- }
280
-
281
- onSpecUrlChange() {
282
- this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
283
- }
284
-
285
- // Public Method
286
- async loadSpec(specUrl) {
287
- if (!specUrl) {
288
- return;
289
- }
290
- try {
291
- this.resolvedSpec = {
292
- specLoadError: false,
293
- isSpecLoading: true,
294
- tags: [],
295
- };
296
- this.loading = true;
297
- this.loadFailed = false;
298
- this.requestUpdate();
299
- const spec = await ProcessSpec.call(
300
- this,
301
- specUrl,
302
- this.generateMissingTags === 'true',
303
- this.sortTags === 'true',
304
- this.sortSchemas === 'true',
305
- this.getAttribute('sort-endpoints-by'),
306
- this.getAttribute('api-key-name'),
307
- this.getAttribute('api-key-location'),
308
- this.getAttribute('api-key-value'),
309
- this.getAttribute('server-url'),
310
- this.matchPaths,
311
- this.matchType,
312
- this.removeEndpointsWithBadgeLabelAs,
313
- );
314
- this.loading = false;
315
- this.afterSpecParsedAndValidated(spec);
316
- } catch (err) {
317
- this.loading = false;
318
- this.loadFailed = true;
319
- this.resolvedSpec = null;
320
- console.error(`RapiDoc: Unable to resolve the API spec.. ${err.message}`); // eslint-disable-line no-console
321
- }
322
- }
323
-
324
- // Public Method - to update security-scheme of type http
325
- setHttpUserNameAndPassword(securitySchemeId, username, password) {
326
- return applyApiKey.call(this, securitySchemeId, username, password);
327
- }
328
-
329
- // Public Method - to update security-scheme of type apiKey or OAuth
330
- setApiKey(securitySchemeId, apiKeyValue) {
331
- return applyApiKey.call(this, securitySchemeId, '', '', apiKeyValue);
332
- }
333
-
334
- // Public Method
335
- removeAllSecurityKeys() {
336
- return onClearAllApiKeys.call(this);
337
- }
338
-
339
- // Public Method
340
- setApiServer(apiServerUrl) {
341
- // return apiServerUrl;
342
- return setApiServer.call(this, apiServerUrl);
343
- }
344
-
345
- async afterSpecParsedAndValidated(spec) {
346
- this.resolvedSpec = spec;
347
- this.selectedServer = undefined;
348
- if (this.defaultApiServerUrl) {
349
- if (this.defaultApiServerUrl === this.serverUrl) {
350
- this.selectedServer = {
351
- url: this.serverUrl,
352
- computedUrl: this.serverUrl,
353
- };
354
- } else if (this.resolvedSpec.servers) {
355
- this.selectedServer = this.resolvedSpec.servers.find((v) => (v.url === this.defaultApiServerUrl));
356
- }
357
- }
358
- if (!this.selectedServer) {
359
- if (this.resolvedSpec.servers) {
360
- this.selectedServer = this.resolvedSpec.servers[0]; // eslint-disable-line prefer-destructuring
361
- }
362
- }
363
- this.requestUpdate();
364
- // eslint-disable-next-line no-await-in-loop
365
- while (!await this.updateComplete);
366
- const specLoadedEvent = new CustomEvent('spec-loaded', { detail: spec });
367
- this.dispatchEvent(specLoadedEvent);
368
- }
369
-
370
- // Called by anchor tags created using markdown
371
- handleHref(e) {
372
- if (e.target.tagName.toLowerCase() === 'a') {
373
- if (e.target.getAttribute('href').startsWith('#')) {
374
- const gotoEl = this.shadowRoot.getElementById(e.target.getAttribute('href').replace('#', ''));
375
- if (gotoEl) {
376
- gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
377
- }
378
- }
379
- }
380
- }
381
- }
382
- customElements.define('rapi-doc-mini', RapiDocMini);