Skip to content

Commit a91fd0a

Browse files
authored
rm depictEnum (#2697)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Updated the changelog to reflect the removal of custom enum depiction in favor of improved native support. - **Refactor** - Removed custom logic for enum depiction in documentation helpers. - **Tests** - Removed tests related to the deprecated enum depiction functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent be2c70a commit a91fd0a

4 files changed

Lines changed: 5 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Version 24
44

5+
### v24.2.1
6+
7+
- Removed overrides for depicting enums in the generated `Documentation`:
8+
- The better implementation provided by [Zod v3.25.45](https://github.com/colinhacks/zod/releases/tag/v3.25.45).
9+
510
### v24.2.0
611

712
- Supporting `z.nonoptional()` schema by `Integration` generator.

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ export const depictNullable: Depicter = ({ jsonSchema }) => {
143143
const isSupportedType = (subject: string): subject is SchemaObjectType =>
144144
subject in samples;
145145

146-
export const depictEnum: Depicter = ({ jsonSchema }) => ({
147-
type: typeof jsonSchema.enum?.[0],
148-
...jsonSchema,
149-
});
150-
151146
export const depictLiteral: Depicter = ({ jsonSchema }) => ({
152147
type: typeof (jsonSchema.const || jsonSchema.enum?.[0]),
153148
...jsonSchema,
@@ -388,7 +383,6 @@ const depicters: Partial<Record<FirstPartyKind | ProprietaryBrand, Depicter>> =
388383
tuple: depictTuple,
389384
pipe: depictPipeline,
390385
literal: depictLiteral,
391-
enum: depictEnum,
392386
[ezDateInBrand]: depictDateIn,
393387
[ezDateOutBrand]: depictDateOut,
394388
[ezUploadBrand]: depictUpload,

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

Lines changed: 0 additions & 10 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": [

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
depictDateIn,
2626
depictDateOut,
2727
depictBody,
28-
depictEnum,
2928
depictLiteral,
3029
depictRequest,
3130
} from "../src/documentation-helpers";
@@ -303,17 +302,6 @@ describe("Documentation helpers", () => {
303302
});
304303
});
305304

306-
describe("depictEnum()", () => {
307-
test("should set type", () => {
308-
expect(
309-
depictEnum(
310-
{ zodSchema: z.never(), jsonSchema: { enum: ["test", "jest"] } },
311-
requestCtx,
312-
),
313-
).toMatchSnapshot();
314-
});
315-
});
316-
317305
describe("depictLiteral()", () => {
318306
test.each([{ const: "test" }, { enum: ["test", "jest"] }])(
319307
"should set type from either const or enum prop %#",

0 commit comments

Comments
 (0)