Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: passing options to zod-to-json-schema #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/trpc-panel/src/parse/parseProcedure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function nodeAndInputSchemaFromInputs(
schema: zodToJsonSchema(emptyZodObject, {
errorMessages: true,
$refStrategy: "none",
...options.zodToJsonSchema,
}),
node: inputParserMap["zod"](emptyZodObject, {
path: [],
Expand All @@ -90,6 +91,7 @@ function nodeAndInputSchemaFromInputs(
schema: zodToJsonSchema(input as any, {
errorMessages: true,
$refStrategy: "none",
...options.zodToJsonSchema,
}), //
node: zodSelectorFunction((input as any)._def, {
path: [],
Expand Down
2 changes: 2 additions & 0 deletions packages/trpc-panel/src/parse/parseRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Router as TRPCRouter } from "@trpc/server";
import { zodToJsonSchema } from "zod-to-json-schema";
import { logParseError } from "./parseErrorLogs";
import { ParsedProcedure, parseProcedure } from "./parseProcedure";
import type { Options as ZodToJsonSchemaOptions } from "zod-to-json-schema/src/Options";

export type JSON7SchemaType = ReturnType<typeof zodToJsonSchema>;

Expand Down Expand Up @@ -64,6 +65,7 @@ function parseRouter(
export type TrpcPanelExtraOptions = {
logFailedProcedureParse?: boolean;
transformer?: "superjson";
zodToJsonSchema?: Partial<Pick<ZodToJsonSchemaOptions, "$refStrategy">>;
};

export function parseRouterWithOptions(
Expand Down