@twin.org/ts-to-openapi 0.0.2-next.4 → 0.0.2-next.6
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/dist/cjs/index.cjs +14 -7
- package/dist/esm/index.mjs +14 -7
- package/docs/changelog.md +28 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -600,7 +600,7 @@ async function tsToOpenApi(config, outputFile, workingDirectory) {
|
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
await finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, config.externalReferences, outputFile);
|
|
603
|
+
await finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, config.externalReferences, autoExpandTypes, outputFile);
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Finalise the schemas and output the spec.
|
|
@@ -609,9 +609,10 @@ async function tsToOpenApi(config, outputFile, workingDirectory) {
|
|
|
609
609
|
* @param openApi The OpenAPI spec.
|
|
610
610
|
* @param securitySchemes The security schemes.
|
|
611
611
|
* @param externalReferences The external references.
|
|
612
|
+
* @param autoExpandTypes The auto expand types.
|
|
612
613
|
* @param outputFile The output file.
|
|
613
614
|
*/
|
|
614
|
-
async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, externalReferences, outputFile) {
|
|
615
|
+
async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, externalReferences, autoExpandTypes, outputFile) {
|
|
615
616
|
cliCore.CLIDisplay.break();
|
|
616
617
|
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.ts-to-openapi.progress.finalisingSchemas"));
|
|
617
618
|
// Remove the response codes that we haven't used
|
|
@@ -652,6 +653,15 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
652
653
|
}
|
|
653
654
|
}
|
|
654
655
|
}
|
|
656
|
+
// We can remove any auto expand types from the final schema as they
|
|
657
|
+
// will have been expanded inline so no need to keep them
|
|
658
|
+
for (const autoExpandType of autoExpandTypes) {
|
|
659
|
+
const regExp = toolsCore.JsonSchemaHelper.autoExpandToRegEx(autoExpandType);
|
|
660
|
+
if (regExp.test(schema)) {
|
|
661
|
+
skipSchema = true;
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
655
665
|
if (!skipSchema) {
|
|
656
666
|
// If the final schema has no properties and is just a ref to another object type
|
|
657
667
|
// then replace the references with that of the referenced type
|
|
@@ -871,10 +881,7 @@ async function generateSchemas(modelDirWildcards, types, autoExpandTypes, output
|
|
|
871
881
|
}
|
|
872
882
|
}
|
|
873
883
|
const referencedSchemas = {};
|
|
874
|
-
toolsCore.JsonSchemaHelper.extractTypes(allSchemas, [
|
|
875
|
-
...types,
|
|
876
|
-
...autoExpandTypes.map(t => (t.startsWith("/") && t.endsWith("/") ? new RegExp(t) : t))
|
|
877
|
-
], referencedSchemas);
|
|
884
|
+
toolsCore.JsonSchemaHelper.extractTypes(allSchemas, [...types, ...autoExpandTypes], referencedSchemas);
|
|
878
885
|
toolsCore.JsonSchemaHelper.expandTypes(referencedSchemas, autoExpandTypes);
|
|
879
886
|
for (const arraySingularType of arraySingularTypes) {
|
|
880
887
|
referencedSchemas[`${arraySingularType}[]`] = {
|
|
@@ -1055,7 +1062,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1055
1062
|
return this.execute({
|
|
1056
1063
|
title: "TWIN TypeScript To OpenAPI",
|
|
1057
1064
|
appName: "ts-to-openapi",
|
|
1058
|
-
version: "0.0.2-next.
|
|
1065
|
+
version: "0.0.2-next.6", // x-release-please-version
|
|
1059
1066
|
icon: "⚙️ ",
|
|
1060
1067
|
supportsEnvFiles: false,
|
|
1061
1068
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/esm/index.mjs
CHANGED
|
@@ -597,7 +597,7 @@ async function tsToOpenApi(config, outputFile, workingDirectory) {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
await finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, config.externalReferences, outputFile);
|
|
600
|
+
await finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, config.externalReferences, autoExpandTypes, outputFile);
|
|
601
601
|
}
|
|
602
602
|
/**
|
|
603
603
|
* Finalise the schemas and output the spec.
|
|
@@ -606,9 +606,10 @@ async function tsToOpenApi(config, outputFile, workingDirectory) {
|
|
|
606
606
|
* @param openApi The OpenAPI spec.
|
|
607
607
|
* @param securitySchemes The security schemes.
|
|
608
608
|
* @param externalReferences The external references.
|
|
609
|
+
* @param autoExpandTypes The auto expand types.
|
|
609
610
|
* @param outputFile The output file.
|
|
610
611
|
*/
|
|
611
|
-
async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, externalReferences, outputFile) {
|
|
612
|
+
async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securitySchemes, externalReferences, autoExpandTypes, outputFile) {
|
|
612
613
|
CLIDisplay.break();
|
|
613
614
|
CLIDisplay.task(I18n.formatMessage("commands.ts-to-openapi.progress.finalisingSchemas"));
|
|
614
615
|
// Remove the response codes that we haven't used
|
|
@@ -649,6 +650,15 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
649
650
|
}
|
|
650
651
|
}
|
|
651
652
|
}
|
|
653
|
+
// We can remove any auto expand types from the final schema as they
|
|
654
|
+
// will have been expanded inline so no need to keep them
|
|
655
|
+
for (const autoExpandType of autoExpandTypes) {
|
|
656
|
+
const regExp = JsonSchemaHelper.autoExpandToRegEx(autoExpandType);
|
|
657
|
+
if (regExp.test(schema)) {
|
|
658
|
+
skipSchema = true;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
652
662
|
if (!skipSchema) {
|
|
653
663
|
// If the final schema has no properties and is just a ref to another object type
|
|
654
664
|
// then replace the references with that of the referenced type
|
|
@@ -868,10 +878,7 @@ async function generateSchemas(modelDirWildcards, types, autoExpandTypes, output
|
|
|
868
878
|
}
|
|
869
879
|
}
|
|
870
880
|
const referencedSchemas = {};
|
|
871
|
-
JsonSchemaHelper.extractTypes(allSchemas, [
|
|
872
|
-
...types,
|
|
873
|
-
...autoExpandTypes.map(t => (t.startsWith("/") && t.endsWith("/") ? new RegExp(t) : t))
|
|
874
|
-
], referencedSchemas);
|
|
881
|
+
JsonSchemaHelper.extractTypes(allSchemas, [...types, ...autoExpandTypes], referencedSchemas);
|
|
875
882
|
JsonSchemaHelper.expandTypes(referencedSchemas, autoExpandTypes);
|
|
876
883
|
for (const arraySingularType of arraySingularTypes) {
|
|
877
884
|
referencedSchemas[`${arraySingularType}[]`] = {
|
|
@@ -1052,7 +1059,7 @@ class CLI extends CLIBase {
|
|
|
1052
1059
|
return this.execute({
|
|
1053
1060
|
title: "TWIN TypeScript To OpenAPI",
|
|
1054
1061
|
appName: "ts-to-openapi",
|
|
1055
|
-
version: "0.0.2-next.
|
|
1062
|
+
version: "0.0.2-next.6", // x-release-please-version
|
|
1056
1063
|
icon: "⚙️ ",
|
|
1057
1064
|
supportsEnvFiles: false,
|
|
1058
1065
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/ts-to-openapi - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.6](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.2-next.5...ts-to-openapi-v0.0.2-next.6) (2025-08-21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* remove auto expanded types from final output ([18e05dc](https://github.com/twinfoundation/tools/commit/18e05dc88f71a0a27b79d1d076b1261b42d2c4c2))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/tools-core bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
16
|
+
|
|
17
|
+
## [0.0.2-next.5](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.2-next.4...ts-to-openapi-v0.0.2-next.5) (2025-08-19)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* correctly handle auto expand types ([57fce0f](https://github.com/twinfoundation/tools/commit/57fce0f9ec4a0876665d70adc6e885f6feb3caf7))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/tools-core bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
30
|
+
|
|
3
31
|
## [0.0.2-next.4](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.2-next.3...ts-to-openapi-v0.0.2-next.4) (2025-08-19)
|
|
4
32
|
|
|
5
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/ts-to-openapi",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.6",
|
|
4
4
|
"description": "Tool to convert TypeScript REST route definitions to OpenAPI Specifications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@twin.org/cli-core": "next",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
|
-
"@twin.org/tools-core": "0.0.2-next.
|
|
21
|
+
"@twin.org/tools-core": "0.0.2-next.6",
|
|
22
22
|
"@twin.org/web": "next",
|
|
23
23
|
"commander": "14.0.0",
|
|
24
24
|
"glob": "11.0.3",
|