You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,7 @@ Re-run the generator command whenever your spec changes — it overwrites genera
93
93
|`namingConvention`| no |`kebab`|`kebab` or `camel` — controls file names |
94
94
|`providedIn`| no |`none`|`none` (use `provideX()` helpers) or `root` (self-registering) |
95
95
|`includeMocks`| no |`false`| Co-generate `.mock.ts` providers, `index.mock.ts` barrels, and `mocks.manifest.json` — requires `@constantant/openapi-resource-mocks`|
96
+
|`includeMswHandlers`| no |`false`| Co-generate `.msw.ts` MSW 2.x handler files and `index.msw.ts` barrels — requires [`msw`](https://mswjs.io) >= 2.0.0 |
96
97
|`specId`| no | derived | Identifier embedded in `MockResourceMeta` and `mocks.manifest.json`. Defaults to `baseUrlToken` with `_BASE_URL` stripped (e.g. `PETSTORE_BASE_URL` → `petstore`). Must match when importing into the DevTools panel. |
97
98
|`verbose`| no |`false`| Print a `+`/`~`/`-` summary of created, updated, and deleted files after generation. |
98
99
@@ -257,17 +258,27 @@ A companion package that provides zero-HTTP, pure-DI mocks for generated tokens.
257
258
-`provideMockResourceBus()` — registers the bus; exposes `window.__openApiMocks__` and `openApiMock(key)` for Playwright
258
259
-`provideMockResource(token, key, initialBehavior?, meta?)` — replaces a token's factory with a mock; the optional `meta` (`MockResourceMeta`) is embedded automatically in generated `.mock.ts` files and used by the DevTools panel to resolve response schemas
259
260
- DOM event bridge (`openapi-mock-event` / `openapi-mock-control`) — lets the Chrome Extension DevTools panel observe and control mocks in real time
261
+
-`injectMockResource<T>(key)` — retrieves the `MockResourceRef<T>` for a registered key inside an injection context (e.g. `TestBed.runInInjectionContext`)
-**`/testing` sub-entry** — `mockResource(token, behavior?)` returns a `MockResourceHandle<T>` extending `FactoryProvider`; drop directly into `TestBed` providers without a full bus setup; supports `{ sequence: [...] }` for multi-step per-call responses
261
264
262
265
See [`tools/openapi-resource-mocks/README.md`](tools/openapi-resource-mocks/README.md) for full documentation.
Current version: **0.6.0** | Status: pending Chrome Web Store review
271
+
Current version: **0.7.0** | Status: pending Chrome Web Store review
269
272
270
-
A Chrome DevTools panel that connects to any Angular app running `@constantant/openapi-resource-mocks`. It lists every registered mock token, shows live state, and lets you resolve, fail, catch, or reset mocks without touching code. The **Specs** tab lets you import a `mocks.manifest.json` or full OpenAPI spec to enable schema-aware features in the Respond tab: auto-generated example payloads (⚡ Example) and JSON schema validation (✓ Validate).
273
+
A Chrome DevTools panel that connects to any Angular app running `@constantant/openapi-resource-mocks`. It lists every registered mock token, shows live state, and lets you resolve, fail, catch, or reset mocks without touching code.
274
+
275
+
Key panel features:
276
+
-**Mock table** — live status, catch mode toggle, resolve/fail/reset actions per token
277
+
-**Respond tab** — JSON editor with schema-aware ⚡ Example generation and ✓ Validate; delay control; catch mode release
278
+
-**History tab** — reverse-chronological event log; for `request`/`caught` events shows the filled URL (`GET /pet/42`), path-param rows labeled by name, and Query / Body sections for remaining args; binary payloads (`[FormData]`, `[Blob]`, etc.) shown as inline badges
279
+
-**Specs tab** — import `mocks.manifest.json` or a full OpenAPI spec (JSON or YAML, file or URL) to enable schema-aware features
280
+
-**Scenarios** toolbar button — save named snapshots of the full mock table state, load / delete them, or export / import as JSON for cross-machine sharing
281
+
-**+ New mock** button — create a panel-managed (local) mock before `provideMockResource()` exists in the app, pre-configure catch mode and a response value, and have it promoted in-place when the key is registered
Copy file name to clipboardExpand all lines: tools/openapi-resource-devtools/README.md
+29-1Lines changed: 29 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,17 @@ Manually resolve, fail, or control the selected mock:
87
87
88
88
### History tab
89
89
90
-
Reverse-chronological event log for the selected mock (up to 200 entries). Each row shows the timestamp, event type badge, and a truncated JSON preview of the value or error. A **Clear** button wipes the log.
90
+
Reverse-chronological event log for the selected mock (up to 200 entries). A **Clear** button wipes the log.
91
+
92
+
Each row shows the timestamp, event type badge, and a one-line preview. For `request` and `caught` events the preview shows the **filled URL** — e.g. `GET /pet/42` — derived from the operation's path template and the actual args the component passed.
93
+
94
+
Clicking a row expands a structured detail view:
95
+
96
+
-**Filled URL** — the path with `{param}` placeholders substituted by positional args (e.g. `GET /pet/{petId}` → `GET /pet/42`)
97
+
-**Path param rows** — one row per `{param}`, labeled by name from the spec, showing the actual value passed
98
+
-**Query / Body section** — remaining args after path params are labeled **Query** (GET/HEAD/DELETE) or **Body** (POST/PUT/PATCH)
99
+
-**Binary badges** — `[FormData]`, `[Blob]`, `[ArrayBuffer]`, and `[File: name]` are displayed as inline badges instead of quoted strings
100
+
-**Response / Error sections** — shown for `resolve` and `error` events
91
101
92
102
---
93
103
@@ -145,10 +155,28 @@ After each release, if catch mode is still on, the resource is immediately re-in
145
155
| ⏸ Catch All | Toggles catch mode on every registered mock |
146
156
| Clear | Removes all mocks from the panel (does not affect the page) |
147
157
| Reset All | Calls `reset()` on every mock, returning them to `idle`|
158
+
| Scenarios | Opens the Scenarios dialog — save named snapshots of the full mock table state, load / delete them, or export / import as JSON for cross-machine sharing |
148
159
| Filter… | Filters the mock table by key name |
149
160
150
161
---
151
162
163
+
## Local (unregistered) mocks
164
+
165
+
The **+ New mock** button in the mock table toolbar lets you create a panel-managed mock before `provideMockResource()` exists in the Angular app. Use this to pre-configure a mock response while you're still writing the component code:
166
+
167
+
1. Click **+ New mock** — the **Create mock** dialog opens.
168
+
2. Pick a spec from the **Specs** tab (the spec must already be imported), then select an operation.
169
+
3. The key is auto-generated from the operationId (e.g. `findPetsByStatus` → `FIND_PETS_BY_STATUS`). Edit it if needed.
170
+
4. Click **Create** — the new entry appears in the mock table with status `local`.
171
+
172
+
Local mock entries support all panel controls: catch mode, the Respond tab (including ⚡ Example and ✓ Validate when a spec is imported), and the History tab. Control messages to the page are silently ignored until the matching key is registered by the app.
173
+
174
+
When the app registers `provideMockResource(..., 'FIND_PETS_BY_STATUS', ...)`, the local entry is **promoted in-place** — its status transitions to `idle`, catch mode is preserved, and any pending catch-mode control is re-sent to the now-live bus.
175
+
176
+
Local mock entries are persisted across DevTools sessions in `chrome.storage.local`.
Copy file name to clipboardExpand all lines: tools/openapi-resource-gen/README.md
+69-1Lines changed: 69 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,7 @@ Re-run the same command whenever your spec changes — the generator overwrites
87
87
|`namingConvention`| no |`kebab`|`kebab` → `find-pets-by-status.token.ts`; `camel` → `findPetsByStatus.token.ts`|
88
88
|`providedIn`| no |`none`|`none` or `root` — see table above |
89
89
|`includeMocks`| no |`false`| Emit a `.mock.ts` per endpoint plus `index.mock.ts` barrels and a `mocks.manifest.json` — requires [`@constantant/openapi-resource-mocks`](https://www.npmjs.com/package/@constantant/openapi-resource-mocks)|
90
+
|`includeMswHandlers`| no |`false`| Emit a `.msw.ts` per endpoint plus `index.msw.ts` barrels — requires [`msw`](https://mswjs.io) >= 2.0.0 |
90
91
|`specId`| no | derived from `baseUrlToken`| Identifier embedded in every generated `MockResourceMeta` and in `mocks.manifest.json`. Defaults to `baseUrlToken` with `_BASE_URL` stripped and lowercased (e.g. `PETSTORE_BASE_URL` → `petstore`). Must match the value used when importing the spec into the DevTools panel. |
91
92
|`verbose`| no |`false`| Print a `+`/`~`/`-` summary of created, updated, and deleted files after generation. |
92
93
@@ -101,12 +102,15 @@ Re-run the same command whenever your spec changes — the generator overwrites
101
102
{scheme}.security-token.ts # one per security scheme (if any)
102
103
index.ts # re-exports all tag barrels + base-url + security tokens
103
104
index.mock.ts # (--includeMocks) re-exports all tag mock barrels
105
+
index.msw.ts # (--includeMswHandlers) re-exports all tag MSW handler arrays
104
106
mocks.manifest.json # (--includeMocks) machine-readable endpoint list + specId for the DevTools panel
105
107
{tag}/
106
108
index.ts # re-exports all token files in this tag folder
107
109
index.mock.ts # (--includeMocks) re-exports all mock files in this tag
110
+
index.msw.ts # (--includeMswHandlers) re-exports all MSW handlers in this tag
108
111
{operation-id}.token.ts # one file per endpoint
109
112
{operation-id}.mock.ts # (--includeMocks) typed mock provider per endpoint
0 commit comments