Only 36 endpoints and "Type instantiation is excessively deep and possibly infinite" error
Richard87 opened this issue · comments
Hi! I have this API definition generated by openapi-zod-client, that errors out with Type instantiation is excessively deep and possibly infinite
only 36 endpoints... Do you have any tips on how to move forward? :/
Running Typescript 5.0.4:
./node_modules/.bin/tsc --version > Version 5.0.4
#256
astahmer/openapi-zod-client#187
Api Code
import { makeApi, Zodios, type ZodiosOptions } from "@zodios/core";
import { z } from "zod";
const BreederChapterView = z
.object({ title: z.string().nullable(), content: z.string().nullable() })
.partial();
const BreederView = z
.object({
id: z.string().uuid(),
location: z.string().nullable(),
races: z.array(z.string()).nullable(),
kennelName: z.string().nullable(),
vision: z.string().nullable(),
aboutUs: z.string().nullable(),
chapters: z.record(BreederChapterView).nullable(),
nextPlannedLitter: z.string().nullable(),
})
.partial();
const DogAddOtherResultsCommand = z
.object({
dogId: z.string().uuid(),
type: z.string().nullable(),
content: z.string().nullable(),
})
.partial();
const IResult = z.object({}).partial();
const DogChangeOtherResultsCommand = z
.object({
dogId: z.string().uuid(),
resultId: z.string().uuid(),
type: z.string().nullable(),
content: z.string().nullable(),
})
.partial();
const DogDeleteOtherResultsCommand = z
.object({ dogId: z.string().uuid(), resultId: z.string().uuid() })
.partial();
const AddBreederChapterCommand = z
.object({
title: z.string().nullable(),
content: z.string().nullable(),
breederId: z.string().uuid(),
})
.partial();
const ChangeBreederAboutUsCommand = z
.object({ content: z.string().nullable(), breederId: z.string().uuid() })
.partial();
const ChangeBreederChapterCommand = z
.object({
chapterId: z.string().uuid(),
title: z.string().nullable(),
content: z.string().nullable(),
breederId: z.string().uuid(),
})
.partial();
const ChangeBreederLocationCommand = z
.object({ location: z.string().nullable(), breederId: z.string().uuid() })
.partial();
const ChangeBreederNextPlannedLitterCommand = z
.object({ nextLitter: z.string().nullable(), breederId: z.string().uuid() })
.partial();
const ChangeBreederRacesCommand = z
.object({
races: z.array(z.string()).nullable(),
breederId: z.string().uuid(),
})
.partial();
const ChangeVisionCommand = z
.object({ vision: z.string().nullable(), breederId: z.string().uuid() })
.partial();
const RegisterEndpointCommand = z
.object({
memberId: z.string().uuid(),
location: z.string().nullable(),
races: z.array(z.string()).nullable(),
kennelName: z.string().nullable(),
})
.partial();
const RemoveBreederChapterCommand = z
.object({ chapterId: z.string().uuid(), breederId: z.string().uuid() })
.partial();
const DogOtherResultView = z
.object({ type: z.string().nullable(), content: z.string().nullable() })
.partial();
const DogView = z
.object({
id: z.string().uuid(),
memberId: z.string().uuid(),
nickname: z.string().nullable(),
registryName: z.string().nullable(),
registryId: z.string().nullable(),
isMale: z.boolean(),
race: z.string().nullable(),
bornAt: z.string().datetime({ offset: true }),
breederKennelName: z.string().nullable(),
otherResults: z.record(DogOtherResultView).nullable(),
location: z.string().nullable(),
isAvailableForBreeding: z.boolean(),
father: z.string().nullable(),
mother: z.string().nullable(),
shortDescription: z.string().nullable(),
breedingPlan: z.string().nullable(),
aboutMe: z.string().nullable(),
})
.partial();
const ChangeDogAboutMeCommand = z
.object({ dogId: z.string().uuid(), content: z.string().nullable() })
.partial();
const ChangeDogBreedingAvailabilityCommand = z
.object({ dogId: z.string().uuid(), isAvailable: z.boolean() })
.partial();
const ChangeDogBreedingPlanCommand = z
.object({ dogId: z.string().uuid(), content: z.string().nullable() })
.partial();
const ChangeDogFatherCommand = z
.object({
dogId: z.string().uuid(),
fatherRegistryName: z.string().nullable(),
})
.partial();
const ChangeDogLocationCommand = z
.object({ dogId: z.string().uuid(), location: z.string().nullable() })
.partial();
const ChangeDogMotherCommand = z
.object({
dogId: z.string().uuid(),
motherRegistryName: z.string().nullable(),
})
.partial();
const ChangeDogNicknameCommand = z
.object({ dogId: z.string().uuid(), content: z.string().nullable() })
.partial();
const ChangeDogRegistryIdCommand = z
.object({ dogId: z.string().uuid(), registryId: z.string().nullable() })
.partial();
const ChangeDogRegistryNameCommand = z
.object({ dogId: z.string().uuid(), registryName: z.string().nullable() })
.partial();
const ChangeDogShortDescriptionCommand = z
.object({ dogId: z.string().uuid(), content: z.string().nullable() })
.partial();
const RegisterDogEndpointCommand = z
.object({
memberId: z.string().uuid(),
nickname: z.string().nullable(),
registryName: z.string().nullable(),
registryId: z.string().nullable(),
isMale: z.boolean(),
race: z.string().nullable(),
bornAt: z.string().datetime({ offset: true }),
breederKennelName: z.string().nullable(),
})
.partial();
const MembersView = z
.object({
id: z.string().uuid(),
clerkId: z.string().nullable(),
name: z.string().nullable(),
email: z.string().nullable(),
location: z.string().nullable(),
})
.partial();
const ChangeEmailCommand = z
.object({ email: z.string().nullable(), memberId: z.string().uuid() })
.partial();
const ChangeMemberLocationCommand = z
.object({ location: z.string().nullable(), memberId: z.string().uuid() })
.partial();
const ChangeMemberNameCommand = z
.object({ name: z.string().nullable(), memberId: z.string().uuid() })
.partial();
const ChangePasswordCommand = z
.object({ password: z.string().nullable(), memberId: z.string().uuid() })
.partial();
const ChangeMemberTelephoneCommand = z
.object({ telephone: z.string().nullable(), memberId: z.string().uuid() })
.partial();
const EmailVerification = z
.object({ status: z.string().nullable(), strategy: z.string().nullable() })
.partial();
const EmailAddress = z
.object({
email_address: z.string().nullable(),
id: z.string().nullable(),
linked_to: z.array(z.unknown()).nullable(),
object: z.string().nullable(),
verification: EmailVerification,
})
.partial();
const UserData = z
.object({
birthday: z.string().nullable(),
created_at: z.number().int(),
email_addresses: z.array(EmailAddress).nullable(),
external_accounts: z.array(z.unknown()).nullable(),
external_id: z.string().nullable(),
first_name: z.string().nullable(),
gender: z.string().nullable(),
id: z.string().nullable(),
image_url: z.string().nullable(),
last_name: z.string().nullable(),
last_sign_in_at: z.number().int().nullable(),
object: z.string().nullable(),
password_enabled: z.boolean(),
phone_numbers: z.array(z.unknown()).nullable(),
primary_email_address_id: z.string().nullable(),
primary_phone_number_id: z.unknown().nullable(),
primary_web3_wallet_id: z.unknown().nullable(),
private_metadata: z.object({}).partial().passthrough().nullable(),
profile_image_url: z.string().nullable(),
public_metadata: z.object({}).partial().passthrough().nullable(),
two_factor_enabled: z.boolean(),
unsafe_metadata: z.object({}).partial().passthrough().nullable(),
updated_at: z.number().int(),
username: z.unknown().nullable(),
web3_wallets: z.array(z.unknown()).nullable(),
})
.partial();
const UserCreatedEvent = z
.object({
data: UserData,
object: z.string().nullable(),
type: z.string().nullable(),
})
.partial();
export const schemas = {
BreederChapterView,
BreederView,
DogAddOtherResultsCommand,
IResult,
DogChangeOtherResultsCommand,
DogDeleteOtherResultsCommand,
AddBreederChapterCommand,
ChangeBreederAboutUsCommand,
ChangeBreederChapterCommand,
ChangeBreederLocationCommand,
ChangeBreederNextPlannedLitterCommand,
ChangeBreederRacesCommand,
ChangeVisionCommand,
RegisterEndpointCommand,
RemoveBreederChapterCommand,
DogOtherResultView,
DogView,
ChangeDogAboutMeCommand,
ChangeDogBreedingAvailabilityCommand,
ChangeDogBreedingPlanCommand,
ChangeDogFatherCommand,
ChangeDogLocationCommand,
ChangeDogMotherCommand,
ChangeDogNicknameCommand,
ChangeDogRegistryIdCommand,
ChangeDogRegistryNameCommand,
ChangeDogShortDescriptionCommand,
RegisterDogEndpointCommand,
MembersView,
ChangeEmailCommand,
ChangeMemberLocationCommand,
ChangeMemberNameCommand,
ChangePasswordCommand,
ChangeMemberTelephoneCommand,
EmailVerification,
EmailAddress,
UserData,
UserCreatedEvent,
};
const endpoints = makeApi([
{
method: "get",
path: "/api/breeders",
requestFormat: "json",
response: z.array(BreederView),
errors: [
{
status: 404,
description: `Not Found`,
schema: z.array(BreederView),
},
],
},
{
method: "get",
path: "/api/breeders/:breederId/private",
requestFormat: "json",
parameters: [
{
name: "breederId",
type: "Path",
schema: z.string().uuid(),
},
],
response: BreederView,
errors: [
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/change-about-us",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeBreederAboutUsCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/change-location",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeBreederLocationCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/change-next-planned-litter",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeBreederNextPlannedLitterCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/change-races",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeBreederRacesCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/change-vision",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeVisionCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/chapter/remove",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: RemoveBreederChapterCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/chapters/add",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: AddBreederChapterCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/chapters/change",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeBreederChapterCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/breeders/register",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: RegisterEndpointCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "get",
path: "/api/dogs",
requestFormat: "json",
response: z.array(DogView),
errors: [
{
status: 404,
description: `Not Found`,
schema: z.array(DogView),
},
],
},
{
method: "get",
path: "/api/dogs/:dogId/private",
requestFormat: "json",
parameters: [
{
name: "dogId",
type: "Path",
schema: z.string().uuid(),
},
],
response: DogView,
errors: [
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-about-me",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogAboutMeCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-breeding-availability",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogBreedingAvailabilityCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-breeding-plan",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogBreedingPlanCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-father",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogFatherCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-location",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogLocationCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-mother",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogMotherCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-nickname",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogNicknameCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-registry-Id",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogRegistryIdCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-registry-name",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogRegistryNameCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/change-short-description",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeDogShortDescriptionCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/register",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: RegisterDogEndpointCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/results/other/add",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: DogAddOtherResultsCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/results/other/change",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: DogChangeOtherResultsCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/dogs/results/other/delete",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: DogDeleteOtherResultsCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "get",
path: "/api/members",
requestFormat: "json",
response: z.array(MembersView),
errors: [
{
status: 404,
description: `Not Found`,
schema: z.array(MembersView),
},
],
},
{
method: "get",
path: "/api/members/:memberId/private",
requestFormat: "json",
parameters: [
{
name: "memberId",
type: "Path",
schema: z.string().uuid(),
},
],
response: MembersView,
errors: [
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/members/change-email",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeEmailCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/members/change-location",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeMemberLocationCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/members/change-name",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeMemberNameCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/members/change-password",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangePasswordCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/members/change-telephone",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: ChangeMemberTelephoneCommand,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "post",
path: "/api/members/clerk/signup",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: UserCreatedEvent,
},
],
response: z.object({}).partial(),
errors: [
{
status: 400,
description: `Bad Request`,
schema: z.void(),
},
{
status: 404,
description: `Not Found`,
schema: z.void(),
},
],
},
{
method: "get",
path: "/hello",
requestFormat: "json",
response: z.void(),
},
]);
export const api = new Zodios(endpoints);
export function createApiClient(baseUrl: string, options?: ZodiosOptions) {
return new Zodios(baseUrl, endpoints, options);
}
Hello,
Zodios can handle way more than 36 endpoints if you give an alias to each endpoint.
Unfortunately in your case you don't have any alias setup.
just give your endpoints aliases (if you are using openapi, give your endpoints an operation id, i think open api converter convert them to aliases).
when using aliases, all your errors should be gone if you call your endpoints with those aliases.
please close if this solves you issue.
Thanks, adding the aliases, and actually using them sovled my problem :D
@Richard87 the issues you encountered should now also be fixed in v10.9.3
without aliases