@cerios/openapi-to-zod 0.1.1 → 0.1.2
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/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +12 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -16
package/dist/index.mjs
CHANGED
|
@@ -65,7 +65,8 @@ var ConfigurationError = class extends GeneratorError {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// src/generator.ts
|
|
68
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
68
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
69
|
+
import { dirname } from "path";
|
|
69
70
|
import { parse } from "yaml";
|
|
70
71
|
|
|
71
72
|
// src/utils/name-utils.ts
|
|
@@ -1397,6 +1398,15 @@ var ZodSchemaGenerator = class {
|
|
|
1397
1398
|
}
|
|
1398
1399
|
return output.join("\n");
|
|
1399
1400
|
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Ensure directory exists for a file path
|
|
1403
|
+
*/
|
|
1404
|
+
ensureDirectoryExists(filePath) {
|
|
1405
|
+
const dir = dirname(filePath);
|
|
1406
|
+
if (!existsSync(dir)) {
|
|
1407
|
+
mkdirSync(dir, { recursive: true });
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1400
1410
|
/**
|
|
1401
1411
|
* Generate the complete output file
|
|
1402
1412
|
*/
|
|
@@ -1408,6 +1418,7 @@ var ZodSchemaGenerator = class {
|
|
|
1408
1418
|
);
|
|
1409
1419
|
}
|
|
1410
1420
|
const output = this.generateString();
|
|
1421
|
+
this.ensureDirectoryExists(this.options.output);
|
|
1411
1422
|
writeFileSync(this.options.output, output);
|
|
1412
1423
|
}
|
|
1413
1424
|
/**
|