Skip to content

Commit b7732fb

Browse files
committed
Removing depictLiteral.
1 parent a91fd0a commit b7732fb

8 files changed

Lines changed: 14 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
### v24.2.1
66

77
- 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).
8+
- The better implementation provided by [Zod v3.25.45](https://github.com/colinhacks/zod/releases/tag/v3.25.45);
9+
- Removed overrides for depicting literals in the generated `Documentation`:
10+
- Fixed in [Zod v3.25.49](https://github.com/colinhacks/zod/releases/tag/v3.25.49).
911

1012
### v24.2.0
1113

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 depictLiteral: Depicter = ({ jsonSchema }) => ({
147-
type: typeof (jsonSchema.const || jsonSchema.enum?.[0]),
148-
...jsonSchema,
149-
});
150-
151146
const ensureCompliance = ({
152147
$ref,
153148
type,
@@ -382,7 +377,6 @@ const depicters: Partial<Record<FirstPartyKind | ProprietaryBrand, Depicter>> =
382377
intersection: depictIntersection,
383378
tuple: depictTuple,
384379
pipe: depictPipeline,
385-
literal: depictLiteral,
386380
[ezDateInBrand]: depictDateIn,
387381
[ezDateOutBrand]: depictDateOut,
388382
[ezUploadBrand]: depictUpload,

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,23 +190,6 @@ exports[`Documentation helpers > depictIntersection() > should merge examples de
190190
}
191191
`;
192192

193-
exports[`Documentation helpers > depictLiteral() > should set type from either const or enum prop 0 1`] = `
194-
{
195-
"const": "test",
196-
"type": "string",
197-
}
198-
`;
199-
200-
exports[`Documentation helpers > depictLiteral() > should set type from either const or enum prop 1 1`] = `
201-
{
202-
"enum": [
203-
"test",
204-
"jest",
205-
],
206-
"type": "string",
207-
}
208-
`;
209-
210193
exports[`Documentation helpers > depictNullable() > should add null type to the first of anyOf 0 1`] = `
211194
{
212195
"type": [

express-zod-api/tests/__snapshots__/endpoint.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ exports[`Endpoint > .getResponses() > should return the negative responses (read
5555
},
5656
"status": {
5757
"const": "error",
58+
"type": "string",
5859
},
5960
},
6061
"required": [
@@ -94,6 +95,7 @@ exports[`Endpoint > .getResponses() > should return the positive responses (read
9495
},
9596
"status": {
9697
"const": "success",
98+
"type": "string",
9799
},
98100
},
99101
"required": [

express-zod-api/tests/__snapshots__/sse.spec.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports[`SSE > makeEventSchema() > should make a valid schema of SSE event 1`] =
1010
},
1111
"event": {
1212
"const": "test",
13+
"type": "string",
1314
},
1415
"id": {
1516
"type": "string",
@@ -45,6 +46,7 @@ exports[`SSE > makeResultHandler() > should create ResultHandler describing poss
4546
},
4647
"event": {
4748
"const": "test",
49+
"type": "string",
4850
},
4951
"id": {
5052
"type": "string",
@@ -69,6 +71,7 @@ exports[`SSE > makeResultHandler() > should create ResultHandler describing poss
6971
},
7072
"event": {
7173
"const": "another",
74+
"type": "string",
7275
},
7376
"id": {
7477
"type": "string",
@@ -126,6 +129,7 @@ exports[`SSE > makeResultHandler() > should create ResultHandler describing poss
126129
},
127130
"event": {
128131
"const": "single",
132+
"type": "string",
129133
},
130134
"id": {
131135
"type": "string",

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-
depictLiteral,
2928
depictRequest,
3029
} from "../src/documentation-helpers";
3130

@@ -302,17 +301,6 @@ describe("Documentation helpers", () => {
302301
});
303302
});
304303

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"typescript": "^5.8.3",
4949
"typescript-eslint": "^8.33.0",
5050
"vitest": "^3.2.0",
51-
"zod": "^3.25.48"
51+
"zod": "^3.25.49"
5252
},
5353
"resolutions": {
5454
"**/@scarf/scarf": "npm:[email protected]"

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,7 @@ yocto-queue@^0.1.0:
31643164
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
31653165
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
31663166

3167-
zod@^3.25.48:
3168-
version "3.25.48"
3169-
resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.48.tgz#6c2b536fbb519905e8f4a4ac58743de4d5331bb2"
3170-
integrity sha512-0X1mz8FtgEIvaxGjdIImYpZEaZMrund9pGXm3M6vM7Reba0e2eI71KPjSCGXBfwKDPwPoywf6waUKc3/tFvX2Q==
3167+
zod@^3.25.49:
3168+
version "3.25.49"
3169+
resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.49.tgz#e044541aac57bd12d1cec5dbf9309cdc768774c2"
3170+
integrity sha512-JMMPMy9ZBk3XFEdbM3iL1brx4NUSejd6xr3ELrrGEfGb355gjhiAWtG3K5o+AViV/3ZfkIrCzXsZn6SbLwTR8Q==

0 commit comments

Comments
 (0)