x-openapi-flow 1.2.1 → 1.2.2
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
CHANGED
|
@@ -36,9 +36,15 @@ Use a GitHub PAT with `read:packages` (install) and `write:packages` (publish).
|
|
|
36
36
|
## Quick Start
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
x-openapi-flow
|
|
40
|
-
x-openapi-flow
|
|
41
|
-
|
|
39
|
+
npx x-openapi-flow init openapi.yaml
|
|
40
|
+
npx x-openapi-flow apply openapi.yaml
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Optional checks:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx x-openapi-flow validate openapi.yaml --profile strict
|
|
47
|
+
npx x-openapi-flow graph openapi.yaml
|
|
42
48
|
```
|
|
43
49
|
|
|
44
50
|
## CLI Commands
|
|
@@ -331,6 +331,8 @@ window.XOpenApiFlowPlugin = function () {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
let overviewRenderedHash = null;
|
|
334
|
+
let overviewRenderInProgress = false;
|
|
335
|
+
let overviewPendingHash = null;
|
|
334
336
|
async function renderOverview() {
|
|
335
337
|
const spec = getSpecFromUi();
|
|
336
338
|
const flows = extractFlowsFromSpec(spec);
|
|
@@ -339,6 +341,7 @@ window.XOpenApiFlowPlugin = function () {
|
|
|
339
341
|
const mermaid = buildOverviewMermaid(flows);
|
|
340
342
|
const currentHash = `${flows.length}:${mermaid}`;
|
|
341
343
|
if (overviewRenderedHash === currentHash) return;
|
|
344
|
+
if (overviewRenderInProgress && overviewPendingHash === currentHash) return;
|
|
342
345
|
|
|
343
346
|
const infoContainer = document.querySelector('.swagger-ui .information-container');
|
|
344
347
|
if (!infoContainer) return;
|
|
@@ -352,6 +355,8 @@ window.XOpenApiFlowPlugin = function () {
|
|
|
352
355
|
}
|
|
353
356
|
|
|
354
357
|
holder.innerHTML = '<div class="xof-title">x-openapi-flow — Flow Overview</div><div class="xof-empty">Rendering Mermaid graph...</div>';
|
|
358
|
+
overviewRenderInProgress = true;
|
|
359
|
+
overviewPendingHash = currentHash;
|
|
355
360
|
|
|
356
361
|
try {
|
|
357
362
|
const mermaidLib = await ensureMermaid();
|
|
@@ -374,6 +379,8 @@ window.XOpenApiFlowPlugin = function () {
|
|
|
374
379
|
<div class="xof-empty">Could not render Mermaid image in this environment.</div>
|
|
375
380
|
<div class="xof-overview-code">${mermaid.replace(/</g, '<').replace(/>/g, '>')}</div>
|
|
376
381
|
`;
|
|
382
|
+
} finally {
|
|
383
|
+
overviewRenderInProgress = false;
|
|
377
384
|
}
|
|
378
385
|
|
|
379
386
|
overviewRenderedHash = currentHash;
|
|
@@ -413,15 +420,27 @@ window.XOpenApiFlowPlugin = function () {
|
|
|
413
420
|
injectStyles();
|
|
414
421
|
const opblocks = document.querySelectorAll('.opblock');
|
|
415
422
|
opblocks.forEach((opblock) => enhanceOperation(opblock));
|
|
416
|
-
renderOverview()
|
|
423
|
+
renderOverview().catch(() => {
|
|
424
|
+
// keep plugin resilient in environments where async rendering fails
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
let enhanceScheduled = false;
|
|
429
|
+
function scheduleEnhance() {
|
|
430
|
+
if (enhanceScheduled) return;
|
|
431
|
+
enhanceScheduled = true;
|
|
432
|
+
window.requestAnimationFrame(() => {
|
|
433
|
+
enhanceScheduled = false;
|
|
434
|
+
enhanceAll();
|
|
435
|
+
});
|
|
417
436
|
}
|
|
418
437
|
|
|
419
438
|
const observer = new MutationObserver(() => {
|
|
420
|
-
|
|
439
|
+
scheduleEnhance();
|
|
421
440
|
});
|
|
422
441
|
|
|
423
442
|
window.addEventListener('load', () => {
|
|
424
|
-
|
|
443
|
+
scheduleEnhance();
|
|
425
444
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
426
445
|
});
|
|
427
446
|
})();
|