@twoday/msw-openapi-backend-integration
Helper to integrate Mock Service Worker with OpenAPI Backend.
Setup in Create React App
- Install:
npm i @twoday/msw-openapi-backend-integration
- Follow Mock Service Worker instructions. In place of
handlers.js
, insrc/mocks/browser.js
use:
import { setupWorker } from 'msw';
import { handlers } from '@twoday/msw-openapi-backend-integration';
import definition from '../petstore.json';
export const worker = setupWorker(...handlers({ definition }));
For dynamic responses and mutations, see requestLogicHandlers
in TodoMVC example source.