Skip to content

Commit

Permalink
chore: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Oct 31, 2024
1 parent 622073d commit 5d55071
Show file tree
Hide file tree
Showing 156 changed files with 133 additions and 914 deletions.
2 changes: 2 additions & 0 deletions examples/advanced/configs/kubb.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default defineConfig(() => {
client: {
importPath: '../../../../swr-client.ts',
dataReturnType: 'data',
baseURL: 'https://petstore3.swagger.io/api/v3',
},
paramsType: 'object',
parser: 'zod',
Expand All @@ -132,6 +133,7 @@ export default defineConfig(() => {
group: { type: 'tag', name: ({ group }) => `${group}Service` },
importPath: '../../../../axios-client.ts',
operations: true,
baseURL: 'https://petstore3.swagger.io/api/v3',
dataReturnType: 'full',
paramsType: 'object',
pathParamsType: 'object',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ async function addPet(
},
config: Partial<RequestConfig<AddPetMutationRequest>> = {},
) {
const res = await client<AddPetMutationResponse, AddPet405, AddPetMutationRequest>({
method: 'POST',
url: '/pet',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
const res = await client<AddPetMutationResponse, AddPet405, AddPetMutationRequest>({ method: 'POST', url: '/pet', data, ...config })
return { ...res, data: addPetMutationResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ async function deletePet(
const res = await client<DeletePetMutationResponse, DeletePet400, unknown>({
method: 'DELETE',
url: `/pet/${petId}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
headers: { ...headers, ...config.headers },
...config,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ async function findPetsByStatus(
},
config: Partial<RequestConfig> = {},
) {
const res = await client<FindPetsByStatusQueryResponse, FindPetsByStatus400, unknown>({
method: 'GET',
url: '/pet/findByStatus',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<FindPetsByStatusQueryResponse, FindPetsByStatus400, unknown>({ method: 'GET', url: '/pet/findByStatus', params, ...config })
return { ...res, data: findPetsByStatusQueryResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async function findPetsByTags(
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
method: 'GET',
url: '/pet/findByTags',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
headers: { ...headers, ...config.headers },
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async function findPetsByTags(
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
method: 'GET',
url: '/pet/findByTags',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
headers: { ...headers, ...config.headers },
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ async function getPetById(
},
config: Partial<RequestConfig> = {},
) {
const res = await client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, unknown>({
method: 'GET',
url: `/pet/${petId}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, unknown>({ method: 'GET', url: `/pet/${petId}`, ...config })
return { ...res, data: getPetByIdQueryResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async function updatePet(
const res = await client<UpdatePetMutationResponse, UpdatePet400 | UpdatePet404 | UpdatePet405, UpdatePetMutationRequest>({
method: 'PUT',
url: '/pet',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ async function updatePetWithForm(
},
config: Partial<RequestConfig> = {},
) {
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({
method: 'POST',
url: `/pet/${petId}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
return { ...res, data: updatePetWithFormMutationResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async function uploadFile(
const res = await client<UploadFileMutationResponse, Error, UploadFileMutationRequest>({
method: 'POST',
url: `/pet/${petId}/uploadImage`,
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
data,
headers: { 'Content-Type': 'application/octet-stream', ...config.headers },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ async function createPets(
const res = await client<CreatePetsMutationResponse, Error, CreatePetsMutationRequest>({
method: 'POST',
url: `/pets/${uuid}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
data,
headers: { ...headers, ...config.headers },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ async function createUser(
},
config: Partial<RequestConfig<CreateUserMutationRequest>> = {},
) {
const res = await client<CreateUserMutationResponse, Error, CreateUserMutationRequest>({
method: 'POST',
url: '/user',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
const res = await client<CreateUserMutationResponse, Error, CreateUserMutationRequest>({ method: 'POST', url: '/user', data, ...config })
return { ...res, data: createUserMutationResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async function createUsersWithListInput(
const res = await client<CreateUsersWithListInputMutationResponse, Error, CreateUsersWithListInputMutationRequest>({
method: 'POST',
url: '/user/createWithList',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ async function deleteUser(
},
config: Partial<RequestConfig> = {},
) {
const res = await client<DeleteUserMutationResponse, DeleteUser400 | DeleteUser404, unknown>({
method: 'DELETE',
url: `/user/${username}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<DeleteUserMutationResponse, DeleteUser400 | DeleteUser404, unknown>({ method: 'DELETE', url: `/user/${username}`, ...config })
return { ...res, data: deleteUserMutationResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ async function getUserByName(
},
config: Partial<RequestConfig> = {},
) {
const res = await client<GetUserByNameQueryResponse, GetUserByName400 | GetUserByName404, unknown>({
method: 'GET',
url: `/user/${username}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<GetUserByNameQueryResponse, GetUserByName400 | GetUserByName404, unknown>({ method: 'GET', url: `/user/${username}`, ...config })
return { ...res, data: getUserByNameQueryResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ async function loginUser(
},
config: Partial<RequestConfig> = {},
) {
const res = await client<LoginUserQueryResponse, LoginUser400, unknown>({
method: 'GET',
url: '/user/login',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<LoginUserQueryResponse, LoginUser400, unknown>({ method: 'GET', url: '/user/login', params, ...config })
return { ...res, data: loginUserQueryResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ export type LogoutUserQueryKey = ReturnType<typeof logoutUserQueryKey>
* @link /user/logout
*/
async function logoutUser(config: Partial<RequestConfig> = {}) {
const res = await client<LogoutUserQueryResponse, Error, unknown>({
method: 'GET',
url: '/user/logout',
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<LogoutUserQueryResponse, Error, unknown>({ method: 'GET', url: '/user/logout', ...config })
return { ...res, data: logoutUserQueryResponseSchema.parse(res.data) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ async function updateUser(
},
config: Partial<RequestConfig<UpdateUserMutationRequest>> = {},
) {
const res = await client<UpdateUserMutationResponse, Error, UpdateUserMutationRequest>({
method: 'PUT',
url: `/user/${username}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
const res = await client<UpdateUserMutationResponse, Error, UpdateUserMutationRequest>({ method: 'PUT', url: `/user/${username}`, data, ...config })
return { ...res, data: updateUserMutationResponseSchema.parse(res.data) }
}

Expand Down
8 changes: 1 addition & 7 deletions examples/client/src/gen/clients/axios/petService/addPet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /pet
*/
export async function addPet(data: AddPetMutationRequest, config: Partial<RequestConfig<AddPetMutationRequest>> = {}) {
const res = await client<AddPetMutationResponse, AddPet405, AddPetMutationRequest>({
method: 'POST',
url: '/pet',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
const res = await client<AddPetMutationResponse, AddPet405, AddPetMutationRequest>({ method: 'POST', url: '/pet', data, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export async function deletePet({ petId }: DeletePetPathParams, headers?: Delete
const res = await client<DeletePetMutationResponse, DeletePet400, unknown>({
method: 'DELETE',
url: `/pet/${petId}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
headers: { ...headers, ...config.headers },
...config,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /pet/findByStatus
*/
export async function findPetsByStatus(params?: FindPetsByStatusQueryParams, config: Partial<RequestConfig> = {}) {
const res = await client<FindPetsByStatusQueryResponse, FindPetsByStatus400, unknown>({
method: 'GET',
url: '/pet/findByStatus',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<FindPetsByStatusQueryResponse, FindPetsByStatus400, unknown>({ method: 'GET', url: '/pet/findByStatus', params, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /pet/findByTags
*/
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
method: 'GET',
url: '/pet/findByTags',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: '/pet/findByTags', params, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /pet/:petId
*/
export async function getPetById({ petId }: GetPetByIdPathParams, config: Partial<RequestConfig> = {}) {
const res = await client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, unknown>({
method: 'GET',
url: `/pet/${petId}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, unknown>({ method: 'GET', url: `/pet/${petId}`, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function updatePet(data: UpdatePetMutationRequest, config: Partial<
const res = await client<UpdatePetMutationResponse, UpdatePet400 | UpdatePet404 | UpdatePet405, UpdatePetMutationRequest>({
method: 'PUT',
url: '/pet',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /pet/:petId
*/
export async function updatePetWithForm({ petId }: UpdatePetWithFormPathParams, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({
method: 'POST',
url: `/pet/${petId}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export async function uploadFile(
const res = await client<UploadFileMutationResponse, Error, UploadFileMutationRequest>({
method: 'POST',
url: `/pet/${petId}/uploadImage`,
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
data: formData,
headers: { 'Content-Type': 'multipart/form-data', ...config.headers },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /user
*/
export async function createUser(data?: CreateUserMutationRequest, config: Partial<RequestConfig<CreateUserMutationRequest>> = {}) {
const res = await client<CreateUserMutationResponse, Error, CreateUserMutationRequest>({
method: 'POST',
url: '/user',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
const res = await client<CreateUserMutationResponse, Error, CreateUserMutationRequest>({ method: 'POST', url: '/user', data, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function createUsersWithListInput(
const res = await client<CreateUsersWithListInputMutationResponse, Error, CreateUsersWithListInputMutationRequest>({
method: 'POST',
url: '/user/createWithList',
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /user/:username
*/
export async function deleteUser({ username }: DeleteUserPathParams, config: Partial<RequestConfig> = {}) {
const res = await client<DeleteUserMutationResponse, DeleteUser400 | DeleteUser404, unknown>({
method: 'DELETE',
url: `/user/${username}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<DeleteUserMutationResponse, DeleteUser400 | DeleteUser404, unknown>({ method: 'DELETE', url: `/user/${username}`, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /user/:username
*/
export async function getUserByName({ username }: GetUserByNamePathParams, config: Partial<RequestConfig> = {}) {
const res = await client<GetUserByNameQueryResponse, GetUserByName400 | GetUserByName404, unknown>({
method: 'GET',
url: `/user/${username}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<GetUserByNameQueryResponse, GetUserByName400 | GetUserByName404, unknown>({ method: 'GET', url: `/user/${username}`, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /user/login
*/
export async function loginUser(params?: LoginUserQueryParams, config: Partial<RequestConfig> = {}) {
const res = await client<LoginUserQueryResponse, LoginUser400, unknown>({
method: 'GET',
url: '/user/login',
baseURL: 'https://petstore3.swagger.io/api/v3',
params,
...config,
})
const res = await client<LoginUserQueryResponse, LoginUser400, unknown>({ method: 'GET', url: '/user/login', params, ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import type { RequestConfig } from '@kubb/plugin-client/client'
* @link /user/logout
*/
export async function logoutUser(config: Partial<RequestConfig> = {}) {
const res = await client<LogoutUserQueryResponse, Error, unknown>({
method: 'GET',
url: '/user/logout',
baseURL: 'https://petstore3.swagger.io/api/v3',
...config,
})
const res = await client<LogoutUserQueryResponse, Error, unknown>({ method: 'GET', url: '/user/logout', ...config })
return res.data
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ export async function updateUser(
data?: UpdateUserMutationRequest,
config: Partial<RequestConfig<UpdateUserMutationRequest>> = {},
) {
const res = await client<UpdateUserMutationResponse, Error, UpdateUserMutationRequest>({
method: 'PUT',
url: `/user/${username}`,
baseURL: 'https://petstore3.swagger.io/api/v3',
data,
...config,
})
const res = await client<UpdateUserMutationResponse, Error, UpdateUserMutationRequest>({ method: 'PUT', url: `/user/${username}`, data, ...config })
return res.data
}
Loading

0 comments on commit 5d55071

Please sign in to comment.