File tree Expand file tree Collapse file tree 4 files changed +28
-5
lines changed
Expand file tree Collapse file tree 4 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,28 @@ const routeTests = ({
302302 ] ) ;
303303 } ) ;
304304
305+ it ( 'supports strict zod objects' , ( ) => {
306+ const routeParameters = generateParamsForRoute ( {
307+ request : {
308+ query : z . strictObject ( {
309+ test : z . string ( ) . optional ( ) . default ( 'test' ) ,
310+ } ) ,
311+ } ,
312+ } ) ;
313+
314+ expect ( routeParameters ) . toEqual ( [
315+ {
316+ in : 'query' ,
317+ name : 'test' ,
318+ required : false ,
319+ schema : {
320+ type : 'string' ,
321+ default : 'test' ,
322+ } ,
323+ } ,
324+ ] ) ;
325+ } ) ;
326+
305327 describe ( 'errors' , ( ) => {
306328 it ( 'throws an error in case of names mismatch' , ( ) => {
307329 expect ( ( ) =>
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ type ZodTypes = {
1212 ZodNull : z . ZodNull ;
1313 ZodNullable : z . ZodNullable < any > ;
1414 ZodNumber : z . ZodNumber ;
15- ZodObject : z . ZodObject < any > ;
15+ ZodObject : z . AnyZodObject ;
1616 ZodOptional : z . ZodOptional < any > ;
1717 ZodRecord : z . ZodRecord ;
1818 ZodSchema : z . ZodSchema ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 DiscriminatorObject ,
1313} from 'openapi3-ts' ;
1414import type {
15+ AnyZodObject ,
1516 ZodObject ,
1617 ZodRawShape ,
1718 ZodSchema ,
@@ -588,7 +589,7 @@ export class OpenAPIGenerator {
588589 }
589590
590591 private mapDiscriminator (
591- zodObjects : ZodObject < any > [ ] ,
592+ zodObjects : AnyZodObject [ ] ,
592593 discriminator : string
593594 ) : DiscriminatorObject | undefined {
594595 // All schemas must be registered to use a discriminator
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import {
1717 SchemaObject ,
1818 SecuritySchemeObject ,
1919} from 'openapi3-ts' ;
20- import type { ZodObject , ZodSchema , ZodType } from 'zod' ;
20+ import type { AnyZodObject , ZodSchema , ZodType } from 'zod' ;
2121
2222type Method = 'get' | 'post' | 'put' | 'delete' | 'patch' ;
2323
@@ -50,8 +50,8 @@ export interface RouteConfig extends OperationObject {
5050 path : string ;
5151 request ?: {
5252 body ?: ZodRequestBody ;
53- params ?: ZodObject < any > ;
54- query ?: ZodObject < any > ;
53+ params ?: AnyZodObject ;
54+ query ?: AnyZodObject ;
5555 headers ?: ZodType < unknown > [ ] ;
5656 } ;
5757 responses : {
You can’t perform that action at this time.
0 commit comments