Skip to content

Commit 730bcae

Browse files
committed
Several todos.
1 parent 7a47f0e commit 730bcae

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ const makeNullableType = ({
277277
| SchemaObjectType
278278
| SchemaObjectType[] => {
279279
if (type === "null") return type;
280-
if (typeof type === "string") return [type as SchemaObjectType, "null"];
280+
if (typeof type === "string") return [type as SchemaObjectType, "null"]; // @todo make method instead of "as"
281281
return type ? [...new Set(type).add("null")] : "null";
282282
};
283283

@@ -503,17 +503,18 @@ const fixReferences = (
503503
const actualName = entry.$ref.split("/").pop()!;
504504
const depiction = $defs[actualName];
505505
if (depiction)
506-
entry.$ref = ctx.makeRef(depiction, depiction as SchemaObject).$ref;
506+
entry.$ref = ctx.makeRef(depiction, depiction as SchemaObject).$ref; // @todo see below
507507
continue;
508508
}
509509
}
510510
stack.push(...R.values(entry));
511511
}
512512
if (R.is(Array, entry)) stack.push(...R.values(entry));
513513
}
514-
return rest as SchemaObject;
514+
return rest as SchemaObject; // @todo ideally, there should be a method to ensure that
515515
};
516516

517+
// @todo rename?
517518
export const delegate = (
518519
schema: $ZodType,
519520
{

express-zod-api/tests/documentation-helpers.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ import {
1717
delegate,
1818
} from "../src/documentation-helpers";
1919

20+
/**
21+
* @todo all these functions is now the one, and the tests naming is not relevant anymore
22+
* @todo these tests should now be transformed into ones of particular postprocessors and assert exactly what they do.
23+
* @todo So we would not test Zod here, but internal methods only.
24+
*/
2025
describe("Documentation helpers", () => {
2126
const makeRefMock = vi.fn();
2227
const requestCtx = {

express-zod-api/tests/documentation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ describe("Documentation", () => {
495495
method: "post",
496496
input: category,
497497
output: z.object({
498-
zodExample: category,
498+
zodExample: category, // @todo consider external registry to deduplicate it
499499
}),
500500
handler: async () => ({
501501
zodExample: {

0 commit comments

Comments
 (0)