1- import { ZodObject , ZodOptional , ZodSchema } from "zod" ;
1+ import { ZodObject , ZodOptional , ZodType } from "zod" ;
22import type { Endpoint , EndpointOptions } from "./endpoint" ;
33
44export type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object" ;
@@ -82,7 +82,7 @@ export interface Path {
8282}
8383const paths : Record < string , Path > = { } ;
8484
85- function getTypeFromZodType ( zodType : ZodSchema ) {
85+ function getTypeFromZodType ( zodType : ZodType < any > ) {
8686 switch ( zodType . constructor . name ) {
8787 case "ZodString" :
8888 return "string" ;
@@ -107,7 +107,7 @@ function getParameters(options: EndpointOptions) {
107107 }
108108 if ( options . query instanceof ZodObject ) {
109109 Object . entries ( options . query . shape ) . forEach ( ( [ key , value ] ) => {
110- if ( value instanceof ZodSchema ) {
110+ if ( value instanceof ZodObject ) {
111111 parameters . push ( {
112112 name : key ,
113113 in : "query" ,
@@ -139,7 +139,7 @@ function getRequestBody(options: EndpointOptions): any {
139139 const properties : Record < string , any > = { } ;
140140 const required : string [ ] = [ ] ;
141141 Object . entries ( shape ) . forEach ( ( [ key , value ] ) => {
142- if ( value instanceof ZodSchema ) {
142+ if ( value instanceof ZodObject ) {
143143 properties [ key ] = {
144144 type : getTypeFromZodType ( value ) ,
145145 description : value . description ,
0 commit comments