Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

refactor: filter model schema composition while parsing (#1461)

mldangelo-oaid27e0e82c2cc
diff --git a/sdk/typescript/scripts/generate-models.cjs b/sdk/typescript/scripts/generate-models.cjs
index d3b5160cc..303bfd1ea 100644
--- a/sdk/typescript/scripts/generate-models.cjs
+++ b/sdk/typescript/scripts/generate-models.cjs
@@ -8,16 +8,6 @@ const schemas = resolve(packageRoot, "../../plugins/codex-security/schemas");
if (!existsSync(schemas)) throw new Error("Could not find the plugin schemas.");
-function withoutAllOf(value) {
- if (Array.isArray(value)) return value.map(withoutAllOf);
- if (value === null || typeof value !== "object") return value;
- return Object.fromEntries(
- Object.entries(value)
- .filter(([key]) => key !== "allOf")
- .map(([key, child]) => [key, withoutAllOf(child)]),
- );
-}
-
async function generate() {
const documents = [
["scan-manifest.schema.json", "ScanManifest"],
@@ -26,9 +16,11 @@ async function generate() {
];
const models = await Promise.all(
documents.map(async ([filename, name]) => {
- const schema = JSON.parse(readFileSync(join(schemas, filename), "utf8"));
// json-schema-to-typescript drops object fields when allOf uses contains or if/then.
- const input = withoutAllOf(schema);
+ const input = JSON.parse(
+ readFileSync(join(schemas, filename), "utf8"),
+ (key, value) => (key === "allOf" ? undefined : value),
+ );
input.title = name;
return compile(input, name, {
bannerComment: "",