diff --git a/.changeset/short-mirrors-walk.md b/.changeset/short-mirrors-walk.md new file mode 100644 index 000000000..51fde3b29 --- /dev/null +++ b/.changeset/short-mirrors-walk.md @@ -0,0 +1,5 @@ +--- +"@kubb/swagger-zod": patch +--- + +Removal of '.schema' for references diff --git a/examples/advanced/src/gen/zod/addPetRequestSchema.ts b/examples/advanced/src/gen/zod/addPetRequestSchema.ts index 7496930b8..50051e0b8 100644 --- a/examples/advanced/src/gen/zod/addPetRequestSchema.ts +++ b/examples/advanced/src/gen/zod/addPetRequestSchema.ts @@ -5,8 +5,8 @@ import { z } from 'zod' export const addPetRequestSchema = z.object({ 'id': z.number().optional(), 'name': z.string(), - 'category': z.lazy(() => categorySchema).schema.optional(), + 'category': z.lazy(() => categorySchema).optional(), 'photoUrls': z.array(z.string()), - 'tags': z.array(z.lazy(() => tagSchema).schema).optional(), + 'tags': z.array(z.lazy(() => tagSchema)).optional(), 'status': z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(), }) diff --git a/examples/advanced/src/gen/zod/customerSchema.ts b/examples/advanced/src/gen/zod/customerSchema.ts index acf1326d0..c6cac4071 100644 --- a/examples/advanced/src/gen/zod/customerSchema.ts +++ b/examples/advanced/src/gen/zod/customerSchema.ts @@ -4,5 +4,5 @@ import { z } from 'zod' export const customerSchema = z.object({ 'id': z.number().optional(), 'username': z.string().optional(), - 'address': z.array(z.lazy(() => addressSchema).schema).optional(), + 'address': z.array(z.lazy(() => addressSchema)).optional(), }) diff --git a/examples/advanced/src/gen/zod/petController/addPetSchema.ts b/examples/advanced/src/gen/zod/petController/addPetSchema.ts index 30e71bae7..f8c101de4 100644 --- a/examples/advanced/src/gen/zod/petController/addPetSchema.ts +++ b/examples/advanced/src/gen/zod/petController/addPetSchema.ts @@ -7,7 +7,7 @@ export const addPet405Schema = z.object({ 'code': z.number().optional(), 'messag /** * @description Create a new pet in the store */ -export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema).schema +export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema) /** * @description Successful operation diff --git a/examples/advanced/src/gen/zod/petController/findPetsByStatusSchema.ts b/examples/advanced/src/gen/zod/petController/findPetsByStatusSchema.ts index d3a912db0..e9c98eec4 100644 --- a/examples/advanced/src/gen/zod/petController/findPetsByStatusSchema.ts +++ b/examples/advanced/src/gen/zod/petController/findPetsByStatusSchema.ts @@ -12,4 +12,4 @@ export const findPetsByStatusQueryParamsSchema = z.object({ /** * @description successful operation */ -export const findPetsByStatusQueryResponseSchema = z.array(z.lazy(() => petSchema).schema) +export const findPetsByStatusQueryResponseSchema = z.array(z.lazy(() => petSchema)) diff --git a/examples/advanced/src/gen/zod/petController/findPetsByTagsSchema.ts b/examples/advanced/src/gen/zod/petController/findPetsByTagsSchema.ts index 9fe3a7bb2..210f7b3ed 100644 --- a/examples/advanced/src/gen/zod/petController/findPetsByTagsSchema.ts +++ b/examples/advanced/src/gen/zod/petController/findPetsByTagsSchema.ts @@ -15,4 +15,4 @@ export const findPetsByTagsQueryParamsSchema = z.object({ /** * @description successful operation */ -export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema).schema) +export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema)) diff --git a/examples/advanced/src/gen/zod/petController/uploadFileSchema.ts b/examples/advanced/src/gen/zod/petController/uploadFileSchema.ts index 33e516dc9..1c27d28ed 100644 --- a/examples/advanced/src/gen/zod/petController/uploadFileSchema.ts +++ b/examples/advanced/src/gen/zod/petController/uploadFileSchema.ts @@ -8,4 +8,4 @@ export const uploadFileQueryParamsSchema = z.object({ 'additionalMetadata': z.st /** * @description successful operation */ -export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema).schema +export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema) diff --git a/examples/advanced/src/gen/zod/petSchema.ts b/examples/advanced/src/gen/zod/petSchema.ts index d7524ad96..22d6e8cb8 100644 --- a/examples/advanced/src/gen/zod/petSchema.ts +++ b/examples/advanced/src/gen/zod/petSchema.ts @@ -5,8 +5,8 @@ import { z } from 'zod' export const petSchema = z.object({ 'id': z.number().readonly().optional(), 'name': z.string(), - 'category': z.lazy(() => categorySchema).schema.optional(), + 'category': z.lazy(() => categorySchema).optional(), 'photoUrls': z.array(z.string()), - 'tags': z.array(z.lazy(() => tagSchema).schema).optional(), + 'tags': z.array(z.lazy(() => tagSchema)).optional(), 'status': z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(), }) diff --git a/examples/advanced/src/gen/zod/petsController/createPetsSchema.ts b/examples/advanced/src/gen/zod/petsController/createPetsSchema.ts index c9adc37a1..d00f4ec68 100644 --- a/examples/advanced/src/gen/zod/petsController/createPetsSchema.ts +++ b/examples/advanced/src/gen/zod/petsController/createPetsSchema.ts @@ -14,4 +14,4 @@ export const createPetsQueryParamsSchema = z.object({ 'offset': z.number().descr /** * @description unexpected error */ -export const createPetsErrorSchema = z.lazy(() => petNotFoundSchema).schema +export const createPetsErrorSchema = z.lazy(() => petNotFoundSchema) diff --git a/examples/advanced/src/gen/zod/userArraySchema.ts b/examples/advanced/src/gen/zod/userArraySchema.ts index 9c642aea8..89abb9ad3 100644 --- a/examples/advanced/src/gen/zod/userArraySchema.ts +++ b/examples/advanced/src/gen/zod/userArraySchema.ts @@ -1,4 +1,4 @@ import { userSchema } from './userSchema' import { z } from 'zod' -export const userArraySchema = z.array(z.lazy(() => userSchema).schema) +export const userArraySchema = z.array(z.lazy(() => userSchema)) diff --git a/examples/advanced/src/gen/zod/userController/createUserSchema.ts b/examples/advanced/src/gen/zod/userController/createUserSchema.ts index 927040a07..485524cde 100644 --- a/examples/advanced/src/gen/zod/userController/createUserSchema.ts +++ b/examples/advanced/src/gen/zod/userController/createUserSchema.ts @@ -6,9 +6,9 @@ export const createUserMutationResponseSchema = z.any() /** * @description successful operation */ -export const createUserErrorSchema = z.lazy(() => userSchema).schema +export const createUserErrorSchema = z.lazy(() => userSchema) /** * @description Created user object */ -export const createUserMutationRequestSchema = z.lazy(() => userSchema).schema +export const createUserMutationRequestSchema = z.lazy(() => userSchema) diff --git a/examples/advanced/src/gen/zod/userController/createUsersWithListInputSchema.ts b/examples/advanced/src/gen/zod/userController/createUsersWithListInputSchema.ts index 67e6c0baa..7fa2465a3 100644 --- a/examples/advanced/src/gen/zod/userController/createUsersWithListInputSchema.ts +++ b/examples/advanced/src/gen/zod/userController/createUsersWithListInputSchema.ts @@ -5,9 +5,9 @@ import { userSchema } from '../userSchema' * @description successful operation */ export const createUsersWithListInputErrorSchema = z.any() -export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema).schema) +export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema)) /** * @description Successful operation */ -export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema).schema +export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema) diff --git a/examples/advanced/src/gen/zod/userController/getUserByNameSchema.ts b/examples/advanced/src/gen/zod/userController/getUserByNameSchema.ts index 68fc836ee..b4d2f2b27 100644 --- a/examples/advanced/src/gen/zod/userController/getUserByNameSchema.ts +++ b/examples/advanced/src/gen/zod/userController/getUserByNameSchema.ts @@ -15,4 +15,4 @@ export const getUserByNamePathParamsSchema = z.object({ 'username': z.string().d /** * @description successful operation */ -export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema).schema +export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema) diff --git a/examples/advanced/src/gen/zod/userController/updateUserSchema.ts b/examples/advanced/src/gen/zod/userController/updateUserSchema.ts index 3c2d7a10e..3f99ccf26 100644 --- a/examples/advanced/src/gen/zod/userController/updateUserSchema.ts +++ b/examples/advanced/src/gen/zod/userController/updateUserSchema.ts @@ -11,4 +11,4 @@ export const updateUserPathParamsSchema = z.object({ 'username': z.string().desc /** * @description Update an existent user in the store */ -export const updateUserMutationRequestSchema = z.lazy(() => userSchema).schema +export const updateUserMutationRequestSchema = z.lazy(() => userSchema) diff --git a/examples/zod/src/gen/zod/addPetRequestSchema.ts b/examples/zod/src/gen/zod/addPetRequestSchema.ts index 56a7c4cec..18cd8591a 100644 --- a/examples/zod/src/gen/zod/addPetRequestSchema.ts +++ b/examples/zod/src/gen/zod/addPetRequestSchema.ts @@ -5,8 +5,8 @@ import { z } from 'zod' export const addPetRequestSchema = z.object({ id: z.number().optional(), name: z.string(), - category: z.lazy(() => categorySchema).schema.optional(), + category: z.lazy(() => categorySchema).optional(), photoUrls: z.array(z.string()), - tags: z.array(z.lazy(() => tagSchema).schema).optional(), + tags: z.array(z.lazy(() => tagSchema)).optional(), status: z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(), }) diff --git a/examples/zod/src/gen/zod/addPetSchema.ts b/examples/zod/src/gen/zod/addPetSchema.ts index c27a6744b..278770e56 100644 --- a/examples/zod/src/gen/zod/addPetSchema.ts +++ b/examples/zod/src/gen/zod/addPetSchema.ts @@ -7,9 +7,9 @@ export const addPet405Schema = z.object({ code: z.number().optional(), message: /** * @description Create a new pet in the store */ -export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema).schema +export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema) /** * @description Successful operation */ -export const addPetMutationResponseSchema = z.lazy(() => petSchema).schema +export const addPetMutationResponseSchema = z.lazy(() => petSchema) diff --git a/examples/zod/src/gen/zod/createUserSchema.ts b/examples/zod/src/gen/zod/createUserSchema.ts index 0a4b4ee5f..59f494825 100644 --- a/examples/zod/src/gen/zod/createUserSchema.ts +++ b/examples/zod/src/gen/zod/createUserSchema.ts @@ -6,9 +6,9 @@ export const createUserMutationResponseSchema = z.any() /** * @description successful operation */ -export const createUserErrorSchema = z.lazy(() => userSchema).schema +export const createUserErrorSchema = z.lazy(() => userSchema) /** * @description Created user object */ -export const createUserMutationRequestSchema = z.lazy(() => userSchema).schema +export const createUserMutationRequestSchema = z.lazy(() => userSchema) diff --git a/examples/zod/src/gen/zod/createUsersWithListInputSchema.ts b/examples/zod/src/gen/zod/createUsersWithListInputSchema.ts index 47c72e9ef..8ca7dd89e 100644 --- a/examples/zod/src/gen/zod/createUsersWithListInputSchema.ts +++ b/examples/zod/src/gen/zod/createUsersWithListInputSchema.ts @@ -5,9 +5,9 @@ import { userSchema } from './userSchema' * @description successful operation */ export const createUsersWithListInputErrorSchema = z.any() -export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema).schema) +export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema)) /** * @description Successful operation */ -export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema).schema +export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema) diff --git a/examples/zod/src/gen/zod/customerSchema.ts b/examples/zod/src/gen/zod/customerSchema.ts index 226d98f68..d3d77de43 100644 --- a/examples/zod/src/gen/zod/customerSchema.ts +++ b/examples/zod/src/gen/zod/customerSchema.ts @@ -1,8 +1,4 @@ import { addressSchema } from './addressSchema' import { z } from 'zod' -export const customerSchema = z.object({ - id: z.number().optional(), - username: z.string().optional(), - address: z.array(z.lazy(() => addressSchema).schema).optional(), -}) +export const customerSchema = z.object({ id: z.number().optional(), username: z.string().optional(), address: z.array(z.lazy(() => addressSchema)).optional() }) diff --git a/examples/zod/src/gen/zod/findPetsByStatusSchema.ts b/examples/zod/src/gen/zod/findPetsByStatusSchema.ts index aabc02ed6..da67b51c3 100644 --- a/examples/zod/src/gen/zod/findPetsByStatusSchema.ts +++ b/examples/zod/src/gen/zod/findPetsByStatusSchema.ts @@ -12,4 +12,4 @@ export const findPetsByStatusQueryParamsSchema = z.object({ /** * @description successful operation */ -export const findPetsByStatusQueryResponseSchema = z.array(z.lazy(() => petSchema).schema) +export const findPetsByStatusQueryResponseSchema = z.array(z.lazy(() => petSchema)) diff --git a/examples/zod/src/gen/zod/findPetsByTagsSchema.ts b/examples/zod/src/gen/zod/findPetsByTagsSchema.ts index b8ccea3fd..b467f6896 100644 --- a/examples/zod/src/gen/zod/findPetsByTagsSchema.ts +++ b/examples/zod/src/gen/zod/findPetsByTagsSchema.ts @@ -14,4 +14,4 @@ export const findPetsByTagsQueryParamsSchema = z.object({ /** * @description successful operation */ -export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema).schema) +export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema)) diff --git a/examples/zod/src/gen/zod/getOrderByIdSchema.ts b/examples/zod/src/gen/zod/getOrderByIdSchema.ts index 580ce06f6..ac65ef684 100644 --- a/examples/zod/src/gen/zod/getOrderByIdSchema.ts +++ b/examples/zod/src/gen/zod/getOrderByIdSchema.ts @@ -15,4 +15,4 @@ export const getOrderByIdPathParamsSchema = z.object({ orderId: z.number().descr /** * @description successful operation */ -export const getOrderByIdQueryResponseSchema = z.lazy(() => orderSchema).schema +export const getOrderByIdQueryResponseSchema = z.lazy(() => orderSchema) diff --git a/examples/zod/src/gen/zod/getPetByIdSchema.ts b/examples/zod/src/gen/zod/getPetByIdSchema.ts index 3790a7665..427fe4b29 100644 --- a/examples/zod/src/gen/zod/getPetByIdSchema.ts +++ b/examples/zod/src/gen/zod/getPetByIdSchema.ts @@ -15,4 +15,4 @@ export const getPetByIdPathParamsSchema = z.object({ petId: z.number().describe( /** * @description successful operation */ -export const getPetByIdQueryResponseSchema = z.lazy(() => petSchema).schema +export const getPetByIdQueryResponseSchema = z.lazy(() => petSchema) diff --git a/examples/zod/src/gen/zod/getUserByNameSchema.ts b/examples/zod/src/gen/zod/getUserByNameSchema.ts index 2c0c0a8ac..bd96da37e 100644 --- a/examples/zod/src/gen/zod/getUserByNameSchema.ts +++ b/examples/zod/src/gen/zod/getUserByNameSchema.ts @@ -15,4 +15,4 @@ export const getUserByNamePathParamsSchema = z.object({ username: z.string().des /** * @description successful operation */ -export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema).schema +export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema) diff --git a/examples/zod/src/gen/zod/petSchema.ts b/examples/zod/src/gen/zod/petSchema.ts index 4d99a5f3c..87830c155 100644 --- a/examples/zod/src/gen/zod/petSchema.ts +++ b/examples/zod/src/gen/zod/petSchema.ts @@ -5,8 +5,8 @@ import { z } from 'zod' export const petSchema = z.object({ id: z.number().optional(), name: z.string(), - category: z.lazy(() => categorySchema).schema.optional(), + category: z.lazy(() => categorySchema).optional(), photoUrls: z.array(z.string()), - tags: z.array(z.lazy(() => tagSchema).schema).optional(), + tags: z.array(z.lazy(() => tagSchema)).optional(), status: z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(), }) diff --git a/examples/zod/src/gen/zod/placeOrderPatchSchema.ts b/examples/zod/src/gen/zod/placeOrderPatchSchema.ts index 4eb593302..5e441eb32 100644 --- a/examples/zod/src/gen/zod/placeOrderPatchSchema.ts +++ b/examples/zod/src/gen/zod/placeOrderPatchSchema.ts @@ -5,9 +5,9 @@ import { orderSchema } from './orderSchema' * @description Invalid input */ export const placeOrderPatch405Schema = z.any() -export const placeOrderPatchMutationRequestSchema = z.lazy(() => orderSchema).schema +export const placeOrderPatchMutationRequestSchema = z.lazy(() => orderSchema) /** * @description successful operation */ -export const placeOrderPatchMutationResponseSchema = z.lazy(() => orderSchema).schema +export const placeOrderPatchMutationResponseSchema = z.lazy(() => orderSchema) diff --git a/examples/zod/src/gen/zod/placeOrderSchema.ts b/examples/zod/src/gen/zod/placeOrderSchema.ts index 65b37da5e..9979bbb94 100644 --- a/examples/zod/src/gen/zod/placeOrderSchema.ts +++ b/examples/zod/src/gen/zod/placeOrderSchema.ts @@ -5,9 +5,9 @@ import { orderSchema } from './orderSchema' * @description Invalid input */ export const placeOrder405Schema = z.any() -export const placeOrderMutationRequestSchema = z.lazy(() => orderSchema).schema +export const placeOrderMutationRequestSchema = z.lazy(() => orderSchema) /** * @description successful operation */ -export const placeOrderMutationResponseSchema = z.lazy(() => orderSchema).schema +export const placeOrderMutationResponseSchema = z.lazy(() => orderSchema) diff --git a/examples/zod/src/gen/zod/updatePetSchema.ts b/examples/zod/src/gen/zod/updatePetSchema.ts index 6db4bf179..751b4ee1d 100644 --- a/examples/zod/src/gen/zod/updatePetSchema.ts +++ b/examples/zod/src/gen/zod/updatePetSchema.ts @@ -19,9 +19,9 @@ export const updatePet405Schema = z.any() /** * @description Update an existent pet in the store */ -export const updatePetMutationRequestSchema = z.lazy(() => petSchema).schema +export const updatePetMutationRequestSchema = z.lazy(() => petSchema) /** * @description Successful operation */ -export const updatePetMutationResponseSchema = z.lazy(() => petSchema).schema +export const updatePetMutationResponseSchema = z.lazy(() => petSchema) diff --git a/examples/zod/src/gen/zod/updateUserSchema.ts b/examples/zod/src/gen/zod/updateUserSchema.ts index 85c246aa9..e179ce68e 100644 --- a/examples/zod/src/gen/zod/updateUserSchema.ts +++ b/examples/zod/src/gen/zod/updateUserSchema.ts @@ -11,4 +11,4 @@ export const updateUserPathParamsSchema = z.object({ username: z.string().descri /** * @description Update an existent user in the store */ -export const updateUserMutationRequestSchema = z.lazy(() => userSchema).schema +export const updateUserMutationRequestSchema = z.lazy(() => userSchema) diff --git a/examples/zod/src/gen/zod/uploadFileSchema.ts b/examples/zod/src/gen/zod/uploadFileSchema.ts index 7865a96ad..8e19b84ea 100644 --- a/examples/zod/src/gen/zod/uploadFileSchema.ts +++ b/examples/zod/src/gen/zod/uploadFileSchema.ts @@ -8,4 +8,4 @@ export const uploadFileQueryParamsSchema = z.object({ additionalMetadata: z.stri /** * @description successful operation */ -export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema).schema +export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema) diff --git a/examples/zod/src/gen/zod/userArraySchema.ts b/examples/zod/src/gen/zod/userArraySchema.ts index 9c642aea8..89abb9ad3 100644 --- a/examples/zod/src/gen/zod/userArraySchema.ts +++ b/examples/zod/src/gen/zod/userArraySchema.ts @@ -1,4 +1,4 @@ import { userSchema } from './userSchema' import { z } from 'zod' -export const userArraySchema = z.array(z.lazy(() => userSchema).schema) +export const userArraySchema = z.array(z.lazy(() => userSchema)) diff --git a/examples/zodios/src/gen/zod/addPetRequestSchema.ts b/examples/zodios/src/gen/zod/addPetRequestSchema.ts index 56a7c4cec..18cd8591a 100644 --- a/examples/zodios/src/gen/zod/addPetRequestSchema.ts +++ b/examples/zodios/src/gen/zod/addPetRequestSchema.ts @@ -5,8 +5,8 @@ import { z } from 'zod' export const addPetRequestSchema = z.object({ id: z.number().optional(), name: z.string(), - category: z.lazy(() => categorySchema).schema.optional(), + category: z.lazy(() => categorySchema).optional(), photoUrls: z.array(z.string()), - tags: z.array(z.lazy(() => tagSchema).schema).optional(), + tags: z.array(z.lazy(() => tagSchema)).optional(), status: z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(), }) diff --git a/examples/zodios/src/gen/zod/addPetSchema.ts b/examples/zodios/src/gen/zod/addPetSchema.ts index c27a6744b..278770e56 100644 --- a/examples/zodios/src/gen/zod/addPetSchema.ts +++ b/examples/zodios/src/gen/zod/addPetSchema.ts @@ -7,9 +7,9 @@ export const addPet405Schema = z.object({ code: z.number().optional(), message: /** * @description Create a new pet in the store */ -export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema).schema +export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema) /** * @description Successful operation */ -export const addPetMutationResponseSchema = z.lazy(() => petSchema).schema +export const addPetMutationResponseSchema = z.lazy(() => petSchema) diff --git a/examples/zodios/src/gen/zod/createUserSchema.ts b/examples/zodios/src/gen/zod/createUserSchema.ts index 0a4b4ee5f..59f494825 100644 --- a/examples/zodios/src/gen/zod/createUserSchema.ts +++ b/examples/zodios/src/gen/zod/createUserSchema.ts @@ -6,9 +6,9 @@ export const createUserMutationResponseSchema = z.any() /** * @description successful operation */ -export const createUserErrorSchema = z.lazy(() => userSchema).schema +export const createUserErrorSchema = z.lazy(() => userSchema) /** * @description Created user object */ -export const createUserMutationRequestSchema = z.lazy(() => userSchema).schema +export const createUserMutationRequestSchema = z.lazy(() => userSchema) diff --git a/examples/zodios/src/gen/zod/createUsersWithListInputSchema.ts b/examples/zodios/src/gen/zod/createUsersWithListInputSchema.ts index 47c72e9ef..8ca7dd89e 100644 --- a/examples/zodios/src/gen/zod/createUsersWithListInputSchema.ts +++ b/examples/zodios/src/gen/zod/createUsersWithListInputSchema.ts @@ -5,9 +5,9 @@ import { userSchema } from './userSchema' * @description successful operation */ export const createUsersWithListInputErrorSchema = z.any() -export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema).schema) +export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema)) /** * @description Successful operation */ -export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema).schema +export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema) diff --git a/examples/zodios/src/gen/zod/customerSchema.ts b/examples/zodios/src/gen/zod/customerSchema.ts index 226d98f68..d3d77de43 100644 --- a/examples/zodios/src/gen/zod/customerSchema.ts +++ b/examples/zodios/src/gen/zod/customerSchema.ts @@ -1,8 +1,4 @@ import { addressSchema } from './addressSchema' import { z } from 'zod' -export const customerSchema = z.object({ - id: z.number().optional(), - username: z.string().optional(), - address: z.array(z.lazy(() => addressSchema).schema).optional(), -}) +export const customerSchema = z.object({ id: z.number().optional(), username: z.string().optional(), address: z.array(z.lazy(() => addressSchema)).optional() }) diff --git a/examples/zodios/src/gen/zod/findPetsByStatusSchema.ts b/examples/zodios/src/gen/zod/findPetsByStatusSchema.ts index aabc02ed6..da67b51c3 100644 --- a/examples/zodios/src/gen/zod/findPetsByStatusSchema.ts +++ b/examples/zodios/src/gen/zod/findPetsByStatusSchema.ts @@ -12,4 +12,4 @@ export const findPetsByStatusQueryParamsSchema = z.object({ /** * @description successful operation */ -export const findPetsByStatusQueryResponseSchema = z.array(z.lazy(() => petSchema).schema) +export const findPetsByStatusQueryResponseSchema = z.array(z.lazy(() => petSchema)) diff --git a/examples/zodios/src/gen/zod/findPetsByTagsSchema.ts b/examples/zodios/src/gen/zod/findPetsByTagsSchema.ts index b8ccea3fd..b467f6896 100644 --- a/examples/zodios/src/gen/zod/findPetsByTagsSchema.ts +++ b/examples/zodios/src/gen/zod/findPetsByTagsSchema.ts @@ -14,4 +14,4 @@ export const findPetsByTagsQueryParamsSchema = z.object({ /** * @description successful operation */ -export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema).schema) +export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema)) diff --git a/examples/zodios/src/gen/zod/getOrderByIdSchema.ts b/examples/zodios/src/gen/zod/getOrderByIdSchema.ts index 580ce06f6..ac65ef684 100644 --- a/examples/zodios/src/gen/zod/getOrderByIdSchema.ts +++ b/examples/zodios/src/gen/zod/getOrderByIdSchema.ts @@ -15,4 +15,4 @@ export const getOrderByIdPathParamsSchema = z.object({ orderId: z.number().descr /** * @description successful operation */ -export const getOrderByIdQueryResponseSchema = z.lazy(() => orderSchema).schema +export const getOrderByIdQueryResponseSchema = z.lazy(() => orderSchema) diff --git a/examples/zodios/src/gen/zod/getPetByIdSchema.ts b/examples/zodios/src/gen/zod/getPetByIdSchema.ts index 3790a7665..427fe4b29 100644 --- a/examples/zodios/src/gen/zod/getPetByIdSchema.ts +++ b/examples/zodios/src/gen/zod/getPetByIdSchema.ts @@ -15,4 +15,4 @@ export const getPetByIdPathParamsSchema = z.object({ petId: z.number().describe( /** * @description successful operation */ -export const getPetByIdQueryResponseSchema = z.lazy(() => petSchema).schema +export const getPetByIdQueryResponseSchema = z.lazy(() => petSchema) diff --git a/examples/zodios/src/gen/zod/getUserByNameSchema.ts b/examples/zodios/src/gen/zod/getUserByNameSchema.ts index 2c0c0a8ac..bd96da37e 100644 --- a/examples/zodios/src/gen/zod/getUserByNameSchema.ts +++ b/examples/zodios/src/gen/zod/getUserByNameSchema.ts @@ -15,4 +15,4 @@ export const getUserByNamePathParamsSchema = z.object({ username: z.string().des /** * @description successful operation */ -export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema).schema +export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema) diff --git a/examples/zodios/src/gen/zod/petSchema.ts b/examples/zodios/src/gen/zod/petSchema.ts index 4d99a5f3c..87830c155 100644 --- a/examples/zodios/src/gen/zod/petSchema.ts +++ b/examples/zodios/src/gen/zod/petSchema.ts @@ -5,8 +5,8 @@ import { z } from 'zod' export const petSchema = z.object({ id: z.number().optional(), name: z.string(), - category: z.lazy(() => categorySchema).schema.optional(), + category: z.lazy(() => categorySchema).optional(), photoUrls: z.array(z.string()), - tags: z.array(z.lazy(() => tagSchema).schema).optional(), + tags: z.array(z.lazy(() => tagSchema)).optional(), status: z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(), }) diff --git a/examples/zodios/src/gen/zod/placeOrderPatchSchema.ts b/examples/zodios/src/gen/zod/placeOrderPatchSchema.ts index 4eb593302..5e441eb32 100644 --- a/examples/zodios/src/gen/zod/placeOrderPatchSchema.ts +++ b/examples/zodios/src/gen/zod/placeOrderPatchSchema.ts @@ -5,9 +5,9 @@ import { orderSchema } from './orderSchema' * @description Invalid input */ export const placeOrderPatch405Schema = z.any() -export const placeOrderPatchMutationRequestSchema = z.lazy(() => orderSchema).schema +export const placeOrderPatchMutationRequestSchema = z.lazy(() => orderSchema) /** * @description successful operation */ -export const placeOrderPatchMutationResponseSchema = z.lazy(() => orderSchema).schema +export const placeOrderPatchMutationResponseSchema = z.lazy(() => orderSchema) diff --git a/examples/zodios/src/gen/zod/placeOrderSchema.ts b/examples/zodios/src/gen/zod/placeOrderSchema.ts index 65b37da5e..9979bbb94 100644 --- a/examples/zodios/src/gen/zod/placeOrderSchema.ts +++ b/examples/zodios/src/gen/zod/placeOrderSchema.ts @@ -5,9 +5,9 @@ import { orderSchema } from './orderSchema' * @description Invalid input */ export const placeOrder405Schema = z.any() -export const placeOrderMutationRequestSchema = z.lazy(() => orderSchema).schema +export const placeOrderMutationRequestSchema = z.lazy(() => orderSchema) /** * @description successful operation */ -export const placeOrderMutationResponseSchema = z.lazy(() => orderSchema).schema +export const placeOrderMutationResponseSchema = z.lazy(() => orderSchema) diff --git a/examples/zodios/src/gen/zod/updatePetSchema.ts b/examples/zodios/src/gen/zod/updatePetSchema.ts index 6db4bf179..751b4ee1d 100644 --- a/examples/zodios/src/gen/zod/updatePetSchema.ts +++ b/examples/zodios/src/gen/zod/updatePetSchema.ts @@ -19,9 +19,9 @@ export const updatePet405Schema = z.any() /** * @description Update an existent pet in the store */ -export const updatePetMutationRequestSchema = z.lazy(() => petSchema).schema +export const updatePetMutationRequestSchema = z.lazy(() => petSchema) /** * @description Successful operation */ -export const updatePetMutationResponseSchema = z.lazy(() => petSchema).schema +export const updatePetMutationResponseSchema = z.lazy(() => petSchema) diff --git a/examples/zodios/src/gen/zod/updateUserSchema.ts b/examples/zodios/src/gen/zod/updateUserSchema.ts index 85c246aa9..e179ce68e 100644 --- a/examples/zodios/src/gen/zod/updateUserSchema.ts +++ b/examples/zodios/src/gen/zod/updateUserSchema.ts @@ -11,4 +11,4 @@ export const updateUserPathParamsSchema = z.object({ username: z.string().descri /** * @description Update an existent user in the store */ -export const updateUserMutationRequestSchema = z.lazy(() => userSchema).schema +export const updateUserMutationRequestSchema = z.lazy(() => userSchema) diff --git a/examples/zodios/src/gen/zod/uploadFileSchema.ts b/examples/zodios/src/gen/zod/uploadFileSchema.ts index 7865a96ad..8e19b84ea 100644 --- a/examples/zodios/src/gen/zod/uploadFileSchema.ts +++ b/examples/zodios/src/gen/zod/uploadFileSchema.ts @@ -8,4 +8,4 @@ export const uploadFileQueryParamsSchema = z.object({ additionalMetadata: z.stri /** * @description successful operation */ -export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema).schema +export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema) diff --git a/examples/zodios/src/gen/zod/userArraySchema.ts b/examples/zodios/src/gen/zod/userArraySchema.ts index 9c642aea8..89abb9ad3 100644 --- a/examples/zodios/src/gen/zod/userArraySchema.ts +++ b/examples/zodios/src/gen/zod/userArraySchema.ts @@ -1,4 +1,4 @@ import { userSchema } from './userSchema' import { z } from 'zod' -export const userArraySchema = z.array(z.lazy(() => userSchema).schema) +export const userArraySchema = z.array(z.lazy(() => userSchema)) diff --git a/packages/swagger-zod/src/ZodGenerator.ts b/packages/swagger-zod/src/ZodGenerator.ts index 1a628bbf4..0e369cf5a 100644 --- a/packages/swagger-zod/src/ZodGenerator.ts +++ b/packages/swagger-zod/src/ZodGenerator.ts @@ -125,7 +125,7 @@ export class ZodGenerator extends Generator Pet).schema', + expected: 'z.lazy(() => Pet)', }, { input: parseZodMeta({ @@ -101,14 +100,7 @@ const input = [ { input: parseZodMeta({ keyword: 'array', - args: [{ keyword: 'ref', args: { name: 'Pet', external: true } }], - }), - expected: 'z.array(z.lazy(() => Pet).schema)', - }, - { - input: parseZodMeta({ - keyword: 'array', - args: [{ keyword: 'ref', args: { name: 'Pet', external: false } }], + args: [{ keyword: 'ref', args: { name: 'Pet' } }], }), expected: 'z.array(z.lazy(() => Pet))', }, @@ -144,9 +136,9 @@ const input = [ { input: parseZodMeta({ keyword: 'catchall', - args: [{ keyword: 'ref', args: { name: 'Pet', external: true } }], + args: [{ keyword: 'ref', args: { name: 'Pet' } }], }), - expected: '.catchall(z.lazy(() => Pet).schema)', + expected: '.catchall(z.lazy(() => Pet))', }, { diff --git a/packages/swagger-zod/src/zodParser.ts b/packages/swagger-zod/src/zodParser.ts index e2959baf8..84237134f 100644 --- a/packages/swagger-zod/src/zodParser.ts +++ b/packages/swagger-zod/src/zodParser.ts @@ -103,10 +103,7 @@ type ZodMetaObject = { keyword: typeof zodKeywords.object; args?: { [x: string]: type ZodMetaCatchall = { keyword: typeof zodKeywords.catchall; args?: ZodMeta[] } -/** - * If external, `.schema` will be added - */ -type ZodMetaRef = { keyword: typeof zodKeywords.ref; args?: { name: string; external?: boolean } } +type ZodMetaRef = { keyword: typeof zodKeywords.ref; args?: { name: string } } type ZodMetaUnion = { keyword: typeof zodKeywords.union; args?: ZodMeta[] } type ZodMetaLiteral = { keyword: typeof zodKeywords.literal; args: string | number } @@ -242,13 +239,8 @@ export function parseZodMeta(item: ZodMeta, mapper: Record = // custom type if (keyword === zodKeywords.ref) { - // use of z.lazy because we need to import from files x or we use the type as a self reference, external will add `.schema` const refArgs = args as ZodMetaRef['args'] - if (refArgs?.external) { - return `${mapper.lazy}(() => ${refArgs?.name}).schema` - } - return `${mapper.lazy}(() => ${refArgs?.name})` } @@ -269,7 +261,7 @@ export function zodParser(items: ZodMeta[], options: { keysToOmit?: string[]; ma } if (options.keysToOmit?.length) { - const omitText = `.omit({ ${options.keysToOmit.map((key) => `${key}: true`).join(',')} })` + const omitText = `.schema.omit({ ${options.keysToOmit.map((key) => `${key}: true`).join(',')} })` return `export const ${options.name} = ${items.map((item) => parseZodMeta(item, { ...zodKeywordMapper, ...options.mapper })).join('')}${omitText};` }