Skip to content

Commit 10c23a9

Browse files
committed
ensureComplicance() application draft.
1 parent 876ca0d commit 10c23a9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

express-zod-api/src/documentation-helpers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ const ensureCompliance = ({
211211
...rest
212212
}: JSONSchema.BaseSchema): SchemaObject | ReferenceObject => {
213213
if ($ref) return { $ref };
214-
if (typeof type === "string") type = isSupportedType(type) ? type : undefined;
215214
return {
216215
type: Array.isArray(type)
217216
? type.filter(isSupportedType)
@@ -490,14 +489,14 @@ const fixReferences = (
490489
const actualName = entry.$ref.split("/").pop()!;
491490
const depiction = defs[actualName];
492491
if (depiction)
493-
entry.$ref = ctx.makeRef(depiction, depiction as SchemaObject).$ref; // @todo see below
492+
entry.$ref = ctx.makeRef(depiction, ensureCompliance(depiction)).$ref;
494493
continue;
495494
}
496495
stack.push(...R.values(entry));
497496
}
498497
if (R.is(Array, entry)) stack.push(...R.values(entry));
499498
}
500-
return subject as SchemaObject; // @todo ideally, there should be a method to ensure that
499+
return ensureCompliance(subject);
501500
};
502501

503502
/** @link https://github.com/colinhacks/zod/issues/4275 */

0 commit comments

Comments
 (0)