Skip to content

Migration: @kubb/plugin-msw

Part of the v4 → v5 migration guide. For the full option reference, see @kubb/plugin-msw.

resolver.name replaces transformers.name. The contentType option moved to adapterOas, covered in Migration: @kubb/adapter-oas, and the generators option is gone. The parser ('data' | 'faker', default 'data'), handlers, and baseURL options carry over unchanged.

Generated output

Handlers are now typed against the request body and headers. They take an HttpResponseResolver callback in place of an inline MSW handler signature.

Generated output
diff
import type { HttpResponseResolver } from 'msw'
import type { CreateUserBody } from '../../../models/CreateUser.ts'

export function createUserHandler(
  data?: string | number | boolean | null | object | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Response | Promise<Response>),
  data?: string | number | boolean | null | object | HttpResponseResolver<Record<string, string>, CreateUserBody>,
) {
  return http.post('http://localhost:3000/user', function handler(info) {
  return http.post<Record<string, string>, CreateUserBody>(`http://localhost:3000/user`, function handler(info) {
    ...
  })
}