Skip to content

Commit a4e75f9

Browse files
committed
Removing depictEnum() and depictLiteral().
1 parent dc7bd91 commit a4e75f9

3 files changed

Lines changed: 0 additions & 78 deletions

File tree

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,6 @@ export const depictNullable: Depicter = ({ jsonSchema }) => {
140140
return Object.assign(original, { type: makeNullableType(original.type) });
141141
};
142142

143-
const isSupportedType = (subject: string): subject is SchemaObjectType =>
144-
subject in samples;
145-
146-
/**
147-
* @todo remove in v25
148-
* @since zod 3.25.45
149-
*/
150-
export const depictEnum: Depicter = ({ jsonSchema }) => {
151-
const suggestedType = typeof jsonSchema.enum?.[0];
152-
if (!jsonSchema.type && isSupportedType(suggestedType))
153-
jsonSchema.type = suggestedType;
154-
return jsonSchema;
155-
};
156-
157-
/**
158-
* @todo remove in v25
159-
* @since zod 3.25.49
160-
* */
161-
export const depictLiteral: Depicter = ({ jsonSchema }) => {
162-
const suggestedType = typeof (jsonSchema.const || jsonSchema.enum?.[0]);
163-
if (!jsonSchema.type && isSupportedType(suggestedType))
164-
jsonSchema.type = suggestedType;
165-
return jsonSchema;
166-
};
167-
168143
/** @since v24.3.1 schema compliance is fully delegated to Zod */
169144
const asOAS = (subject: JSONSchema.BaseSchema) =>
170145
subject as SchemaObject | ReferenceObject;
@@ -380,8 +355,6 @@ const depicters: Partial<Record<FirstPartyKind | ProprietaryBrand, Depicter>> =
380355
intersection: depictIntersection,
381356
tuple: depictTuple,
382357
pipe: depictPipeline,
383-
literal: depictLiteral,
384-
enum: depictEnum,
385358
[ezDateInBrand]: depictDateIn,
386359
[ezDateOutBrand]: depictDateOut,
387360
[ezUploadBrand]: depictUpload,

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,6 @@ DocumentationError({
106106
})
107107
`;
108108

109-
exports[`Documentation helpers > depictEnum() > should set type 1`] = `
110-
{
111-
"enum": [
112-
"test",
113-
"jest",
114-
],
115-
"type": "string",
116-
}
117-
`;
118-
119109
exports[`Documentation helpers > depictIntersection() > should NOT flatten object schemas having conflicting props 1`] = `
120110
{
121111
"allOf": [
@@ -200,23 +190,6 @@ exports[`Documentation helpers > depictIntersection() > should merge examples de
200190
}
201191
`;
202192

203-
exports[`Documentation helpers > depictLiteral() > should set type from either const or enum prop 0 1`] = `
204-
{
205-
"const": "test",
206-
"type": "string",
207-
}
208-
`;
209-
210-
exports[`Documentation helpers > depictLiteral() > should set type from either const or enum prop 1 1`] = `
211-
{
212-
"enum": [
213-
"test",
214-
"jest",
215-
],
216-
"type": "string",
217-
}
218-
`;
219-
220193
exports[`Documentation helpers > depictNullable() > should add null type to the first of anyOf 0 1`] = `
221194
{
222195
"type": [

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import {
2525
depictDateIn,
2626
depictDateOut,
2727
depictBody,
28-
depictEnum,
29-
depictLiteral,
3028
depictRequest,
3129
} from "../src/documentation-helpers";
3230

@@ -309,28 +307,6 @@ describe("Documentation helpers", () => {
309307
});
310308
});
311309

312-
describe("depictEnum()", () => {
313-
test("should set type", () => {
314-
expect(
315-
depictEnum(
316-
{ zodSchema: z.never(), jsonSchema: { enum: ["test", "jest"] } },
317-
requestCtx,
318-
),
319-
).toMatchSnapshot();
320-
});
321-
});
322-
323-
describe("depictLiteral()", () => {
324-
test.each([{ const: "test" }, { enum: ["test", "jest"] }])(
325-
"should set type from either const or enum prop %#",
326-
(jsonSchema) => {
327-
expect(
328-
depictLiteral({ zodSchema: z.never(), jsonSchema }, requestCtx),
329-
).toMatchSnapshot();
330-
},
331-
);
332-
});
333-
334310
describe("depictBigInt()", () => {
335311
test("should set type:string and format:bigint", () => {
336312
expect(

0 commit comments

Comments
 (0)