rapidoc 11.0.1 → 12.1.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 (96) hide show
  1. package/README.md +171 -54
  2. package/dist/rapidoc-flow-min.js +580 -0
  3. package/dist/rapidoc-flow-min.js.LICENSE.txt +171 -0
  4. package/dist/rapidoc-min.js +645 -202
  5. package/dist/rapidoc-min.js.LICENSE.txt +381 -0
  6. package/package.json +57 -42
  7. package/src/README.md +150 -0
  8. package/src/components/README.md +91 -0
  9. package/src/components/api-request.ts +912 -0
  10. package/src/components/api-response.ts +514 -0
  11. package/src/components/json-tree.ts +171 -0
  12. package/src/components/schema-base-element.ts +329 -0
  13. package/src/components/schema-table.ts +475 -0
  14. package/src/components/schema-tree.ts +393 -0
  15. package/src/components/tag-input.ts +180 -0
  16. package/src/flow.js +3 -0
  17. package/src/index.js +6 -0
  18. package/src/oauth-receiver.ts +29 -0
  19. package/src/rapi-flow.ts +1178 -0
  20. package/src/rapidoc-mini.ts +603 -0
  21. package/src/rapidoc.ts +1854 -0
  22. package/src/styles/README.md +96 -0
  23. package/src/styles/auth-styles.js +318 -0
  24. package/src/styles/border-styles.js +24 -0
  25. package/src/styles/css-bundle.js +129 -0
  26. package/src/styles/custom-styles.js +8 -0
  27. package/src/styles/dialog-box-styles.js +102 -0
  28. package/src/styles/endpoint-styles.js +564 -0
  29. package/src/styles/flex-styles.js +16 -0
  30. package/src/styles/flow-styles.js +248 -0
  31. package/src/styles/font-styles.js +432 -0
  32. package/src/styles/info-styles.js +36 -0
  33. package/src/styles/input-styles.js +555 -0
  34. package/src/styles/layout-styles.js +396 -0
  35. package/src/styles/microlighter-styles.js +99 -0
  36. package/src/styles/nav-styles.js +633 -0
  37. package/src/styles/param-list-styles.js +261 -0
  38. package/src/styles/schema-styles.js +296 -0
  39. package/src/styles/tab-styles.js +106 -0
  40. package/src/styles/theme-tokens.js +582 -0
  41. package/src/templates/README.md +89 -0
  42. package/src/templates/advanced-search-dialog-template.js +94 -0
  43. package/src/templates/api-response-template.js +223 -0
  44. package/src/templates/callback-template.js +86 -0
  45. package/src/templates/code-samples-template.js +52 -0
  46. package/src/templates/components-template.js +86 -0
  47. package/src/templates/downloads-template.js +70 -0
  48. package/src/templates/endpoint-template.js +377 -0
  49. package/src/templates/expanded-endpoint-template.js +270 -0
  50. package/src/templates/focused-endpoint-template.js +146 -0
  51. package/src/templates/header-template.js +92 -0
  52. package/src/templates/logo-template.js +21 -0
  53. package/src/templates/main-body-template.js +102 -0
  54. package/src/templates/navbar-template.js +498 -0
  55. package/src/templates/overview-template.js +104 -0
  56. package/src/templates/request-body-template.js +673 -0
  57. package/src/templates/request-params-template.js +485 -0
  58. package/src/templates/security-scheme-template.js +1272 -0
  59. package/src/templates/server-template.js +153 -0
  60. package/src/utils/README.md +146 -0
  61. package/src/utils/arazzo/README.md +119 -0
  62. package/src/utils/arazzo/components.js +15 -0
  63. package/src/utils/arazzo/graph.js +269 -0
  64. package/src/utils/arazzo/index.js +52 -0
  65. package/src/utils/arazzo/operations.js +106 -0
  66. package/src/utils/arazzo/parse.js +196 -0
  67. package/src/utils/arazzo/refs.js +40 -0
  68. package/src/utils/arazzo/svg.js +707 -0
  69. package/src/utils/auto-color-scheme.js +99 -0
  70. package/src/utils/bind-navbar.js +175 -0
  71. package/src/utils/color-utils.js +59 -0
  72. package/src/utils/common-utils.js +191 -0
  73. package/src/utils/curl-utils.js +126 -0
  74. package/src/utils/highlighter.js +419 -0
  75. package/src/utils/markdown-utils.js +110 -0
  76. package/src/utils/mcp/README.md +155 -0
  77. package/src/utils/mcp/common.js +166 -0
  78. package/src/utils/mcp/manifest.js +382 -0
  79. package/src/utils/mcp/project/server.ts +53 -0
  80. package/src/utils/mcp/project.js +88 -0
  81. package/src/utils/mcp/runtime.js +289 -0
  82. package/src/utils/mcp/schema.js +98 -0
  83. package/src/utils/mcp/workflow-runtime.js +374 -0
  84. package/src/utils/mcp/workflows.js +240 -0
  85. package/src/utils/mcp/zip.js +102 -0
  86. package/src/utils/mcp-generator.js +47 -0
  87. package/src/utils/mock-interceptor.js +557 -0
  88. package/src/utils/oauth-utils.js +87 -0
  89. package/src/utils/request-utils.js +264 -0
  90. package/src/utils/response-utils.js +203 -0
  91. package/src/utils/sanitize.js +57 -0
  92. package/src/utils/schema-utils.js +1954 -0
  93. package/src/utils/slugger.js +187 -0
  94. package/src/utils/spec-parser.js +941 -0
  95. package/src/utils/url-utils.js +246 -0
  96. package/src/utils/xml-utils.js +61 -0
@@ -0,0 +1,475 @@
1
+ import { html, css, nothing } from "lit";
2
+ import { customElement } from "lit/decorators.js";
3
+ import FontStyles from "../styles/font-styles.js";
4
+ import SchemaStyles from "../styles/schema-styles.js";
5
+ import CustomStyles from "../styles/custom-styles.js";
6
+ import SchemaBaseElement from "./schema-base-element";
7
+
8
+ @customElement("schema-table")
9
+ export default class SchemaTable extends SchemaBaseElement {
10
+ static get styles() {
11
+ return [
12
+ FontStyles,
13
+ SchemaStyles,
14
+ css`
15
+ .table {
16
+ font-size: var(--font-size-small);
17
+ text-align: left;
18
+ line-height: calc(var(--font-size-small) + 6px);
19
+
20
+ & .table-container {
21
+ border: 1px solid var(--border);
22
+ /* Card surface, same as .param-list */
23
+ background: color-mix(in srgb, var(--card) 80%, transparent);
24
+ overflow-x: auto;
25
+ max-width: 100%;
26
+ }
27
+ & .table-header {
28
+ display: flex;
29
+ background: var(--card);
30
+ padding: 8px 4px;
31
+ border-bottom: 1px solid var(--border);
32
+
33
+ & .td {
34
+ font-family: var(--font-sans);
35
+ font-weight: bold;
36
+ color: var(--foreground);
37
+ }
38
+ }
39
+ & .tr {
40
+ width: calc(100% - 5px);
41
+ padding: 0 0 0 5px;
42
+ border-bottom: 1px dotted var(--border);
43
+
44
+ &.expanded {
45
+ & .obj-toggle::after {
46
+ content: '-';
47
+ }
48
+ & + .object-body {
49
+ display: block;
50
+ }
51
+ }
52
+ &.collapsed {
53
+ & .obj-toggle::after {
54
+ content: '+';
55
+ }
56
+ & + .object-body {
57
+ display: none;
58
+ }
59
+ }
60
+ }
61
+ & .td {
62
+ padding: 4px 0;
63
+ }
64
+ & .key {
65
+ width: var(--table-schema-key-width);
66
+ text-overflow: var(--table-schema-key-text-overflow);
67
+ white-space: var(--table-schema-key-whitespace);
68
+ overflow: hidden;
69
+
70
+ & .key-label {
71
+ font-size: var(--font-size-mono);
72
+ }
73
+ &.deprecated .key-label {
74
+ color: var(--destructive);
75
+ }
76
+ }
77
+ & .key-type {
78
+ white-space: normal;
79
+ width: 150px;
80
+ }
81
+ &.collapsed-all-descr .tr:not(.expanded-descr) {
82
+ overflow: hidden;
83
+ max-height: calc(var(--font-size-small) + 16px);
84
+ }
85
+ }
86
+
87
+ .obj-toggle {
88
+ background: transparent;
89
+ border: 1px solid transparent;
90
+ padding: 0;
91
+ border-radius: 2px;
92
+ display: inline-flex;
93
+ align-items: center;
94
+ justify-content: center;
95
+ margin-left: -16px;
96
+ margin-top: -2px;
97
+ color: var(--primary);
98
+ cursor: pointer;
99
+ font-size: 14px;
100
+ font-family: var(--font-mono);
101
+ line-height: 12px;
102
+ width: 14px;
103
+ height: 14px;
104
+ min-width: 14px;
105
+ text-align: center;
106
+ user-select: none;
107
+ box-sizing: border-box;
108
+ vertical-align: middle;
109
+
110
+ &:hover {
111
+ border-color: var(--primary);
112
+ }
113
+ &:focus-visible {
114
+ outline: 2px solid var(--primary);
115
+ border-color: var(--primary);
116
+ }
117
+ }
118
+
119
+ @supports (grid-template-columns: subgrid) {
120
+ .table {
121
+ & .table-container {
122
+ display: grid;
123
+ grid-template-columns: minmax(var(--table-schema-key-width), auto) minmax(150px, auto) 1fr;
124
+ }
125
+ & .table-header,
126
+ & .tr {
127
+ display: grid;
128
+ grid-column: 1 / -1;
129
+ grid-template-columns: subgrid;
130
+ width: 100%;
131
+ padding: 0 4px;
132
+ box-sizing: border-box;
133
+
134
+ & .key,
135
+ & .key-type {
136
+ width: auto;
137
+ }
138
+ & .key-descr {
139
+ min-width: 0;
140
+ }
141
+ }
142
+ & .object-body {
143
+ display: contents;
144
+ }
145
+ & .tr.collapsed + .object-body {
146
+ display: none;
147
+ }
148
+ & .tr.expanded + .object-body {
149
+ display: contents;
150
+ }
151
+ }
152
+ }
153
+
154
+ /* Narrow schemas: the description spans the row, under the field and type, with no column of its own (#1074) */
155
+ @container (width < 500px) {
156
+ .table {
157
+ /* no column for descriptions, and field and type share the width instead of scrolling sideways */
158
+ & .table-container {
159
+ grid-template-columns: minmax(0, 1fr) minmax(0, max-content) 0;
160
+ }
161
+ & .tr > .key-descr {
162
+ grid-column: 1 / -1;
163
+ }
164
+ & .table-header > .key-descr {
165
+ display: none;
166
+ }
167
+ &.collapsed-all-descr .tr:not(.expanded-descr) {
168
+ max-height: calc(2 * (var(--font-size-small) + 16px));
169
+ }
170
+ }
171
+ }
172
+ `,
173
+ CustomStyles,
174
+ ];
175
+ }
176
+
177
+ render() {
178
+ if (!this.data) {
179
+ return "";
180
+ }
181
+
182
+ const rootType = this.data.kind === "primitive" ? this.data.type : this.data.kind || "";
183
+ const rootDescription = this.data.description || "";
184
+
185
+ return html`
186
+ <div
187
+ class="table ${this.schemaDescriptionExpanded === "true" ? "expanded-all-descr" : "collapsed-all-descr"}"
188
+ @click="${(e) => this.handleAllEvents(e)}"
189
+ @keydown="${(e) => this.handleKeyDown(e)}"
190
+ >
191
+ ${this.renderToolbar(rootType)}
192
+ <span part="schema-description" class="m-markdown"> ${this.renderDescriptionHtml(rootDescription)} </span>
193
+ <div class="table-container">
194
+ <div class="tr table-header">
195
+ <div class="td key">Field</div>
196
+ <div class="td key-type">Type</div>
197
+ <div class="td key-descr">Description</div>
198
+ </div>
199
+ ${this.renderAST(this.data)}
200
+ </div>
201
+ </div>
202
+ `;
203
+ }
204
+
205
+ renderAST(node, parentType = "", schemaLevel = 0, indentLevel = 0) {
206
+ if (this.isFieldHidden(node)) {
207
+ return "";
208
+ }
209
+
210
+ const leftPadding = 16 * (indentLevel + 1);
211
+ const isExpanded = schemaLevel < this.schemaExpandLevel;
212
+ const nullClass = node.nullable ? "nullable" : "";
213
+ const deprecatedIcon = this.renderDeprecatedIcon(node);
214
+ const readWriteBadge = this.getReadWriteBadge(node);
215
+ const readWriteTip = this.getReadWriteTip(node);
216
+
217
+ // 1. Array kind
218
+ if (node.kind === "array") {
219
+ const items = node.items;
220
+ if (!items) {
221
+ const typeLabel = node.dataTypeLabel || (node.nullable ? "array ┃ null" : "array");
222
+ return html`
223
+ <div class="tr array ${nullClass}" data-obj="${node.name || ""}">
224
+ <div class="td key" style="padding-left:${leftPadding}px">
225
+ <span class="key-label" title="${node.name || nothing}">${deprecatedIcon}${node.name || ""}</span>
226
+ ${node.required ? html`<span style="color:var(--destructive);">*</span>` : ""}
227
+ </div>
228
+ <div class="td key-type" title="${readWriteTip || nothing}">${typeLabel}${readWriteBadge}</div>
229
+ ${this.renderDescrCell(node.description)}
230
+ </div>
231
+ `;
232
+ }
233
+
234
+ if (items.kind === "primitive") {
235
+ const itemType = items.format || items.contentMediaType || items.type || "string";
236
+ const dataTypeCss = this.getDataTypeCss(itemType);
237
+
238
+ return html`
239
+ <div class="tr primitive ${nullClass}" title="${node.deprecated || items.deprecated ? "Deprecated" : nothing}">
240
+ <div class="td key ${node.deprecated || items.deprecated ? "deprecated" : ""}" style="padding-left:${leftPadding}px">
241
+ ${deprecatedIcon}${node.name ? html`<span class="key-label" title="${node.name}">${node.name}</span>` : ""}
242
+ ${node.required ? html`<span style="color:var(--destructive);">*</span>` : ""}
243
+ </div>
244
+ <div class="td key-type ${dataTypeCss}" title="${readWriteTip || nothing}">
245
+ [${itemType}]${node.nullable ? " ┃ null" : ""}${readWriteBadge}
246
+ </div>
247
+ ${this.renderDescrCell(node.description || items.description, items)}
248
+ </div>
249
+ `;
250
+ }
251
+
252
+ let arrLabel = "array";
253
+ if (items.kind === "object") {
254
+ arrLabel = "array of object";
255
+ } else if (items.kind === "array") {
256
+ arrLabel = `array of array ${node.arrayType ? `of ${node.arrayType}` : ""}`.trim();
257
+ } else if (items.kind === "union") {
258
+ arrLabel = "array of union";
259
+ }
260
+ if (node.nullable) {
261
+ arrLabel += " ┃ null";
262
+ }
263
+
264
+ const hasChildren =
265
+ items.kind === "object"
266
+ ? !!(
267
+ (items.properties && items.properties.length > 0) ||
268
+ (items.patternProperties && items.patternProperties.length > 0) ||
269
+ items.additionalProperties ||
270
+ (items.unions && items.unions.length > 0)
271
+ )
272
+ : true;
273
+
274
+ return html`
275
+ <div
276
+ class="tr ${isExpanded ? "expanded" : "collapsed"} array ${nullClass}"
277
+ data-obj="${node.name || ""}"
278
+ title="${node.deprecated ? `Deprecated ${node.name}` : node.name || nothing}"
279
+ >
280
+ <div class="td key ${node.deprecated ? "deprecated" : ""}" style="padding-left:${leftPadding}px">
281
+ ${
282
+ node.name && hasChildren
283
+ ? html`<button
284
+ type="button"
285
+ class="obj-toggle"
286
+ data-obj="${node.name}"
287
+ aria-label="Toggle ${node.name}"
288
+ aria-expanded="${isExpanded ? "true" : "false"}"
289
+ ></button>`
290
+ : ""
291
+ }
292
+ <span class="key-label" title="${node.name || nothing}" style="display:inline-block; ${hasChildren ? "margin-left:-6px;" : ""}">
293
+ ${deprecatedIcon}${node.name || ""}
294
+ </span>
295
+ ${node.required ? html`<span style="color:var(--destructive);">*</span>` : ""}
296
+ </div>
297
+ <div class="td key-type" title="${readWriteTip || nothing}">${arrLabel}${readWriteBadge}</div>
298
+ ${this.renderDescrCell(node.description || items.description)}
299
+ </div>
300
+ ${
301
+ hasChildren
302
+ ? html`
303
+ <div class="object-body">
304
+ ${
305
+ items.kind === "object"
306
+ ? html`
307
+ ${items.properties?.map((p) => this.renderAST(p, "object", schemaLevel + 1, indentLevel + 1))}
308
+ ${items.patternProperties?.map((p) => this.renderAST(p, "object", schemaLevel + 1, indentLevel + 1))}
309
+ ${items.additionalProperties ? this.renderAST(items.additionalProperties, "object", schemaLevel + 1, indentLevel + 1) : ""}
310
+ ${items.unions?.map((u) => this.renderAST(u, "object", schemaLevel + 1, indentLevel + 1))}
311
+ `
312
+ : this.renderAST(items, "array", schemaLevel + 1, indentLevel + 1)
313
+ }
314
+ </div>
315
+ `
316
+ : ""
317
+ }
318
+ `;
319
+ }
320
+
321
+ // 2. Object kind
322
+ if (node.kind === "object") {
323
+ const typeLabel = node.dataTypeLabel || (node.nullable ? "object ┃ null" : "object");
324
+
325
+ const hasChildren = !!(
326
+ (node.properties && node.properties.length > 0) ||
327
+ (node.patternProperties && node.patternProperties.length > 0) ||
328
+ node.additionalProperties ||
329
+ (node.unions && node.unions.length > 0)
330
+ );
331
+
332
+ return html`
333
+ ${
334
+ node.name
335
+ ? html`
336
+ <div
337
+ class="tr ${isExpanded ? "expanded" : "collapsed"} object ${nullClass}"
338
+ data-obj="${node.name}"
339
+ title="${node.deprecated ? `Deprecated ${node.name}` : node.name}"
340
+ >
341
+ <div class="td key ${node.deprecated ? "deprecated" : ""}" style="padding-left:${leftPadding}px">
342
+ ${
343
+ hasChildren
344
+ ? html`<button
345
+ type="button"
346
+ class="obj-toggle"
347
+ data-obj="${node.name}"
348
+ aria-label="Toggle ${node.name}"
349
+ aria-expanded="${isExpanded ? "true" : "false"}"
350
+ ></button>`
351
+ : ""
352
+ }
353
+ <span
354
+ class="key-label"
355
+ title="${node.name || nothing}"
356
+ style="display:inline-block; ${hasChildren ? "margin-left:-6px;" : ""}"
357
+ >
358
+ ${deprecatedIcon}${node.name}
359
+ </span>
360
+ ${node.required ? html`<span style="color:var(--destructive);">*</span>` : ""}
361
+ </div>
362
+ <div class="td key-type" title="${readWriteTip || nothing}">${typeLabel}${readWriteBadge}</div>
363
+ ${this.renderDescrCell(node.description)}
364
+ </div>
365
+ `
366
+ : ""
367
+ }
368
+ ${
369
+ hasChildren
370
+ ? html`
371
+ <div class="object-body">
372
+ ${node.properties?.map((p) => this.renderAST(p, "object", schemaLevel + 1, indentLevel + (node.name ? 1 : 0)))}
373
+ ${node.patternProperties?.map((p) => this.renderAST(p, "object", schemaLevel + 1, indentLevel + (node.name ? 1 : 0)))}
374
+ ${node.additionalProperties ? this.renderAST(node.additionalProperties, "object", schemaLevel + 1, indentLevel + (node.name ? 1 : 0)) : ""}
375
+ ${node.unions?.map((u) => this.renderAST(u, "object", schemaLevel + 1, indentLevel + (node.name ? 1 : 0)))}
376
+ </div>
377
+ `
378
+ : ""
379
+ }
380
+ `;
381
+ }
382
+
383
+ // 3. Union kind (oneOf / anyOf)
384
+ if (node.kind === "union") {
385
+ const opLabel =
386
+ (node.operator === "anyOf" ? "ANY OF" : "ONE OF") + (node.suffix ? ` ${node.suffix}` : "");
387
+ // Options are already labelled by their OPT row, so only property names are shown
388
+ const showName = node.name && parentType !== "xxx-of-option";
389
+
390
+ return html`
391
+ ${node.properties?.map((p) => this.renderAST(p, "object", schemaLevel, indentLevel))}
392
+ <div class="tr expanded xxx-of" data-obj="${showName ? node.name : opLabel}">
393
+ ${
394
+ showName
395
+ ? html`
396
+ <div class="td key" style="padding-left:${leftPadding}px">
397
+ <span class="key-label" title="${node.name}">${node.name}</span>
398
+ ${node.required ? html`<span style="color:var(--destructive);">*</span>` : ""}
399
+ </div>
400
+ <div class="td key-type"><span class="xxx-of-key">${opLabel}</span></div>
401
+ `
402
+ : html`
403
+ <div class="td key" style="padding-left:${leftPadding}px">
404
+ <span class="xxx-of-key" style="margin-left:-6px">${opLabel}</span>
405
+ </div>
406
+ <div class="td key-type"></div>
407
+ `
408
+ }
409
+ ${this.renderDescrCell(node.description)}
410
+ </div>
411
+ <div class="object-body">
412
+ ${node.options?.map((opt, i) =>
413
+ opt.kind === "primitive"
414
+ ? // A primitive option fits on a single row: the badge, then its type and description
415
+ html`<div class="object-body">
416
+ ${this.renderAST(opt, "xxx-of-option", schemaLevel + 1, indentLevel + 1)}
417
+ </div>`
418
+ : html`
419
+ <div class="tr expanded xxx-of-option" data-obj="OPTION ${opt.optionIndex || i + 1}">
420
+ <div class="td key" style="padding-left:${leftPadding + 16}px">
421
+ <span class="xxx-of-key">OPT ${opt.optionIndex || i + 1}</span>
422
+ ${
423
+ opt.optionTitle
424
+ ? html`<span class="xxx-of-descr">${opt.optionTitle}</span>`
425
+ : ""
426
+ }
427
+ </div>
428
+ <div class="td key-type"></div>
429
+ <div class="td key-descr"></div>
430
+ </div>
431
+ <div class="object-body">
432
+ ${this.renderAST(opt, "xxx-of-option", schemaLevel + 1, indentLevel + 1)}
433
+ </div>
434
+ `,
435
+ )}
436
+ </div>
437
+ `;
438
+ }
439
+
440
+ // 4. Primitive kind
441
+ if (node.kind === "primitive") {
442
+ const dataTypeCss = this.getDataTypeCss(node.type);
443
+ // Primitive option of a oneOf / anyOf: the OPT n badge (and the title) takes the place of the name
444
+ const isOption = parentType === "xxx-of-option" && !!node.optionIndex;
445
+
446
+ return html`
447
+ <div class="tr primitive ${nullClass}" title="${node.deprecated ? "Deprecated" : nothing}">
448
+ <div class="td key ${node.deprecated ? "deprecated" : ""}" style="padding-left:${leftPadding}px">
449
+ ${
450
+ isOption
451
+ ? html`<span class="xxx-of-key">OPT ${node.optionIndex}</span
452
+ >${
453
+ node.optionTitle
454
+ ? html`<span class="xxx-of-descr">${node.optionTitle}</span>`
455
+ : ""
456
+ }`
457
+ : ""
458
+ }${deprecatedIcon}${
459
+ node.name && !isOption
460
+ ? html`<span class="key-label" title="${node.name}">${node.name}</span>`
461
+ : ""
462
+ }
463
+ ${node.required ? html`<span style="color:var(--destructive);">*</span>` : ""}
464
+ </div>
465
+ <div class="td key-type ${dataTypeCss}" title="${readWriteTip || nothing}">
466
+ ${parentType === "array" ? `[${node.type}]` : node.type}${readWriteBadge}
467
+ </div>
468
+ ${this.renderDescrCell(node.description, node, node.title)}
469
+ </div>
470
+ `;
471
+ }
472
+
473
+ return "";
474
+ }
475
+ }