Skip to content

Commit

Permalink
fix(types): remove generic from axios query function generator (#284) (
Browse files Browse the repository at this point in the history
  • Loading branch information
yekver authored Dec 18, 2021
1 parent 55285b0 commit 0bc3169
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ export const getListPetsMock = () => ([...Array(faker.datatype.number({min: 1, m
export const getShowPetByIdMock = () => ((()=>({id:faker.datatype.number({min:1,max:99}),name:faker.name.firstName(),tag:faker.helpers.randomize([faker.random.word(),void 0])}))())

export const getSwaggerPetstoreMSW = () => [
rest.get('*/v:version/pets', (req, res, ctx) => {
rest.get('*/v:version/pets', (_req, res, ctx) => {
return res(
ctx.delay(1000),
ctx.status(200, 'Mocked status'),
ctx.json(getListPetsMock()),
)
}),rest.post('*/v:version/pets', (req, res, ctx) => {
}),rest.post('*/v:version/pets', (_req, res, ctx) => {
return res(
ctx.delay(1000),
ctx.status(200, 'Mocked status'),
)
}),rest.get('*/v:version/pets/:petId', (req, res, ctx) => {
}),rest.get('*/v:version/pets/:petId', (_req, res, ctx) => {
return res(
ctx.delay(1000),
ctx.status(200, 'Mocked status'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { customInstance } from '../mutator/custom-instance'
/**
* @summary List all pets
*/
export const listPets = <TData = Pets>(
export const listPets = (
params?: ListPetsParams,
version= 1,
) => {
return customInstance<TData>(
return customInstance<Pets>(
{url: `/v${version}/pets`, method: 'get',
params,
},
Expand All @@ -30,11 +30,11 @@ export const listPets = <TData = Pets>(
/**
* @summary Create a pet
*/
export const createPets = <TData = void>(
export const createPets = (
createPetsBody: CreatePetsBody,
version= 1,
) => {
return customInstance<TData>(
return customInstance<void>(
{url: `/v${version}/pets`, method: 'post',
data: createPetsBody
},
Expand All @@ -44,11 +44,11 @@ export const createPets = <TData = void>(
/**
* @summary Info for a specific pet
*/
export const showPetById = <TData = Pet>(
export const showPetById = (
petId: string,
version= 1,
) => {
return customInstance<TData>(
return customInstance<Pet>(
{url: `/v${version}/pets/${petId}`, method: 'get'
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/generators/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const generateAxiosImplementation = (
)
: '';

return `const ${operationName} = ${toObjectString(
return `const ${operationName} = (\n ${toObjectString(
props,
'implementation',
)}\n ${
Expand Down

1 comment on commit 0bc3169

@vercel
Copy link

@vercel vercel bot commented on 0bc3169 Dec 18, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.