Skip to content

Commit 1458fdd

Browse files
committed
refactor: resolveRequestBody with examples
1 parent e165924 commit 1458fdd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/body.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ import type { HttpMethod } from "~/types/http";
22
import type { FixedRequest } from "~/types/request";
33
import { resolveContent } from "./content";
44
import { safeParse } from "./zod-error-handler";
5+
import type { ExampleObject } from "@omer-x/openapi-types/example";
56
import type { RequestBodyObject } from "@omer-x/openapi-types/request-body";
67
import type { ZodError, ZodType, ZodTypeDef } from "zod";
78

89
export function resolveRequestBody<I, O>(
910
source?: ZodType<O, ZodTypeDef, I> | string,
1011
isFormData: boolean = false,
11-
customExample?: O,
12+
customExample?: NoInfer<O>,
13+
customExamples?: Record<string, ExampleObject<NoInfer<O>>>,
1214
) {
1315
if (!source) return undefined;
1416
return {
1517
// description: "", // how to fill this?
1618
required: true,
17-
content: resolveContent(source, false, isFormData, customExample),
19+
content: resolveContent(source, false, isFormData, customExample, customExamples),
1820
} as RequestBodyObject;
1921
}
2022

0 commit comments

Comments
 (0)