@mittwald/api-code-generator 4.497.1 → 4.498.0

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.
@@ -34,12 +34,14 @@ export const widenDateTimeInputs = (something, clone = true) => {
34
34
  if (clone) {
35
35
  something = cloneDeep(something);
36
36
  }
37
- if (!is.nonEmptyObject(something)) {
38
- return something;
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
- if (!is.nonEmptyObject(something)) {
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
- if (!is.nonEmptyObject(something)) {
7
- return;
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
- if (!is.nonEmptyObject(something)) {
29
- return something;
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/lib/interfaces/parser.js").BooleanFlag<boolean>;
6
- name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
- optionalHeader: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
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/lib/interfaces/parser.js").Arg<string, {
11
- exists?: boolean | undefined;
10
+ input: import("@oclif/core/interfaces").Arg<string, {
11
+ exists?: boolean;
12
12
  }>;
13
- output: import("@oclif/core/lib/interfaces/parser.js").Arg<string, {
14
- exists?: boolean | undefined;
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/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
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.497.1",
3
+ "version": "4.498.0",
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": "^3.27.0",
32
- "@oclif/plugin-help": "^6.2.33",
33
- "@oclif/plugin-plugins": "^4.3.10",
34
- "@sindresorhus/is": "^6.3.1",
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": "^8.0.0",
41
+ "camelcase": "^9.0.0",
43
42
  "clone-deep": "^4.0.1",
44
- "dot-prop": "^8.0.2",
43
+ "dot-prop": "^10.2.0",
45
44
  "fs-jetpack": "^5.1.0",
46
- "get-stdin": "^9.0.0",
45
+ "get-stdin": "^10.0.0",
47
46
  "invariant": "^2.2.4",
48
- "js-yaml": "^4.1.0",
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,8 +53,8 @@
54
53
  "type-fest": "^4.30.0",
55
54
  "verror": "^1.10.1",
56
55
  "yieldable-json": "^2.1.0",
57
- "zod": "^3.25.76",
58
- "zod-validation-error": "^3.5.3"
56
+ "zod": "^4.4.3",
57
+ "zod-validation-error": "^5.0.0"
59
58
  },
60
59
  "devDependencies": {
61
60
  "@eslint/js": "^10.0.1",
@@ -86,5 +85,5 @@
86
85
  "@oclif/plugin-plugins"
87
86
  ]
88
87
  },
89
- "gitHead": "f88e7011ac4040227a436165373366131dcf838e"
88
+ "gitHead": "921f7cf94b66b91338f1400f91064782464c7bb9"
90
89
  }