agsamantha/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.mjs
2024-10-02 15:15:21 -05:00

21 lines
No EOL
591 B
JavaScript

import { parseDef } from "../parseDef.mjs";
export const parseOptionalDef = (def, refs) => {
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
return parseDef(def.innerType._def, refs);
}
const innerSchema = parseDef(def.innerType._def, {
...refs,
currentPath: [...refs.currentPath, 'anyOf', '1'],
});
return innerSchema ?
{
anyOf: [
{
not: {},
},
innerSchema,
],
}
: {};
};
//# sourceMappingURL=optional.mjs.map