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