Skip to content

Commit 6da7888

Browse files
docs: add section about openapi-msw (#1415)
1 parent 43b1b69 commit 6da7888

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/src/content/docs/advanced.md

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ Fetching data can be done simply and safely using an **automatically-typed fetch
1616
>
1717
> A good fetch wrapper should **never use generics.** Generics require more typing and can hide errors!
1818
19+
## Integrating with Mock-Service-Worker (MSW)
20+
21+
Using `openapi-typescript` and a wrapper around fetch, such as `openapi-fetch`, ensures that our application's API client does not have conflicts with your OpenAPI specification.
22+
However, while you can address issues with the API client easily, you have to "manually" remember to adjust API mocks since there is no mechanism that warns you about conflicts.
23+
24+
If you are using [Mock Service Worker (MSW)](https://mswjs.io) to define your API mocks, you can use a **small, automatically-typed wrapper** around MSW, which enables you to address conflicts in your API mocks easily when your OpenAPI specification changes. Ultimately, you can have the same level of confidence in your application's API client **and** API mocks.
25+
26+
We recommend the following wrapper, which works flawlessly with `openapi-typescript`:
27+
28+
- [openapi-msw](https://www.npmjs.com/package/openapi-msw) by [@christoph-fricke](https://github.com/christoph-fricke)
29+
1930
## Testing
2031

2132
One of the most common causes of false positive tests is when mocks are out-of-date with the actual API responses.

0 commit comments

Comments
 (0)