Skip to content

Commit

Permalink
fix: exclude min/max (#929)
Browse files Browse the repository at this point in the history
* fix: exclude min/max

* fix: nullable enums are not generated as nullable

* chore: cleanup

* chore: update examples

* chore

* chore: typecheck fix
  • Loading branch information
stijnvanhulle authored Apr 13, 2024
1 parent 0a8b59c commit e32b6bd
Show file tree
Hide file tree
Showing 233 changed files with 4,375 additions and 4,385 deletions.
7 changes: 7 additions & 0 deletions .changeset/short-hats-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@kubb/swagger-zod": patch
"@kubb/swagger-ts": patch
"@kubb/swagger": patch
---

Nullable enums are not generated as nullable
6 changes: 6 additions & 0 deletions .changeset/thin-clocks-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kubb/swagger-zod": patch
"@kubb/swagger": patch
---

exclude min/max out of Array schema
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"@vercel/analytics": "^1.2.2",
"@vercel/speed-insights": "^1.0.10",
"sitemap": "^7.1.1",
"vitepress": "^1.0.2",
"vitepress": "^1.1.0",
"vue": "^3.4.21"
},
"devDependencies": {
"@types/node": "^20.12.5"
"@types/node": "^20.12.7"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@kubb/swagger-ts": "workspace:*",
"@kubb/swagger-zod": "workspace:*",
"@kubb/swagger-zodios": "workspace:*",
"@tanstack/react-query": "^5.29.0",
"@tanstack/solid-query": "^5.29.0",
"@tanstack/react-query": "^5.29.2",
"@tanstack/solid-query": "^5.29.3",
"@tanstack/svelte-query": "^5.29.0",
"@tanstack/vue-query": "^5.29.0",
"@zodios/core": "^10.9.6",
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/zod/addPetRequestSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { tagTagSchema } from './tag/tagSchema'
export const addPetRequestSchema = z.object({
id: z.number().optional(),
name: z.string(),
category: z.lazy(() => categorySchema).optional(),
category: z.lazy(() => categorySchema).schema.optional(),
photoUrls: z.array(z.string()),
tags: z.array(z.lazy(() => tagTagSchema)).optional(),
tags: z.array(z.lazy(() => tagTagSchema).schema).optional(),
status: z.enum(['available', 'pending', 'sold']).describe('pet status in the store').optional(),
}) as z.ZodType<AddPetRequest>
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/zod/customerSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { addressSchema } from './addressSchema'
export const customerSchema = z.object({
id: z.number().optional(),
username: z.string().optional(),
address: z.array(z.lazy(() => addressSchema)).optional(),
address: z.array(z.lazy(() => addressSchema).schema).optional(),
}) as z.ZodType<Customer>
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/zod/petController/addPetSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { petSchema } from '../petSchema'
/**
* @description Successful operation
*/
export const addPet200Schema = z.lazy(() => petSchema)
export const addPet200Schema = z.lazy(() => petSchema).schema

/**
* @description Pet not found
Expand All @@ -15,7 +15,7 @@ export const addPet405Schema = z.object({ code: z.number().optional(), message:
/**
* @description Create a new pet in the store
*/
export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema)
export const addPetMutationRequestSchema = z.lazy(() => addPetRequestSchema).schema

/**
* @description Successful operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const findPetsByStatusQueryParamsSchema = z
* @description successful operation
*/
export const findPetsByStatus200Schema = z
.array(z.lazy(() => petSchema))
.array(z.lazy(() => petSchema).schema)
.min(1)
.max(3)

Expand All @@ -22,6 +22,6 @@ export const findPetsByStatus400Schema = z.any()
* @description successful operation
*/
export const findPetsByStatusQueryResponseSchema = z
.array(z.lazy(() => petSchema))
.array(z.lazy(() => petSchema).schema)
.min(1)
.max(3)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const findPetsByTagsHeaderParamsSchema = z.object({ 'X-EXAMPLE': z.enum([
/**
* @description successful operation
*/
export const findPetsByTags200Schema = z.array(z.lazy(() => petSchema))
export const findPetsByTags200Schema = z.array(z.lazy(() => petSchema).schema)

/**
* @description Invalid tag value
Expand All @@ -24,4 +24,4 @@ export const findPetsByTags400Schema = z.any()
/**
* @description successful operation
*/
export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema))
export const findPetsByTagsQueryResponseSchema = z.array(z.lazy(() => petSchema).schema)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getPetByIdPathParamsSchema = z.object({ petId: z.number().describe(
/**
* @description successful operation
*/
export const getPetById200Schema = z.lazy(() => petSchema)
export const getPetById200Schema = z.lazy(() => petSchema).schema

/**
* @description Invalid ID supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { petSchema } from '../petSchema'
/**
* @description Successful operation
*/
export const updatePet200Schema = z.lazy(() => petSchema)
export const updatePet200Schema = z.lazy(() => petSchema).schema

/**
* @description Invalid ID supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export const uploadFileQueryParamsSchema = z.object({ additionalMetadata: z.stri
/**
* @description successful operation
*/
export const uploadFile200Schema = z.lazy(() => apiResponseSchema)
export const uploadFile200Schema = z.lazy(() => apiResponseSchema).schema

export const uploadFileMutationRequestSchema = z.string()

/**
* @description successful operation
*/
export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema)
export const uploadFileMutationResponseSchema = z.lazy(() => apiResponseSchema).schema
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/zod/petSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { tagTagSchema } from './tag/tagSchema'
export const petSchema = z.object({
id: z.number().optional(),
name: z.string(),
category: z.lazy(() => categorySchema).optional(),
category: z.lazy(() => categorySchema).schema.optional(),
photoUrls: z.array(z.string()),
tags: z.array(z.lazy(() => tagTagSchema)).optional(),
tags: z.array(z.lazy(() => tagTagSchema).schema).optional(),
status: z.enum(['available', 'pending', 'sold']).describe('pet status in the store').optional(),
}) as z.ZodType<Pet>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createPets201Schema = z.any()
/**
* @description unexpected error
*/
export const createPetsErrorSchema = z.lazy(() => petNotFoundSchema).describe('Pet not found')
export const createPetsErrorSchema = z.lazy(() => petNotFoundSchema).schema.describe('Pet not found')

export const createPetsMutationRequestSchema = z.object({ name: z.string(), tag: z.string() })

Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/zod/userArraySchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { z } from 'zod'
import type { UserArray } from '../models/ts/UserArray'
import { userSchema } from './userSchema'

export const userArraySchema = z.array(z.lazy(() => userSchema)) as z.ZodType<UserArray>
export const userArraySchema = z.array(z.lazy(() => userSchema).schema) as z.ZodType<UserArray>
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { userSchema } from '../userSchema'
/**
* @description successful operation
*/
export const createUserErrorSchema = z.lazy(() => userSchema)
export const createUserErrorSchema = z.lazy(() => userSchema).schema

/**
* @description Created user object
*/
export const createUserMutationRequestSchema = z.lazy(() => userSchema)
export const createUserMutationRequestSchema = z.lazy(() => userSchema).schema

export const createUserMutationResponseSchema = z.any()
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { userSchema } from '../userSchema'
/**
* @description Successful operation
*/
export const createUsersWithListInput200Schema = z.lazy(() => userSchema)
export const createUsersWithListInput200Schema = z.lazy(() => userSchema).schema

/**
* @description successful operation
*/
export const createUsersWithListInputErrorSchema = z.any()

export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema))
export const createUsersWithListInputMutationRequestSchema = z.array(z.lazy(() => userSchema).schema)

/**
* @description Successful operation
*/
export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema)
export const createUsersWithListInputMutationResponseSchema = z.lazy(() => userSchema).schema
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getUserByNamePathParamsSchema = z.object({ username: z.string().des
/**
* @description successful operation
*/
export const getUserByName200Schema = z.lazy(() => userSchema)
export const getUserByName200Schema = z.lazy(() => userSchema).schema

/**
* @description Invalid username supplied
Expand All @@ -21,4 +21,4 @@ export const getUserByName404Schema = z.any()
/**
* @description successful operation
*/
export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema)
export const getUserByNameQueryResponseSchema = z.lazy(() => userSchema).schema
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const updateUserErrorSchema = z.any()
/**
* @description Update an existent user in the store
*/
export const updateUserMutationRequestSchema = z.lazy(() => userSchema)
export const updateUserMutationRequestSchema = z.lazy(() => userSchema).schema

export const updateUserMutationResponseSchema = z.any()
2 changes: 1 addition & 1 deletion examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@kubb/ts-config": "workspace:*",
"react": "^18.2.0",
"tsup": "^8.0.2",
"typescript": "^5.4.4"
"typescript": "^5.4.5"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion examples/faker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"devDependencies": {
"@kubb/ts-config": "workspace:*",
"typescript": "^5.4.4"
"typescript": "^5.4.5"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions examples/python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
},
"devDependencies": {
"@kubb/ts-config": "workspace:*",
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@types/react": "^18.2.77",
"@types/react-dom": "^18.2.25",
"tsup": "^8.0.2",
"typescript": "^5.4.4"
"typescript": "^5.4.5"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions examples/react-query-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"@kubb/swagger-client": "workspace:*",
"@kubb/swagger-tanstack-query": "workspace:*",
"@kubb/swagger-ts": "workspace:*",
"@tanstack/react-query": "^5.29.0",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "5.0.0",
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@types/react": "^18.2.77",
"@types/react-dom": "^18.2.25",
"@vitejs/plugin-react": "^4.2.1",
"msw": "^1.3.3",
"tsup": "^8.0.2",
Expand Down
40 changes: 20 additions & 20 deletions examples/react-query-v5/src/gen/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export * from './useAddPetHook'
export * from './useCreateUserHook'
export * from './useCreateUsersWithListInputHook'
export * from './useDeleteOrderHook'
export * from './useDeletePetHook'
export * from './useDeleteUserHook'
export * from './useFindPetsByStatusHook'
export * from './useFindPetsByTagsHook'
export * from './useGetInventoryHook'
export * from './useGetOrderByIdHook'
export * from './useGetPetByIdHook'
export * from './useGetUserByNameHook'
export * from './useLoginUserHook'
export * from './useLogoutUserHook'
export * from './usePlaceOrderHook'
export * from './usePlaceOrderPatchHook'
export * from './useUpdatePetHook'
export * from './useUpdatePetWithFormHook'
export * from './useUpdateUserHook'
export * from './useUploadFileHook'
export * from "./useAddPetHook";
export * from "./useCreateUserHook";
export * from "./useCreateUsersWithListInputHook";
export * from "./useDeleteOrderHook";
export * from "./useDeletePetHook";
export * from "./useDeleteUserHook";
export * from "./useFindPetsByStatusHook";
export * from "./useFindPetsByTagsHook";
export * from "./useGetInventoryHook";
export * from "./useGetOrderByIdHook";
export * from "./useGetPetByIdHook";
export * from "./useGetUserByNameHook";
export * from "./useLoginUserHook";
export * from "./useLogoutUserHook";
export * from "./usePlaceOrderHook";
export * from "./usePlaceOrderPatchHook";
export * from "./useUpdatePetHook";
export * from "./useUpdatePetWithFormHook";
export * from "./useUpdateUserHook";
export * from "./useUploadFileHook";
Loading

0 comments on commit e32b6bd

Please sign in to comment.