-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch-openapi.mjs
More file actions
29 lines (22 loc) · 926 Bytes
/
Copy pathpatch-openapi.mjs
File metadata and controls
29 lines (22 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
import { readFile, writeFile } from "node:fs/promises";
import { applyOpenApiDriftPatches } from "./openapi-drift-patches.mjs";
import { resolveContractsOpenApiPaths } from "./contracts-openapi-paths.mjs";
const { specPath, source } = resolveContractsOpenApiPaths();
async function main() {
const raw = await readFile(specPath, "utf8");
const spec = JSON.parse(raw);
const patchSummary = applyOpenApiDriftPatches(spec);
if (patchSummary.mutationCount === 0) {
console.log("✅ OpenAPI drift patch already applied");
return;
}
await writeFile(specPath, `${JSON.stringify(spec)}\n`);
console.log(
`✅ OpenAPI drift patch applied (${patchSummary.enumPatchedCount} enum updates, ${patchSummary.nullablePatchedCount} nullable updates, source=${source})`,
);
}
main().catch((error) => {
console.error("❌ Failed to patch OpenAPI spec:", error);
process.exitCode = 1;
});