openapi-msw
Advanced tools
Changelog
0.2.1
232ae11
Thanks @luchsamapparat! - Fixed a compilation warning in projects using OpenAPI-MSW, which was caused by missing sources in source maps.Changelog
0.2.0
bfd7a99
Thanks @christoph-fricke! - Added JSDoc comments to public API for improved DX.29ecb9c
Thanks @christoph-fricke! - Fixed a small naming mistake in the "Getting Started" code example.Changelog
0.1.2
#17 2931f0c
Thanks @christoph-fricke! - Fixed OpenAPI operations with no-content responses cannot return a response. Now they are required to return an empty response, i.e. null
as response body.
const http = createOpenApiHttp<paths>();
// Resolver function is required to return a `StrictResponse<null>` (empty response)
// if the OpenAPI operation specifies `content?: never` for the response.
const noContent = http.delete("/resource", ({ params }) => {
return HttpResponse.json(null, { status: 204 });
});
Changelog
0.1.1
96ce15c
Thanks @christoph-fricke! - Add legacy entrypoint definitions (types, module) for tools and bundlers that do not understand package.json#exports fields.Changelog
0.1.0
#9 6364870
Thanks @christoph-fricke! - Added installation and complete usage guide to the documentation.
#5 d15a0c2
Thanks @christoph-fricke! - Added createOpenApiHttp(...)
to create a thin, type-safe wrapper around MSW's http
that uses openapi-ts paths
:
import type { paths } from "./openapi-ts-definitions";
const http = createOpenApiHttp<paths>();
// Define handlers with fully typed paths, path params, and request/response bodies
const handler = http.get("/pets/{id}", () => {
/* ... */
});
// Fallback to default http implementation
const catchAll = http.untyped.all("*", () => {
/* ... */
});