@cerios/openapi-to-zod 0.2.0 → 0.3.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.
- package/README.md +112 -114
- package/dist/cli.js +5131 -156
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +5108 -153
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +20 -8
- package/dist/index.d.ts +20 -8
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -66,7 +66,7 @@ var ConfigurationError = class extends GeneratorError {
|
|
|
66
66
|
|
|
67
67
|
// src/generator.ts
|
|
68
68
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
69
|
-
import { dirname } from "path";
|
|
69
|
+
import { dirname, normalize } from "path";
|
|
70
70
|
import { parse } from "yaml";
|
|
71
71
|
|
|
72
72
|
// src/utils/name-utils.ts
|
|
@@ -1406,7 +1406,8 @@ var ZodSchemaGenerator = class {
|
|
|
1406
1406
|
* Ensure directory exists for a file path
|
|
1407
1407
|
*/
|
|
1408
1408
|
ensureDirectoryExists(filePath) {
|
|
1409
|
-
const
|
|
1409
|
+
const normalizedPath = normalize(filePath);
|
|
1410
|
+
const dir = dirname(normalizedPath);
|
|
1410
1411
|
if (!existsSync(dir)) {
|
|
1411
1412
|
mkdirSync(dir, { recursive: true });
|
|
1412
1413
|
}
|
|
@@ -1422,8 +1423,9 @@ var ZodSchemaGenerator = class {
|
|
|
1422
1423
|
);
|
|
1423
1424
|
}
|
|
1424
1425
|
const output = this.generateString();
|
|
1425
|
-
|
|
1426
|
-
|
|
1426
|
+
const normalizedOutput = normalize(this.options.output);
|
|
1427
|
+
this.ensureDirectoryExists(normalizedOutput);
|
|
1428
|
+
writeFileSync(normalizedOutput, output);
|
|
1427
1429
|
}
|
|
1428
1430
|
/**
|
|
1429
1431
|
* Resolve options for a specific context (request or response)
|
|
@@ -1431,17 +1433,18 @@ var ZodSchemaGenerator = class {
|
|
|
1431
1433
|
* Response schemas always use 'inferred' mode (Zod schemas)
|
|
1432
1434
|
*/
|
|
1433
1435
|
resolveOptionsForContext(context) {
|
|
1434
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1436
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1435
1437
|
const contextOptions = context === "request" ? this.options.request : this.options.response;
|
|
1438
|
+
const nativeEnumType = context === "request" ? (_c = (_b = (_a = this.options.request) == null ? void 0 : _a.nativeEnumType) != null ? _b : this.options.nativeEnumType) != null ? _c : "union" : (_d = this.options.nativeEnumType) != null ? _d : "union";
|
|
1436
1439
|
return {
|
|
1437
|
-
mode: (
|
|
1438
|
-
enumType: (
|
|
1439
|
-
useDescribe: (
|
|
1440
|
-
includeDescriptions: (
|
|
1440
|
+
mode: (_f = (_e = contextOptions == null ? void 0 : contextOptions.mode) != null ? _e : this.options.mode) != null ? _f : "normal",
|
|
1441
|
+
enumType: (_h = (_g = contextOptions == null ? void 0 : contextOptions.enumType) != null ? _g : this.options.enumType) != null ? _h : "zod",
|
|
1442
|
+
useDescribe: (_j = (_i = contextOptions == null ? void 0 : contextOptions.useDescribe) != null ? _i : this.options.useDescribe) != null ? _j : false,
|
|
1443
|
+
includeDescriptions: (_l = (_k = contextOptions == null ? void 0 : contextOptions.includeDescriptions) != null ? _k : this.options.includeDescriptions) != null ? _l : true,
|
|
1441
1444
|
// Response schemas always use 'inferred' mode (Zod schemas are required)
|
|
1442
1445
|
// Request schemas can optionally use 'native' mode
|
|
1443
|
-
typeMode: context === "response" ? "inferred" : (
|
|
1444
|
-
nativeEnumType
|
|
1446
|
+
typeMode: context === "response" ? "inferred" : (_n = (_m = this.options.request) == null ? void 0 : _m.typeMode) != null ? _n : "inferred",
|
|
1447
|
+
nativeEnumType
|
|
1445
1448
|
};
|
|
1446
1449
|
}
|
|
1447
1450
|
/**
|