@twin.org/ts-to-openapi 0.0.1-next.27 → 0.0.1-next.29
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 +24 -17
- package/dist/esm/index.mjs +24 -17
- package/docs/changelog.md +25 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -698,12 +698,7 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
698
698
|
// Remove the array [] from the type names
|
|
699
699
|
// eslint-disable-next-line unicorn/better-regex
|
|
700
700
|
json = json.replace(/#\/components\/schemas\/(.*)\[\]/g, "#/components/schemas/ListOf$1");
|
|
701
|
-
|
|
702
|
-
json = json.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
703
|
-
// Remove the omit markers
|
|
704
|
-
json = json.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
705
|
-
// Cleanup the generic markers
|
|
706
|
-
json = json.replace(/%3Cunknown%3E/g, "");
|
|
701
|
+
json = normaliseTypeName(json);
|
|
707
702
|
// Remove external references
|
|
708
703
|
for (const finalExternal in finalExternals) {
|
|
709
704
|
json = json.replace(new RegExp(`"#/components/schemas/${core.StringHelper.stripPrefix(finalExternal)}"`, "g"), `"${finalExternals[finalExternal]}"`);
|
|
@@ -857,12 +852,7 @@ async function generateSchemas(modelDirWildcards, types, outputWorkingDir) {
|
|
|
857
852
|
const schema = generator.createSchema("*");
|
|
858
853
|
if (schema.definitions) {
|
|
859
854
|
for (const def in schema.definitions) {
|
|
860
|
-
|
|
861
|
-
let defSub = def.replace(/^Partial<(.*?)>/g, "$1");
|
|
862
|
-
// Remove the omit markers
|
|
863
|
-
defSub = defSub.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
864
|
-
// Cleanup the generic markers
|
|
865
|
-
defSub = defSub.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
855
|
+
const defSub = normaliseTypeName(def);
|
|
866
856
|
allSchemas[defSub] = schema.definitions[def];
|
|
867
857
|
}
|
|
868
858
|
}
|
|
@@ -904,10 +894,7 @@ function extractTypes(allSchemas, requiredTypes, referencedSchemas) {
|
|
|
904
894
|
function extractTypesFromSchema(allTypes, schema, output) {
|
|
905
895
|
const additionalTypes = [];
|
|
906
896
|
if (core.Is.stringValue(schema.$ref)) {
|
|
907
|
-
additionalTypes.push(schema.$ref
|
|
908
|
-
.replace("#/definitions/", "")
|
|
909
|
-
.replace(/^Partial%3C(.*?)%3E/g, "$1")
|
|
910
|
-
.replace(/^Omit%3C(.*?)%2C.*%3E/g, "$1"));
|
|
897
|
+
additionalTypes.push(normaliseTypeName(schema.$ref).replace("#/definitions/", ""));
|
|
911
898
|
}
|
|
912
899
|
else if (core.Is.object(schema.items)) {
|
|
913
900
|
if (core.Is.arrayValue(schema.items)) {
|
|
@@ -1153,6 +1140,26 @@ function processSchemaArray(schemaArray) {
|
|
|
1153
1140
|
}
|
|
1154
1141
|
}
|
|
1155
1142
|
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Cleanup TypeScript markers from the type name.
|
|
1145
|
+
* @param typeName The definition string to clean up.
|
|
1146
|
+
* @returns The cleaned up definition string.
|
|
1147
|
+
*/
|
|
1148
|
+
function normaliseTypeName(typeName) {
|
|
1149
|
+
// Remove the partial markers
|
|
1150
|
+
let sTypeName = typeName.replace(/^Partial<(.*?)>/g, "$1");
|
|
1151
|
+
sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
1152
|
+
// Remove the omit markers
|
|
1153
|
+
sTypeName = sTypeName.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
1154
|
+
sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
1155
|
+
// Remove the pick markers
|
|
1156
|
+
sTypeName = sTypeName.replace(/^Pick<(.*?),.*>/g, "$1");
|
|
1157
|
+
sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
|
|
1158
|
+
// Cleanup the generic markers
|
|
1159
|
+
sTypeName = sTypeName.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
1160
|
+
sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
|
|
1161
|
+
return sTypeName;
|
|
1162
|
+
}
|
|
1156
1163
|
|
|
1157
1164
|
// Copyright 2024 IOTA Stiftung.
|
|
1158
1165
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -1172,7 +1179,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1172
1179
|
return this.execute({
|
|
1173
1180
|
title: "TWIN TypeScript To OpenAPI",
|
|
1174
1181
|
appName: "ts-to-openapi",
|
|
1175
|
-
version: "0.0.1-next.
|
|
1182
|
+
version: "0.0.1-next.29", // x-release-please-version
|
|
1176
1183
|
icon: "⚙️ ",
|
|
1177
1184
|
supportsEnvFiles: false,
|
|
1178
1185
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/esm/index.mjs
CHANGED
|
@@ -695,12 +695,7 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
695
695
|
// Remove the array [] from the type names
|
|
696
696
|
// eslint-disable-next-line unicorn/better-regex
|
|
697
697
|
json = json.replace(/#\/components\/schemas\/(.*)\[\]/g, "#/components/schemas/ListOf$1");
|
|
698
|
-
|
|
699
|
-
json = json.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
700
|
-
// Remove the omit markers
|
|
701
|
-
json = json.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
702
|
-
// Cleanup the generic markers
|
|
703
|
-
json = json.replace(/%3Cunknown%3E/g, "");
|
|
698
|
+
json = normaliseTypeName(json);
|
|
704
699
|
// Remove external references
|
|
705
700
|
for (const finalExternal in finalExternals) {
|
|
706
701
|
json = json.replace(new RegExp(`"#/components/schemas/${StringHelper.stripPrefix(finalExternal)}"`, "g"), `"${finalExternals[finalExternal]}"`);
|
|
@@ -854,12 +849,7 @@ async function generateSchemas(modelDirWildcards, types, outputWorkingDir) {
|
|
|
854
849
|
const schema = generator.createSchema("*");
|
|
855
850
|
if (schema.definitions) {
|
|
856
851
|
for (const def in schema.definitions) {
|
|
857
|
-
|
|
858
|
-
let defSub = def.replace(/^Partial<(.*?)>/g, "$1");
|
|
859
|
-
// Remove the omit markers
|
|
860
|
-
defSub = defSub.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
861
|
-
// Cleanup the generic markers
|
|
862
|
-
defSub = defSub.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
852
|
+
const defSub = normaliseTypeName(def);
|
|
863
853
|
allSchemas[defSub] = schema.definitions[def];
|
|
864
854
|
}
|
|
865
855
|
}
|
|
@@ -901,10 +891,7 @@ function extractTypes(allSchemas, requiredTypes, referencedSchemas) {
|
|
|
901
891
|
function extractTypesFromSchema(allTypes, schema, output) {
|
|
902
892
|
const additionalTypes = [];
|
|
903
893
|
if (Is.stringValue(schema.$ref)) {
|
|
904
|
-
additionalTypes.push(schema.$ref
|
|
905
|
-
.replace("#/definitions/", "")
|
|
906
|
-
.replace(/^Partial%3C(.*?)%3E/g, "$1")
|
|
907
|
-
.replace(/^Omit%3C(.*?)%2C.*%3E/g, "$1"));
|
|
894
|
+
additionalTypes.push(normaliseTypeName(schema.$ref).replace("#/definitions/", ""));
|
|
908
895
|
}
|
|
909
896
|
else if (Is.object(schema.items)) {
|
|
910
897
|
if (Is.arrayValue(schema.items)) {
|
|
@@ -1150,6 +1137,26 @@ function processSchemaArray(schemaArray) {
|
|
|
1150
1137
|
}
|
|
1151
1138
|
}
|
|
1152
1139
|
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Cleanup TypeScript markers from the type name.
|
|
1142
|
+
* @param typeName The definition string to clean up.
|
|
1143
|
+
* @returns The cleaned up definition string.
|
|
1144
|
+
*/
|
|
1145
|
+
function normaliseTypeName(typeName) {
|
|
1146
|
+
// Remove the partial markers
|
|
1147
|
+
let sTypeName = typeName.replace(/^Partial<(.*?)>/g, "$1");
|
|
1148
|
+
sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
1149
|
+
// Remove the omit markers
|
|
1150
|
+
sTypeName = sTypeName.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
1151
|
+
sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
1152
|
+
// Remove the pick markers
|
|
1153
|
+
sTypeName = sTypeName.replace(/^Pick<(.*?),.*>/g, "$1");
|
|
1154
|
+
sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
|
|
1155
|
+
// Cleanup the generic markers
|
|
1156
|
+
sTypeName = sTypeName.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
1157
|
+
sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
|
|
1158
|
+
return sTypeName;
|
|
1159
|
+
}
|
|
1153
1160
|
|
|
1154
1161
|
// Copyright 2024 IOTA Stiftung.
|
|
1155
1162
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -1169,7 +1176,7 @@ class CLI extends CLIBase {
|
|
|
1169
1176
|
return this.execute({
|
|
1170
1177
|
title: "TWIN TypeScript To OpenAPI",
|
|
1171
1178
|
appName: "ts-to-openapi",
|
|
1172
|
-
version: "0.0.1-next.
|
|
1179
|
+
version: "0.0.1-next.29", // x-release-please-version
|
|
1173
1180
|
icon: "⚙️ ",
|
|
1174
1181
|
supportsEnvFiles: false,
|
|
1175
1182
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @twin.org/ts-to-openapi - Changelog
|
|
2
2
|
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* move package to framework repo ([4490bda](https://github.com/twinfoundation/tools/commit/4490bda472d4dc8ddfe931e2fce81f3411de9ab3))
|
|
9
|
+
|
|
10
|
+
## [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)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* improve schema type name normalisation ([1a18b26](https://github.com/twinfoundation/tools/commit/1a18b267d87e9179bda01b396b256c450ae2889e))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* The following workspace dependencies were updated
|
|
21
|
+
* dependencies
|
|
22
|
+
* @twin.org/nameof bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
23
|
+
* devDependencies
|
|
24
|
+
* @twin.org/merge-locales bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
25
|
+
* @twin.org/nameof-transformer bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
26
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
27
|
+
|
|
3
28
|
## [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)
|
|
4
29
|
|
|
5
30
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/ts-to-openapi",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.29",
|
|
4
4
|
"description": "Tool to convert TypeScript REST route definitions to OpenAPI Specifications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@twin.org/api-models": "next",
|
|
18
18
|
"@twin.org/cli-core": "next",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
|
-
"@twin.org/nameof": "
|
|
20
|
+
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|
|
22
22
|
"ajv": "8.17.1",
|
|
23
23
|
"commander": "14.0.0",
|