@kubb/plugin-msw
Version:
Mock Service Worker (MSW) handlers generator plugin for Kubb, creating API mocks from OpenAPI specifications for frontend development and testing.
22 lines (18 loc) • 629 B
text/typescript
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/
import { http } from 'msw'
export function createPetsResponse201(data?: CreatePetsMutationResponse) {
return new Response(JSON.stringify(data), {
status: 201,
})
}
export function createPets(data?: CreatePetsMutationResponse | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Response | Promise<Response>)) {
return http.post('/pets', function handler(info) {
if (typeof data === 'function') return data(info)
return new Response(JSON.stringify(data || createPetsMutationResponse(data)), {
status: 201,
})
})
}