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
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 structured as a **Monorepo** using workspaces, compatible with **Node/npm**, **pnpm**, and **Bun**:
62
+ This repository is a monorepo built on **npm workspaces** (`packages/*` and `docs`):
63
63
 
64
64
  ```text
65
- astro-rapidoc/
65
+ rapidoc/
66
66
  ├── packages/
67
- │ ├── rapidoc/ # Core Web Component library (published as "rapidoc")
68
- │ │ ├── src/ # Web component source code (Lit + modern ESM)
69
- │ │ ├── dist/ # Production bundle (rapidoc-min.js)
70
- │ │ ├── package.json # Library package config
71
- │ │ └── vite.config.mjs # Dedicated library build config
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-cli/ # Command-line utility (lint, preview, bundle)
74
- │ │ ├── src/ # CLI source code
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
- │ └── rapidoc-portal/ # PocketBase developer portal to host & secure specs
78
- │ └── package.json
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 & showcase site (GitHub Pages)
81
- │ ├── src/ # Astro pages, components, and layouts
82
- │ │ ├── pages/examples/ # Public showcase pages (code-highlight, petstore, etc.)
83
- │ │ └── pages/tests/ # Internal test & edge-case pages
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/ # PUBLIC showcase specs (used by /examples)
86
- │ │ └── specs-test/ # INTERNAL test specs (edge cases & parser fixtures)
87
- │ │ └── parser/ # Malformed & validation test specs
88
- │ ├── astro.config.mjs # Astro site configuration
89
- │ └── package.json # Workspace package "docs"
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
- │ └── visual/ # Automated visual regression test suite (Playwright)
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
- ├── package.json # Monorepo root configuration (workspaces)
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
- | Command | Workspace | Description |
179
- |---|---|---|
180
- | `npm run dev` | `docs` | Launches Astro documentation & showcase dev server (`http://localhost:4321`) with live unminified RapiDoc ESM directly from source. |
181
- | `npm run stop` | `docs` | Terminates background Astro dev server processes. |
182
- | `npm run preview` | `docs` | Previews the production build of the documentation site (`docs/dist`) locally. |
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
- | Command | Workspace | Description |
186
- |---|---|---|
187
- | `npm run build` | Monorepo | Sequentially builds production RapiDoc library bundle and the Astro documentation site. |
188
- | `npm run build:rapidoc` | `rapidoc` | Compiles production, minified Web Component bundle to `packages/rapidoc/dist/rapidoc-min.js`. |
189
- | `npm run build:rapidoc:dev` | `rapidoc` | Compiles unminified Web Component bundle with source maps & console logs to `packages/rapidoc/dist/`. |
190
- | `npm run build:docs` | `docs` | Builds the production Astro documentation site into `docs/dist/` (and syncs bundle to `generated-docs/`). |
191
- | `npm run build:size` | `rapidoc` | Builds RapiDoc with `ANALYZE=true` and opens an interactive bundle visualizer (`dist/stats.html`). |
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
- | Command | Workspace | Description |
195
- |---|---|---|
196
- | `npm run test:unit` | Monorepo | Runs Node.js native unit tests (`tests/unit/*.test.js`) for schema parsers and AST converters. |
197
- | `npm run test:perf` | Monorepo | Runs spec parsing, circular ref, and dereferencing benchmarks (`tests/perf/benchmark.js`). |
198
- | `npm run test:render` | Monorepo | Measures headless browser rendering performance across render styles using Puppeteer (`tests/perf/render-benchmark.js`). |
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
- | Command | Workspace | Description |
202
- |---|---|---|
203
- | `npm run lint` | `rapidoc` | Runs ESLint on `packages/rapidoc/src/**/*.js` with Lit rules. |
204
- | `npm run analyze` | `rapidoc` | Runs Lit Analyzer to validate custom element templates and bindings. |
205
- | `npm run format` | Monorepo | Checks code formatting against `.prettierrc` across packages and docs. |
206
- | `npm run format-fix` | Monorepo | Automatically formats code using Prettier across packages and docs. |
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
- | Command | Workspace | Description |
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
- When code is pushed to `master` or `main`, the [deploy-docs.yml](file:///Users/mrin/work/astro-rapidoc/.github/workflows/deploy-docs.yml) GitHub Action automatically:
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
- * **`docs/public/specs/`**: Public showcase specs referenced in [example-list.yaml](file:///Users/mrin/work/astro-rapidoc/docs/src/data/example-list.yaml) and displayed on `rapidocui.com` (e.g., `petstore.yaml`, `code-highlight.yaml`, `auth.yaml`).
235
- * **`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`).
236
- * **`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`).
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
- - [ ] Build `rapidoc-portal` with PocketBase for developer API portals
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)