UNPKG

@kubb/plugin-msw

Version:

Mock Service Worker (MSW) handlers generator plugin for Kubb, creating API mocks from OpenAPI specifications for frontend development and testing.

34 lines (29 loc) 839 B
/** * Generated by Kubb (https://kubb.dev/). * Do not edit manually. */ import { http } from 'msw' export function listPetsResponse200(data: ListPetsQueryResponse) { return new Response(JSON.stringify(data), { status: 200, headers: { 'Content-Type': 'application/json', }, }) } export function listPetsResponse400(data?: ListPets400) { return new Response(JSON.stringify(data), { status: 400, }) } export function listPets(data?: ListPetsQueryResponse | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Response | Promise<Response>)) { return http.get(`/pets`, function handler(info) { if (typeof data === 'function') return data(info) return new Response(JSON.stringify(data), { status: 200, headers: { 'Content-Type': 'application/json', }, }) }) }