@sdk-it/generic 0.41.0 → 0.42.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 +10 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<p align="center">A TypeScript analysis tool for generating OpenAPI specifications from TypeScript code</p>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Analyzes TypeScript code to generate OpenAPI specifications. Extracts route information, parameter types, and response schemas from your codebase.
|
|
6
6
|
|
|
7
7
|
## Frameworks specific integrations
|
|
8
8
|
|
|
@@ -82,7 +82,7 @@ You can customize the operations as well as add more through the `onOperation` f
|
|
|
82
82
|
|
|
83
83
|
**Use file name as tag**
|
|
84
84
|
|
|
85
|
-
Assuming your
|
|
85
|
+
Assuming your project is structured like the following, where routes are grouped by representative file names:
|
|
86
86
|
|
|
87
87
|
```
|
|
88
88
|
apps/
|
|
@@ -93,7 +93,7 @@ apps/
|
|
|
93
93
|
authors.ts
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
The file name becomes the default tag for each operation. Specify a tag in JSDoc only to override this default.
|
|
97
97
|
|
|
98
98
|
```typescript
|
|
99
99
|
import { basename } from 'node:path';
|
|
@@ -119,9 +119,9 @@ const { paths, components } = await analyze('apps/backend/tsconfig.app.json', {
|
|
|
119
119
|
|
|
120
120
|
### Customizing Type Mappings
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
Custom type mappings handle non-standard TypeScript types like Prisma's `Decimal`. Use the `typesMap` option in `analyze` to define your mappings.
|
|
123
123
|
|
|
124
|
-
The example below
|
|
124
|
+
The example below maps `Decimal` to `string`.
|
|
125
125
|
|
|
126
126
|
```typescript
|
|
127
127
|
import { writeFile } from 'node:fs/promises';
|
|
@@ -158,11 +158,11 @@ const spec = {
|
|
|
158
158
|
await writeFile('openapi.json', JSON.stringify(spec, null, 2));
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
With this, the generator maps `Decimal` properties to `string` in the OpenAPI specification.
|
|
162
162
|
|
|
163
163
|
### Referencing external schemas
|
|
164
164
|
|
|
165
|
-
By default, the analyzer
|
|
165
|
+
By default, the analyzer only sees schemas defined inline in the validate middleware.
|
|
166
166
|
|
|
167
167
|
For instance the following route handler is perfectly valid and will be analyzed correctly.
|
|
168
168
|
|
|
@@ -229,9 +229,9 @@ app.post(
|
|
|
229
229
|
);
|
|
230
230
|
```
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
The analyzer must resolve the `authorSchema` reference to generate the correct OpenAPI schema. Otherwise it will fail.
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
The analyzer's `imports` option lets you include additional files in the analysis.
|
|
235
235
|
|
|
236
236
|
```ts
|
|
237
237
|
import { join } from 'node:path';
|
|
@@ -279,7 +279,7 @@ app.post(
|
|
|
279
279
|
|
|
280
280
|
### Control endpoint/operation visibility
|
|
281
281
|
|
|
282
|
-
|
|
282
|
+
Control endpoint visibility with the `@access` tag in JSDoc comments. For now, only `private` is supported.
|
|
283
283
|
|
|
284
284
|
```typescript
|
|
285
285
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdk-it/generic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"!**/*.test.*"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@sdk-it/core": "0.
|
|
25
|
+
"@sdk-it/core": "0.42.0",
|
|
26
26
|
"stringcase": "^4.3.1",
|
|
27
27
|
"debug": "^4.4.0",
|
|
28
28
|
"openapi3-ts": "^4.4.0"
|