@@ -3,6 +3,7 @@ import { expectTypeOf } from "expect-type";
33import type * as t from "../types" ;
44import { z } from "zod/v4" ;
55import type { StandardSchemaV1 } from "@standard-schema/spec" ;
6+ import type { ErrorResponse } from "../error-response" ;
67
78describe ( "Types" , ( ) => {
89 describe ( "MergeRoutes" , ( ) => {
@@ -127,7 +128,7 @@ describe("Types", () => {
127128 } ) ;
128129
129130 describe ( "GetRequestParamsInputFromDef" , ( ) => {
130- it ( "should get input type for all fields, ignoring response" , ( ) => {
131+ it ( "should get input type for all fields, ignoring a single response" , ( ) => {
131132 type Def = {
132133 query : z . ZodObject < { asc : z . ZodCoercedBoolean < string > } > ;
133134 params : z . ZodObject < { id : z . ZodString } > ;
@@ -147,6 +148,27 @@ describe("Types", () => {
147148 expectTypeOf < Actual > ( ) . toEqualTypeOf < Expected > ( ) ;
148149 } ) ;
149150
151+ it ( "should get input type for all fields, ignoring multiple responses" , ( ) => {
152+ type Def = {
153+ query : z . ZodObject < { asc : z . ZodCoercedBoolean < string > } > ;
154+ params : z . ZodObject < { id : z . ZodString } > ;
155+ body : z . ZodObject < { id : z . ZodString ; user : z . ZodString } > ;
156+ responses : {
157+ 200 : z . ZodArray < z . ZodObject < { id : z . ZodString ; user : z . ZodString } > > ;
158+ 400 : ErrorResponse ;
159+ } ;
160+ } ;
161+ type Expected = {
162+ query : { asc : string } ;
163+ params : { id : string } ;
164+ body : { id : string ; user : string } ;
165+ } ;
166+
167+ type Actual = t . GetRequestParamsInputFromDef < Def > ;
168+
169+ expectTypeOf < Actual > ( ) . toEqualTypeOf < Expected > ( ) ;
170+ } ) ;
171+
150172 it ( "should include only the body" , ( ) => {
151173 type Def = {
152174 body : z . ZodObject < { id : z . ZodString ; user : z . ZodString } > ;
0 commit comments