Skip to content

Commit d8457f1

Browse files
committed
chore: fix types
1 parent c19986b commit d8457f1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/openapi.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ZodObject, ZodOptional, ZodSchema } from "zod";
1+
import { ZodObject, ZodOptional, ZodType } from "zod";
22
import type { Endpoint, EndpointOptions } from "./endpoint";
33

44
export type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
@@ -82,7 +82,7 @@ export interface Path {
8282
}
8383
const 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

Comments
 (0)