@constantant/openapi-resource-gen 1.1.4 → 1.3.1
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/CHANGELOG.md +45 -0
- package/README.md +143 -22
- package/executors.json +9 -0
- package/package.json +3 -2
- package/src/executors/generate/executor.d.ts +6 -0
- package/src/executors/generate/executor.js +22 -0
- package/src/executors/generate/executor.js.map +1 -0
- package/src/executors/generate/schema.json +38 -0
- package/src/generators/api-resource/endpoint-model.d.ts +5 -1
- package/src/generators/api-resource/generator.js +118 -7
- package/src/generators/api-resource/generator.js.map +1 -1
- package/src/generators/api-resource/parse-spec.js +18 -15
- package/src/generators/api-resource/parse-spec.js.map +1 -1
- package/src/generators/api-resource/render-token.d.ts +1 -1
- package/src/generators/api-resource/render-token.js +42 -3
- package/src/generators/api-resource/render-token.js.map +1 -1
- package/src/generators/api-resource/schema.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
## 1.3.1 (2026-06-07)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **openapi-resource-gen:** bump tsconfig target/lib to ES2022 ([30db4f0](https://github.com/constantant/angular-openapi-gen/commit/30db4f0))
|
|
6
|
+
- **openapi-resource-gen:** resolve lint errors in generator source ([f89f4b2](https://github.com/constantant/angular-openapi-gen/commit/f89f4b2))
|
|
7
|
+
|
|
8
|
+
### ❤️ Thank You
|
|
9
|
+
|
|
10
|
+
- Claude Sonnet 4.6
|
|
11
|
+
- kk
|
|
12
|
+
|
|
13
|
+
## 1.3.0 (2026-06-07)
|
|
14
|
+
|
|
15
|
+
### 🚀 Features
|
|
16
|
+
|
|
17
|
+
- **openapi-resource-gen:** tier 2 community-readiness improvements ([990d850](https://github.com/constantant/angular-openapi-gen/commit/990d850))
|
|
18
|
+
- **openapi-resource-gen:** tier 1 community-readiness improvements ([a344f50](https://github.com/constantant/angular-openapi-gen/commit/a344f50))
|
|
19
|
+
|
|
20
|
+
### 📖 Documentation
|
|
21
|
+
|
|
22
|
+
- align docs with Tier 1 & 2 generator changes ([a30f2fc](https://github.com/constantant/angular-openapi-gen/commit/a30f2fc))
|
|
23
|
+
- document public repo governance and branch protection ([d7bd84e](https://github.com/constantant/angular-openapi-gen/commit/d7bd84e))
|
|
24
|
+
|
|
25
|
+
### ❤️ Thank You
|
|
26
|
+
|
|
27
|
+
- Claude Opus 4.8
|
|
28
|
+
- Claude Sonnet 4.6
|
|
29
|
+
- kk
|
|
30
|
+
|
|
31
|
+
## 1.2.0 (2026-06-07)
|
|
32
|
+
|
|
33
|
+
### 🚀 Features
|
|
34
|
+
|
|
35
|
+
- **generator:** add Digest auth security scheme support ([a31e1b9](https://github.com/constantant/angular-openapi-gen/commit/a31e1b9))
|
|
36
|
+
|
|
37
|
+
### 📖 Documentation
|
|
38
|
+
|
|
39
|
+
- document Digest auth security scheme support ([5265b0a](https://github.com/constantant/angular-openapi-gen/commit/5265b0a))
|
|
40
|
+
|
|
41
|
+
### ❤️ Thank You
|
|
42
|
+
|
|
43
|
+
- Claude Sonnet 4.6
|
|
44
|
+
- kk
|
|
45
|
+
|
|
1
46
|
## 1.1.4 (2026-06-07)
|
|
2
47
|
|
|
3
48
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -58,18 +58,29 @@ base URL overrides.
|
|
|
58
58
|
|
|
59
59
|
## Running the generator
|
|
60
60
|
|
|
61
|
+
Pass a local file path or any `https://` URL:
|
|
62
|
+
|
|
61
63
|
```bash
|
|
64
|
+
# From a local file
|
|
62
65
|
npx nx g @constantant/openapi-resource-gen:api-resource \
|
|
63
66
|
--specPath=specs/petstore.yaml \
|
|
64
67
|
--outputDir=libs/petstore-data-access/src \
|
|
65
68
|
--baseUrlToken=PETSTORE_BASE_URL
|
|
69
|
+
|
|
70
|
+
# From a remote URL (no curl step needed)
|
|
71
|
+
npx nx g @constantant/openapi-resource-gen:api-resource \
|
|
72
|
+
--specPath=https://petstore3.swagger.io/api/v3/openapi.yaml \
|
|
73
|
+
--outputDir=libs/petstore-data-access/src \
|
|
74
|
+
--baseUrlToken=PETSTORE_BASE_URL
|
|
66
75
|
```
|
|
67
76
|
|
|
77
|
+
Re-run the same command whenever your spec changes — the generator overwrites updated files and **deletes any token files that no longer correspond to an endpoint in the spec**.
|
|
78
|
+
|
|
68
79
|
### Options
|
|
69
80
|
|
|
70
81
|
| Option | Required | Default | Description |
|
|
71
82
|
|--------|----------|---------|-------------|
|
|
72
|
-
| `specPath` | yes | — |
|
|
83
|
+
| `specPath` | yes | — | Local path **or** `https://` URL to the OpenAPI 3.x YAML or JSON spec |
|
|
73
84
|
| `outputDir` | yes | — | Output directory relative to the workspace root |
|
|
74
85
|
| `baseUrlToken` | no | `API_BASE_URL` | Name of the base-URL `InjectionToken` emitted alongside the endpoint tokens |
|
|
75
86
|
| `tagFilter` | no | all tags | Comma-separated list of OpenAPI tags to include |
|
|
@@ -151,6 +162,30 @@ export const REPOS_GET = new InjectionToken<
|
|
|
151
162
|
>('REPOS_GET');
|
|
152
163
|
```
|
|
153
164
|
|
|
165
|
+
### GET with header params
|
|
166
|
+
|
|
167
|
+
`in: header` parameters (e.g. `X-Api-Version`, `Accept-Language`) become named
|
|
168
|
+
string arguments on the returned function, placed after path params but before
|
|
169
|
+
query params. Required header params are required args; optional ones get `?`:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
export const LIST_REPORTS = new InjectionToken<
|
|
173
|
+
(xApiVersion: string, acceptLanguage?: string, params?: ListReportsParams)
|
|
174
|
+
=> ReturnType<typeof httpResource<ListReportsResponse>>
|
|
175
|
+
>('LIST_REPORTS');
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Inside the resource, they are merged into the `headers` object. Required params
|
|
179
|
+
are set directly; optional ones use a conditional spread so no header is sent
|
|
180
|
+
when the value is `undefined`:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
headers: {
|
|
184
|
+
'X-Api-Version': xApiVersion,
|
|
185
|
+
...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : {}),
|
|
186
|
+
},
|
|
187
|
+
```
|
|
188
|
+
|
|
154
189
|
### Mutation (POST/PUT/PATCH/DELETE)
|
|
155
190
|
|
|
156
191
|
The factory returns `(body: BodyType | Signal<BodyType>) => httpResource(...)`.
|
|
@@ -158,8 +193,16 @@ The resource config receives `method: 'POST'` (etc.) and `body` automatically.
|
|
|
158
193
|
|
|
159
194
|
### Security schemes
|
|
160
195
|
|
|
161
|
-
|
|
162
|
-
|
|
196
|
+
The generator emits one file per security scheme. Two patterns are used depending on the
|
|
197
|
+
scheme kind.
|
|
198
|
+
|
|
199
|
+
#### Signal-based schemes
|
|
200
|
+
|
|
201
|
+
`bearer`, `oauth2`, `openIdConnect`, `basic`, `apiKey-header`, `apiKey-query` — emit
|
|
202
|
+
`InjectionToken<Signal<string | null>>`. Endpoint tokens inject these optionally and merge
|
|
203
|
+
auth into the request as headers or query params. Reading the signal inside the `httpResource`
|
|
204
|
+
lambda creates a reactive dependency — the request re-fires automatically when the token value
|
|
205
|
+
changes:
|
|
163
206
|
|
|
164
207
|
```typescript
|
|
165
208
|
// oauth2.security-token.ts
|
|
@@ -167,9 +210,6 @@ import { InjectionToken, Signal } from '@angular/core';
|
|
|
167
210
|
export const OAUTH2 = new InjectionToken<Signal<string | null>>('OAUTH2');
|
|
168
211
|
```
|
|
169
212
|
|
|
170
|
-
Endpoint tokens inject these optionally. Reading the signal inside the `httpResource`
|
|
171
|
-
lambda creates a reactive dependency — the request re-fires when the token value changes:
|
|
172
|
-
|
|
173
213
|
```typescript
|
|
174
214
|
const oauth2 = inject(OAUTH2, { optional: true }); // Signal<string | null> | null
|
|
175
215
|
// In the reactive lambda:
|
|
@@ -178,8 +218,6 @@ headers: {
|
|
|
178
218
|
},
|
|
179
219
|
```
|
|
180
220
|
|
|
181
|
-
Supported scheme kinds:
|
|
182
|
-
|
|
183
221
|
| Kind | Auth mechanism |
|
|
184
222
|
|------|---------------|
|
|
185
223
|
| `bearer` / `oauth2` / `openIdConnect` | `Authorization: Bearer <token>` |
|
|
@@ -187,18 +225,95 @@ Supported scheme kinds:
|
|
|
187
225
|
| `apiKey-header` | Custom header (e.g. `X-API-Key: <token>`) |
|
|
188
226
|
| `apiKey-query` | Query param (e.g. `?apiKey=<token>`) |
|
|
189
227
|
|
|
190
|
-
|
|
228
|
+
Wire up in `app.config.ts`:
|
|
191
229
|
|
|
192
230
|
```typescript
|
|
193
|
-
// Create a writable signal at the app level
|
|
194
231
|
export const MY_API_KEY = new InjectionToken<WritableSignal<string | null>>(
|
|
195
232
|
'MY_API_KEY', { providedIn: 'root', factory: () => signal(null) }
|
|
196
233
|
);
|
|
197
234
|
|
|
198
|
-
// Provide the scheme token
|
|
199
235
|
{ provide: OAUTH2, useFactory: () => inject(MY_API_KEY) }
|
|
200
236
|
```
|
|
201
237
|
|
|
238
|
+
#### Interceptor-based schemes
|
|
239
|
+
|
|
240
|
+
`digest` — HTTP Digest is a challenge-response protocol: the Authorization header value
|
|
241
|
+
depends on the request URL, method, and a server-issued nonce, so it cannot be computed
|
|
242
|
+
as a static signal value. The generator emits `InjectionToken<HttpInterceptorFn>` plus a
|
|
243
|
+
**named, host-scoped interceptor wrapper**:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// digest-auth.security-token.ts (generated for MYAPI_BASE_URL)
|
|
247
|
+
import { InjectionToken, inject } from '@angular/core';
|
|
248
|
+
import { HttpInterceptorFn } from '@angular/common/http';
|
|
249
|
+
import { MYAPI_BASE_URL } from './api-base-url.token';
|
|
250
|
+
|
|
251
|
+
export const DIGEST_AUTH = new InjectionToken<HttpInterceptorFn>('DIGEST_AUTH');
|
|
252
|
+
|
|
253
|
+
export const myapiDigestAuthInterceptor: HttpInterceptorFn = (req, next) => {
|
|
254
|
+
const base = inject(MYAPI_BASE_URL);
|
|
255
|
+
if (!req.url.startsWith(base)) return next(req); // scoped to this API only
|
|
256
|
+
const fn = inject(DIGEST_AUTH, { optional: true });
|
|
257
|
+
if (!fn) return next(req);
|
|
258
|
+
return fn(req, next);
|
|
259
|
+
};
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The interceptor name is derived from the base URL token name (`MYAPI_BASE_URL` → `myapi`)
|
|
263
|
+
and the scheme name. This makes it unique per API — if two APIs both use Digest, they emit
|
|
264
|
+
distinct interceptors with distinct host guards and never interfere with each other.
|
|
265
|
+
|
|
266
|
+
The consumer's implementation receives the full `HttpRequest`, which carries
|
|
267
|
+
`req.urlWithParams`, `req.method`, and `req.body` — everything needed to compute the
|
|
268
|
+
RFC 7616 hash with no reconstruction:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { myapiDigestAuthInterceptor, DIGEST_AUTH } from '@angular-openapi-gen/myapi-data-access';
|
|
272
|
+
|
|
273
|
+
export const appConfig: ApplicationConfig = {
|
|
274
|
+
providers: [
|
|
275
|
+
provideHttpClient(
|
|
276
|
+
withInterceptors([myapiDigestAuthInterceptor])
|
|
277
|
+
),
|
|
278
|
+
{ provide: DIGEST_AUTH, useValue: myDigestInterceptorFn },
|
|
279
|
+
],
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Digest endpoint tokens do not inject the `DIGEST_AUTH` token directly — auth is applied
|
|
284
|
+
transparently by the interceptor at the HTTP layer.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Declarative re-generation with the executor
|
|
289
|
+
|
|
290
|
+
Instead of remembering the full `nx g` command, declare a `generate` target in
|
|
291
|
+
your lib's `project.json` using the bundled executor:
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"name": "petstore-data-access",
|
|
296
|
+
"targets": {
|
|
297
|
+
"generate": {
|
|
298
|
+
"executor": "@constantant/openapi-resource-gen:generate",
|
|
299
|
+
"options": {
|
|
300
|
+
"specPath": "https://petstore3.swagger.io/api/v3/openapi.yaml",
|
|
301
|
+
"outputDir": "libs/petstore-data-access/src",
|
|
302
|
+
"baseUrlToken": "PETSTORE_BASE_URL"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Then regenerate any time with:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
npx nx run petstore-data-access:generate
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The executor accepts the same options as the generator.
|
|
316
|
+
|
|
202
317
|
---
|
|
203
318
|
|
|
204
319
|
## Consuming tokens in a component
|
|
@@ -271,28 +386,22 @@ type PetStatus = FindPetsByStatusParams['status']; // 'available' | 'pending' |
|
|
|
271
386
|
|
|
272
387
|
## Adding a new data-access lib
|
|
273
388
|
|
|
274
|
-
1.
|
|
275
|
-
```bash
|
|
276
|
-
curl -L https://example.com/openapi.yaml -o specs/myapi.yaml
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
2. Run the generator:
|
|
389
|
+
1. Run the generator (pass a URL directly — no curl step needed):
|
|
280
390
|
```bash
|
|
281
391
|
npx nx g @constantant/openapi-resource-gen:api-resource \
|
|
282
|
-
--specPath=
|
|
392
|
+
--specPath=https://example.com/openapi.yaml \
|
|
283
393
|
--outputDir=libs/myapi-data-access/src \
|
|
284
394
|
--baseUrlToken=MYAPI_BASE_URL
|
|
285
395
|
```
|
|
286
396
|
|
|
287
|
-
|
|
397
|
+
2. Add a path alias to `tsconfig.base.json`:
|
|
288
398
|
```json
|
|
289
399
|
"@angular-openapi-gen/myapi-data-access": ["libs/myapi-data-access/src/index.ts"]
|
|
290
400
|
```
|
|
291
401
|
|
|
292
|
-
|
|
402
|
+
3. Add base URL provider and token providers to `app.config.ts`.
|
|
293
403
|
|
|
294
|
-
|
|
295
|
-
overwrites all files in `outputDir`.
|
|
404
|
+
4. Optionally, add a `generate` target to your lib's `project.json` (see the executor section above) so future regeneration is just `nx run myapi-data-access:generate`.
|
|
296
405
|
|
|
297
406
|
---
|
|
298
407
|
|
|
@@ -310,3 +419,15 @@ overwrites all files in `outputDir`.
|
|
|
310
419
|
Hyphenated path parameter names (e.g. `{enterprise-team}` in the GitHub spec)
|
|
311
420
|
and dotted operationIds (e.g. `youtube.search.list`) are converted to camelCase /
|
|
312
421
|
PascalCase via `toCamelCase()` / `toPascalCase()` to produce valid JavaScript identifiers.
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Contributing
|
|
426
|
+
|
|
427
|
+
This package is developed in the [`angular-openapi-gen`](https://github.com/constantant/angular-openapi-gen)
|
|
428
|
+
Nx workspace. Issues and pull requests are welcome — see
|
|
429
|
+
[CONTRIBUTING.md](https://github.com/constantant/angular-openapi-gen/blob/master/CONTRIBUTING.md).
|
|
430
|
+
|
|
431
|
+
## License
|
|
432
|
+
|
|
433
|
+
[MIT](https://github.com/constantant/angular-openapi-gen/blob/master/LICENSE)
|
package/executors.json
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constantant/openapi-resource-gen",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Nx generator: one InjectionToken per OpenAPI endpoint — tree-shakeable Angular data-access libs via httpResource",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"types": "src/index.d.ts",
|
|
8
8
|
"generators": "./generators.json",
|
|
9
|
+
"executors": "./executors.json",
|
|
9
10
|
"keywords": [
|
|
10
11
|
"nx",
|
|
11
12
|
"nx-plugin",
|
|
@@ -31,4 +32,4 @@
|
|
|
31
32
|
"tslib": "^2.3.0"
|
|
32
33
|
},
|
|
33
34
|
"type": "commonjs"
|
|
34
|
-
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { ApiResourceGeneratorSchema } from '../../generators/api-resource/generator';
|
|
3
|
+
export type GenerateExecutorSchema = ApiResourceGeneratorSchema;
|
|
4
|
+
export default function generateExecutor(options: GenerateExecutorSchema, context: ExecutorContext): Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = generateExecutor;
|
|
4
|
+
// FsTree, flushChanges, printChanges are not re-exported from @nx/devkit —
|
|
5
|
+
// import from the stable internal path (consistent across Nx 22+).
|
|
6
|
+
const { FsTree, flushChanges, printChanges } = require('nx/src/generators/tree');
|
|
7
|
+
const generator_1 = require("../../generators/api-resource/generator");
|
|
8
|
+
async function generateExecutor(options, context) {
|
|
9
|
+
try {
|
|
10
|
+
const tree = new FsTree(context.root, context.isVerbose ?? false);
|
|
11
|
+
await (0, generator_1.apiResourceGenerator)(tree, options);
|
|
12
|
+
const changes = tree.listChanges();
|
|
13
|
+
flushChanges(context.root, changes);
|
|
14
|
+
printChanges(changes);
|
|
15
|
+
return { success: true };
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.error(e.message ?? String(e));
|
|
19
|
+
return { success: false };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../tools/openapi-resource-gen/src/executors/generate/executor.ts"],"names":[],"mappings":";;AAWA,mCAeC;AAzBD,2EAA2E;AAC3E,mEAAmE;AACnE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAA4C,CAAC;AAC5H,uEAGiD;AAIlC,KAAK,UAAU,gBAAgB,CAC5C,OAA+B,EAC/B,OAAwB;IAExB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC;QAClE,MAAM,IAAA,gCAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAE,CAAW,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "Generate",
|
|
4
|
+
"title": "Re-generate API resource tokens from an OpenAPI spec",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"specPath": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Local path or https:// URL to the OpenAPI 3.x YAML or JSON spec file"
|
|
10
|
+
},
|
|
11
|
+
"outputDir": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Output directory for generated files (relative to workspace root)"
|
|
14
|
+
},
|
|
15
|
+
"baseUrlToken": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Name of the InjectionToken holding the API base URL",
|
|
18
|
+
"default": "API_BASE_URL"
|
|
19
|
+
},
|
|
20
|
+
"tagFilter": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Comma-separated list of OpenAPI tags to include (empty = all tags)"
|
|
23
|
+
},
|
|
24
|
+
"namingConvention": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["camel", "kebab"],
|
|
27
|
+
"default": "kebab",
|
|
28
|
+
"description": "File naming convention: kebab-case filenames with SCREAMING_SNAKE token names"
|
|
29
|
+
},
|
|
30
|
+
"providedIn": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"enum": ["root", "none"],
|
|
33
|
+
"default": "none",
|
|
34
|
+
"description": "none: export provideX() helpers for scoped provision. root: self-registering singleton."
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": ["specPath", "outputDir"]
|
|
38
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SecurityKind = 'bearer' | 'basic' | 'apiKey-header' | 'apiKey-query' | 'oauth2' | 'openIdConnect';
|
|
1
|
+
export type SecurityKind = 'bearer' | 'basic' | 'digest' | 'apiKey-header' | 'apiKey-query' | 'oauth2' | 'openIdConnect';
|
|
2
2
|
export interface SecuritySchemeModel {
|
|
3
3
|
schemeName: string;
|
|
4
4
|
kind: SecurityKind;
|
|
@@ -15,6 +15,10 @@ export interface EndpointModel {
|
|
|
15
15
|
method: string;
|
|
16
16
|
apiPath: string;
|
|
17
17
|
pathParams: string[];
|
|
18
|
+
headerParams: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
required: boolean;
|
|
21
|
+
}>;
|
|
18
22
|
tokenName: string;
|
|
19
23
|
fileName: string;
|
|
20
24
|
hasQueryParams: boolean;
|
|
@@ -39,10 +39,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.apiResourceGenerator = apiResourceGenerator;
|
|
40
40
|
const devkit_1 = require("@nx/devkit");
|
|
41
41
|
const fs = __importStar(require("fs"));
|
|
42
|
+
const https = __importStar(require("https"));
|
|
43
|
+
const http = __importStar(require("http"));
|
|
42
44
|
const jsYaml = __importStar(require("js-yaml"));
|
|
43
45
|
// openapi-typescript ships as ESM-only; use the bundled CJS build so this
|
|
44
46
|
// CommonJS generator can call it without a dynamic import().
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
46
47
|
const openapiTS = require('openapi-typescript/dist/index.cjs');
|
|
47
48
|
const path = __importStar(require("path"));
|
|
48
49
|
const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
@@ -69,6 +70,45 @@ function stripNonSchemaRefs(obj) {
|
|
|
69
70
|
}
|
|
70
71
|
return obj;
|
|
71
72
|
}
|
|
73
|
+
/** Download a URL to a local temp file. Returns the temp file path. */
|
|
74
|
+
function fetchSpecUrl(url, destPath) {
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const proto = url.startsWith('https://') ? https : http;
|
|
77
|
+
const file = fs.createWriteStream(destPath);
|
|
78
|
+
proto
|
|
79
|
+
.get(url, (res) => {
|
|
80
|
+
if (res.statusCode !== 200) {
|
|
81
|
+
file.close();
|
|
82
|
+
fs.unlink(destPath, () => undefined);
|
|
83
|
+
reject(new Error(`Failed to fetch spec from ${url}: HTTP ${res.statusCode ?? 'unknown'}`));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
res.pipe(file);
|
|
87
|
+
file.on('finish', () => file.close(() => resolve()));
|
|
88
|
+
})
|
|
89
|
+
.on('error', (err) => {
|
|
90
|
+
file.close();
|
|
91
|
+
fs.unlink(destPath, () => undefined);
|
|
92
|
+
reject(new Error(`Failed to fetch spec from ${url}: ${err.message}`));
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** Recursively collect all file paths under a tree directory. */
|
|
97
|
+
function collectTreeFiles(tree, dir) {
|
|
98
|
+
const result = [];
|
|
99
|
+
if (!tree.exists(dir))
|
|
100
|
+
return result;
|
|
101
|
+
for (const child of tree.children(dir)) {
|
|
102
|
+
const childPath = (0, devkit_1.joinPathFragments)(dir, child);
|
|
103
|
+
if (tree.isFile(childPath)) {
|
|
104
|
+
result.push(childPath);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
result.push(...collectTreeFiles(tree, childPath));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
72
112
|
async function apiResourceGenerator(tree, options) {
|
|
73
113
|
const { specPath, outputDir, baseUrlToken = 'API_BASE_URL', tagFilter, namingConvention = 'kebab', providedIn = 'none', } = options;
|
|
74
114
|
const allowedTags = tagFilter
|
|
@@ -77,26 +117,78 @@ async function apiResourceGenerator(tree, options) {
|
|
|
77
117
|
.map((t) => t.trim())
|
|
78
118
|
.filter(Boolean)
|
|
79
119
|
: null;
|
|
120
|
+
// Snapshot which token/security files already exist so we can delete stale
|
|
121
|
+
// ones that this run no longer produces.
|
|
122
|
+
const preExistingFiles = new Set(collectTreeFiles(tree, outputDir).filter((f) => f.endsWith('.token.ts') || f.endsWith('.security-token.ts')));
|
|
123
|
+
const isUrl = specPath.startsWith('http://') || specPath.startsWith('https://');
|
|
124
|
+
// For URL specs, download to a temp file alongside the workspace root so
|
|
125
|
+
// relative file $refs in the spec (rare for remote specs) still resolve.
|
|
126
|
+
const tmpDownload = isUrl
|
|
127
|
+
? path.join(process.cwd(), `_tmp_oas_download_${Date.now()}.yaml`).replace(/\\/g, '/')
|
|
128
|
+
: null;
|
|
80
129
|
// 1. Parse spec with js-yaml, strip any $refs pointing to non-spec files
|
|
81
130
|
// (e.g. x-topics.$ref: ./docs/getting-started.md in the travel spec).
|
|
82
131
|
// Write the cleaned spec next to the original so relative file $refs
|
|
83
132
|
// within the spec still resolve when swagger-parser dereferences.
|
|
84
|
-
|
|
85
|
-
|
|
133
|
+
let absoluteSpecPath;
|
|
134
|
+
if (isUrl) {
|
|
135
|
+
await fetchSpecUrl(specPath, tmpDownload);
|
|
136
|
+
absoluteSpecPath = tmpDownload;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
absoluteSpecPath = path.resolve(specPath);
|
|
140
|
+
if (!fs.existsSync(absoluteSpecPath)) {
|
|
141
|
+
throw new Error(`Spec file not found: ${absoluteSpecPath}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
let rawParsed;
|
|
145
|
+
try {
|
|
146
|
+
rawParsed = jsYaml.load(fs.readFileSync(absoluteSpecPath, 'utf-8'));
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
throw new Error(`Failed to parse spec as YAML/JSON: ${e.message}`, { cause: e });
|
|
150
|
+
}
|
|
151
|
+
// Validate it looks like an OpenAPI 3.x document before doing any work.
|
|
152
|
+
const specObj = rawParsed;
|
|
153
|
+
if (!specObj || typeof specObj !== 'object') {
|
|
154
|
+
throw new Error(`Spec does not appear to be a valid YAML/JSON document: ${specPath}`);
|
|
155
|
+
}
|
|
156
|
+
const openapiVersion = String(specObj['openapi'] ?? '');
|
|
157
|
+
if (!openapiVersion.startsWith('3')) {
|
|
158
|
+
throw new Error(`Only OpenAPI 3.x specs are supported. Found: "${openapiVersion || '(no openapi field)'}". ` +
|
|
159
|
+
`For Swagger 2.x specs, convert first with swagger2openapi.`);
|
|
160
|
+
}
|
|
161
|
+
if (!specObj['paths'] || typeof specObj['paths'] !== 'object') {
|
|
162
|
+
throw new Error(`No "paths" object found in spec. Is "${specPath}" a valid OpenAPI 3.x file?`);
|
|
163
|
+
}
|
|
86
164
|
const cleanedParsed = stripNonSchemaRefs(rawParsed);
|
|
87
165
|
const tmpClean = path
|
|
88
166
|
.join(path.dirname(absoluteSpecPath), `_tmp_oas_${Date.now()}.json`)
|
|
89
167
|
.replace(/\\/g, '/');
|
|
168
|
+
// Track every file path written in this run to detect stale files.
|
|
169
|
+
const writtenFiles = new Set();
|
|
90
170
|
try {
|
|
91
171
|
fs.writeFileSync(tmpClean, JSON.stringify(cleanedParsed));
|
|
92
172
|
// 2. Emit schema.d.ts via openapi-typescript programmatic API, using the
|
|
93
173
|
// cleaned spec (not the dereferenced result — dereferenced Stripe has
|
|
94
174
|
// circular refs; openapi-typescript resolves $refs itself).
|
|
95
|
-
|
|
175
|
+
let schemaDts;
|
|
176
|
+
try {
|
|
177
|
+
schemaDts = await openapiTS(tmpClean);
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
throw new Error(`Failed to generate TypeScript types from spec: ${e.message}`, { cause: e });
|
|
181
|
+
}
|
|
96
182
|
tree.write((0, devkit_1.joinPathFragments)(outputDir, 'schema.d.ts'), schemaDts);
|
|
97
183
|
// 3. Dereference for endpoint extraction (may produce circular objects —
|
|
98
184
|
// that's fine because we only iterate over it, never serialize it).
|
|
99
|
-
|
|
185
|
+
let api;
|
|
186
|
+
try {
|
|
187
|
+
api = (await swagger_parser_1.default.dereference(tmpClean));
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
throw new Error(`Failed to resolve $ref chains in spec: ${e.message}`, { cause: e });
|
|
191
|
+
}
|
|
100
192
|
// 4. Emit api-base-url.token.ts from the EJS template in files/
|
|
101
193
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), outputDir, {
|
|
102
194
|
baseUrlToken,
|
|
@@ -106,7 +198,9 @@ async function apiResourceGenerator(tree, options) {
|
|
|
106
198
|
const securitySchemes = (0, parse_spec_1.parseSecuritySchemes)(api);
|
|
107
199
|
const schemesByName = new Map(securitySchemes.map((s) => [s.schemeName, s]));
|
|
108
200
|
for (const scheme of securitySchemes) {
|
|
109
|
-
|
|
201
|
+
const filePath = (0, devkit_1.joinPathFragments)(outputDir, `${scheme.fileName}.ts`);
|
|
202
|
+
tree.write(filePath, (0, render_token_1.renderSecurityTokenFile)(scheme, baseUrlToken));
|
|
203
|
+
writtenFiles.add(filePath);
|
|
110
204
|
}
|
|
111
205
|
const endpoints = (0, parse_spec_1.buildEndpoints)(api, allowedTags, namingConvention);
|
|
112
206
|
// 6. Group by tag
|
|
@@ -120,7 +214,9 @@ async function apiResourceGenerator(tree, options) {
|
|
|
120
214
|
for (const [tag, tagEndpoints] of byTag) {
|
|
121
215
|
const tagDir = (0, devkit_1.joinPathFragments)(outputDir, tag);
|
|
122
216
|
for (const ep of tagEndpoints) {
|
|
123
|
-
|
|
217
|
+
const filePath = (0, devkit_1.joinPathFragments)(tagDir, `${ep.fileName}.token.ts`);
|
|
218
|
+
tree.write(filePath, (0, render_token_1.renderTokenFile)(ep, baseUrlToken, providedIn, schemesByName));
|
|
219
|
+
writtenFiles.add(filePath);
|
|
124
220
|
}
|
|
125
221
|
const tagBarrel = tagEndpoints
|
|
126
222
|
.map((ep) => `export * from './${ep.fileName}.token';`)
|
|
@@ -132,6 +228,13 @@ async function apiResourceGenerator(tree, options) {
|
|
|
132
228
|
securitySchemes.map((s) => `export * from './${s.fileName}';\n`).join('') +
|
|
133
229
|
[...byTag.keys()].map((tag) => `export * from './${tag}';\n`).join('');
|
|
134
230
|
tree.write((0, devkit_1.joinPathFragments)(outputDir, 'index.ts'), rootBarrel);
|
|
231
|
+
// 9. Delete stale token/security files from previous runs that this run
|
|
232
|
+
// no longer produces (e.g. removed endpoints, changed tagFilter).
|
|
233
|
+
for (const stale of preExistingFiles) {
|
|
234
|
+
if (!writtenFiles.has(stale)) {
|
|
235
|
+
tree.delete(stale);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
135
238
|
}
|
|
136
239
|
finally {
|
|
137
240
|
try {
|
|
@@ -140,6 +243,14 @@ async function apiResourceGenerator(tree, options) {
|
|
|
140
243
|
catch {
|
|
141
244
|
/* ignore */
|
|
142
245
|
}
|
|
246
|
+
if (tmpDownload) {
|
|
247
|
+
try {
|
|
248
|
+
fs.unlinkSync(tmpDownload);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
/* ignore */
|
|
252
|
+
}
|
|
253
|
+
}
|
|
143
254
|
}
|
|
144
255
|
await (0, devkit_1.formatFiles)(tree);
|
|
145
256
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../tools/openapi-resource-gen/src/generators/api-resource/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../tools/open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AQ,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACzE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,KAAK,CAAC,IAAA,0BAAiB,EAAC,SAAS,EAAE,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;QAEjE,wEAAwE;QACxE,qEAAqE;QACrE,KAAK,MAAM,KAAK,IAAI,gBAAgB,EAAE,CAAC;YACrC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAC7B,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,kBAAe,oBAAoB,CAAC"}
|
|
@@ -42,10 +42,8 @@ function parseSecuritySchemes(api) {
|
|
|
42
42
|
let kind;
|
|
43
43
|
let apiKeyParamName;
|
|
44
44
|
if (scheme.type === 'http') {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
? 'bearer'
|
|
48
|
-
: 'basic';
|
|
45
|
+
const httpScheme = scheme.scheme?.toLowerCase();
|
|
46
|
+
kind = httpScheme === 'bearer' ? 'bearer' : httpScheme === 'digest' ? 'digest' : 'basic';
|
|
49
47
|
}
|
|
50
48
|
else if (scheme.type === 'apiKey') {
|
|
51
49
|
const apiKey = scheme;
|
|
@@ -98,6 +96,9 @@ function buildEndpoints(api, allowedTags, namingConvention) {
|
|
|
98
96
|
const pathParams = allParams
|
|
99
97
|
.filter((p) => p.in === 'path')
|
|
100
98
|
.map((p) => p.name);
|
|
99
|
+
const headerParams = allParams
|
|
100
|
+
.filter((p) => p.in === 'header')
|
|
101
|
+
.map((p) => ({ name: p.name, required: p.required === true }));
|
|
101
102
|
const hasQueryParams = allParams.some((p) => p.in === 'query');
|
|
102
103
|
// Operation-level security overrides global; [] means explicitly no security.
|
|
103
104
|
const operationSecurity = operation.security;
|
|
@@ -116,17 +117,18 @@ function buildEndpoints(api, allowedTags, namingConvention) {
|
|
|
116
117
|
Object.keys(bodyContent)[0] ??
|
|
117
118
|
null;
|
|
118
119
|
const hasBody = bodyContentType !== null;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
// Pick the first 2xx response code that carries application/json content.
|
|
121
|
+
// Covers 200, 201, 202, 206, and the catch-all '2XX' used by some specs.
|
|
122
|
+
const RESPONSE_PRIORITY = ['200', '201', '202', '206', '2XX', '203', '207', '208', '226'];
|
|
123
|
+
const allResponseCodes = Object.keys(operation.responses ?? {});
|
|
124
|
+
const orderedCodes = [
|
|
125
|
+
...RESPONSE_PRIORITY.filter((c) => allResponseCodes.includes(c)),
|
|
126
|
+
...allResponseCodes.filter((c) => !RESPONSE_PRIORITY.includes(c) && /^2/.test(c)),
|
|
127
|
+
];
|
|
128
|
+
const responseStatus = orderedCodes.find((code) => {
|
|
129
|
+
const obj = operation.responses?.[code];
|
|
130
|
+
return obj?.content?.['application/json'] != null;
|
|
131
|
+
}) ?? null;
|
|
130
132
|
const hasResponse = responseStatus !== null;
|
|
131
133
|
endpoints.push({
|
|
132
134
|
tag: toKebabCase(tag),
|
|
@@ -134,6 +136,7 @@ function buildEndpoints(api, allowedTags, namingConvention) {
|
|
|
134
136
|
method,
|
|
135
137
|
apiPath,
|
|
136
138
|
pathParams,
|
|
139
|
+
headerParams,
|
|
137
140
|
tokenName,
|
|
138
141
|
fileName,
|
|
139
142
|
hasQueryParams,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-spec.js","sourceRoot":"","sources":["../../../../../../tools/openapi-resource-gen/src/generators/api-resource/parse-spec.ts"],"names":[],"mappings":";;;;;AAYA,4CAQC;AAED,kCAQC;AAED,
|
|
1
|
+
{"version":3,"file":"parse-spec.js","sourceRoot":"","sources":["../../../../../../tools/openapi-resource-gen/src/generators/api-resource/parse-spec.ts"],"names":[],"mappings":";;;;;AAYA,4CAQC;AAED,kCAQC;AAED,oDAkCC;AAED,wCA6GC;AAGD,8BAOC;AA3LD,iFAAwD;AACxD,iDAA0C;AAG1C,MAAM,YAAY,GAAyC;IACzD,yBAAS,CAAC,WAAW,CAAC,GAAG;IACzB,yBAAS,CAAC,WAAW,CAAC,IAAI;IAC1B,yBAAS,CAAC,WAAW,CAAC,GAAG;IACzB,yBAAS,CAAC,WAAW,CAAC,KAAK;IAC3B,yBAAS,CAAC,WAAW,CAAC,MAAM;CAC7B,CAAC;AAEF,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,OAAO,GAAG;SACP,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,oBAAoB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AAS,EAAE,CAAC,IAAI,CAAyC,CAAC;gBAChF,OAAO,GAAG,EAAE,OAAO,EAAE,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC;YACpD,CAAC,CAAC,IAAI,IAAI,CAAC;YACb,MAAM,WAAW,GAAG,cAAc,KAAK,IAAI,CAAC;YAE5C,SAAS,CAAC,IAAI,CAAC;gBACb,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC;gBACrB,WAAW,EAAE,KAAK;gBAClB,MAAM;gBACN,OAAO;gBACP,UAAU;gBACV,YAAY;gBACZ,SAAS;gBACT,QAAQ;gBACR,cAAc;gBACd,OAAO;gBACP,WAAW;gBACX,cAAc;gBACd,eAAe;gBACf,mBAAmB;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,gFAAgF;AACzE,KAAK,UAAU,SAAS,CAC7B,QAAgB,EAChB,WAA4B,EAC5B,gBAAmC;IAEnC,MAAM,GAAG,GAAG,CAAC,MAAM,wBAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAuB,CAAC;IAC9E,OAAO,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { EndpointModel, SecuritySchemeModel } from './endpoint-model';
|
|
2
|
-
export declare function renderSecurityTokenFile(scheme: SecuritySchemeModel): string;
|
|
2
|
+
export declare function renderSecurityTokenFile(scheme: SecuritySchemeModel, baseUrlToken: string): string;
|
|
3
3
|
export declare function renderTokenFile(ep: EndpointModel, baseUrlToken: string, providedIn?: 'root' | 'none', schemesByName?: Map<string, SecuritySchemeModel>): string;
|
|
@@ -30,7 +30,30 @@ function headerEntryForScheme(s, varName) {
|
|
|
30
30
|
return '{}';
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function apiPrefixFromBaseToken(baseUrlToken) {
|
|
34
|
+
const stripped = baseUrlToken.replace(/_BASE_URL$/i, '');
|
|
35
|
+
return toCamelCase(stripped.toLowerCase().replace(/_/g, '-'));
|
|
36
|
+
}
|
|
37
|
+
function renderSecurityTokenFile(scheme, baseUrlToken) {
|
|
38
|
+
if (scheme.kind === 'digest') {
|
|
39
|
+
const interceptorName = apiPrefixFromBaseToken(baseUrlToken) + toPascalCase(scheme.schemeName) + 'Interceptor';
|
|
40
|
+
return [
|
|
41
|
+
`import { InjectionToken, inject } from '@angular/core';`,
|
|
42
|
+
`import { HttpInterceptorFn } from '@angular/common/http';`,
|
|
43
|
+
`import { ${baseUrlToken} } from './api-base-url.token';`,
|
|
44
|
+
``,
|
|
45
|
+
`export const ${scheme.tokenName} = new InjectionToken<HttpInterceptorFn>('${scheme.tokenName}');`,
|
|
46
|
+
``,
|
|
47
|
+
`export const ${interceptorName}: HttpInterceptorFn = (req, next) => {`,
|
|
48
|
+
` const base = inject(${baseUrlToken});`,
|
|
49
|
+
` if (!req.url.startsWith(base)) return next(req);`,
|
|
50
|
+
` const fn = inject(${scheme.tokenName}, { optional: true });`,
|
|
51
|
+
` if (!fn) return next(req);`,
|
|
52
|
+
` return fn(req, next);`,
|
|
53
|
+
`};`,
|
|
54
|
+
``,
|
|
55
|
+
].join('\n');
|
|
56
|
+
}
|
|
34
57
|
return [
|
|
35
58
|
`import { InjectionToken, Signal } from '@angular/core';`,
|
|
36
59
|
``,
|
|
@@ -45,7 +68,7 @@ function renderTokenFile(ep, baseUrlToken, providedIn = 'none', schemesByName =
|
|
|
45
68
|
const { responseStatus } = ep;
|
|
46
69
|
const applicableSchemes = ep.securitySchemeNames
|
|
47
70
|
.map((name) => schemesByName.get(name))
|
|
48
|
-
.filter((s) => s !== undefined);
|
|
71
|
+
.filter((s) => s !== undefined && s.kind !== 'digest');
|
|
49
72
|
const headerSchemes = applicableSchemes.filter((s) => s.kind !== 'apiKey-query');
|
|
50
73
|
const querySchemes = applicableSchemes.filter((s) => s.kind === 'apiKey-query');
|
|
51
74
|
const lines = [];
|
|
@@ -141,8 +164,20 @@ function appendResourceOptions(lines, ep, isGet, indent, headerSchemes, querySch
|
|
|
141
164
|
if (!isGet && ep.hasBody) {
|
|
142
165
|
lines.push(`${indent}body,`);
|
|
143
166
|
}
|
|
144
|
-
|
|
167
|
+
const hasHeaderParams = ep.headerParams.length > 0;
|
|
168
|
+
if (headerSchemes.length > 0 || hasHeaderParams) {
|
|
145
169
|
lines.push(`${indent}headers: {`);
|
|
170
|
+
// Explicit header params from the spec (e.g. X-Api-Version, Accept-Language)
|
|
171
|
+
for (const h of ep.headerParams) {
|
|
172
|
+
const varName = toCamelCase(h.name);
|
|
173
|
+
if (h.required) {
|
|
174
|
+
lines.push(`${indent} ${JSON.stringify(h.name)}: ${varName},`);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
lines.push(`${indent} ...(${varName} != null ? { ${JSON.stringify(h.name)}: ${varName} } : {}),`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Auth scheme headers (signal-based, always optional)
|
|
146
181
|
for (const s of headerSchemes) {
|
|
147
182
|
const varName = toCamelCase(s.schemeName);
|
|
148
183
|
lines.push(`${indent} ...(${varName}?.() != null ? ${headerEntryForScheme(s, varName)} : {}),`);
|
|
@@ -151,7 +186,11 @@ function appendResourceOptions(lines, ep, isGet, indent, headerSchemes, querySch
|
|
|
151
186
|
}
|
|
152
187
|
}
|
|
153
188
|
function buildFnArgs(ep, pascal, isGet) {
|
|
189
|
+
// Order: required path params, required header params, optional header params, query params / body
|
|
154
190
|
const args = ep.pathParams.map((p) => `${toCamelCase(p)}: string`);
|
|
191
|
+
for (const h of ep.headerParams) {
|
|
192
|
+
args.push(h.required ? `${toCamelCase(h.name)}: string` : `${toCamelCase(h.name)}?: string`);
|
|
193
|
+
}
|
|
155
194
|
if (isGet && ep.hasQueryParams)
|
|
156
195
|
args.push(`params?: ${pascal}Params | (() => ${pascal}Params | undefined)`);
|
|
157
196
|
if (!isGet && ep.hasBody)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-token.js","sourceRoot":"","sources":["../../../../../../tools/openapi-resource-gen/src/generators/api-resource/render-token.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"render-token.js","sourceRoot":"","sources":["../../../../../../tools/openapi-resource-gen/src/generators/api-resource/render-token.ts"],"names":[],"mappings":";;AAsCA,0DA+BC;AAED,0CAuIC;AA5MD,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG;SACP,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,KAAK,CAAC,UAAU,CAAC;SACjB,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAClD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnE,OAAO,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,SAAS,oBAAoB,CAAC,CAAsB,EAAE,OAAe;IACnE,MAAM,GAAG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C"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"properties": {
|
|
8
8
|
"specPath": {
|
|
9
9
|
"type": "string",
|
|
10
|
-
"description": "Path to the OpenAPI 3.x YAML or JSON spec file",
|
|
10
|
+
"description": "Path or https:// URL to the OpenAPI 3.x YAML or JSON spec file",
|
|
11
11
|
"$default": { "$source": "argv", "index": 0 }
|
|
12
12
|
},
|
|
13
13
|
"outputDir": {
|