@twin.org/ts-to-openapi 0.0.1-next.9 → 0.0.2-next.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.
@@ -1,4 +1,4 @@
1
- import type { JSONSchema7 } from "json-schema";
1
+ import type { IJsonSchema } from "@twin.org/tools-core";
2
2
  import type { IOpenApiPathMethod } from "./IOpenApiPathMethod";
3
3
  import type { IOpenApiSecurityScheme } from "./IOpenApiSecurityScheme";
4
4
  /**
@@ -46,7 +46,7 @@ export interface IOpenApi {
46
46
  * The components.
47
47
  */
48
48
  components?: {
49
- schemas?: JSONSchema7;
49
+ schemas?: IJsonSchema;
50
50
  securitySchemes?: {
51
51
  [name: string]: IOpenApiSecurityScheme;
52
52
  };
@@ -1,4 +1,4 @@
1
- import type { JSONSchema7Type, JSONSchema7TypeName } from "json-schema";
1
+ import type { IJsonSchema, JsonTypeName } from "@twin.org/tools-core";
2
2
  import type { IOpenApiExample } from "./IOpenApiExample";
3
3
  import type { IOpenApiResponse } from "./IOpenApiResponse";
4
4
  /**
@@ -26,8 +26,8 @@ export interface IOpenApiPathMethod {
26
26
  description?: string;
27
27
  required: boolean;
28
28
  schema: {
29
- type?: JSONSchema7TypeName | JSONSchema7TypeName[];
30
- enum?: JSONSchema7Type[];
29
+ type?: JsonTypeName | JsonTypeName[];
30
+ enum?: IJsonSchema[];
31
31
  $ref?: string;
32
32
  };
33
33
  style?: string;
@@ -1,3 +1,4 @@
1
+ import type { IJsonSchema } from "@twin.org/tools-core";
1
2
  import type { ITsToOpenApiConfigEntryPoint } from "./ITsToOpenApiConfigEntryPoint";
2
3
  /**
3
4
  * Configuration for the API.
@@ -58,4 +59,14 @@ export interface ITsToOpenApiConfig {
58
59
  externalReferences?: {
59
60
  [id: string]: string;
60
61
  };
62
+ /**
63
+ * Override for specific types, to be used when the type cannot be generated automatically, or is generated incorrectly.
64
+ */
65
+ overrides?: {
66
+ [id: string]: IJsonSchema;
67
+ };
68
+ /**
69
+ * The types to automatically expand inline in type definitions, reg ex string matches.
70
+ */
71
+ autoExpandTypes?: string[];
61
72
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,226 @@
1
1
  # @twin.org/ts-to-openapi - Changelog
2
2
 
3
- ## v0.0.1-next.9
3
+ ## [0.0.2-next.1](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.2-next.0...ts-to-openapi-v0.0.2-next.1) (2025-07-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * add latest json schema features ([494293f](https://github.com/twinfoundation/tools/commit/494293f4252b9c7d4a20790ec157fc9d8c96c3d2))
9
+ * add support for auto expand types ([dd1e10a](https://github.com/twinfoundation/tools/commit/dd1e10a5b2fea6f80890ff6f3971f48e239cb4c1))
10
+ * add ts-to-schema overrides ([3c54504](https://github.com/twinfoundation/tools/commit/3c5450468eb998204a75576b7791a7ca4027da62))
11
+ * generate schemas as individual entities ([9f372ab](https://github.com/twinfoundation/tools/commit/9f372abdfc27aba93b303c7b214991919c0c18c3))
12
+ * improve schema type name normalisation ([1a18b26](https://github.com/twinfoundation/tools/commit/1a18b267d87e9179bda01b396b256c450ae2889e))
13
+ * move package to framework repo ([4490bda](https://github.com/twinfoundation/tools/commit/4490bda472d4dc8ddfe931e2fce81f3411de9ab3))
14
+ * strip Omit types ([3a079f9](https://github.com/twinfoundation/tools/commit/3a079f9abe8127c5b44a2b9382babf2f19629d08))
15
+ * use most recent JSON schema specs ([4598cbf](https://github.com/twinfoundation/tools/commit/4598cbf29f7b82dba4a9f3b19f81dfe66f5a6060))
16
+ * use shared store mechanism ([#31](https://github.com/twinfoundation/tools/issues/31)) ([d9fe68b](https://github.com/twinfoundation/tools/commit/d9fe68b903d1268c7cb3c64772df5cb78fd63667))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * fix locale resource name ([53ad5b5](https://github.com/twinfoundation/tools/commit/53ad5b56f19a5082f16a4f1e4a761e114dce8250))
22
+
23
+
24
+ ### Dependencies
25
+
26
+ * The following workspace dependencies were updated
27
+ * dependencies
28
+ * @twin.org/tools-core bumped from 0.0.2-next.0 to 0.0.2-next.1
29
+
30
+ ## 0.0.1 (2025-07-03)
31
+
32
+
33
+ ### Features
34
+
35
+ * release to production ([ad24b7e](https://github.com/twinfoundation/tools/commit/ad24b7eb16784165b6c93b5c48788199f0e17526))
36
+
37
+ ## [0.0.1-next.29](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.28...ts-to-openapi-v0.0.1-next.29) (2025-07-02)
38
+
39
+
40
+ ### Features
41
+
42
+ * move package to framework repo ([4490bda](https://github.com/twinfoundation/tools/commit/4490bda472d4dc8ddfe931e2fce81f3411de9ab3))
43
+
44
+ ## [0.0.1-next.28](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.27...ts-to-openapi-v0.0.1-next.28) (2025-06-18)
45
+
46
+
47
+ ### Features
48
+
49
+ * improve schema type name normalisation ([1a18b26](https://github.com/twinfoundation/tools/commit/1a18b267d87e9179bda01b396b256c450ae2889e))
50
+
51
+
52
+ ### Dependencies
53
+
54
+ * The following workspace dependencies were updated
55
+ * dependencies
56
+ * @twin.org/nameof bumped from 0.0.1-next.27 to 0.0.1-next.28
57
+ * devDependencies
58
+ * @twin.org/merge-locales bumped from 0.0.1-next.27 to 0.0.1-next.28
59
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.27 to 0.0.1-next.28
60
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.27 to 0.0.1-next.28
61
+
62
+ ## [0.0.1-next.27](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.26...ts-to-openapi-v0.0.1-next.27) (2025-06-17)
63
+
64
+
65
+ ### Features
66
+
67
+ * add latest json schema features ([494293f](https://github.com/twinfoundation/tools/commit/494293f4252b9c7d4a20790ec157fc9d8c96c3d2))
68
+
69
+
70
+ ### Dependencies
71
+
72
+ * The following workspace dependencies were updated
73
+ * dependencies
74
+ * @twin.org/nameof bumped from 0.0.1-next.26 to 0.0.1-next.27
75
+ * devDependencies
76
+ * @twin.org/merge-locales bumped from 0.0.1-next.26 to 0.0.1-next.27
77
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.26 to 0.0.1-next.27
78
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.26 to 0.0.1-next.27
79
+
80
+ ## [0.0.1-next.26](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.25...ts-to-openapi-v0.0.1-next.26) (2025-06-11)
81
+
82
+
83
+ ### Features
84
+
85
+ * use most recent JSON schema specs ([4598cbf](https://github.com/twinfoundation/tools/commit/4598cbf29f7b82dba4a9f3b19f81dfe66f5a6060))
86
+
87
+
88
+ ### Dependencies
89
+
90
+ * The following workspace dependencies were updated
91
+ * dependencies
92
+ * @twin.org/nameof bumped from 0.0.1-next.25 to 0.0.1-next.26
93
+ * devDependencies
94
+ * @twin.org/merge-locales bumped from 0.0.1-next.25 to 0.0.1-next.26
95
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.25 to 0.0.1-next.26
96
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.25 to 0.0.1-next.26
97
+
98
+ ## [0.0.1-next.25](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.24...ts-to-openapi-v0.0.1-next.25) (2025-06-10)
99
+
100
+
101
+ ### Features
102
+
103
+ * add ts-to-schema overrides ([3c54504](https://github.com/twinfoundation/tools/commit/3c5450468eb998204a75576b7791a7ca4027da62))
104
+
105
+
106
+ ### Dependencies
107
+
108
+ * The following workspace dependencies were updated
109
+ * dependencies
110
+ * @twin.org/nameof bumped from 0.0.1-next.24 to 0.0.1-next.25
111
+ * devDependencies
112
+ * @twin.org/merge-locales bumped from 0.0.1-next.24 to 0.0.1-next.25
113
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.24 to 0.0.1-next.25
114
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.24 to 0.0.1-next.25
115
+
116
+ ## [0.0.1-next.24](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.23...ts-to-openapi-v0.0.1-next.24) (2025-06-05)
117
+
118
+
119
+ ### Features
120
+
121
+ * strip Omit types ([3a079f9](https://github.com/twinfoundation/tools/commit/3a079f9abe8127c5b44a2b9382babf2f19629d08))
122
+
123
+
124
+ ### Dependencies
125
+
126
+ * The following workspace dependencies were updated
127
+ * dependencies
128
+ * @twin.org/nameof bumped from 0.0.1-next.23 to 0.0.1-next.24
129
+ * devDependencies
130
+ * @twin.org/merge-locales bumped from 0.0.1-next.23 to 0.0.1-next.24
131
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.23 to 0.0.1-next.24
132
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.23 to 0.0.1-next.24
133
+
134
+ ## [0.0.1-next.23](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.22...ts-to-openapi-v0.0.1-next.23) (2025-06-03)
135
+
136
+
137
+ ### Bug Fixes
138
+
139
+ * fix locale resource name ([53ad5b5](https://github.com/twinfoundation/tools/commit/53ad5b56f19a5082f16a4f1e4a761e114dce8250))
140
+
141
+
142
+ ### Dependencies
143
+
144
+ * The following workspace dependencies were updated
145
+ * dependencies
146
+ * @twin.org/nameof bumped from 0.0.1-next.22 to 0.0.1-next.23
147
+ * devDependencies
148
+ * @twin.org/merge-locales bumped from 0.0.1-next.22 to 0.0.1-next.23
149
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.22 to 0.0.1-next.23
150
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.22 to 0.0.1-next.23
151
+
152
+ ## [0.0.1-next.22](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.21...ts-to-openapi-v0.0.1-next.22) (2025-06-03)
153
+
154
+
155
+ ### Features
156
+
157
+ * generate schemas as individual entities ([9f372ab](https://github.com/twinfoundation/tools/commit/9f372abdfc27aba93b303c7b214991919c0c18c3))
158
+
159
+
160
+ ### Dependencies
161
+
162
+ * The following workspace dependencies were updated
163
+ * dependencies
164
+ * @twin.org/nameof bumped from 0.0.1-next.21 to 0.0.1-next.22
165
+ * devDependencies
166
+ * @twin.org/merge-locales bumped from 0.0.1-next.21 to 0.0.1-next.22
167
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.21 to 0.0.1-next.22
168
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.21 to 0.0.1-next.22
169
+
170
+ ## [0.0.1-next.21](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.20...ts-to-openapi-v0.0.1-next.21) (2025-04-17)
171
+
172
+
173
+ ### Features
174
+
175
+ * use shared store mechanism ([#31](https://github.com/twinfoundation/tools/issues/31)) ([d9fe68b](https://github.com/twinfoundation/tools/commit/d9fe68b903d1268c7cb3c64772df5cb78fd63667))
176
+
177
+
178
+ ### Dependencies
179
+
180
+ * The following workspace dependencies were updated
181
+ * dependencies
182
+ * @twin.org/nameof bumped from 0.0.1-next.20 to 0.0.1-next.21
183
+ * devDependencies
184
+ * @twin.org/merge-locales bumped from 0.0.1-next.20 to 0.0.1-next.21
185
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.20 to 0.0.1-next.21
186
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.20 to 0.0.1-next.21
187
+
188
+ ## [0.0.1-next.20](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.19...ts-to-openapi-v0.0.1-next.20) (2025-03-28)
189
+
190
+
191
+ ### Miscellaneous Chores
192
+
193
+ * **ts-to-openapi:** Synchronize repo versions
194
+
195
+
196
+ ### Dependencies
197
+
198
+ * The following workspace dependencies were updated
199
+ * dependencies
200
+ * @twin.org/nameof bumped from 0.0.1-next.19 to 0.0.1-next.20
201
+ * devDependencies
202
+ * @twin.org/merge-locales bumped from 0.0.1-next.19 to 0.0.1-next.20
203
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.19 to 0.0.1-next.20
204
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.19 to 0.0.1-next.20
205
+
206
+ ## [0.0.1-next.19](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.1-next.18...ts-to-openapi-v0.0.1-next.19) (2025-03-26)
207
+
208
+
209
+ ### Miscellaneous Chores
210
+
211
+ * **ts-to-openapi:** Synchronize repo versions
212
+
213
+
214
+ ### Dependencies
215
+
216
+ * The following workspace dependencies were updated
217
+ * dependencies
218
+ * @twin.org/nameof bumped from 0.0.1-next.18 to 0.0.1-next.19
219
+ * devDependencies
220
+ * @twin.org/merge-locales bumped from 0.0.1-next.18 to 0.0.1-next.19
221
+ * @twin.org/nameof-transformer bumped from 0.0.1-next.18 to 0.0.1-next.19
222
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.18 to 0.0.1-next.19
223
+
224
+ ## v0.0.1-next.18
4
225
 
5
226
  - Initial Release
@@ -8,13 +8,13 @@ The main entry point for the CLI.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new CLI()
11
+ ### Constructor
12
12
 
13
- > **new CLI**(): [`CLI`](CLI.md)
13
+ > **new CLI**(): `CLI`
14
14
 
15
15
  #### Returns
16
16
 
17
- [`CLI`](CLI.md)
17
+ `CLI`
18
18
 
19
19
  #### Inherited from
20
20
 
@@ -24,25 +24,31 @@ The main entry point for the CLI.
24
24
 
25
25
  ### run()
26
26
 
27
- > **run**(`argv`, `localesDirectory`?, `options`?): `Promise`\<`number`\>
27
+ > **run**(`argv`, `localesDirectory?`, `options?`): `Promise`\<`number`\>
28
28
 
29
29
  Run the app.
30
30
 
31
31
  #### Parameters
32
32
 
33
- **argv**: `string`[]
33
+ ##### argv
34
+
35
+ `string`[]
34
36
 
35
37
  The process arguments.
36
38
 
37
- **localesDirectory?**: `string`
39
+ ##### localesDirectory?
40
+
41
+ `string`
38
42
 
39
43
  The directory for the locales, default to relative to the script.
40
44
 
41
- **options?**
45
+ ##### options?
42
46
 
43
47
  Additional options.
44
48
 
45
- **options.overrideOutputWidth?**: `number`
49
+ ###### overrideOutputWidth?
50
+
51
+ `number`
46
52
 
47
53
  Override the output width.
48
54
 
@@ -62,7 +68,9 @@ Configure any options or actions at the root program level.
62
68
 
63
69
  #### Parameters
64
70
 
65
- **program**: `Command`
71
+ ##### program
72
+
73
+ `Command`
66
74
 
67
75
  The root program command.
68
76
 
@@ -6,15 +6,21 @@ Action the root command.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **configFile**: `string`
9
+ ### configFile
10
+
11
+ `string`
10
12
 
11
13
  The optional configuration file.
12
14
 
13
- **outputFile**: `string`
15
+ ### outputFile
16
+
17
+ `string`
14
18
 
15
19
  The output file for the generation OpenApi spec.
16
20
 
17
- **opts**: `unknown`
21
+ ### opts
22
+
23
+ `unknown`
18
24
 
19
25
  The options for the command.
20
26
 
@@ -6,7 +6,9 @@ Build the root command to be consumed by the CLI.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **program**: `Command`
9
+ ### program
10
+
11
+ `Command`
10
12
 
11
13
  The command to build on.
12
14
 
@@ -6,15 +6,21 @@ Convert the TypeScript definitions to OpenAPI spec.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **config**: [`ITsToOpenApiConfig`](../interfaces/ITsToOpenApiConfig.md)
9
+ ### config
10
+
11
+ [`ITsToOpenApiConfig`](../interfaces/ITsToOpenApiConfig.md)
10
12
 
11
13
  The configuration for the app.
12
14
 
13
- **outputFile**: `string`
15
+ ### outputFile
16
+
17
+ `string`
14
18
 
15
19
  The location of the file to output the OpenAPI spec.
16
20
 
17
- **workingDirectory**: `string`
21
+ ### workingDirectory
22
+
23
+ `string`
18
24
 
19
25
  The folder the app was run from.
20
26
 
@@ -66,6 +66,30 @@ The authentication methods.
66
66
 
67
67
  The packages containing routes.
68
68
 
69
+ #### package?
70
+
71
+ > `optional` **package**: `string`
72
+
73
+ The package containing the routes.
74
+
75
+ #### version?
76
+
77
+ > `optional` **version**: `string`
78
+
79
+ The version of the package to use, defaults to latest.
80
+
81
+ #### packageRoot?
82
+
83
+ > `optional` **packageRoot**: `string`
84
+
85
+ To point to a local instance of a package use this property instead of package/version.
86
+
87
+ #### entryPoints?
88
+
89
+ > `optional` **entryPoints**: [`ITsToOpenApiConfigEntryPoint`](ITsToOpenApiConfigEntryPoint.md)[]
90
+
91
+ The rest entry points to include, defaults to all exported entry points.
92
+
69
93
  ***
70
94
 
71
95
  ### externalReferences?
@@ -76,4 +100,24 @@ External type references
76
100
 
77
101
  #### Index Signature
78
102
 
79
- \[`id`: `string`\]: `string`
103
+ \[`id`: `string`\]: `string`
104
+
105
+ ***
106
+
107
+ ### overrides?
108
+
109
+ > `optional` **overrides**: `object`
110
+
111
+ Override for specific types, to be used when the type cannot be generated automatically, or is generated incorrectly.
112
+
113
+ #### Index Signature
114
+
115
+ \[`id`: `string`\]: `AnySchemaObject`
116
+
117
+ ***
118
+
119
+ ### autoExpandTypes?
120
+
121
+ > `optional` **autoExpandTypes**: `string`[]
122
+
123
+ The types to automatically expand inline in type definitions, reg ex string matches.
package/locales/en.json CHANGED
@@ -26,6 +26,7 @@
26
26
  "creatingWorkingDir": "Creating Working Directory",
27
27
  "creatingSecuritySchemas": "Creating Security Schemas",
28
28
  "generatingSchemas": "Generating Schemas",
29
+ "overridingSchema": "Overriding Schema",
29
30
  "finalisingSchemas": "Finalising Schemas",
30
31
  "writingOutputFile": "Writing Output File",
31
32
  "models": "Models",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@twin.org/ts-to-openapi",
3
- "version": "0.0.1-next.9",
3
+ "version": "0.0.2-next.1",
4
4
  "description": "Tool to convert TypeScript REST route definitions to OpenAPI Specifications",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/tools.git",
8
- "directory": "packages/ts-to-openapi"
8
+ "directory": "apps/ts-to-openapi"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
11
11
  "license": "Apache-2.0",
@@ -17,21 +17,21 @@
17
17
  "@twin.org/api-models": "next",
18
18
  "@twin.org/cli-core": "next",
19
19
  "@twin.org/core": "next",
20
- "@twin.org/nameof": "0.0.1-next.9",
20
+ "@twin.org/nameof": "next",
21
+ "@twin.org/tools-core": "0.0.2-next.1",
21
22
  "@twin.org/web": "next",
22
- "commander": "12.1.0",
23
- "glob": "11.0.0",
24
- "jsonschema": "1.4.1",
25
- "ts-json-schema-generator": "2.4.0-next.1"
23
+ "commander": "14.0.0",
24
+ "glob": "11.0.2",
25
+ "ts-json-schema-generator": "2.4.0"
26
26
  },
27
27
  "main": "./dist/cjs/index.cjs",
28
28
  "module": "./dist/esm/index.mjs",
29
29
  "types": "./dist/types/index.d.ts",
30
30
  "exports": {
31
31
  ".": {
32
+ "types": "./dist/types/index.d.ts",
32
33
  "require": "./dist/cjs/index.cjs",
33
- "import": "./dist/esm/index.mjs",
34
- "types": "./dist/types/index.d.ts"
34
+ "import": "./dist/esm/index.mjs"
35
35
  }
36
36
  },
37
37
  "files": [
@@ -1,15 +0,0 @@
1
- /**
2
- * Configuration for each individual package.
3
- */
4
- export interface IPackageJson {
5
- /**
6
- * The name of the package.
7
- */
8
- name: string;
9
- /**
10
- * The dependencies for the package.
11
- */
12
- dependencies?: {
13
- [id: string]: string;
14
- };
15
- }