@mittwald/api-code-generator 4.497.1 → 4.498.1
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/esm/generation/dateTime/dateTimeInput.js +9 -6
- package/dist/esm/generation/dateTime/dateTimeInputSchemaNames.js +5 -3
- package/dist/esm/generation/refs/componentRefsToCustomTypes.js +5 -3
- package/dist/esm/generation/refs/componentRefsToCustomTypes.test.js +14 -0
- package/dist/esm/lib/makeError.js +2 -2
- package/dist/types/commands/generate/index.d.ts +7 -7
- package/dist/types/commands/validate/index.d.ts +1 -1
- package/package.json +17 -18
|
@@ -34,12 +34,14 @@ export const widenDateTimeInputs = (something, clone = true) => {
|
|
|
34
34
|
if (clone) {
|
|
35
35
|
something = cloneDeep(something);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
37
|
+
// Note: as of @sindresorhus/is v8, `is.nonEmptyObject()` no longer reports
|
|
38
|
+
// `true` for arrays, so arrays have to be handled before that check.
|
|
40
39
|
if (is.array(something)) {
|
|
41
40
|
return something.map((item) => widenDateTimeInputs(item, false));
|
|
42
41
|
}
|
|
42
|
+
if (!is.nonEmptyObject(something)) {
|
|
43
|
+
return something;
|
|
44
|
+
}
|
|
43
45
|
if (isDateTimeStringSchema(something)) {
|
|
44
46
|
return { ...something, tsType: dateTimeInputTsType };
|
|
45
47
|
}
|
|
@@ -53,12 +55,13 @@ export const widenDateTimeInputs = (something, clone = true) => {
|
|
|
53
55
|
* i.e. without following `$ref`s.
|
|
54
56
|
*/
|
|
55
57
|
export const containsDateTimeInput = (something) => {
|
|
56
|
-
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
58
|
+
// see the note in `widenDateTimeInputs()` on why arrays come first
|
|
59
59
|
if (is.array(something)) {
|
|
60
60
|
return something.some((item) => containsDateTimeInput(item));
|
|
61
61
|
}
|
|
62
|
+
if (!is.nonEmptyObject(something)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
62
65
|
if (isDateTimeStringSchema(something)) {
|
|
63
66
|
return true;
|
|
64
67
|
}
|
|
@@ -3,13 +3,15 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
3
3
|
import { containsDateTimeInput } from "./dateTimeInput.js";
|
|
4
4
|
const schemaRefPrefix = "#/components/schemas/";
|
|
5
5
|
const collectSchemaRefs = (something, into) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
// Note: as of @sindresorhus/is v8, `is.nonEmptyObject()` no longer reports
|
|
7
|
+
// `true` for arrays, so arrays have to be handled before that check.
|
|
9
8
|
if (is.array(something)) {
|
|
10
9
|
something.forEach((item) => collectSchemaRefs(item, into));
|
|
11
10
|
return;
|
|
12
11
|
}
|
|
12
|
+
if (!is.nonEmptyObject(something)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
13
15
|
for (const [key, value] of Object.entries(something)) {
|
|
14
16
|
if (key === "$ref") {
|
|
15
17
|
if (typeof value === "string" && value.startsWith(schemaRefPrefix)) {
|
|
@@ -25,12 +25,14 @@ export const componentRefsToCustomTypes = (rootNamespace, something, clone = tru
|
|
|
25
25
|
if (clone) {
|
|
26
26
|
something = cloneDeep(something);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
28
|
+
// Note: as of @sindresorhus/is v8, `is.nonEmptyObject()` no longer reports
|
|
29
|
+
// `true` for arrays, so arrays have to be handled before that check.
|
|
31
30
|
if (is.array(something)) {
|
|
32
31
|
return something.map((item) => componentRefsToCustomTypes(rootNamespace, item, false, resolveTSName));
|
|
33
32
|
}
|
|
33
|
+
if (!is.nonEmptyObject(something)) {
|
|
34
|
+
return something;
|
|
35
|
+
}
|
|
34
36
|
const componentRef = getComponentRef(something);
|
|
35
37
|
if (componentRef !== undefined) {
|
|
36
38
|
// see https://github.com/bcherny/json-schema-to-typescript#custom-schema-properties
|
|
@@ -38,6 +38,20 @@ test.each([
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
inArray: [{ $ref: "#/components/foo/bar" }, { noRef: "No fun" }],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
inArray: [
|
|
47
|
+
{
|
|
48
|
+
type: "object",
|
|
49
|
+
tsType: "Test.Components.Foo.Bar",
|
|
50
|
+
},
|
|
51
|
+
{ noRef: "No fun" },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
41
55
|
[
|
|
42
56
|
{
|
|
43
57
|
$ref: "#/components/foo/bar",
|
|
@@ -3,5 +3,5 @@ import { getProperty } from "dot-prop";
|
|
|
3
3
|
export const makeError = (error) => error instanceof Error
|
|
4
4
|
? error
|
|
5
5
|
: new VError({
|
|
6
|
-
name: getProperty(error, "name") ?? "Error",
|
|
7
|
-
}, getProperty(error, "message") ?? "");
|
|
6
|
+
name: String(getProperty(error, "name") ?? "Error"),
|
|
7
|
+
}, String(getProperty(error, "message") ?? ""));
|
|
@@ -2,16 +2,16 @@ import { Command } from "@oclif/core";
|
|
|
2
2
|
export default class Generate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
|
-
skipValidation: import("@oclif/core/
|
|
6
|
-
name: import("@oclif/core/
|
|
7
|
-
optionalHeader: import("@oclif/core/
|
|
5
|
+
skipValidation: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
optionalHeader: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
static args: {
|
|
10
|
-
input: import("@oclif/core/
|
|
11
|
-
exists?: boolean
|
|
10
|
+
input: import("@oclif/core/interfaces").Arg<string, {
|
|
11
|
+
exists?: boolean;
|
|
12
12
|
}>;
|
|
13
|
-
output: import("@oclif/core/
|
|
14
|
-
exists?: boolean
|
|
13
|
+
output: import("@oclif/core/interfaces").Arg<string, {
|
|
14
|
+
exists?: boolean;
|
|
15
15
|
}>;
|
|
16
16
|
};
|
|
17
17
|
run(): Promise<void>;
|
|
@@ -2,7 +2,7 @@ import { Command } from "@oclif/core";
|
|
|
2
2
|
export default class Validate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static args: {
|
|
5
|
-
input: import("@oclif/core/
|
|
5
|
+
input: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
6
|
};
|
|
7
7
|
run(): Promise<void>;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/api-code-generator",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.498.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "https://github.com/mittwald/api-client-js.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,24 +28,23 @@
|
|
|
28
28
|
"test:unit:coverage": "run test:unit --coverage"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@oclif/core": "^
|
|
32
|
-
"@oclif/plugin-help": "^6.
|
|
33
|
-
"@oclif/plugin-plugins": "^
|
|
34
|
-
"@sindresorhus/is": "^
|
|
31
|
+
"@oclif/core": "^4.14.0",
|
|
32
|
+
"@oclif/plugin-help": "^6.3.0",
|
|
33
|
+
"@oclif/plugin-plugins": "^5.5.2",
|
|
34
|
+
"@sindresorhus/is": "^8.1.0",
|
|
35
35
|
"@types/clone-deep": "^4.0.4",
|
|
36
36
|
"@types/invariant": "^2.2.37",
|
|
37
|
-
"@types/js-yaml": "^4.0.9",
|
|
38
37
|
"@types/prettier": "^3.0.0",
|
|
39
38
|
"@types/verror": "^1.10.11",
|
|
40
39
|
"@types/yieldable-json": "^2.0.2",
|
|
41
40
|
"axios": "^1.15.2",
|
|
42
|
-
"camelcase": "^
|
|
41
|
+
"camelcase": "^9.0.0",
|
|
43
42
|
"clone-deep": "^4.0.1",
|
|
44
|
-
"dot-prop": "^
|
|
43
|
+
"dot-prop": "^10.2.0",
|
|
45
44
|
"fs-jetpack": "^5.1.0",
|
|
46
|
-
"get-stdin": "^
|
|
45
|
+
"get-stdin": "^10.0.0",
|
|
47
46
|
"invariant": "^2.2.4",
|
|
48
|
-
"js-yaml": "^4.1
|
|
47
|
+
"js-yaml": "^5.4.1",
|
|
49
48
|
"json-schema-to-typescript": "^15.0.4",
|
|
50
49
|
"openapi-schema-validator": "^12.1.3",
|
|
51
50
|
"openapi-types": "^12.1.3",
|
|
@@ -54,25 +53,25 @@
|
|
|
54
53
|
"type-fest": "^4.30.0",
|
|
55
54
|
"verror": "^1.10.1",
|
|
56
55
|
"yieldable-json": "^2.1.0",
|
|
57
|
-
"zod": "^
|
|
58
|
-
"zod-validation-error": "^
|
|
56
|
+
"zod": "^4.4.3",
|
|
57
|
+
"zod-validation-error": "^5.0.0"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
61
60
|
"@eslint/js": "^10.0.1",
|
|
62
|
-
"@jest/globals": "^
|
|
63
|
-
"@types/jest": "^
|
|
61
|
+
"@jest/globals": "^30.5.0",
|
|
62
|
+
"@types/jest": "^30.0.0",
|
|
64
63
|
"@types/swagger2openapi": "^7.0.4",
|
|
65
64
|
"eslint": "^10.9.1",
|
|
66
65
|
"eslint-config-prettier": "^10.1.8",
|
|
67
66
|
"eslint-plugin-json": "^5.0.0",
|
|
68
67
|
"eslint-plugin-prettier": "^5.5.6",
|
|
69
68
|
"globals": "^17.11.0",
|
|
70
|
-
"jest": "^
|
|
69
|
+
"jest": "^30.5.0",
|
|
71
70
|
"prettier": "^3.6.2",
|
|
72
71
|
"prettier-plugin-jsdoc": "^1.3.3",
|
|
73
72
|
"prettier-plugin-pkgsort": "^0.2.1",
|
|
74
|
-
"prettier-plugin-sort-json": "^
|
|
75
|
-
"rimraf": "^
|
|
73
|
+
"prettier-plugin-sort-json": "^4.2.0",
|
|
74
|
+
"rimraf": "^6.1.3",
|
|
76
75
|
"ts-jest": "^29.2.5",
|
|
77
76
|
"typescript": "^5.7.2",
|
|
78
77
|
"typescript-eslint": "^8.68.0"
|
|
@@ -86,5 +85,5 @@
|
|
|
86
85
|
"@oclif/plugin-plugins"
|
|
87
86
|
]
|
|
88
87
|
},
|
|
89
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "2b098b734d3d0babae5ff934d92d79bc0634123d"
|
|
90
89
|
}
|