rapidoc 12.0.0 → 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.
- package/README.md +127 -25
- package/dist/rapidoc-flow-min.js +580 -0
- package/dist/rapidoc-flow-min.js.LICENSE.txt +171 -0
- package/dist/rapidoc-min.js +541 -1309
- package/dist/rapidoc-min.js.LICENSE.txt +381 -0
- package/package.json +21 -18
- package/src/README.md +150 -0
- package/src/components/README.md +91 -0
- package/src/components/api-request.ts +43 -0
- package/src/components/api-response.ts +9 -4
- package/src/components/schema-base-element.ts +18 -4
- package/src/components/schema-table.ts +58 -13
- package/src/components/schema-tree.ts +7 -0
- package/src/components/tag-input.ts +5 -9
- package/src/flow.js +3 -0
- package/src/rapi-flow.ts +1178 -0
- package/src/rapidoc-mini.ts +27 -6
- package/src/rapidoc.ts +108 -62
- package/src/styles/README.md +96 -0
- package/src/styles/css-bundle.js +2 -2
- package/src/styles/endpoint-styles.js +6 -1
- package/src/styles/flow-styles.js +248 -0
- package/src/styles/nav-styles.js +39 -15
- package/src/styles/schema-styles.js +13 -5
- package/src/styles/theme-tokens.js +2 -2
- package/src/templates/README.md +89 -0
- package/src/templates/api-response-template.js +14 -10
- package/src/templates/callback-template.js +1 -1
- package/src/templates/downloads-template.js +12 -27
- package/src/templates/endpoint-template.js +15 -24
- package/src/templates/expanded-endpoint-template.js +8 -4
- package/src/templates/focused-endpoint-template.js +4 -3
- package/src/templates/navbar-template.js +20 -11
- package/src/templates/request-body-template.js +29 -7
- package/src/templates/request-params-template.js +15 -4
- package/src/templates/security-scheme-template.js +11 -2
- package/src/templates/server-template.js +3 -2
- package/src/utils/README.md +146 -0
- package/src/utils/arazzo/README.md +119 -0
- package/src/utils/arazzo/components.js +15 -0
- package/src/utils/arazzo/graph.js +269 -0
- package/src/utils/arazzo/index.js +52 -0
- package/src/utils/arazzo/operations.js +106 -0
- package/src/utils/arazzo/parse.js +196 -0
- package/src/utils/arazzo/refs.js +40 -0
- package/src/utils/arazzo/svg.js +707 -0
- package/src/utils/curl-utils.js +5 -2
- package/src/utils/highlighter.js +3 -0
- package/src/utils/mcp/README.md +155 -0
- package/src/utils/mcp/common.js +45 -346
- package/src/utils/mcp/manifest.js +382 -0
- package/src/utils/mcp/project/server.ts +53 -0
- package/src/utils/mcp/project.js +88 -0
- package/src/utils/mcp/runtime.js +289 -0
- package/src/utils/mcp/schema.js +98 -0
- package/src/utils/mcp/workflow-runtime.js +374 -0
- package/src/utils/mcp/workflows.js +240 -0
- package/src/utils/mcp/zip.js +102 -0
- package/src/utils/mcp-generator.js +29 -125
- package/src/utils/mock-interceptor.js +134 -85
- package/src/utils/request-utils.js +61 -0
- package/src/utils/schema-utils.js +33 -6
- package/src/utils/slugger.js +5 -7
- package/src/utils/spec-parser.js +190 -164
- package/src/utils/url-utils.js +36 -1
- package/dist/rapidoc-static-min.js +0 -13542
- package/src/static/index.d.ts +0 -149
- package/src/static/index.js +0 -62
- package/src/static/navigation.js +0 -497
- package/src/static/render.js +0 -490
- package/src/static/serializer.js +0 -216
- package/src/utils/mcp/generators/csharp.js +0 -242
- package/src/utils/mcp/generators/go.js +0 -298
- package/src/utils/mcp/generators/java.js +0 -330
- package/src/utils/mcp/generators/python.js +0 -248
- package/src/utils/mcp/generators/rust.js +0 -281
- package/src/utils/mcp/generators/typescript.js +0 -290
package/README.md
CHANGED
|
@@ -59,39 +59,52 @@ Include the script in your HTML page and use the `<rapi-doc>` custom element:
|
|
|
59
59
|
|
|
60
60
|
## Repository Architecture
|
|
61
61
|
|
|
62
|
-
This repository is
|
|
62
|
+
This repository is a monorepo built on **npm workspaces** (`packages/*` and `docs`):
|
|
63
63
|
|
|
64
64
|
```text
|
|
65
65
|
rapidoc/
|
|
66
66
|
├── packages/
|
|
67
|
-
│ ├── rapidoc/ # Core
|
|
68
|
-
│ │ ├── src/ #
|
|
69
|
-
│ │ ├── dist/ #
|
|
70
|
-
│ │ ├──
|
|
71
|
-
│ │ └── vite.config.mjs
|
|
67
|
+
│ ├── rapidoc/ # Core web component library (npm "rapidoc"): <rapi-doc>, <rapi-doc-mini>
|
|
68
|
+
│ │ ├── src/ # Lit 3 source; each folder has a README.md contract
|
|
69
|
+
│ │ ├── dist/ # rapidoc-min.js and rapidoc-flow-min.js ("rapidoc/flow"), both for browsers
|
|
70
|
+
│ │ ├── vite.config.mjs # Browser bundle build
|
|
71
|
+
│ │ └── vite.config.flow.mjs # <rapi-flow> bundle build
|
|
72
72
|
│ │
|
|
73
|
-
│ ├── rapidoc-
|
|
74
|
-
│
|
|
75
|
-
│ │ └── package.json
|
|
73
|
+
│ ├── rapidoc-prerender/ # @rapidoc/prerender: build-time renderer (pre-rendered <rapi-doc>, sidebar HTML) for Node
|
|
74
|
+
│ ├── rapidoc-mcp/ # @rapidoc/mcp: MCP manifest builder, runtime and project writer for Node
|
|
76
75
|
│ │
|
|
77
|
-
│
|
|
78
|
-
│
|
|
76
|
+
│ ├── rapidoc-cli/ # @rapidoc/cli, the `rapidoc` command: init, dev, build, serve, mock, validate, migrate
|
|
77
|
+
│ ├── rapidoc-portal/ # @rapidoc/portal: docs-as-code developer portal for OpenAPI and Markdoc (Astro)
|
|
78
|
+
│ ├── rapidoc-server/ # @rapidoc/server: serves a built portal with OpenID Connect sign-in and access rules
|
|
79
|
+
│ ├── rapidoc-mock/ # @rapidoc/mock: mock server for a portal's APIs, with OAuth scope checks
|
|
80
|
+
│ └── create-rapidoc/ # create-rapidoc: scaffolds a new portal (npm create rapidoc)
|
|
79
81
|
│
|
|
80
|
-
├── docs/ # Astro documentation
|
|
81
|
-
│ ├── src/
|
|
82
|
-
│ │ ├──
|
|
83
|
-
│ │
|
|
82
|
+
├── docs/ # Astro + Starlight documentation and showcase site (GitHub Pages)
|
|
83
|
+
│ ├── src/
|
|
84
|
+
│ │ ├── content/docs/ # Documentation pages
|
|
85
|
+
│ │ ├── pages/examples/ # Public showcase pages
|
|
86
|
+
│ │ ├── pages/tests/ # Internal test and edge-case pages
|
|
87
|
+
│ │ └── page-data/ # YAML data for attribute tables and the example list
|
|
84
88
|
│ ├── public/
|
|
85
|
-
│ │ ├── specs/ #
|
|
86
|
-
│ │ └── specs-test/ #
|
|
87
|
-
│ │ └── parser/ # Malformed
|
|
88
|
-
│ ├──
|
|
89
|
-
│ └──
|
|
89
|
+
│ │ ├── specs/ # Public showcase specs (used by /examples)
|
|
90
|
+
│ │ └── specs-test/ # Internal edge-case specs
|
|
91
|
+
│ │ └── parser/ # Malformed and invalid specs for validation tests
|
|
92
|
+
│ ├── generated-docs/ # Committed build of the site; the docs build refreshes only its rapidoc-min.js
|
|
93
|
+
│ └── astro.config.mjs # Astro site configuration
|
|
90
94
|
│
|
|
91
|
-
├── tests/
|
|
92
|
-
│
|
|
95
|
+
├── tests/ # See tests/README.md
|
|
96
|
+
│ ├── unit/ # Node test runner: parser, schema, templates, static renderer
|
|
97
|
+
│ ├── component/ # Lit component tests
|
|
98
|
+
│ ├── e2e/ # Functional tests in a headless browser (playwright-core)
|
|
99
|
+
│ ├── perf/ # Spec parsing and rendering benchmarks
|
|
100
|
+
│ ├── fixtures/ # Shared specs and the HTML test harness
|
|
101
|
+
│ └── helpers/ # Test server and browser helpers
|
|
93
102
|
│
|
|
94
|
-
├──
|
|
103
|
+
├── scripts/ # Build info capture, demo prerender, test loader
|
|
104
|
+
├── docker/ # Dockerfile and Nginx config for hosting RapiDoc
|
|
105
|
+
├── brand/ # Logo SVGs and usage notes
|
|
106
|
+
├── package.json # Monorepo root: npm workspaces (packages/*, docs) and scripts
|
|
107
|
+
├── AGENTS.md # Guidance for contributors and coding agents
|
|
95
108
|
└── README.md
|
|
96
109
|
```
|
|
97
110
|
|
|
@@ -246,7 +259,7 @@ When code is pushed to `master` or `main`, the [deploy-docs.yml](file:///Users/m
|
|
|
246
259
|
|
|
247
260
|
OpenAPI specs are organized inside `docs/public/` based on their visibility and purpose:
|
|
248
261
|
|
|
249
|
-
- **`docs/public/specs/`**: Public showcase specs referenced in
|
|
262
|
+
- **`docs/public/specs/`**: Public showcase specs referenced in `docs/src/page-data/example-list.yaml` and displayed on `rapidocui.com` (e.g., `petstore.yaml`, `code-highlight.yaml`, `auth.yaml`).
|
|
250
263
|
- **`docs/public/specs-test/`**: Internal edge-case and boundary specs used for UI verification and regression tests (e.g., `circular-refs.yaml`, `xxx-of-combinations.yaml`).
|
|
251
264
|
- **`docs/public/specs-test/parser/`**: Malformed or invalid specs used to test CLI validation and error reporting (e.g., `invalid-syntax.yaml`, `missing-info.yaml`, `broken-ref.yaml`).
|
|
252
265
|
|
|
@@ -257,12 +270,101 @@ OpenAPI specs are organized inside `docs/public/` based on their visibility and
|
|
|
257
270
|
- [x] Modernize project dependencies (Vite + Astro + Node 22+)
|
|
258
271
|
- [x] Restructure as a multi-package Monorepo
|
|
259
272
|
- [ ] Build `rapidoc-cli` for OpenAPI linting and local zero-config previews
|
|
260
|
-
- [
|
|
273
|
+
- [x] Build `rapidoc-portal`, a docs-as-code developer portal, with sign-in (`rapidoc-server`) and mocking (`rapidoc-mock`)
|
|
261
274
|
- [ ] Automated visual regression testing suite with Playwright
|
|
262
275
|
- [ ] Web Content Accessibility Guidelines (WCAG 2.1) compliance enhancements
|
|
263
276
|
|
|
264
277
|
---
|
|
265
278
|
|
|
279
|
+
## Architecture Contract
|
|
280
|
+
|
|
281
|
+
What this package exposes, what must stay true, and what touches the outside world. Each folder
|
|
282
|
+
under `src/` has its own `README.md` contract with the detail; this section covers the package as
|
|
283
|
+
a whole.
|
|
284
|
+
|
|
285
|
+
### Overview
|
|
286
|
+
|
|
287
|
+
`packages/rapidoc` is a Lit 3 web component library built by Vite into two ES module bundles. It
|
|
288
|
+
has no runtime dependencies: its libraries are `devDependencies` bundled into those files. Each
|
|
289
|
+
build writes `dist/<bundle>.LICENSE.txt`, the list of bundled packages with their versions and
|
|
290
|
+
license notices, and the bundle's banner names it:
|
|
291
|
+
|
|
292
|
+
- `dist/rapidoc-min.js` (`vite.config.mjs`, entry `src/index.js`): registers `<rapi-doc>`,
|
|
293
|
+
`<rapi-doc-mini>` and `<oauth-receiver>` on import. Production builds are minified, carry the
|
|
294
|
+
license banner, and have `console.*` and `debugger` removed.
|
|
295
|
+
- `dist/rapidoc-flow-min.js` (`vite.config.flow.mjs`, entry `src/flow.js`), exported as
|
|
296
|
+
`rapidoc/flow`: registers `<rapi-flow>`, the Arazzo workflow diagram, with the workflow runtime
|
|
297
|
+
that runs them in the browser. It bundles its own copy of Lit and `yaml`, so pages that do not
|
|
298
|
+
load it pay nothing; `rapidoc-min.js` carries no Arazzo runtime.
|
|
299
|
+
|
|
300
|
+
Two Node packages are built from this source: `@rapidoc/prerender` (`packages/rapidoc-prerender`), the
|
|
301
|
+
build-time renderer that renders these templates and components to HTML, and `@rapidoc/mcp`
|
|
302
|
+
(`packages/rapidoc-mcp`), the MCP code in `src/utils/` (`mcp-generator.js`, `mcp/`, `arazzo/`).
|
|
303
|
+
Nothing in `src/` imports either package.
|
|
304
|
+
|
|
305
|
+
```text
|
|
306
|
+
spec-url / inline spec ──▶ utils/spec-parser.js ProcessSpec (load, upgrade, dereference, group)
|
|
307
|
+
│ └─ dispatches before-render on the host
|
|
308
|
+
▼ resolvedSpec
|
|
309
|
+
<rapi-doc> (src/rapidoc.ts) ──▶ templates/ ──▶ components/ (<api-request>, <api-response>, schema views)
|
|
310
|
+
├── events: spec-loaded, nav-active-change (components: before-try, after-try, request-aborted)
|
|
311
|
+
└── utils/mock-interceptor.js patches fetch / XMLHttpRequest while mock-server="true"
|
|
312
|
+
|
|
313
|
+
@rapidoc/prerender ──▶ the same templates and components, serialized by its serializer.js
|
|
314
|
+
renderTemplateToString (no DOM)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Folder Contracts
|
|
318
|
+
|
|
319
|
+
- [`src/`](./src/README.md): the three custom elements and the bundle entry.
|
|
320
|
+
- [`src/components/`](./src/components/README.md): nested elements for request, response and
|
|
321
|
+
schema panels.
|
|
322
|
+
- [`src/templates/`](./src/templates/README.md): Lit `html` functions bound to the host.
|
|
323
|
+
- [`src/utils/`](./src/utils/README.md): spec pipeline, stable anchors, schema, request and mock
|
|
324
|
+
helpers; [`utils/mcp/`](./src/utils/mcp/README.md) for the MCP manifest, runtime and exported
|
|
325
|
+
project;
|
|
326
|
+
[`utils/arazzo/`](./src/utils/arazzo/README.md) for Arazzo workflow diagrams.
|
|
327
|
+
- [`src/styles/`](./src/styles/README.md): stylesheets and the theme-token contract.
|
|
328
|
+
- [`../rapidoc-prerender/src/`](../rapidoc-prerender/src/README.md): the `@rapidoc/prerender` renderer, a
|
|
329
|
+
separate package that renders this folder's templates.
|
|
330
|
+
|
|
331
|
+
### Global Invariants
|
|
332
|
+
|
|
333
|
+
- **No runtime dependencies for browser users**: everything is bundled into
|
|
334
|
+
`dist/rapidoc-min.js`.
|
|
335
|
+
- **One spec shape**: `ProcessSpec` never rejects. It resolves to the parsed spec
|
|
336
|
+
(`info`, `tags`, `tagGroups`, `components`, `securitySchemes`, `servers`, ...) or to a result
|
|
337
|
+
with `specLoadError: true`, and templates, components and the static renderer all read it as
|
|
338
|
+
`this.resolvedSpec`.
|
|
339
|
+
- **Stable anchors**: operation ids come from `utils/slugger.js` `OperationSlugger`; the static
|
|
340
|
+
sidebar and `@rapidoc/portal` depend on them and on `nav-active-change`, so changing the rules is
|
|
341
|
+
a breaking change (see `src/utils/README.md`).
|
|
342
|
+
- **Boolean-like attributes are strings** (`allow-try="false"`) and are compared as strings.
|
|
343
|
+
- **Semantic headings and parts**, **theme tokens** and **DSD hydration** follow
|
|
344
|
+
`packages/rapidoc/AGENTS.md` §5 and are checked by `tests/unit/semantic-markup.test.js` and
|
|
345
|
+
`tests/unit/css-variables.test.js`.
|
|
346
|
+
- **Markdown** passes through `utils/sanitize.js` before `unsafeHTML`. In Node there is no
|
|
347
|
+
`DOMParser`, so the static renderer's markdown is not sanitized.
|
|
348
|
+
|
|
349
|
+
### Global Side Effects
|
|
350
|
+
|
|
351
|
+
- **Network**: spec and external `$ref` fetches, Try requests from `<api-request>`, OAuth token
|
|
352
|
+
requests and the sign-in popup.
|
|
353
|
+
- **Global patching**: the mock server replaces `window.fetch` and three `XMLHttpRequest`
|
|
354
|
+
prototype methods and restores them on disable; importing `@rapidoc/prerender` installs or wraps
|
|
355
|
+
`customElements.define`; importing the elements configures the global `marked` instance.
|
|
356
|
+
- **Storage and messaging**: `localStorage["rapidoc"]` with `persist-auth="true"`; OAuth replies
|
|
357
|
+
via `window.opener.postMessage` and a `BroadcastChannel`.
|
|
358
|
+
- **URL and history**: `<rapi-doc>` replaces the location hash when `update-route="true"`;
|
|
359
|
+
`bindNavBar` pushes or replaces history for portal sidebars.
|
|
360
|
+
|
|
361
|
+
### Verification
|
|
362
|
+
|
|
363
|
+
From the monorepo root: `npm run test:unit`, then `npm run lint` and `npm run format-fix`. After
|
|
364
|
+
any change under `src/`, run `npm run build:rapidoc`; never restore `dist/rapidoc-min.js` from git.
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
266
368
|
## License
|
|
267
369
|
|
|
268
370
|
MIT © [Mrinmoy Majumdar](https://github.com/mrin9)
|