@twin.org/ts-to-openapi 0.0.1-next.3 → 0.0.1-next.4
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/bin/index.js +0 -0
- package/dist/cjs/index.cjs +7 -6
- package/dist/esm/index.mjs +7 -6
- package/dist/locales/en.json +4 -0
- package/docs/changelog.md +1 -1
- package/package.json +2 -31
package/bin/index.js
CHANGED
|
File without changes
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -607,6 +607,7 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
const substituteSchemas = [];
|
|
610
|
+
const finalExternals = {};
|
|
610
611
|
// Remove the I, < and > from names
|
|
611
612
|
const finalSchemas = {};
|
|
612
613
|
for (const schema in schemas) {
|
|
@@ -629,8 +630,10 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
629
630
|
// If the schema is external then remove it from the final schemas
|
|
630
631
|
if (core.Is.object(externalReferences)) {
|
|
631
632
|
for (const external in externalReferences) {
|
|
632
|
-
|
|
633
|
+
const re = new RegExp(`^I?${external}(?<!Request|Response)$`);
|
|
634
|
+
if (re.test(schema)) {
|
|
633
635
|
skipSchema = true;
|
|
636
|
+
finalExternals[core.StringHelper.stripPrefix(schema)] = schema.replace(re, externalReferences[external]);
|
|
634
637
|
break;
|
|
635
638
|
}
|
|
636
639
|
}
|
|
@@ -695,10 +698,8 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
695
698
|
// Cleanup the generic markers
|
|
696
699
|
json = json.replace(/%3Cunknown%3E/g, "");
|
|
697
700
|
// Remove external references
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
json = json.replace(new RegExp(`#/components/schemas/${core.StringHelper.stripPrefix(external)}`, "g"), externalReferences[external]);
|
|
701
|
-
}
|
|
701
|
+
for (const finalExternal in finalExternals) {
|
|
702
|
+
json = json.replace(new RegExp(`"#/components/schemas/${core.StringHelper.stripPrefix(finalExternal)}"`, "g"), `"${finalExternals[finalExternal]}"`);
|
|
702
703
|
}
|
|
703
704
|
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.ts-to-openapi.progress.writingOutputFile"), outputFile);
|
|
704
705
|
try {
|
|
@@ -1104,7 +1105,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1104
1105
|
return this.execute({
|
|
1105
1106
|
title: "TWIN TypeScript To OpenAPI",
|
|
1106
1107
|
appName: "ts-to-openapi",
|
|
1107
|
-
version: "0.0.1-next.
|
|
1108
|
+
version: "0.0.1-next.4",
|
|
1108
1109
|
icon: "⚙️ ",
|
|
1109
1110
|
supportsEnvFiles: false
|
|
1110
1111
|
}, localesDirectory ?? path.join(path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../locales"), argv);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -604,6 +604,7 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
const substituteSchemas = [];
|
|
607
|
+
const finalExternals = {};
|
|
607
608
|
// Remove the I, < and > from names
|
|
608
609
|
const finalSchemas = {};
|
|
609
610
|
for (const schema in schemas) {
|
|
@@ -626,8 +627,10 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
626
627
|
// If the schema is external then remove it from the final schemas
|
|
627
628
|
if (Is.object(externalReferences)) {
|
|
628
629
|
for (const external in externalReferences) {
|
|
629
|
-
|
|
630
|
+
const re = new RegExp(`^I?${external}(?<!Request|Response)$`);
|
|
631
|
+
if (re.test(schema)) {
|
|
630
632
|
skipSchema = true;
|
|
633
|
+
finalExternals[StringHelper.stripPrefix(schema)] = schema.replace(re, externalReferences[external]);
|
|
631
634
|
break;
|
|
632
635
|
}
|
|
633
636
|
}
|
|
@@ -692,10 +695,8 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
692
695
|
// Cleanup the generic markers
|
|
693
696
|
json = json.replace(/%3Cunknown%3E/g, "");
|
|
694
697
|
// Remove external references
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
json = json.replace(new RegExp(`#/components/schemas/${StringHelper.stripPrefix(external)}`, "g"), externalReferences[external]);
|
|
698
|
-
}
|
|
698
|
+
for (const finalExternal in finalExternals) {
|
|
699
|
+
json = json.replace(new RegExp(`"#/components/schemas/${StringHelper.stripPrefix(finalExternal)}"`, "g"), `"${finalExternals[finalExternal]}"`);
|
|
699
700
|
}
|
|
700
701
|
CLIDisplay.task(I18n.formatMessage("commands.ts-to-openapi.progress.writingOutputFile"), outputFile);
|
|
701
702
|
try {
|
|
@@ -1101,7 +1102,7 @@ class CLI extends CLIBase {
|
|
|
1101
1102
|
return this.execute({
|
|
1102
1103
|
title: "TWIN TypeScript To OpenAPI",
|
|
1103
1104
|
appName: "ts-to-openapi",
|
|
1104
|
-
version: "0.0.1-next.
|
|
1105
|
+
version: "0.0.1-next.4",
|
|
1105
1106
|
icon: "⚙️ ",
|
|
1106
1107
|
supportsEnvFiles: false
|
|
1107
1108
|
}, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
|
package/dist/locales/en.json
CHANGED
|
@@ -105,6 +105,10 @@
|
|
|
105
105
|
"bitString": {
|
|
106
106
|
"outOfRange": "The index should be >= 0 and less than the length of the bit string"
|
|
107
107
|
},
|
|
108
|
+
"entitySchemaHelper": {
|
|
109
|
+
"noIsPrimary": "Property \"entitySchema.properties\" must contain a value with isPrimary set",
|
|
110
|
+
"multipleIsPrimary": "Property \"entitySchema.properties\" contains more than one property with isPrimary set"
|
|
111
|
+
},
|
|
108
112
|
"fetchHelper": {
|
|
109
113
|
"decodingJSON": "Decoding JSON failed for route \"{route}\"",
|
|
110
114
|
"failureStatusText": "The request to the API failed: \"{statusText}\"",
|
package/docs/changelog.md
CHANGED
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.4",
|
|
4
4
|
"description": "Tool to convert TypeScript REST route definitions to OpenAPI Specifications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,46 +13,17 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"merge-locales": "merge-locales",
|
|
20
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
22
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
23
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
24
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
25
|
-
"docs:clean": "rimraf docs/reference",
|
|
26
|
-
"docs:generate": "typedoc",
|
|
27
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
28
|
-
"dist": "npm run clean && npm run build && npm run merge-locales && npm run test && npm run bundle && npm run docs"
|
|
29
|
-
},
|
|
30
16
|
"dependencies": {
|
|
31
17
|
"@twin.org/api-models": "next",
|
|
32
18
|
"@twin.org/cli-core": "next",
|
|
33
19
|
"@twin.org/core": "next",
|
|
34
|
-
"@twin.org/nameof": "0.0.1-next.
|
|
20
|
+
"@twin.org/nameof": "0.0.1-next.4",
|
|
35
21
|
"@twin.org/web": "next",
|
|
36
22
|
"commander": "12.1.0",
|
|
37
23
|
"glob": "11.0.0",
|
|
38
24
|
"jsonschema": "1.4.1",
|
|
39
25
|
"ts-json-schema-generator": "2.4.0-next.1"
|
|
40
26
|
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@twin.org/merge-locales": "0.0.1-next.3",
|
|
43
|
-
"@twin.org/nameof-transformer": "0.0.1-next.3",
|
|
44
|
-
"@types/node": "22.5.5",
|
|
45
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
46
|
-
"copyfiles": "2.4.1",
|
|
47
|
-
"rimraf": "6.0.1",
|
|
48
|
-
"rollup": "4.21.3",
|
|
49
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
50
|
-
"ts-patch": "3.2.1",
|
|
51
|
-
"typedoc": "0.26.7",
|
|
52
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
53
|
-
"typescript": "5.6.2",
|
|
54
|
-
"vitest": "2.1.1"
|
|
55
|
-
},
|
|
56
27
|
"main": "./dist/cjs/index.cjs",
|
|
57
28
|
"module": "./dist/esm/index.mjs",
|
|
58
29
|
"types": "./dist/types/index.d.ts",
|