Beta You're reading the docs for Kubb v5, which is currently in beta. View the stable v4 docs
Skip to content

Migration: @kubb/plugin-msw

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

resolver.resolveName replaces transformers.name. The contentType option moved to adapterOas, covered in Migration: @kubb/adapter-oas. Every other option stays the same.

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
typescript
import type { HttpResponseResolver } from 'msw'
import type { CreateUserData } 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>, CreateUserData, any>,
) {
  return http.post('http://localhost:3000/user', function handler(info) {
  return http.post<Record<string, string>, CreateUserData, any>(`http://localhost:3000/user`, function handler(info) {
    ...
  })
}