@twin.org/ts-to-openapi 0.0.1-next.26 → 0.0.1-next.27
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 +60 -5
- package/dist/esm/index.mjs +61 -6
- package/docs/changelog.md +18 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -659,11 +659,13 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
|
-
|
|
663
|
-
|
|
662
|
+
// Remove standard types that we don't want in the final output
|
|
663
|
+
const removeTypes = ["HttpStatusCode", "Uint8Array", "ArrayBuffer"];
|
|
664
|
+
for (const type of removeTypes) {
|
|
665
|
+
delete finalSchemas[type];
|
|
664
666
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
+
for (const type in finalSchemas) {
|
|
668
|
+
processArrays(finalSchemas[type]);
|
|
667
669
|
}
|
|
668
670
|
const schemaKeys = Object.keys(finalSchemas);
|
|
669
671
|
schemaKeys.sort();
|
|
@@ -1098,6 +1100,59 @@ async function loadPackages(tsToOpenApiConfig, outputWorkingDir, typeRoots) {
|
|
|
1098
1100
|
}
|
|
1099
1101
|
return restRoutes;
|
|
1100
1102
|
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Process arrays in the schema object.
|
|
1105
|
+
* @param schemaObject The schema object to process.
|
|
1106
|
+
*/
|
|
1107
|
+
function processArrays(schemaObject) {
|
|
1108
|
+
if (core.Is.object(schemaObject)) {
|
|
1109
|
+
// latest specs have singular items in `items` property
|
|
1110
|
+
// and multiple items in prefixItems, so update the schema accordingly
|
|
1111
|
+
// https://www.learnjsonschema.com/2020-12/applicator/items/
|
|
1112
|
+
// https://www.learnjsonschema.com/2020-12/applicator/prefixitems/
|
|
1113
|
+
const schemaItems = schemaObject.items;
|
|
1114
|
+
if (core.Is.array(schemaItems) || core.Is.object(schemaItems)) {
|
|
1115
|
+
schemaObject.prefixItems = core.ArrayHelper.fromObjectOrArray(schemaItems);
|
|
1116
|
+
delete schemaObject.items;
|
|
1117
|
+
}
|
|
1118
|
+
const additionalItems = schemaObject.additionalItems;
|
|
1119
|
+
if (core.Is.array(additionalItems) || core.Is.object(additionalItems)) {
|
|
1120
|
+
schemaObject.items = core.ArrayHelper.fromObjectOrArray(additionalItems)[0];
|
|
1121
|
+
delete schemaObject.additionalItems;
|
|
1122
|
+
}
|
|
1123
|
+
processSchemaDictionary(schemaObject.properties);
|
|
1124
|
+
processArrays(schemaObject.additionalProperties);
|
|
1125
|
+
processSchemaArray(schemaObject.allOf);
|
|
1126
|
+
processSchemaArray(schemaObject.anyOf);
|
|
1127
|
+
processSchemaArray(schemaObject.oneOf);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Process arrays in the schema object.
|
|
1132
|
+
* @param schemaDictionary The schema object to process.
|
|
1133
|
+
*/
|
|
1134
|
+
function processSchemaDictionary(schemaDictionary) {
|
|
1135
|
+
if (core.Is.object(schemaDictionary)) {
|
|
1136
|
+
for (const item of Object.values(schemaDictionary)) {
|
|
1137
|
+
if (core.Is.object(item)) {
|
|
1138
|
+
processArrays(item);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Process arrays in the schema object.
|
|
1145
|
+
* @param schemaArray The schema object to process.
|
|
1146
|
+
*/
|
|
1147
|
+
function processSchemaArray(schemaArray) {
|
|
1148
|
+
if (core.Is.arrayValue(schemaArray)) {
|
|
1149
|
+
for (const item of schemaArray) {
|
|
1150
|
+
if (core.Is.object(item)) {
|
|
1151
|
+
processArrays(item);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1101
1156
|
|
|
1102
1157
|
// Copyright 2024 IOTA Stiftung.
|
|
1103
1158
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -1117,7 +1172,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1117
1172
|
return this.execute({
|
|
1118
1173
|
title: "TWIN TypeScript To OpenAPI",
|
|
1119
1174
|
appName: "ts-to-openapi",
|
|
1120
|
-
version: "0.0.1-next.
|
|
1175
|
+
version: "0.0.1-next.27", // x-release-please-version
|
|
1121
1176
|
icon: "⚙️ ",
|
|
1122
1177
|
supportsEnvFiles: false,
|
|
1123
1178
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { CLIDisplay, CLIUtils, CLIBase } from '@twin.org/cli-core';
|
|
4
4
|
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { I18n, GeneralError, Is, StringHelper, ObjectHelper } from '@twin.org/core';
|
|
5
|
+
import { I18n, GeneralError, Is, StringHelper, ObjectHelper, ArrayHelper } from '@twin.org/core';
|
|
6
6
|
import { HttpStatusCode, MimeTypes } from '@twin.org/web';
|
|
7
7
|
import { createGenerator } from 'ts-json-schema-generator';
|
|
8
8
|
|
|
@@ -656,11 +656,13 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
|
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
|
-
|
|
660
|
-
|
|
659
|
+
// Remove standard types that we don't want in the final output
|
|
660
|
+
const removeTypes = ["HttpStatusCode", "Uint8Array", "ArrayBuffer"];
|
|
661
|
+
for (const type of removeTypes) {
|
|
662
|
+
delete finalSchemas[type];
|
|
661
663
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
+
for (const type in finalSchemas) {
|
|
665
|
+
processArrays(finalSchemas[type]);
|
|
664
666
|
}
|
|
665
667
|
const schemaKeys = Object.keys(finalSchemas);
|
|
666
668
|
schemaKeys.sort();
|
|
@@ -1095,6 +1097,59 @@ async function loadPackages(tsToOpenApiConfig, outputWorkingDir, typeRoots) {
|
|
|
1095
1097
|
}
|
|
1096
1098
|
return restRoutes;
|
|
1097
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Process arrays in the schema object.
|
|
1102
|
+
* @param schemaObject The schema object to process.
|
|
1103
|
+
*/
|
|
1104
|
+
function processArrays(schemaObject) {
|
|
1105
|
+
if (Is.object(schemaObject)) {
|
|
1106
|
+
// latest specs have singular items in `items` property
|
|
1107
|
+
// and multiple items in prefixItems, so update the schema accordingly
|
|
1108
|
+
// https://www.learnjsonschema.com/2020-12/applicator/items/
|
|
1109
|
+
// https://www.learnjsonschema.com/2020-12/applicator/prefixitems/
|
|
1110
|
+
const schemaItems = schemaObject.items;
|
|
1111
|
+
if (Is.array(schemaItems) || Is.object(schemaItems)) {
|
|
1112
|
+
schemaObject.prefixItems = ArrayHelper.fromObjectOrArray(schemaItems);
|
|
1113
|
+
delete schemaObject.items;
|
|
1114
|
+
}
|
|
1115
|
+
const additionalItems = schemaObject.additionalItems;
|
|
1116
|
+
if (Is.array(additionalItems) || Is.object(additionalItems)) {
|
|
1117
|
+
schemaObject.items = ArrayHelper.fromObjectOrArray(additionalItems)[0];
|
|
1118
|
+
delete schemaObject.additionalItems;
|
|
1119
|
+
}
|
|
1120
|
+
processSchemaDictionary(schemaObject.properties);
|
|
1121
|
+
processArrays(schemaObject.additionalProperties);
|
|
1122
|
+
processSchemaArray(schemaObject.allOf);
|
|
1123
|
+
processSchemaArray(schemaObject.anyOf);
|
|
1124
|
+
processSchemaArray(schemaObject.oneOf);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Process arrays in the schema object.
|
|
1129
|
+
* @param schemaDictionary The schema object to process.
|
|
1130
|
+
*/
|
|
1131
|
+
function processSchemaDictionary(schemaDictionary) {
|
|
1132
|
+
if (Is.object(schemaDictionary)) {
|
|
1133
|
+
for (const item of Object.values(schemaDictionary)) {
|
|
1134
|
+
if (Is.object(item)) {
|
|
1135
|
+
processArrays(item);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Process arrays in the schema object.
|
|
1142
|
+
* @param schemaArray The schema object to process.
|
|
1143
|
+
*/
|
|
1144
|
+
function processSchemaArray(schemaArray) {
|
|
1145
|
+
if (Is.arrayValue(schemaArray)) {
|
|
1146
|
+
for (const item of schemaArray) {
|
|
1147
|
+
if (Is.object(item)) {
|
|
1148
|
+
processArrays(item);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1098
1153
|
|
|
1099
1154
|
// Copyright 2024 IOTA Stiftung.
|
|
1100
1155
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -1114,7 +1169,7 @@ class CLI extends CLIBase {
|
|
|
1114
1169
|
return this.execute({
|
|
1115
1170
|
title: "TWIN TypeScript To OpenAPI",
|
|
1116
1171
|
appName: "ts-to-openapi",
|
|
1117
|
-
version: "0.0.1-next.
|
|
1172
|
+
version: "0.0.1-next.27", // x-release-please-version
|
|
1118
1173
|
icon: "⚙️ ",
|
|
1119
1174
|
supportsEnvFiles: false,
|
|
1120
1175
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @twin.org/ts-to-openapi - Changelog
|
|
2
2
|
|
|
3
|
+
## [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
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add latest json schema features ([494293f](https://github.com/twinfoundation/tools/commit/494293f4252b9c7d4a20790ec157fc9d8c96c3d2))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/nameof bumped from 0.0.1-next.26 to 0.0.1-next.27
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/merge-locales bumped from 0.0.1-next.26 to 0.0.1-next.27
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.1-next.26 to 0.0.1-next.27
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.26 to 0.0.1-next.27
|
|
20
|
+
|
|
3
21
|
## [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)
|
|
4
22
|
|
|
5
23
|
|
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.27",
|
|
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": "0.0.1-next.
|
|
20
|
+
"@twin.org/nameof": "0.0.1-next.27",
|
|
21
21
|
"@twin.org/web": "next",
|
|
22
22
|
"ajv": "8.17.1",
|
|
23
23
|
"commander": "14.0.0",
|