openapi-msw
Advanced tools
+19
-15
| # openapi-msw | ||
| ## 0.1.2 | ||
| ### Patch Changes | ||
| - [#17](https://github.com/christoph-fricke/openapi-msw/pull/17) [`2931f0c`](https://github.com/christoph-fricke/openapi-msw/commit/2931f0c37e5ca66378ec2a9596e07736b417a96b) Thanks [@christoph-fricke](https://github.com/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. | ||
| ```typescript | ||
| 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 }); | ||
| }); | ||
| ``` | ||
| ## 0.1.1 | ||
@@ -7,7 +23,3 @@ | ||
| - [#12](https://github.com/christoph-fricke/openapi-msw/pull/12) | ||
| [`96ce15c`](https://github.com/christoph-fricke/openapi-msw/commit/96ce15c5f81535fb1091143dab2dce671ba65836) | ||
| Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Add legacy | ||
| entrypoint definitions (types, module) for tools and bundlers that do not | ||
| understand package.json#exports fields. | ||
| - [#12](https://github.com/christoph-fricke/openapi-msw/pull/12) [`96ce15c`](https://github.com/christoph-fricke/openapi-msw/commit/96ce15c5f81535fb1091143dab2dce671ba65836) Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Add legacy entrypoint definitions (types, module) for tools and bundlers that do not understand package.json#exports fields. | ||
@@ -18,13 +30,5 @@ ## 0.1.0 | ||
| - [#9](https://github.com/christoph-fricke/openapi-msw/pull/9) | ||
| [`6364870`](https://github.com/christoph-fricke/openapi-msw/commit/636487083c131f582507b096318d114c97131630) | ||
| Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Added | ||
| installation and complete usage guide to the documentation. | ||
| - [#9](https://github.com/christoph-fricke/openapi-msw/pull/9) [`6364870`](https://github.com/christoph-fricke/openapi-msw/commit/636487083c131f582507b096318d114c97131630) Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Added installation and complete usage guide to the documentation. | ||
| - [#5](https://github.com/christoph-fricke/openapi-msw/pull/5) | ||
| [`d15a0c2`](https://github.com/christoph-fricke/openapi-msw/commit/d15a0c2720f4d51415309f432cdc50aefb90f25f) | ||
| Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Added | ||
| `createOpenApiHttp(...)` to create a thin, type-safe wrapper around | ||
| [MSW](https://mswjs.io/)'s `http` that uses | ||
| [openapi-ts](https://openapi-ts.pages.dev/introduction/) `paths`: | ||
| - [#5](https://github.com/christoph-fricke/openapi-msw/pull/5) [`d15a0c2`](https://github.com/christoph-fricke/openapi-msw/commit/d15a0c2720f4d51415309f432cdc50aefb90f25f) Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Added `createOpenApiHttp(...)` to create a thin, type-safe wrapper around [MSW](https://mswjs.io/)'s `http` that uses [openapi-ts](https://openapi-ts.pages.dev/introduction/) `paths`: | ||
@@ -31,0 +35,0 @@ ```ts |
@@ -20,3 +20,9 @@ import type { FilterKeys, MediaType, OperationRequestBodyContent, PathsWithMethod, ResponseObjectMap, SuccessResponse } from "openapi-typescript-helpers"; | ||
| responses: any; | ||
| } ? FilterKeys<SuccessResponse<ResponseObjectMap<ApiSpec[Path][Method]>>, MediaType> : never : never; | ||
| } ? ConvertNoContent<FilterKeys<SuccessResponse<ResponseObjectMap<ApiSpec[Path][Method]>>, MediaType>> : never : never; | ||
| /** | ||
| * OpenAPI-TS generates "no content" with `content?: never`. | ||
| * However, `new Response().body` is `null` and strictly typing no-content in MSW requires `null`. | ||
| * Therefore, this helper maps no-content to `null`. | ||
| */ | ||
| export type ConvertNoContent<Content> = [Content] extends [never] ? null : Content; | ||
| /** MSW http handler factory with type inference for provided api paths. */ | ||
@@ -23,0 +29,0 @@ export type HttpHandlerFactory<ApiSpec extends AnyApiSpec, Method extends HttpMethod> = <Path extends PathsForMethod<ApiSpec, Method>>(path: Path, resolver: ResponseResolver<ApiSpec, Path, Method>, options?: RequestHandlerOptions) => ReturnType<typeof http.all>; |
+2
-2
@@ -5,6 +5,6 @@ { | ||
| "type": "module", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "license": "MIT", | ||
| "author": "Christoph Fricke <christoph@frickeonline.de>", | ||
| "description": "Tiny, type-safe wrapper around MSW wrapper for type inference from OpenAPI schemas.", | ||
| "description": "Tiny, type-safe wrapper around MSW for type inference from OpenAPI schemas.", | ||
| "repository": "github:christoph-fricke/openapi-msw", | ||
@@ -11,0 +11,0 @@ "files": [ |
15557
7.4%90
7.14%