@twin.org/ts-to-openapi 0.0.2-next.5 → 0.0.2-next.7

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.
@@ -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
@@ -1052,7 +1062,7 @@ class CLI extends cliCore.CLIBase {
1052
1062
  return this.execute({
1053
1063
  title: "TWIN TypeScript To OpenAPI",
1054
1064
  appName: "ts-to-openapi",
1055
- version: "0.0.2-next.5", // x-release-please-version
1065
+ version: "0.0.2-next.7", // x-release-please-version
1056
1066
  icon: "⚙️ ",
1057
1067
  supportsEnvFiles: false,
1058
1068
  overrideOutputWidth: options?.overrideOutputWidth
@@ -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
@@ -1049,7 +1059,7 @@ class CLI extends CLIBase {
1049
1059
  return this.execute({
1050
1060
  title: "TWIN TypeScript To OpenAPI",
1051
1061
  appName: "ts-to-openapi",
1052
- version: "0.0.2-next.5", // x-release-please-version
1062
+ version: "0.0.2-next.7", // x-release-please-version
1053
1063
  icon: "⚙️ ",
1054
1064
  supportsEnvFiles: false,
1055
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.7](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.2-next.6...ts-to-openapi-v0.0.2-next.7) (2025-08-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * eslint migration to flat config ([25acfcf](https://github.com/twinfoundation/tools/commit/25acfcf4c4e0c496fffeaf67659fe171bc15199a))
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.6 to 0.0.2-next.7
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * remove auto expanded types from final output ([18e05dc](https://github.com/twinfoundation/tools/commit/18e05dc88f71a0a27b79d1d076b1261b42d2c4c2))
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.5 to 0.0.2-next.6
30
+
3
31
  ## [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)
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.5",
3
+ "version": "0.0.2-next.7",
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.5",
21
+ "@twin.org/tools-core": "0.0.2-next.7",
22
22
  "@twin.org/web": "next",
23
23
  "commander": "14.0.0",
24
24
  "glob": "11.0.3",