Skip to content

Commit

Permalink
Merge pull request #615 from kubb-project/fix/strictTypeSwaggerClient
Browse files Browse the repository at this point in the history
fix: strict type for swagger-client
  • Loading branch information
stijnvanhulle authored Nov 9, 2023
2 parents 5b3cc03 + eacdd8c commit 637a2b1
Show file tree
Hide file tree
Showing 37 changed files with 122 additions and 129 deletions.
8 changes: 4 additions & 4 deletions examples/advanced/src/gen/clients/axios/petService/addPet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { AddPetMutationRequest, AddPetMutationResponse } from '../../../mod
* @summary Add a new pet to the store
* @link /pet
*/
export async function addPet<TData = AddPetMutationResponse, TVariables = AddPetMutationRequest>(
data: TVariables,
export async function addPet(
data: AddPetMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<AddPetMutationResponse>> {
return client<AddPetMutationResponse, AddPetMutationRequest>({
method: 'post',
url: `/pet`,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type { DeletePetMutationResponse, DeletePetPathParams, DeletePetHeaderPar
* @summary Deletes a pet
* @link /pet/:petId
*/
export async function deletePet<TData = DeletePetMutationResponse>(
export async function deletePet(
{ petId }: DeletePetPathParams,
headers?: DeletePetHeaderParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<DeletePetMutationResponse>> {
return client<DeletePetMutationResponse>({
method: 'delete',
url: `/pet/${petId}`,
headers: { ...headers, ...options.headers },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams } from
* @summary Finds Pets by status
* @link /pet/findByStatus
*/
export async function findPetsByStatus<TData = FindPetsByStatusQueryResponse>(
export async function findPetsByStatus(
params?: FindPetsByStatusQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<FindPetsByStatusQueryResponse>> {
return client<FindPetsByStatusQueryResponse>({
method: 'get',
url: `/pet/findByStatus`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsBy
* @summary Finds Pets by tags
* @link /pet/findByTags
*/
export async function findPetsByTags<TData = FindPetsByTagsQueryResponse>(
export async function findPetsByTags(
headers: FindPetsByTagsHeaderParams,
params?: FindPetsByTagsQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<FindPetsByTagsQueryResponse>> {
return client<FindPetsByTagsQueryResponse>({
method: 'get',
url: `/pet/findByTags`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { GetPetByIdQueryResponse, GetPetByIdPathParams } from '../../../mod
* @summary Find pet by ID
* @link /pet/:petId
*/
export async function getPetById<TData = GetPetByIdQueryResponse>(
export async function getPetById(
{ petId }: GetPetByIdPathParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<GetPetByIdQueryResponse>> {
return client<GetPetByIdQueryResponse>({
method: 'get',
url: `/pet/${petId}`,
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { UpdatePetMutationRequest, UpdatePetMutationResponse } from '../../
* @summary Update an existing pet
* @link /pet
*/
export async function updatePet<TData = UpdatePetMutationResponse, TVariables = UpdatePetMutationRequest>(
data: TVariables,
export async function updatePet(
data: UpdatePetMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<UpdatePetMutationResponse>> {
return client<UpdatePetMutationResponse, UpdatePetMutationRequest>({
method: 'put',
url: `/pet`,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import type {
* @summary Updates a pet in the store with form data
* @link /pet/:petId
*/
export async function updatePetWithForm<TData = UpdatePetWithFormMutationResponse>(
export async function updatePetWithForm(
{ petId }: UpdatePetWithFormPathParams,
params?: UpdatePetWithFormQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<UpdatePetWithFormMutationResponse>> {
return client<UpdatePetWithFormMutationResponse>({
method: 'post',
url: `/pet/${petId}`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import type {
* @summary uploads an image
* @link /pet/:petId/uploadImage
*/
export async function uploadFile<TData = UploadFileMutationResponse, TVariables = UploadFileMutationRequest>(
export async function uploadFile(
{ petId }: UploadFilePathParams,
data?: TVariables,
data?: UploadFileMutationRequest,
params?: UploadFileQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<UploadFileMutationResponse>> {
return client<UploadFileMutationResponse, UploadFileMutationRequest>({
method: 'post',
url: `/pet/${petId}/uploadImage`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import type {
* @summary Create a pet
* @link /pets/:uuid
*/
export async function createPets<TData = CreatePetsMutationResponse, TVariables = CreatePetsMutationRequest>(
export async function createPets(
{ uuid }: CreatePetsPathParams,
data: TVariables,
data: CreatePetsMutationRequest,
headers: CreatePetsHeaderParams,
params?: CreatePetsQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<CreatePetsMutationResponse>> {
return client<CreatePetsMutationResponse, CreatePetsMutationRequest>({
method: 'post',
url: `/pets/${uuid}`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { CreateUserMutationRequest, CreateUserMutationResponse } from '../.
* @summary Create user
* @link /user
*/
export async function createUser<TData = CreateUserMutationResponse, TVariables = CreateUserMutationRequest>(
data?: TVariables,
export async function createUser(
data?: CreateUserMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<CreateUserMutationResponse>> {
return client<CreateUserMutationResponse, CreateUserMutationRequest>({
method: 'post',
url: `/user`,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import type {
* @summary Creates list of users with given input array
* @link /user/createWithList
*/
export async function createUsersWithListInput<TData = CreateUsersWithListInputMutationResponse, TVariables = CreateUsersWithListInputMutationRequest>(
data?: TVariables,
export async function createUsersWithListInput(
data?: CreateUsersWithListInputMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<CreateUsersWithListInputMutationResponse>> {
return client<CreateUsersWithListInputMutationResponse, CreateUsersWithListInputMutationRequest>({
method: 'post',
url: `/user/createWithList`,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { DeleteUserMutationResponse, DeleteUserPathParams } from '../../../
* @summary Delete user
* @link /user/:username
*/
export async function deleteUser<TData = DeleteUserMutationResponse>(
export async function deleteUser(
{ username }: DeleteUserPathParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<DeleteUserMutationResponse>> {
return client<DeleteUserMutationResponse>({
method: 'delete',
url: `/user/${username}`,
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import type { GetUserByNameQueryResponse, GetUserByNamePathParams } from '../../
* @summary Get user by user name
* @link /user/:username
*/
export async function getUserByName<TData = GetUserByNameQueryResponse>(
export async function getUserByName(
{ username }: GetUserByNamePathParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<GetUserByNameQueryResponse>> {
return client<GetUserByNameQueryResponse>({
method: 'get',
url: `/user/${username}`,
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import type { LoginUserQueryResponse, LoginUserQueryParams } from '../../../mode
* @summary Logs user into the system
* @link /user/login
*/
export async function loginUser<TData = LoginUserQueryResponse>(
export async function loginUser(
params?: LoginUserQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData>({
): Promise<ResponseConfig<LoginUserQueryResponse>> {
return client<LoginUserQueryResponse>({
method: 'get',
url: `/user/login`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { LogoutUserQueryResponse } from '../../../models/ts/userController/
* @summary Logs out current logged in user session
* @link /user/logout
*/
export async function logoutUser<TData = LogoutUserQueryResponse>(options: Partial<Parameters<typeof client>[0]> = {}): Promise<ResponseConfig<TData>> {
return client<TData>({
export async function logoutUser(options: Partial<Parameters<typeof client>[0]> = {}): Promise<ResponseConfig<LogoutUserQueryResponse>> {
return client<LogoutUserQueryResponse>({
method: 'get',
url: `/user/logout`,
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type { UpdateUserMutationRequest, UpdateUserMutationResponse, UpdateUserP
* @summary Update user
* @link /user/:username
*/
export async function updateUser<TData = UpdateUserMutationResponse, TVariables = UpdateUserMutationRequest>(
export async function updateUser(
{ username }: UpdateUserPathParams,
data?: TVariables,
data?: UpdateUserMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>> {
return client<TData, TVariables>({
): Promise<ResponseConfig<UpdateUserMutationResponse>> {
return client<UpdateUserMutationResponse, UpdateUserMutationRequest>({
method: 'put',
url: `/user/${username}`,
data,
Expand Down
8 changes: 4 additions & 4 deletions examples/client/src/gen/clients/axios/petService/addPet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { AddPetMutationRequest, AddPetMutationResponse } from '../../../mod
* @summary Add a new pet to the store
* @link /pet
*/
export async function addPet<TData = AddPetMutationResponse, TVariables = AddPetMutationRequest>(
data: TVariables,
export async function addPet(
data: AddPetMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData, TVariables>({
): Promise<ResponseConfig<AddPetMutationResponse>['data']> {
const { data: resData } = await client<AddPetMutationResponse, AddPetMutationRequest>({
method: 'post',
url: `/pet`,
data,
Expand Down
6 changes: 3 additions & 3 deletions examples/client/src/gen/clients/axios/petService/deletePet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type { DeletePetMutationResponse, DeletePetPathParams, DeletePetHeaderPar
* @summary Deletes a pet
* @link /pet/:petId
*/
export async function deletePet<TData = DeletePetMutationResponse>(
export async function deletePet(
petId: DeletePetPathParams['petId'],
headers?: DeletePetHeaderParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData>({
): Promise<ResponseConfig<DeletePetMutationResponse>['data']> {
const { data: resData } = await client<DeletePetMutationResponse>({
method: 'delete',
url: `/pet/${petId}`,
headers: { ...headers, ...options.headers },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams } from
* @summary Finds Pets by status
* @link /pet/findByStatus
*/
export async function findPetsByStatus<TData = FindPetsByStatusQueryResponse>(
export async function findPetsByStatus(
params?: FindPetsByStatusQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData>({
): Promise<ResponseConfig<FindPetsByStatusQueryResponse>['data']> {
const { data: resData } = await client<FindPetsByStatusQueryResponse>({
method: 'get',
url: `/pet/findByStatus`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsBy
* @summary Finds Pets by tags
* @link /pet/findByTags
*/
export async function findPetsByTags<TData = FindPetsByTagsQueryResponse>(
export async function findPetsByTags(
headers: FindPetsByTagsHeaderParams,
params?: FindPetsByTagsQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData>({
): Promise<ResponseConfig<FindPetsByTagsQueryResponse>['data']> {
const { data: resData } = await client<FindPetsByTagsQueryResponse>({
method: 'get',
url: `/pet/findByTags`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { GetPetByIdQueryResponse, GetPetByIdPathParams } from '../../../mod
* @summary Find pet by ID
* @link /pet/:petId
*/
export async function getPetById<TData = GetPetByIdQueryResponse>(
export async function getPetById(
petId: GetPetByIdPathParams['petId'],
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData>({
): Promise<ResponseConfig<GetPetByIdQueryResponse>['data']> {
const { data: resData } = await client<GetPetByIdQueryResponse>({
method: 'get',
url: `/pet/${petId}`,
...options,
Expand Down
8 changes: 4 additions & 4 deletions examples/client/src/gen/clients/axios/petService/updatePet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { UpdatePetMutationRequest, UpdatePetMutationResponse } from '../../
* @summary Update an existing pet
* @link /pet
*/
export async function updatePet<TData = UpdatePetMutationResponse, TVariables = UpdatePetMutationRequest>(
data: TVariables,
export async function updatePet(
data: UpdatePetMutationRequest,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData, TVariables>({
): Promise<ResponseConfig<UpdatePetMutationResponse>['data']> {
const { data: resData } = await client<UpdatePetMutationResponse, UpdatePetMutationRequest>({
method: 'put',
url: `/pet`,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import type {
* @summary Updates a pet in the store with form data
* @link /pet/:petId
*/
export async function updatePetWithForm<TData = UpdatePetWithFormMutationResponse>(
export async function updatePetWithForm(
petId: UpdatePetWithFormPathParams['petId'],
params?: UpdatePetWithFormQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData>({
): Promise<ResponseConfig<UpdatePetWithFormMutationResponse>['data']> {
const { data: resData } = await client<UpdatePetWithFormMutationResponse>({
method: 'post',
url: `/pet/${petId}`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import type {
* @summary uploads an image
* @link /pet/:petId/uploadImage
*/
export async function uploadFile<TData = UploadFileMutationResponse, TVariables = UploadFileMutationRequest>(
export async function uploadFile(
petId: UploadFilePathParams['petId'],
data?: TVariables,
data?: UploadFileMutationRequest,
params?: UploadFileQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData, TVariables>({
): Promise<ResponseConfig<UploadFileMutationResponse>['data']> {
const { data: resData } = await client<UploadFileMutationResponse, UploadFileMutationRequest>({
method: 'post',
url: `/pet/${petId}/uploadImage`,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import type {
* @summary Create a pet
* @link /pets/:uuid
*/
export async function createPets<TData = CreatePetsMutationResponse, TVariables = CreatePetsMutationRequest>(
export async function createPets(
uuid: CreatePetsPathParams['uuid'],
data: TVariables,
data: CreatePetsMutationRequest,
headers: CreatePetsHeaderParams,
params?: CreatePetsQueryParams,
options: Partial<Parameters<typeof client>[0]> = {},
): Promise<ResponseConfig<TData>['data']> {
const { data: resData } = await client<TData, TVariables>({
): Promise<ResponseConfig<CreatePetsMutationResponse>['data']> {
const { data: resData } = await client<CreatePetsMutationResponse, CreatePetsMutationRequest>({
method: 'post',
url: `/pets/${uuid}`,
params,
Expand Down
Loading

1 comment on commit 637a2b1

@vercel
Copy link

@vercel vercel bot commented on 637a2b1 Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kubb – ./

kubb-kubb.vercel.app
kubb-git-main-kubb.vercel.app
www.kubb.dev
beta.kubb.dev
kubb.dev

Please sign in to comment.