UEA-PRODEM
This commit is contained in:
+13
-2
@@ -86,7 +86,7 @@ export function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
||||
delete result.schema.default;
|
||||
}
|
||||
// set prefault as default
|
||||
if (ctx.io === "input" && result.schema._prefault)
|
||||
if (ctx.io === "input" && "_prefault" in result.schema)
|
||||
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
||||
delete result.schema._prefault;
|
||||
// pulling fresh from ctx.seen in case it was overwritten
|
||||
@@ -253,7 +253,7 @@ export function finalize(ctx, schema) {
|
||||
}
|
||||
}
|
||||
// When ref was extracted to $defs, remove properties that match the definition
|
||||
if (refSchema.$ref) {
|
||||
if (refSchema.$ref && refSeen.def) {
|
||||
for (const key in schema) {
|
||||
if (key === "$ref" || key === "allOf")
|
||||
continue;
|
||||
@@ -318,11 +318,20 @@ export function finalize(ctx, schema) {
|
||||
result.$id = ctx.external.uri(id);
|
||||
}
|
||||
Object.assign(result, root.def ?? root.schema);
|
||||
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
||||
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
||||
// from the output body where it would otherwise leak. The id is preserved
|
||||
// implicitly via the $defs key (and via $ref paths).
|
||||
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
||||
if (rootMetaId !== undefined && result.id === rootMetaId)
|
||||
delete result.id;
|
||||
// build defs object
|
||||
const defs = ctx.external?.defs ?? {};
|
||||
for (const entry of ctx.seen.entries()) {
|
||||
const seen = entry[1];
|
||||
if (seen.def && seen.defId) {
|
||||
if (seen.def.id === seen.defId)
|
||||
delete seen.def.id;
|
||||
defs[seen.defId] = seen.def;
|
||||
}
|
||||
}
|
||||
@@ -391,6 +400,8 @@ function isTransforming(_schema, _ctx) {
|
||||
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
||||
}
|
||||
if (def.type === "pipe") {
|
||||
if (_schema._zod.traits.has("$ZodCodec"))
|
||||
return true;
|
||||
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
||||
}
|
||||
if (def.type === "object") {
|
||||
|
||||
Reference in New Issue
Block a user