Skip to content

Commit e3984ed

Browse files
authored
Removing overrides for any (#2559)
Unnecessary complication
1 parent de75df6 commit e3984ed

4 files changed

Lines changed: 9 additions & 34 deletions

File tree

example/example.documentation.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ paths:
472472
type: object
473473
propertyNames:
474474
type: string
475-
additionalProperties:
476-
format: any
475+
additionalProperties: {}
477476
required:
478477
- name
479478
- size

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ const onDefault: Overrider = ({ zodSchema, jsonSchema }) =>
101101
globalRegistry.get(zodSchema)?.[metaSymbol]?.defaultLabel ??
102102
jsonSchema.default);
103103

104-
const onAny: Overrider = ({ jsonSchema }) => (jsonSchema.format = "any");
105-
106104
const onUpload: Overrider = ({ jsonSchema }, ctx) => {
107105
if (ctx.isResponse)
108106
throw new DocumentationError("Please use ez.upload() only for input.", ctx);
@@ -280,8 +278,6 @@ const onPipeline: Overrider = ({ zodSchema, jsonSchema }, ctx) => {
280278
Object.assign(jsonSchema, {
281279
type: targetType as "number" | "string" | "boolean",
282280
});
283-
} else {
284-
onAny({ zodSchema, jsonSchema }, ctx);
285281
}
286282
}
287283
}
@@ -415,7 +411,6 @@ const overrides: Partial<Record<FirstPartyKind | ProprietaryBrand, Overrider>> =
415411
{
416412
nullable: onNullable,
417413
default: onDefault,
418-
any: onAny,
419414
union: onUnion,
420415
bigint: onBigInt,
421416
intersection: onIntersection,

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Documentation helpers > depictAny() > should set format:any 1`] = `
4-
{
5-
"format": "any",
6-
}
7-
`;
3+
exports[`Documentation helpers > depictAny() > should set format:any 1`] = `{}`;
84

95
exports[`Documentation helpers > depictArray() > should reflect min/max/exact length of the array 0 1`] = `
106
{
@@ -677,17 +673,9 @@ exports[`Documentation helpers > depictPipeline > should depict as 'string (prep
677673
}
678674
`;
679675

680-
exports[`Documentation helpers > depictPipeline > should handle edge cases 0 1`] = `
681-
{
682-
"format": "any",
683-
}
684-
`;
676+
exports[`Documentation helpers > depictPipeline > should handle edge cases 0 1`] = `{}`;
685677

686-
exports[`Documentation helpers > depictPipeline > should handle edge cases 1 1`] = `
687-
{
688-
"format": "any",
689-
}
690-
`;
678+
exports[`Documentation helpers > depictPipeline > should handle edge cases 1 1`] = `{}`;
691679

692680
exports[`Documentation helpers > depictRaw() > should depict the raw property 1`] = `
693681
{
@@ -770,9 +758,7 @@ exports[`Documentation helpers > depictRecord() > should set properties+required
770758

771759
exports[`Documentation helpers > depictRecord() > should set properties+required or additionalProperties props 5 1`] = `
772760
{
773-
"additionalProperties": {
774-
"format": "any",
775-
},
761+
"additionalProperties": {},
776762
"propertyNames": {
777763
"type": "string",
778764
},
@@ -1327,9 +1313,7 @@ exports[`Documentation helpers > depictUnion() > should wrap next depicters in o
13271313
"anyOf": [
13281314
{
13291315
"properties": {
1330-
"data": {
1331-
"format": "any",
1332-
},
1316+
"data": {},
13331317
"status": {
13341318
"const": "success",
13351319
},

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,7 @@ paths:
746746
properties:
747747
status:
748748
const: success
749-
data:
750-
format: any
749+
data: {}
751750
required:
752751
- status
753752
- data
@@ -2058,8 +2057,7 @@ paths:
20582057
in: query
20592058
required: false
20602059
description: GET /v1/getSomething Parameter
2061-
schema:
2062-
format: any
2060+
schema: {}
20632061
responses:
20642062
"200":
20652063
description: GET /v1/getSomething Positive response
@@ -2073,8 +2071,7 @@ paths:
20732071
data:
20742072
type: object
20752073
properties:
2076-
any:
2077-
format: any
2074+
any: {}
20782075
required:
20792076
- any
20802077
required:

0 commit comments

Comments
 (0)