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.
- package/README.md +171 -54
- package/dist/rapidoc-flow-min.js +580 -0
- package/dist/rapidoc-flow-min.js.LICENSE.txt +171 -0
- package/dist/rapidoc-min.js +645 -202
- package/dist/rapidoc-min.js.LICENSE.txt +381 -0
- package/package.json +57 -42
- package/src/README.md +150 -0
- package/src/components/README.md +91 -0
- package/src/components/api-request.ts +912 -0
- package/src/components/api-response.ts +514 -0
- package/src/components/json-tree.ts +171 -0
- package/src/components/schema-base-element.ts +329 -0
- package/src/components/schema-table.ts +475 -0
- package/src/components/schema-tree.ts +393 -0
- package/src/components/tag-input.ts +180 -0
- package/src/flow.js +3 -0
- package/src/index.js +6 -0
- package/src/oauth-receiver.ts +29 -0
- package/src/rapi-flow.ts +1178 -0
- package/src/rapidoc-mini.ts +603 -0
- package/src/rapidoc.ts +1854 -0
- package/src/styles/README.md +96 -0
- package/src/styles/auth-styles.js +318 -0
- package/src/styles/border-styles.js +24 -0
- package/src/styles/css-bundle.js +129 -0
- package/src/styles/custom-styles.js +8 -0
- package/src/styles/dialog-box-styles.js +102 -0
- package/src/styles/endpoint-styles.js +564 -0
- package/src/styles/flex-styles.js +16 -0
- package/src/styles/flow-styles.js +248 -0
- package/src/styles/font-styles.js +432 -0
- package/src/styles/info-styles.js +36 -0
- package/src/styles/input-styles.js +555 -0
- package/src/styles/layout-styles.js +396 -0
- package/src/styles/microlighter-styles.js +99 -0
- package/src/styles/nav-styles.js +633 -0
- package/src/styles/param-list-styles.js +261 -0
- package/src/styles/schema-styles.js +296 -0
- package/src/styles/tab-styles.js +106 -0
- package/src/styles/theme-tokens.js +582 -0
- package/src/templates/README.md +89 -0
- package/src/templates/advanced-search-dialog-template.js +94 -0
- package/src/templates/api-response-template.js +223 -0
- package/src/templates/callback-template.js +86 -0
- package/src/templates/code-samples-template.js +52 -0
- package/src/templates/components-template.js +86 -0
- package/src/templates/downloads-template.js +70 -0
- package/src/templates/endpoint-template.js +377 -0
- package/src/templates/expanded-endpoint-template.js +270 -0
- package/src/templates/focused-endpoint-template.js +146 -0
- package/src/templates/header-template.js +92 -0
- package/src/templates/logo-template.js +21 -0
- package/src/templates/main-body-template.js +102 -0
- package/src/templates/navbar-template.js +498 -0
- package/src/templates/overview-template.js +104 -0
- package/src/templates/request-body-template.js +673 -0
- package/src/templates/request-params-template.js +485 -0
- package/src/templates/security-scheme-template.js +1272 -0
- package/src/templates/server-template.js +153 -0
- 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/auto-color-scheme.js +99 -0
- package/src/utils/bind-navbar.js +175 -0
- package/src/utils/color-utils.js +59 -0
- package/src/utils/common-utils.js +191 -0
- package/src/utils/curl-utils.js +126 -0
- package/src/utils/highlighter.js +419 -0
- package/src/utils/markdown-utils.js +110 -0
- package/src/utils/mcp/README.md +155 -0
- package/src/utils/mcp/common.js +166 -0
- 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 +47 -0
- package/src/utils/mock-interceptor.js +557 -0
- package/src/utils/oauth-utils.js +87 -0
- package/src/utils/request-utils.js +264 -0
- package/src/utils/response-utils.js +203 -0
- package/src/utils/sanitize.js +57 -0
- package/src/utils/schema-utils.js +1954 -0
- package/src/utils/slugger.js +187 -0
- package/src/utils/spec-parser.js +941 -0
- package/src/utils/url-utils.js +246 -0
- package/src/utils/xml-utils.js +61 -0
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
|
|
|
@@ -100,11 +113,14 @@ astro-rapidoc/
|
|
|
100
113
|
## Development & Build Instructions
|
|
101
114
|
|
|
102
115
|
### Prerequisites
|
|
116
|
+
|
|
103
117
|
- **Node.js**: `>= 22.12.0` (or [Bun](https://bun.sh/))
|
|
104
118
|
- **npm** (or `bun`)
|
|
105
119
|
|
|
106
120
|
### 1. Installation
|
|
121
|
+
|
|
107
122
|
Clone the repository and install dependencies across all workspaces:
|
|
123
|
+
|
|
108
124
|
```bash
|
|
109
125
|
git clone https://github.com/rapi-doc/RapiDoc.git
|
|
110
126
|
cd RapiDoc
|
|
@@ -112,7 +128,9 @@ npm install
|
|
|
112
128
|
```
|
|
113
129
|
|
|
114
130
|
### 2. Development Server & Live Debugging
|
|
131
|
+
|
|
115
132
|
Start the local documentation and interactive examples showcase:
|
|
133
|
+
|
|
116
134
|
```bash
|
|
117
135
|
# Start dev server (http://localhost:4321)
|
|
118
136
|
npm run dev
|
|
@@ -120,6 +138,7 @@ npm run dev
|
|
|
120
138
|
# Stop background dev server
|
|
121
139
|
npm run stop
|
|
122
140
|
```
|
|
141
|
+
|
|
123
142
|
- Open `http://localhost:4321` in your browser.
|
|
124
143
|
- **Live Unminified ES Modules:** In development mode (`npm run dev`), the Astro dev server bypasses pre-compiled production bundles and serves live ES modules directly from `packages/rapidoc/src/index.js`.
|
|
125
144
|
- **Full DevTools & Console Visibility:** All `console.log`, `console.warn`, `console.error`, and `debugger` breakpoints remain completely intact with original file names and exact line numbers (e.g., `rapidoc.js:516`).
|
|
@@ -132,6 +151,7 @@ npm run stop
|
|
|
132
151
|
This monorepo contains multiple packages: the core Web Component library (**`packages/rapidoc`**) and the documentation showcase site (**`docs`**). The build system coordinates them as follows:
|
|
133
152
|
|
|
134
153
|
#### Core Library Production Build (`npm run build:rapidoc`)
|
|
154
|
+
|
|
135
155
|
- **Workspace:** `packages/rapidoc`
|
|
136
156
|
- **Output:** `packages/rapidoc/dist/rapidoc-min.js`
|
|
137
157
|
- Compiles the RapiDoc custom element in library mode using [Vite 6](https://vitejs.dev/).
|
|
@@ -141,6 +161,7 @@ This monorepo contains multiple packages: the core Web Component library (**`pac
|
|
|
141
161
|
- Injects the license and version header banner.
|
|
142
162
|
|
|
143
163
|
#### Core Library Development Build (`npm run build:rapidoc:dev`)
|
|
164
|
+
|
|
144
165
|
- **Workspace:** `packages/rapidoc`
|
|
145
166
|
- **Output:** `packages/rapidoc/dist/rapidoc-min.js` + `packages/rapidoc/dist/rapidoc-min.js.map`
|
|
146
167
|
- Compiles the standalone library bundle with `mode: 'development'`.
|
|
@@ -148,6 +169,7 @@ This monorepo contains multiple packages: the core Web Component library (**`pac
|
|
|
148
169
|
- Useful when you need to test the bundled `<rapi-doc>` script tag artifact in external standalone HTML pages or apps with full DevTools logging.
|
|
149
170
|
|
|
150
171
|
#### Full Monorepo Build (`npm run build`)
|
|
172
|
+
|
|
151
173
|
- **Scope:** Root monorepo
|
|
152
174
|
- Sequentially executes `npm run build:rapidoc` followed by `npm run build:docs`.
|
|
153
175
|
|
|
@@ -175,39 +197,43 @@ Astro documentation and example pages include the component via `<script type="m
|
|
|
175
197
|
All primary commands can be run from the root of the repository:
|
|
176
198
|
|
|
177
199
|
#### Development & Live Preview
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
|
181
|
-
| `npm run
|
|
182
|
-
| `npm run
|
|
200
|
+
|
|
201
|
+
| Command | Workspace | Description |
|
|
202
|
+
| ----------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
203
|
+
| `npm run dev` | `docs` | Launches Astro documentation & showcase dev server (`http://localhost:4321`) with live unminified RapiDoc ESM directly from source. |
|
|
204
|
+
| `npm run stop` | `docs` | Terminates background Astro dev server processes. |
|
|
205
|
+
| `npm run preview` | `docs` | Previews the production build of the documentation site (`docs/dist`) locally. |
|
|
183
206
|
|
|
184
207
|
#### Building
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
|
188
|
-
| `npm run build
|
|
189
|
-
| `npm run build:rapidoc
|
|
190
|
-
| `npm run build:
|
|
191
|
-
| `npm run build:
|
|
208
|
+
|
|
209
|
+
| Command | Workspace | Description |
|
|
210
|
+
| --------------------------- | --------- | --------------------------------------------------------------------------------------------------------- |
|
|
211
|
+
| `npm run build` | Monorepo | Sequentially builds production RapiDoc library bundle and the Astro documentation site. |
|
|
212
|
+
| `npm run build:rapidoc` | `rapidoc` | Compiles production, minified Web Component bundle to `packages/rapidoc/dist/rapidoc-min.js`. |
|
|
213
|
+
| `npm run build:rapidoc:dev` | `rapidoc` | Compiles unminified Web Component bundle with source maps & console logs to `packages/rapidoc/dist/`. |
|
|
214
|
+
| `npm run build:docs` | `docs` | Builds the production Astro documentation site into `docs/dist/` (and syncs bundle to `generated-docs/`). |
|
|
215
|
+
| `npm run build:size` | `rapidoc` | Builds RapiDoc with `ANALYZE=true` and opens an interactive bundle visualizer (`dist/stats.html`). |
|
|
192
216
|
|
|
193
217
|
#### Testing & Benchmarks
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
|
197
|
-
| `npm run test:
|
|
198
|
-
| `npm run test:
|
|
218
|
+
|
|
219
|
+
| Command | Workspace | Description |
|
|
220
|
+
| --------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
221
|
+
| `npm run test:unit` | Monorepo | Runs Node.js native unit tests (`tests/unit/*.test.js`) for schema parsers and AST converters. |
|
|
222
|
+
| `npm run test:perf` | Monorepo | Runs spec parsing, circular ref, and dereferencing benchmarks (`tests/perf/benchmark.js`). |
|
|
223
|
+
| `npm run test:render` | Monorepo | Measures headless browser rendering performance across render styles using Puppeteer (`tests/perf/render-benchmark.js`). |
|
|
199
224
|
|
|
200
225
|
#### Code Quality & Formatting
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
|
204
|
-
| `npm run
|
|
205
|
-
| `npm run format`
|
|
206
|
-
| `npm run format-fix` | Monorepo
|
|
226
|
+
|
|
227
|
+
| Command | Workspace | Description |
|
|
228
|
+
| -------------------- | --------- | -------------------------------------------------------------------------------------- |
|
|
229
|
+
| `npm run lint` | Monorepo | Runs oxlint (default rules, no config) across packages, docs, tests and scripts. |
|
|
230
|
+
| `npm run format` | Monorepo | Checks formatting with oxfmt (default style) across packages, docs, tests and scripts. |
|
|
231
|
+
| `npm run format-fix` | Monorepo | Formats the same files with oxfmt. |
|
|
207
232
|
|
|
208
233
|
#### Publishing
|
|
209
|
-
|
|
210
|
-
|
|
234
|
+
|
|
235
|
+
| Command | Workspace | Description |
|
|
236
|
+
| ------------------------- | --------- | ---------------------------------------------------- |
|
|
211
237
|
| `npm run publish:rapidoc` | `rapidoc` | Publishes the `rapidoc` package to the npm registry. |
|
|
212
238
|
|
|
213
239
|
---
|
|
@@ -217,7 +243,9 @@ All primary commands can be run from the root of the repository:
|
|
|
217
243
|
The documentation site is built with modern **Astro** using clean, extensionless URLs (`/api`, `/examples`, `/list`, `/quickstart`).
|
|
218
244
|
|
|
219
245
|
### Deployment via GitHub Actions
|
|
220
|
-
|
|
246
|
+
|
|
247
|
+
When code is pushed to `master` or `main`, the [deploy-docs.yml](file:///Users/mrin/work/rapidoc/.github/workflows/deploy-docs.yml) GitHub Action automatically:
|
|
248
|
+
|
|
221
249
|
1. Compiles the `rapidoc` library bundle (`packages/rapidoc/dist/rapidoc-min.js`).
|
|
222
250
|
2. Builds the Astro documentation site into `docs/dist/` (`npm run build`).
|
|
223
251
|
3. Deploys the static output directory (`docs/dist/`) directly to **GitHub Pages** using `@actions/deploy-pages`.
|
|
@@ -231,9 +259,9 @@ When code is pushed to `master` or `main`, the [deploy-docs.yml](file:///Users/m
|
|
|
231
259
|
|
|
232
260
|
OpenAPI specs are organized inside `docs/public/` based on their visibility and purpose:
|
|
233
261
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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`).
|
|
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`).
|
|
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`).
|
|
237
265
|
|
|
238
266
|
---
|
|
239
267
|
|
|
@@ -242,12 +270,101 @@ OpenAPI specs are organized inside `docs/public/` based on their visibility and
|
|
|
242
270
|
- [x] Modernize project dependencies (Vite + Astro + Node 22+)
|
|
243
271
|
- [x] Restructure as a multi-package Monorepo
|
|
244
272
|
- [ ] Build `rapidoc-cli` for OpenAPI linting and local zero-config previews
|
|
245
|
-
- [
|
|
273
|
+
- [x] Build `rapidoc-portal`, a docs-as-code developer portal, with sign-in (`rapidoc-server`) and mocking (`rapidoc-mock`)
|
|
246
274
|
- [ ] Automated visual regression testing suite with Playwright
|
|
247
275
|
- [ ] Web Content Accessibility Guidelines (WCAG 2.1) compliance enhancements
|
|
248
276
|
|
|
249
277
|
---
|
|
250
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
|
+
|
|
251
368
|
## License
|
|
252
369
|
|
|
253
370
|
MIT © [Mrinmoy Majumdar](https://github.com/mrin9)
|