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
5.`@apidevtools/swagger-parser` — dereference all `$ref` chains for endpoint extraction.
209
209
6.`parseSecuritySchemes(api)` — extract security schemes into `SecuritySchemeModel[]`.
210
210
7.`buildEndpoints(api, tags, convention)` — map each operation to `EndpointModel`.
211
-
8.`renderTokenFile()` / `renderSecurityTokenFile()` — emit token files as strings.
212
-
9. Stale file cleanup — delete any `.token.ts` / `.security-token.ts` files present before the run that weren't produced this run.
211
+
8.`renderTokenFile()` / `renderSecurityTokenFile()`/ `renderMockFile()`— emit token and mock files as strings.
212
+
9. Stale file cleanup — snapshot `.token.ts`, `.security-token.ts`, `.mock.ts`, `mocks.manifest.json`, `index.ts`, and `index.mock.ts` files before the run; delete any that weren't produced this run.
213
213
10.`@nx/devkit``formatFiles()` — run Prettier over all written files.
"specId": "string — embedded in MockResourceMeta._meta; must match the specId used when importing the spec into the DevTools panel"
226
+
"specId": "string — embedded in MockResourceMeta._meta; must match the specId used when importing the spec into the DevTools panel",
227
+
"verbose": "true | false (default: false) — print +/~/- summary of created/updated/deleted files after generation"
227
228
}
228
229
```
229
230
@@ -484,7 +485,11 @@ Conventional Commits PR title (it becomes the squash commit). See
484
485
| Security tokens — digest |`InjectionToken<HttpInterceptorFn>` + named host-scoped interceptor | Challenge-response at HTTP layer; base URL token prevents cross-API interceptor conflicts |
485
486
| Remote spec URL |`specPath` accepts `http://`/`https://` URLs — downloads to a temp file, then processes identically to local files | Eliminates the `curl` pre-step; temp file is cleaned up in the `finally` block regardless of success/failure |
486
487
| Header params |`in: header` params become named string args (required or optional), rendered into a `headers` block alongside auth scheme headers | Consistent with how path params are surfaced; keeps the public API surface explicit and typed |
487
-
| Stale file cleanup | Before generation, snapshot existing `.token.ts`/`.security-token.ts` files; after generation, delete any that weren't produced this run | Prevents phantom exports when endpoints are removed or `tagFilter` narrows the output |
488
+
| Cookie params |`in: cookie` params become named string args (after header params) and are combined into a single `Cookie` header using `[...].join('; ')`; optional cookies use a conditional spread | Cookie params work in SSR (Node HttpClient); browser Cookie header is a forbidden header — document that constraint at usage time rather than in the type |
489
+
|`@deprecated` JSDoc | Generator emits `/** @deprecated */` above the `InjectionToken` constant when `operation.deprecated === true` in the spec | TypeScript deprecation warning at the inject() call site; no runtime cost |
490
+
| Response type unions | Generator collects all 2xx codes with `application/json` content (not just the first); emits a `\|`-union type alias when multiple codes exist | Some endpoints legitimately return 200 (update) or 201 (create) with different shapes; a union preserves that information instead of silently picking one |
491
+
| Binary body | When `requestBody` has no json/form/multipart content type (e.g. `application/octet-stream`, `image/*`), the generated `Body` type alias is `Blob \| ArrayBuffer` instead of the `paths` chain |`paths[...]['requestBody']['content']['application/octet-stream']` would be `string \| Blob` from openapi-typescript — not useful for Angular's `HttpClient` which needs the actual binary object |
492
+
| Stale file cleanup | Before generation, snapshot `.token.ts`, `.security-token.ts`, `.mock.ts`, `mocks.manifest.json`, `index.ts`, and `index.mock.ts` files; after generation, delete any that weren't produced this run | Prevents phantom exports when endpoints are removed or `tagFilter` narrows the output; including barrel files ensures orphaned tag folders (with their `index.ts`) are also removed |
488
493
| Nx executor |`@constantant/openapi-resource-gen:generate` executor wraps the generator so users can declare a `generate` target in `project.json`|`nx run mylib:generate` is easier to remember and can be wired into CI; uses `FsTree`+`flushChanges` from `nx/src/generators/tree` (not in `@nx/devkit` public API) |
489
494
| Lint cache invalidation |`@nx/eslint:lint` has an `externalDependencies` input listing the ESLint plugin packages (`eslint`, `angular-eslint`, `typescript-eslint`, `@eslint/js`, …) in `nx.json`| A rule-strengthening dependency bump (e.g. an `angular-eslint` major) must re-lint against current source, not return a stale cached "pass". Without this, the angular-eslint 22 upgrade merged green while leaving `master` failing `prefer-on-push-component-change-detection`|
490
495
|`includeMocks` + MockResourceMeta | Generator emits `*.mock.ts` alongside each `*.token.ts`; each mock file exports `_meta: MockResourceMeta` with `specId`, `operationId`, `path`, `method`, `tag`| DevTools panel needs this metadata to display operation info and match mock keys to spec entries |
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,6 +94,7 @@ Re-run the generator command whenever your spec changes — it overwrites genera
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
96
|`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
+
|`verbose`| no |`false`| Print a `+`/`~`/`-` summary of created, updated, and deleted files after generation. |
97
98
98
99
See [`tools/openapi-resource-gen/README.md`](tools/openapi-resource-gen/README.md) for full documentation.
99
100
@@ -148,6 +149,10 @@ Key properties of every generated file:
148
149
-**Request suppression** — returning `undefined` from the lambda keeps the resource idle (no request)
149
150
-**Scoped base URL** — each lib has its own `InjectionToken<string>` so different parts of an app can point at different environments
150
151
-**Header params** — `in: header` parameters become named string args on the factory function and are merged into the `headers` object alongside any auth scheme headers
152
+
-**Cookie params** — `in: cookie` parameters become named string args (after header params) and are combined into a single `Cookie` header value; optional cookies are conditionally included
153
+
-**Binary body** — non-json/form/multipart request bodies (e.g. `application/octet-stream`, `image/*`) emit `Blob | ArrayBuffer` as the body type
154
+
-**Response type unions** — when an endpoint returns multiple 2xx JSON response codes (e.g. 200 and 201), the generated `Response` type alias is a union of all of them
155
+
-**`@deprecated` JSDoc** — operations marked `deprecated: true` in the spec emit `/** @deprecated */` above the token constant, surfacing the warning at every `inject()` call site
151
156
-**Security tokens** — signal-based schemes (`bearer`, `basic`, `apiKey`) emit `InjectionToken<Signal<string | null>>`; `digest` schemes emit `InjectionToken<HttpInterceptorFn>` + a named, host-scoped interceptor that delegates only to requests matching the lib's base URL, preventing cross-API conflicts
Copy file name to clipboardExpand all lines: tools/openapi-resource-gen/README.md
+76-2Lines changed: 76 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,7 @@ Re-run the same command whenever your spec changes — the generator overwrites
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
90
|`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
+
|`verbose`| no |`false`| Print a `+`/`~`/`-` summary of created, updated, and deleted files after generation. |
91
92
92
93
---
93
94
@@ -218,8 +219,13 @@ are never accidentally bundled into a production build.
218
219
219
220
### Stale cleanup
220
221
221
-
Re-running the generator without `--includeMocks` deletes any `.mock.ts` files from
222
-
the previous run. Removing an endpoint from the spec also removes its `.mock.ts`.
222
+
Re-running the generator cleans up any file it no longer produces. This includes:
223
+
-`.token.ts` / `.mock.ts` for removed endpoints
224
+
-`.security-token.ts` for removed security schemes
225
+
-`{tag}/index.ts` / `{tag}/index.mock.ts` barrel files when all endpoints for a tag are removed (e.g. after narrowing `--tagFilter`)
226
+
-`mocks.manifest.json` when `--includeMocks` is dropped
227
+
228
+
Stale tag folders (left empty after their barrels are removed) are also deleted.
223
229
224
230
---
225
231
@@ -303,6 +309,42 @@ headers: {
303
309
},
304
310
```
305
311
312
+
### GET with cookie params
313
+
314
+
`in: cookie` parameters become named string args placed after header params. Required
315
+
cookies are required args; optional ones get `?`. All cookies for the endpoint are
316
+
combined into a single `Cookie` header value at request time:
> **Browser note:** The `Cookie` header is a [forbidden header name](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name) — browsers silently block it. Cookie params work correctly in Angular Universal / SSR (Node's `HttpClient` has no such restriction). For browser-only apps, set cookies via `document.cookie` before making the request and pass `withCredentials: true`.
334
+
335
+
### Deprecated operations
336
+
337
+
When the spec marks an operation with `deprecated: true`, the generator emits a
338
+
`/** @deprecated */` JSDoc comment immediately above the token constant:
0 commit comments