Skip to content

Commit 3b0c309

Browse files
committed
Revert "refactor: resolveParams with example strategy"
This reverts commit 2200b67.
1 parent 5bed3e0 commit 3b0c309

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/core/definer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ function defineRoute<
110110
};
111111

112112
const parameters = [
113-
...resolveParams("path", input.exampleStrategy ?? "none", input.pathParams),
114-
...resolveParams("query", input.exampleStrategy ?? "none", input.queryParams),
113+
...resolveParams("path", input.pathParams),
114+
...resolveParams("query", input.queryParams),
115115
];
116116

117117
const responses = bundleResponses(input.responses);

src/core/params.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import type { ParameterObject } from "@omer-x/openapi-types/parameter";
55

66
describe("resolveParams", () => {
77
it("should return an empty array if source is not provided", () => {
8-
const result = resolveParams("query", "none", undefined);
8+
const result = resolveParams("query", undefined);
99
expect(result).toEqual([]);
1010
});
1111

1212
it("should throw an error if the schema does not have properties", () => {
1313
const zodSchema = z.string();
1414

15-
expect(() => resolveParams("query", "none", zodSchema)).toThrow("Invalid object schema");
15+
expect(() => resolveParams("query", zodSchema)).toThrow("Invalid object schema");
1616
});
1717

1818
it("should resolve parameters for a valid Zod object schema", () => {
@@ -21,7 +21,7 @@ describe("resolveParams", () => {
2121
includeDetails: z.boolean().optional().describe("Whether to include user details"),
2222
});
2323

24-
const result = resolveParams("query", "none", zodSchema);
24+
const result = resolveParams("query", zodSchema);
2525

2626
const expectedParams: ParameterObject[] = [
2727
{
@@ -55,7 +55,7 @@ describe("resolveParams", () => {
5555
includeDetails: z.boolean().optional().describe("Whether to include user details"),
5656
});
5757

58-
const result = resolveParams("query", "none", zodSchema);
58+
const result = resolveParams("query", zodSchema);
5959

6060
const expectedParams: ParameterObject[] = [
6161
{

src/core/params.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import type { ExampleStrategy } from "~/types/example";
2-
import { injectExample } from "./example";
31
import convertToOpenAPI from "./zod-to-openapi";
42
import type { ParameterObject } from "@omer-x/openapi-types/parameter";
53
import type { ZodType } from "zod";
64

7-
export function resolveParams(kind: ParameterObject["in"], exampleStrategy: ExampleStrategy, source?: ZodType<unknown>) {
5+
export function resolveParams(kind: ParameterObject["in"], source?: ZodType<unknown>) {
86
if (!source) return [];
97
const schema = convertToOpenAPI(source, false);
108
if (!("properties" in schema)) throw new Error("Invalid object schema");
@@ -15,6 +13,5 @@ export function resolveParams(kind: ParameterObject["in"], exampleStrategy: Exam
1513
required: schema.required?.includes(name) ?? false,
1614
description: definition.description,
1715
schema: definition,
18-
...injectExample(exampleStrategy, source, false),
1916
}));
2017
}

0 commit comments

Comments
 (0)