mswjs / source

Generate MSW request handlers from various sources (HAR files, OpenAPI documents, etc).
https://source.mswjs.io
134 stars 5 forks source link

Support JSON Server #40

Closed kettanaito closed 2 months ago

kettanaito commented 3 months ago

We may support JSON Server description file as the input to Source.

import { fromJsonServer } from '@mswjs/source/json-server'
import server from './json-server.json'

fromJsonServer(server) // Array<RequestHandler>

Motivation

This can help folks who are using JSON Server to migrate to MSW while keeping the JSON Server description format.

kettanaito commented 2 months ago

I'm going to close this. It was never the intention behind Source to support all sorts of inputs. JSON Server isn't even an input but an custom format of the JSON Server library. We won't be shipping its support out of the box but you are certainly welcome to create your own custom generator package.